ObjFW  Check-in [de552578e7]

Overview
Comment:Use <cet.h> and _CET_ENDBR macro

This only uses endbr32/endbr64 when actually needed and emits the
necessary .note.gnu.property.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 1.0
Files: files | file ages | folders
SHA3-256: de552578e76755535f95b71dfc0805e50ae763b48ab68d563a2fdabceca645d6
User & Date: js on 2024-02-26 20:32:55
Other Links: branch diff | manifest | tags
Context
2024-02-27
00:57
OFStream: Minor documentation fix check-in: f111a22ede user: js tags: 1.0
2024-02-26
20:32
Use <cet.h> and _CET_ENDBR macro check-in: de552578e7 user: js tags: 1.0
20:32
Use <cet.h> and _CET_ENDBR macro check-in: 0b441e52d6 user: js tags: trunk
20:09
OFLHAArchive: Properly zero-terminate archives check-in: 4fbf5837fd user: js tags: 1.0
Changes

Modified configure.ac from [c0c6842cf8] to [406fbcd150].

853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874


875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
853
854
855
856
857
858
859















860
861










862
863
864
865
866
867
868







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-







	], [
		AC_DEFINE(HAVE_BTI, 1, [Whether we have bti])
		AC_MSG_RESULT(yes)
	], [
		AC_MSG_RESULT(no)
	])
	;;
i?86)
	AC_MSG_CHECKING(for endbr32)
	AC_COMPILE_IFELSE([
		AC_LANG_PROGRAM([], [
			__asm__ __volatile__ ("endbr32");
		])
	], [
		AC_DEFINE(HAVE_ENDBR32, 1, [Whether we have endbr32])
		AC_MSG_RESULT(yes)
	], [
		AC_MSG_RESULT(no)
	])
	;;
x86_64)
	AC_MSG_CHECKING(for endbr64)
i?86 | x86_64)
	AC_CHECK_HEADERS(cet.h)
	AC_COMPILE_IFELSE([
		AC_LANG_PROGRAM([], [
			__asm__ __volatile__ ("endbr64");
		])
	], [
		AC_DEFINE(HAVE_ENDBR64, 1, [Whether we have endbr64])
		AC_MSG_RESULT(yes)
	], [
		AC_MSG_RESULT(no)
	])
	;;
esac

AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm")
AC_CHECK_LIB(complex, creal, TESTS_LIBS="$TESTS_LIBS -lcomplex")

AC_CHECK_FUNCS(strtof truncf)

Modified src/forwarding/apple-forwarding-amd64.S from [a6a790786d] to [7f321ef4ac].

10
11
12
13
14
15
16






17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42
43
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

40


41
42
43
44
45
46
47







+
+
+
+
+
+

















-
+
-
-







 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#ifdef HAVE_CET_H
# include <cet.h>
#else
# define _CET_ENDBR
#endif

.globl _OFForward
.globl _OFForward_stret

.section __TEXT, __objc_methname, cstring_literals
str_forwardingTargetForSelector_:
	.asciz "forwardingTargetForSelector:"

.section __DATA, __objc_selrefs, literal_pointers, no_dead_strip
sel_forwardingTargetForSelector_:
	.quad str_forwardingTargetForSelector_

.section __DATA, __objc_imageinfo, regular, no_dead_strip
	.long 0, 0

.section __TEXT, __text, regular, pure_instructions
_OFForward:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	pushq	%rbp
	movq	%rsp, %rbp

	/* Save all arguments */
	subq	$0xC0, %rsp	/* 16-byte alignment */
	movq	%rax, -0x8(%rbp)
104
105
106
107
108
109
110
111

112
113
114
115
116
117
118
119
120
108
109
110
111
112
113
114

115


116
117
118
119
120
121
122







-
+
-
-








	movq	%rbp, %rsp
	popq	%rbp

	jmp	_OFMethodNotFound

_OFForward_stret:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	pushq	%rbp
	movq	%rsp, %rbp

	/* Save all arguments */
	subq	$0xC0, %rsp	/* 16-byte alignment */
	movq	%rax, -0x8(%rbp)

Modified src/forwarding/apple-forwarding-x86.S from [9691a2ccf3] to [cc0359ce26].

10
11
12
13
14
15
16






17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42
43
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

40


41
42
43
44
45
46
47







+
+
+
+
+
+

















-
+
-
-







 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#ifdef HAVE_CET_H
# include <cet.h>
#else
# define _CET_ENDBR
#endif

.globl _OFForward
.globl _OFForward_stret

.section __TEXT, __cstring, cstring_literals
str_forwardingTargetForSelector_:
	.asciz "forwardingTargetForSelector:"

.section __OBJC, __message_refs, literal_pointers, no_dead_strip
sel_forwardingTargetForSelector_:
	.long str_forwardingTargetForSelector_

.section __OBJC, __image_info
	.long 0, 0

.section __TEXT, __text, regular, pure_instructions
_OFForward:
#ifdef HAVE_ENDBR32
	_CET_ENDBR
	endbr32
#endif

	pushl	%ebp
	movl	%esp, %ebp

	pushl	%ebx
	subl	$20, %esp

81
82
83
84
85
86
87
88

89
90
91
92
93
94
95
96
97
85
86
87
88
89
90
91

92


93
94
95
96
97
98
99







-
+
-
-







	addl	$20, %esp
	popl	%ebx
	popl	%ebp

	jmp	_OFMethodNotFound

_OFForward_stret:
#ifdef HAVE_ENDBR32
	_CET_ENDBR
	endbr32
#endif

	pushl	%ebp
	movl	%esp, %ebp

	pushl	%ebx
	subl	$20, %esp

Modified src/forwarding/forwarding-amd64-elf.S from [51b886f131] to [7d81c22aa1].

12
13
14
15
16
17
18






19
20
21
22
23
24
25

26
27
28
29
30
31
32
33
34
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

31


32
33
34
35
36
37
38







+
+
+
+
+
+






-
+
-
-







 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include "platform.h"

#ifdef HAVE_CET_H
# include <cet.h>
#else
# define _CET_ENDBR
#endif

.globl OFForward
.globl OFForward_stret

.section .text
OFForward:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	pushq	%rbp
	movq	%rsp, %rbp

	/* Save all arguments */
	subq	$0xC0, %rsp	/* 16-byte alignment */
	movq	%rax, -0x8(%rbp)
107
108
109
110
111
112
113
114

115
116
117
118
119
120
121
122
123
111
112
113
114
115
116
117

118


119
120
121
122
123
124
125







-
+
-
-







	popq	%rbp

	jmp	OFMethodNotFound@PLT
.type OFForward, %function
.size OFForward, .-OFForward

OFForward_stret:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	pushq	%rbp
	movq	%rsp, %rbp

	/* Save all arguments */
	subq	$0xC0, %rsp	/* 16-byte alignment */
	movq	%rax, -0x8(%rbp)
198
199
200
201
202
203
204
205

206
207
208
209
210
211
212
213
214
200
201
202
203
204
205
206

207


208
209
210
211
212
213
214







-
+
-
-







	popq	%rbp

	jmp	OFMethodNotFound_stret@PLT
.type OFForward_stret, %function
.size OFForward_stret, .-OFForward_stret

init:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	leaq	module(%rip), %rdi
	jmp	__objc_exec_class@PLT

#ifdef OF_SOLARIS
.section .init_array, "aw"
#else

Modified src/forwarding/forwarding-amd64-macho.S from [d1ee87766e] to [98f0f66032].

12
13
14
15
16
17
18






19
20
21
22
23
24
25

26
27
28
29
30
31
32
33
34
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

31


32
33
34
35
36
37
38







+
+
+
+
+
+






-
+
-
-







 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include "platform.h"

#ifdef HAVE_CET_H
# include <cet.h>
#else
# define _CET_ENDBR
#endif

.globl _OFForward
.globl _OFForward_stret

.section __TEXT, __text, regular, pure_instructions
_OFForward:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	pushq	%rbp
	movq	%rsp, %rbp

	/* Save all arguments */
	subq	$0xC0, %rsp	/* 16-byte alignment */
	movq	%rax, -0x8(%rbp)
105
106
107
108
109
110
111
112

113
114
115
116
117
118
119
120
121
109
110
111
112
113
114
115

116


117
118
119
120
121
122
123







-
+
-
-








	movq	%rbp, %rsp
	popq	%rbp

	jmp	_OFMethodNotFound

_OFForward_stret:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	pushq	%rbp
	movq	%rsp, %rbp

	/* Save all arguments */
	subq	$0xC0, %rsp	/* 16-byte alignment */
	movq	%rax, -0x8(%rbp)
194
195
196
197
198
199
200
201

202
203
204
205
206
207
208
209
210
196
197
198
199
200
201
202

203


204
205
206
207
208
209
210







-
+
-
-








	movq	%rbp, %rsp
	popq	%rbp

	jmp	_OFMethodNotFound_stret

init:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	leaq	module(%rip), %rdi
	jmp	___objc_exec_class

.section __DATA, __mod_init_func, mod_init_funcs
	.quad init

Modified src/forwarding/forwarding-amd64-win64.S from [1c68b17637] to [231a1b0400].

10
11
12
13
14
15
16






17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

29


30
31
32
33
34
35
36







+
+
+
+
+
+






-
+
-
-







 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#ifdef HAVE_CET_H
# include <cet.h>
#else
# define _CET_ENDBR
#endif

.globl OFForward
.globl OFForward_stret

.section .text
OFForward:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	pushq	%rbp
	movq	%rsp, %rbp

	/* Save all arguments */
	subq	$0x90, %rsp	/* 16-byte alignment */
	movq	%rax, -0x28(%rbp)
95
96
97
98
99
100
101
102

103
104
105
106
107
108
109
110
111
99
100
101
102
103
104
105

106


107
108
109
110
111
112
113







-
+
-
-







	jmp	OFMethodNotFound
.def OFForward
.scl 2
.type 32
.endef

OFForward_stret:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	pushq	%rbp
	movq	%rsp, %rbp

	/* Save all arguments */
	subq	$0x90, %rsp	/* 16-byte alignment */
	movq	%rax, -0x28(%rbp)
176
177
178
179
180
181
182
183

184
185
186
187
188
189
190
191
192
178
179
180
181
182
183
184

185


186
187
188
189
190
191
192







-
+
-
-







	jmp	OFMethodNotFound_stret
.def OFForward_stret
.scl 2
.type 32
.endef

init:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	leaq	module(%rip), %rcx
	jmp	__objc_exec_class

.section .ctors, "aw"
	.quad init

Modified src/forwarding/forwarding-x86-elf.S from [c03caf592c] to [e4a862d16c].

12
13
14
15
16
17
18






19
20
21
22
23
24
25

26
27
28
29
30
31
32
33
34
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

31


32
33
34
35
36
37
38







+
+
+
+
+
+






-
+
-
-







 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include "platform.h"

#ifdef HAVE_CET_H
# include <cet.h>
#else
# define _CET_ENDBR
#endif

.globl OFForward
.globl OFForward_stret

.section .text
OFForward:
#ifdef HAVE_ENDBR32
	_CET_ENDBR
	endbr32
#endif

	pushl	%ebp
	movl	%esp, %ebp

	pushl	%ebx
	subl	$20, %esp

86
87
88
89
90
91
92
93

94
95
96
97
98
99
100
101
102
90
91
92
93
94
95
96

97


98
99
100
101
102
103
104







-
+
-
-







	popl	%ebp

	jmp	*%eax
.type OFForward, %function
.size OFForward, .-OFForward

OFForward_stret:
#ifdef HAVE_ENDBR32
	_CET_ENDBR
	endbr32
#endif

	pushl	%ebp
	movl	%esp, %ebp

	pushl	%ebx
	subl	$20, %esp

154
155
156
157
158
159
160
161

162
163
164
165
166
167
168
169
170
156
157
158
159
160
161
162

163


164
165
166
167
168
169
170







-
+
-
-







	popl	%ebp

	jmp	*%eax
.type OFForward_stret, %function
.size OFForward_stret, .-OFForward_stret

init:
#ifdef HAVE_ENDBR32
	_CET_ENDBR
	endbr32
#endif

	pushl	%ebp
	movl	%esp, %ebp

	pushl	%ebx
	subl	$4, %esp

Modified src/forwarding/forwarding-x86-win32.S from [c4fe9cb723] to [4e5611c007].

13
14
15
16
17
18
19






20
21
22
23

24
25
26
27
28
29
30
31
32
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

29


30
31
32
33
34
35
36







+
+
+
+
+
+



-
+
-
-







 * file.
 */

#include "config.h"

.globl _OFForward
.globl _OFForward_stret

#ifdef HAVE_CET_H
# include <cet.h>
#else
# define _CET_ENDBR
#endif

.section .text
_OFForward:
#ifdef HAVE_ENDBR32
	_CET_ENDBR
	endbr32
#endif

	pushl	%ebp
	movl	%esp, %ebp

	pushl	%ebx
	subl	$20, %esp

81
82
83
84
85
86
87
88

89
90
91
92
93
94
95
96
97
85
86
87
88
89
90
91

92


93
94
95
96
97
98
99







-
+
-
-







	jmp	_OFMethodNotFound
.def _OFForward
.scl 2
.type 32
.endef

_OFForward_stret:
#ifdef HAVE_ENDBR32
	_CET_ENDBR
	endbr32
#endif

	pushl	%ebp
	movl	%esp, %ebp

	pushl	%ebx
	subl	$20, %esp

146
147
148
149
150
151
152
153

154
155
156
157
158
159
160
161
162
148
149
150
151
152
153
154

155


156
157
158
159
160
161
162







-
+
-
-







	jmp	_OFMethodNotFound_stret
.def _OFForward_stret
.scl 2
.type 32
.endef

init:
#ifdef HAVE_ENDBR32
	_CET_ENDBR
	endbr32
#endif

	pushl	%ebp
	movl	%esp, %ebp

	pushl	%ebx
	subl	$4, %esp

Modified src/runtime/lookup-asm/lookup-asm-amd64-elf.S from [0aa1c677f8] to [dba62cdfa5].

12
13
14
15
16
17
18






19
20
21
22
23
24
25
26
27
28

29
30
31
32
33
34
35
36
37
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

34


35
36
37
38
39
40
41







+
+
+
+
+
+









-
+
-
-







 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include "platform.h"

#ifdef HAVE_CET_H
# include <cet.h>
#else
# define _CET_ENDBR
#endif

.globl objc_msg_lookup
.globl objc_msg_lookup_stret
.globl objc_msg_lookup_super
.globl objc_msg_lookup_super_stret

.section .text
.macro GENERATE_LOOKUP name notFound
\name:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	testq	%rdi, %rdi
	jz	returnNilMethod

	testb	$1, %dil
	jnz	.LtaggedPointer_\name

68
69
70
71
72
73
74
75

76
77
78
79
80
81
82
83
84
72
73
74
75
76
77
78

79


80
81
82
83
84
85
86







-
+
-
-







	jmp	.Lmain_\name
.type \name, %function
.size \name, .-\name
.endm

.macro GENERATE_LOOKUP_SUPER name lookup
\name:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	movq	%rdi, %r8
	movq	(%rdi), %rdi
	testq	%rdi, %rdi
	jz	returnNilMethod

	movq	8(%r8), %r8

Modified src/runtime/lookup-asm/lookup-asm-amd64-win64.S from [a1a718f0ad] to [df92e91b57].

10
11
12
13
14
15
16






17
18
19
20
21
22
23
24
25
26

27
28
29
30
31
32
33
34
35
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

32


33
34
35
36
37
38
39







+
+
+
+
+
+









-
+
-
-







 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#ifdef HAVE_CET_H
# include <cet.h>
#else
# define _CET_ENDBR
#endif

.globl objc_msg_lookup
.globl objc_msg_lookup_stret
.globl objc_msg_lookup_super
.globl objc_msg_lookup_super_stret

.section .text
.macro GENERATE_LOOKUP name notFound
\name:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	testq	%rcx, %rcx
	jz	returnNilMethod

	testb	$1, %cl
	jnz	.LtaggedPointer_\name

75
76
77
78
79
80
81
82

83
84
85
86
87
88
89
90
91
79
80
81
82
83
84
85

86


87
88
89
90
91
92
93







-
+
-
-







.scl 2
.type 32
.endef
.endm

.macro GENERATE_LOOKUP_SUPER name lookup
\name:
#ifdef HAVE_ENDBR64
	_CET_ENDBR
	endbr64
#endif

	movq	%rcx, %r8
	movq	(%rcx), %rcx
	testq	%rcx, %rcx
	jz	returnNilMethod

	movq	8(%r8), %r8

Modified src/runtime/lookup-asm/lookup-asm-x86-elf.S from [ff64827806] to [d4dd1a2da5].

12
13
14
15
16
17
18






19
20
21
22
23
24
25
26
27
28

29
30
31
32
33
34
35
36
37
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

34


35
36
37
38
39
40
41







+
+
+
+
+
+









-
+
-
-







 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include "platform.h"

#ifdef HAVE_CET_H
# include <cet.h>
#else
# define _CET_ENDBR
#endif

.globl objc_msg_lookup
.globl objc_msg_lookup_stret
.globl objc_msg_lookup_super
.globl objc_msg_lookup_super_stret

.section .text
.macro GENERATE_LOOKUP name notFound
\name:
#ifdef HAVE_ENDBR32
	_CET_ENDBR
	endbr32
#endif

	movl	4(%esp), %edx
	testl	%edx, %edx
	jz	returnNilMethod

	testb	$1, %dl
	jnz	.LtaggedPointer_\name
78
79
80
81
82
83
84
85

86
87
88
89
90
91
92
93
94
82
83
84
85
86
87
88

89


90
91
92
93
94
95
96







-
+
-
-







	jmp	.Lmain_\name
.type \name, %function
.size \name, .-\name
.endm

.macro GENERATE_LOOKUP_SUPER name lookup
\name:
#ifdef HAVE_ENDBR32
	_CET_ENDBR
	endbr32
#endif

	movl	4(%esp), %edx
	movl	(%edx), %eax
	testl	%eax, %eax
	jz	returnNilMethod

	movl	%eax, 4(%esp)

Modified src/runtime/lookup-asm/lookup-asm-x86-win32.S from [ba2d9c7098] to [447b9d83b0].

10
11
12
13
14
15
16






17
18
19
20
21
22
23
24
25
26

27
28
29
30
31
32
33
34
35
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

32


33
34
35
36
37
38
39







+
+
+
+
+
+









-
+
-
-







 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#ifdef HAVE_CET_H
# include <cet.h>
#else
# define _CET_ENDBR
#endif

.globl _objc_msg_lookup
.globl _objc_msg_lookup_stret
.globl _objc_msg_lookup_super
.globl _objc_msg_lookup_super_stret

.section .text
.macro GENERATE_LOOKUP name notFound
\name:
#ifdef HAVE_ENDBR32
	_CET_ENDBR
	endbr32
#endif

	movl	4(%esp), %edx
	testl	%edx, %edx
	jz	returnNilMethod

	testb	$1, %dl
	jnz	.LtaggedPointer_\name
67
68
69
70
71
72
73
74

75
76
77
78
79
80
81
82
83
71
72
73
74
75
76
77

78


79
80
81
82
83
84
85







-
+
-
-







.scl 2
.type 32
.endef
.endm

.macro GENERATE_LOOKUP_SUPER name lookup
\name:
#ifdef HAVE_ENDBR32
	_CET_ENDBR
	endbr32
#endif

	movl	4(%esp), %edx
	movl	(%edx), %eax
	test	%eax, %eax
	jz	returnNilMethod

	movl	%eax, 4(%esp)