ffi 1.12.2 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.appveyor.yml +3 -0
- data/.github/workflows/ci.yml +64 -0
- data/.travis.yml +19 -5
- data/CHANGELOG.md +30 -0
- data/Gemfile +4 -2
- data/Rakefile +24 -43
- data/ext/ffi_c/Buffer.c +2 -2
- data/ext/ffi_c/Call.c +1 -7
- data/ext/ffi_c/ClosurePool.c +11 -14
- data/ext/ffi_c/Function.c +8 -23
- data/ext/ffi_c/FunctionInfo.c +1 -2
- data/ext/ffi_c/LongDouble.c +5 -3
- data/ext/ffi_c/LongDouble.h +0 -4
- data/ext/ffi_c/MemoryPointer.c +1 -1
- data/ext/ffi_c/MethodHandle.c +18 -24
- data/ext/ffi_c/MethodHandle.h +3 -2
- data/ext/ffi_c/Platform.c +1 -0
- data/ext/ffi_c/Pointer.c +1 -1
- data/ext/ffi_c/StructLayout.c +7 -2
- data/ext/ffi_c/Thread.c +0 -3
- data/ext/ffi_c/Thread.h +0 -3
- data/ext/ffi_c/compat.h +4 -0
- data/ext/ffi_c/extconf.rb +13 -15
- data/ext/ffi_c/libffi/.travis.yml +4 -0
- data/ext/ffi_c/libffi/.travis/build.sh +4 -0
- data/ext/ffi_c/libffi/Makefile.am +2 -1
- data/ext/ffi_c/libffi/README.md +7 -1
- data/ext/ffi_c/libffi/configure.ac +25 -9
- data/ext/ffi_c/libffi/include/ffi.h.in +8 -0
- data/ext/ffi_c/libffi/libffi.map.in +8 -12
- data/ext/ffi_c/libffi/libtool-version +1 -1
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +6 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +13 -2
- data/ext/ffi_c/libffi/src/closures.c +10 -4
- data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
- data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
- data/ext/ffi_c/libffi/src/pa/linux.S +4 -2
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
- data/ext/ffi_c/libffi/src/x86/ffi.c +7 -4
- data/ext/ffi_c/libffi/src/x86/ffi64.c +10 -8
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +10 -8
- data/ext/ffi_c/libffi/src/x86/sysv.S +13 -4
- data/ext/ffi_c/libffi/src/x86/unix64.S +58 -2
- data/ext/ffi_c/libffi/src/x86/win64.S +4 -1
- data/ffi.gemspec +1 -1
- data/lib/ffi.rb +10 -2
- data/lib/ffi/library.rb +5 -1
- data/lib/ffi/platform.rb +2 -2
- data/lib/ffi/platform/arm-linux/types.conf +32 -4
- data/lib/ffi/platform/i386-windows/types.conf +26 -79
- data/lib/ffi/platform/powerpc-linux/types.conf +32 -2
- data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
- data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
- data/lib/ffi/platform/x86_64-darwin/types.conf +4 -0
- data/lib/ffi/platform/x86_64-linux/types.conf +21 -0
- data/lib/ffi/platform/x86_64-windows/types.conf +10 -78
- data/lib/ffi/pointer.rb +19 -12
- data/lib/ffi/struct.rb +8 -2
- data/lib/ffi/tools/types_generator.rb +2 -0
- data/lib/ffi/version.rb +1 -1
- data/samples/getlogin.rb +1 -1
- data/samples/getpid.rb +1 -1
- data/samples/gettimeofday.rb +8 -8
- data/samples/hello.rb +2 -1
- data/samples/inotify.rb +1 -1
- data/samples/pty.rb +1 -2
- data/samples/qsort.rb +0 -1
- metadata +6 -4
- data/samples/sample_helper.rb +0 -6
@@ -68,12 +68,7 @@ typedef enum ffi_abi {
|
|
68
68
|
|
69
69
|
#define FFI_CLOSURES 1
|
70
70
|
#define FFI_NATIVE_RAW_API 0
|
71
|
-
|
72
|
-
#ifdef PA_LINUX
|
73
|
-
#define FFI_TRAMPOLINE_SIZE 32
|
74
|
-
#else
|
75
|
-
#define FFI_TRAMPOLINE_SIZE 40
|
76
|
-
#endif
|
71
|
+
#define FFI_TRAMPOLINE_SIZE 12
|
77
72
|
|
78
73
|
#define FFI_TYPE_SMALL_STRUCT2 -1
|
79
74
|
#define FFI_TYPE_SMALL_STRUCT3 -2
|
@@ -259,7 +259,7 @@ L$done
|
|
259
259
|
L$FE1
|
260
260
|
|
261
261
|
/* void ffi_closure_pa32(void);
|
262
|
-
Called with closure argument in %
|
262
|
+
Called with closure argument in %r19 */
|
263
263
|
|
264
264
|
.SPACE $TEXT$
|
265
265
|
.SUBSPA $CODE$
|
@@ -285,7 +285,9 @@ L$CFI22
|
|
285
285
|
stw %arg2, -44(%r3)
|
286
286
|
stw %arg3, -48(%r3)
|
287
287
|
|
288
|
-
|
288
|
+
/* Retrieve closure pointer and real gp. */
|
289
|
+
copy %r19, %arg0
|
290
|
+
ldw 8(%r19), %r19
|
289
291
|
bl ffi_closure_inner_pa32, %r2
|
290
292
|
copy %r3, %arg1
|
291
293
|
ldwm -64(%sp), %r3
|
@@ -252,7 +252,7 @@ ffi_call_pa32:
|
|
252
252
|
.LFE1:
|
253
253
|
|
254
254
|
/* void ffi_closure_pa32(void);
|
255
|
-
Called with closure argument in %
|
255
|
+
Called with closure argument in %r19 */
|
256
256
|
.export ffi_closure_pa32,code
|
257
257
|
.import ffi_closure_inner_pa32,code
|
258
258
|
|
@@ -277,7 +277,9 @@ ffi_closure_pa32:
|
|
277
277
|
stw %arg2, -44(%r3)
|
278
278
|
stw %arg3, -48(%r3)
|
279
279
|
|
280
|
-
|
280
|
+
/* Retrieve closure pointer and real gp. */
|
281
|
+
copy %r19, %arg0
|
282
|
+
ldw 8(%r19), %r19
|
281
283
|
bl ffi_closure_inner_pa32, %r2
|
282
284
|
copy %r3, %arg1
|
283
285
|
|
@@ -104,17 +104,16 @@ ENTRY(ffi_call_SYSV)
|
|
104
104
|
bctrl
|
105
105
|
|
106
106
|
/* Now, deal with the return value. */
|
107
|
-
mtcrf
|
107
|
+
mtcrf 0x03,%r31 /* cr6-cr7 */
|
108
108
|
bt- 31,L(small_struct_return_value)
|
109
109
|
bt- 30,L(done_return_value)
|
110
110
|
#ifndef __NO_FPRS__
|
111
111
|
bt- 29,L(fp_return_value)
|
112
112
|
#endif
|
113
113
|
stw %r3,0(%r30)
|
114
|
-
bf+
|
114
|
+
bf+ 27,L(done_return_value)
|
115
115
|
stw %r4,4(%r30)
|
116
|
-
|
117
|
-
bf 27,L(done_return_value)
|
116
|
+
bf 26,L(done_return_value)
|
118
117
|
stw %r5,8(%r30)
|
119
118
|
stw %r6,12(%r30)
|
120
119
|
/* Fall through... */
|
@@ -145,10 +144,9 @@ L(done_return_value):
|
|
145
144
|
#ifndef __NO_FPRS__
|
146
145
|
L(fp_return_value):
|
147
146
|
.cfi_restore_state
|
148
|
-
bf
|
147
|
+
bf 27,L(float_return_value)
|
149
148
|
stfd %f1,0(%r30)
|
150
|
-
|
151
|
-
bf 27,L(done_return_value)
|
149
|
+
bf 26,L(done_return_value)
|
152
150
|
stfd %f2,8(%r30)
|
153
151
|
b L(done_return_value)
|
154
152
|
L(float_return_value):
|
@@ -557,13 +557,16 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
|
557
557
|
return FFI_BAD_ABI;
|
558
558
|
}
|
559
559
|
|
560
|
+
/* endbr32. */
|
561
|
+
*(UINT32 *) tramp = 0xfb1e0ff3;
|
562
|
+
|
560
563
|
/* movl or pushl immediate. */
|
561
|
-
tramp[
|
562
|
-
*(void **)(tramp +
|
564
|
+
tramp[4] = op;
|
565
|
+
*(void **)(tramp + 5) = codeloc;
|
563
566
|
|
564
567
|
/* jmp dest */
|
565
|
-
tramp[
|
566
|
-
*(unsigned *)(tramp +
|
568
|
+
tramp[9] = 0xe9;
|
569
|
+
*(unsigned *)(tramp + 10) = (unsigned)dest - ((unsigned)codeloc + 14);
|
567
570
|
|
568
571
|
closure->cif = cif;
|
569
572
|
closure->fun = fun;
|
@@ -728,13 +728,15 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
|
728
728
|
void *user_data,
|
729
729
|
void *codeloc)
|
730
730
|
{
|
731
|
-
static const unsigned char trampoline[
|
732
|
-
/*
|
733
|
-
|
734
|
-
/*
|
735
|
-
|
736
|
-
/*
|
737
|
-
|
731
|
+
static const unsigned char trampoline[24] = {
|
732
|
+
/* endbr64 */
|
733
|
+
0xf3, 0x0f, 0x1e, 0xfa,
|
734
|
+
/* leaq -0xb(%rip),%r10 # 0x0 */
|
735
|
+
0x4c, 0x8d, 0x15, 0xf5, 0xff, 0xff, 0xff,
|
736
|
+
/* jmpq *0x7(%rip) # 0x18 */
|
737
|
+
0xff, 0x25, 0x07, 0x00, 0x00, 0x00,
|
738
|
+
/* nopl 0(%rax) */
|
739
|
+
0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
|
738
740
|
};
|
739
741
|
void (*dest)(void);
|
740
742
|
char *tramp = closure->tramp;
|
@@ -752,7 +754,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
|
752
754
|
dest = ffi_closure_unix64;
|
753
755
|
|
754
756
|
memcpy (tramp, trampoline, sizeof(trampoline));
|
755
|
-
*(UINT64 *)(tramp +
|
757
|
+
*(UINT64 *)(tramp + sizeof (trampoline)) = (uintptr_t)dest;
|
756
758
|
|
757
759
|
closure->cif = cif;
|
758
760
|
closure->fun = fun;
|
@@ -136,12 +136,25 @@ typedef enum ffi_abi {
|
|
136
136
|
|
137
137
|
#if defined (X86_64) || defined(X86_WIN64) \
|
138
138
|
|| (defined (__x86_64__) && defined (X86_DARWIN))
|
139
|
-
|
139
|
+
/* 4 bytes of ENDBR64 + 7 bytes of LEA + 6 bytes of JMP + 7 bytes of NOP
|
140
|
+
+ 8 bytes of pointer. */
|
141
|
+
# define FFI_TRAMPOLINE_SIZE 32
|
140
142
|
# define FFI_NATIVE_RAW_API 0
|
141
143
|
#else
|
142
|
-
|
144
|
+
/* 4 bytes of ENDBR32 + 5 bytes of MOV + 5 bytes of JMP + 2 unused
|
145
|
+
bytes. */
|
146
|
+
# define FFI_TRAMPOLINE_SIZE 16
|
143
147
|
# define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
|
144
148
|
#endif
|
145
149
|
|
150
|
+
#if !defined(GENERATE_LIBFFI_MAP) && defined(__ASSEMBLER__) \
|
151
|
+
&& defined(__CET__)
|
152
|
+
# include <cet.h>
|
153
|
+
# define _CET_NOTRACK notrack
|
154
|
+
#else
|
155
|
+
# define _CET_ENDBR
|
156
|
+
# define _CET_NOTRACK
|
157
|
+
#endif
|
158
|
+
|
146
159
|
#endif
|
147
160
|
|
@@ -196,13 +196,15 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure,
|
|
196
196
|
void *user_data,
|
197
197
|
void *codeloc)
|
198
198
|
{
|
199
|
-
static const unsigned char trampoline[
|
200
|
-
/*
|
201
|
-
|
202
|
-
/*
|
203
|
-
|
204
|
-
/*
|
205
|
-
|
199
|
+
static const unsigned char trampoline[FFI_TRAMPOLINE_SIZE - 8] = {
|
200
|
+
/* endbr64 */
|
201
|
+
0xf3, 0x0f, 0x1e, 0xfa,
|
202
|
+
/* leaq -0xb(%rip),%r10 # 0x0 */
|
203
|
+
0x4c, 0x8d, 0x15, 0xf5, 0xff, 0xff, 0xff,
|
204
|
+
/* jmpq *0x7(%rip) # 0x18 */
|
205
|
+
0xff, 0x25, 0x07, 0x00, 0x00, 0x00,
|
206
|
+
/* nopl 0(%rax) */
|
207
|
+
0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
|
206
208
|
};
|
207
209
|
char *tramp = closure->tramp;
|
208
210
|
|
@@ -216,7 +218,7 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure,
|
|
216
218
|
}
|
217
219
|
|
218
220
|
memcpy (tramp, trampoline, sizeof(trampoline));
|
219
|
-
*(UINT64 *)(tramp +
|
221
|
+
*(UINT64 *)(tramp + sizeof (trampoline)) = (uintptr_t)ffi_closure_win64;
|
220
222
|
|
221
223
|
closure->cif = cif;
|
222
224
|
closure->fun = fun;
|
@@ -92,6 +92,7 @@
|
|
92
92
|
ffi_call_i386:
|
93
93
|
L(UW0):
|
94
94
|
# cfi_startproc
|
95
|
+
_CET_ENDBR
|
95
96
|
#if !HAVE_FASTCALL
|
96
97
|
movl 4(%esp), %ecx
|
97
98
|
movl 8(%esp), %edx
|
@@ -133,7 +134,7 @@ L(pc1):
|
|
133
134
|
leal L(store_table)(,%ecx, 8), %ebx
|
134
135
|
#endif
|
135
136
|
movl 16(%ebp), %ecx /* load result address */
|
136
|
-
jmp
|
137
|
+
_CET_NOTRACK jmp *%ebx
|
137
138
|
|
138
139
|
.balign 8
|
139
140
|
L(store_table):
|
@@ -256,7 +257,7 @@ ENDF(ffi_call_i386)
|
|
256
257
|
andl $X86_RET_TYPE_MASK, %eax; \
|
257
258
|
leal L(C1(load_table,N))(, %eax, 8), %edx; \
|
258
259
|
movl closure_CF(%esp), %eax; /* optimiztic load */ \
|
259
|
-
jmp
|
260
|
+
_CET_NOTRACK jmp *%edx
|
260
261
|
|
261
262
|
#ifdef __PIC__
|
262
263
|
# if defined X86_DARWIN || defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
|
@@ -267,7 +268,7 @@ ENDF(ffi_call_i386)
|
|
267
268
|
L(C1(pc,N)): \
|
268
269
|
leal L(C1(load_table,N))-L(C1(pc,N))(%edx, %eax, 8), %edx; \
|
269
270
|
movl closure_CF(%esp), %eax; /* optimiztic load */ \
|
270
|
-
jmp
|
271
|
+
_CET_NOTRACK jmp *%edx
|
271
272
|
# else
|
272
273
|
# define FFI_CLOSURE_CALL_INNER_SAVE_EBX
|
273
274
|
# undef FFI_CLOSURE_CALL_INNER
|
@@ -286,7 +287,7 @@ L(C1(UW,UWN)): \
|
|
286
287
|
L(C1(UW,UWN)): \
|
287
288
|
/* cfi_restore(%ebx); */ \
|
288
289
|
movl closure_CF(%esp), %eax; /* optimiztic load */ \
|
289
|
-
jmp
|
290
|
+
_CET_NOTRACK jmp *%edx
|
290
291
|
# endif /* DARWIN || HIDDEN */
|
291
292
|
#endif /* __PIC__ */
|
292
293
|
|
@@ -296,6 +297,7 @@ L(C1(UW,UWN)): \
|
|
296
297
|
C(ffi_go_closure_EAX):
|
297
298
|
L(UW6):
|
298
299
|
# cfi_startproc
|
300
|
+
_CET_ENDBR
|
299
301
|
subl $closure_FS, %esp
|
300
302
|
L(UW7):
|
301
303
|
# cfi_def_cfa_offset(closure_FS + 4)
|
@@ -316,6 +318,7 @@ ENDF(C(ffi_go_closure_EAX))
|
|
316
318
|
C(ffi_go_closure_ECX):
|
317
319
|
L(UW9):
|
318
320
|
# cfi_startproc
|
321
|
+
_CET_ENDBR
|
319
322
|
subl $closure_FS, %esp
|
320
323
|
L(UW10):
|
321
324
|
# cfi_def_cfa_offset(closure_FS + 4)
|
@@ -340,6 +343,7 @@ ENDF(C(ffi_go_closure_ECX))
|
|
340
343
|
C(ffi_closure_i386):
|
341
344
|
L(UW12):
|
342
345
|
# cfi_startproc
|
346
|
+
_CET_ENDBR
|
343
347
|
subl $closure_FS, %esp
|
344
348
|
L(UW13):
|
345
349
|
# cfi_def_cfa_offset(closure_FS + 4)
|
@@ -423,6 +427,7 @@ ENDF(C(ffi_closure_i386))
|
|
423
427
|
C(ffi_go_closure_STDCALL):
|
424
428
|
L(UW21):
|
425
429
|
# cfi_startproc
|
430
|
+
_CET_ENDBR
|
426
431
|
subl $closure_FS, %esp
|
427
432
|
L(UW22):
|
428
433
|
# cfi_def_cfa_offset(closure_FS + 4)
|
@@ -448,6 +453,7 @@ L(UW24):
|
|
448
453
|
# cfi_startproc
|
449
454
|
# cfi_def_cfa(%esp, 8)
|
450
455
|
# cfi_offset(%eip, -8)
|
456
|
+
_CET_ENDBR
|
451
457
|
subl $closure_FS-4, %esp
|
452
458
|
L(UW25):
|
453
459
|
# cfi_def_cfa_offset(closure_FS + 4)
|
@@ -470,6 +476,7 @@ ENDF(C(ffi_closure_REGISTER))
|
|
470
476
|
C(ffi_closure_STDCALL):
|
471
477
|
L(UW27):
|
472
478
|
# cfi_startproc
|
479
|
+
_CET_ENDBR
|
473
480
|
subl $closure_FS, %esp
|
474
481
|
L(UW28):
|
475
482
|
# cfi_def_cfa_offset(closure_FS + 4)
|
@@ -576,6 +583,7 @@ ENDF(C(ffi_closure_STDCALL))
|
|
576
583
|
C(ffi_closure_raw_SYSV):
|
577
584
|
L(UW32):
|
578
585
|
# cfi_startproc
|
586
|
+
_CET_ENDBR
|
579
587
|
subl $raw_closure_S_FS, %esp
|
580
588
|
L(UW33):
|
581
589
|
# cfi_def_cfa_offset(raw_closure_S_FS + 4)
|
@@ -679,6 +687,7 @@ ENDF(C(ffi_closure_raw_SYSV))
|
|
679
687
|
C(ffi_closure_raw_THISCALL):
|
680
688
|
L(UW41):
|
681
689
|
# cfi_startproc
|
690
|
+
_CET_ENDBR
|
682
691
|
/* Rearrange the stack such that %ecx is the first argument.
|
683
692
|
This means moving the return address. */
|
684
693
|
popl %edx
|
@@ -42,7 +42,11 @@
|
|
42
42
|
#if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__))
|
43
43
|
# define E(BASE, X) .balign 8
|
44
44
|
#else
|
45
|
-
#
|
45
|
+
# ifdef __CET__
|
46
|
+
# define E(BASE, X) .balign 8; .org BASE + X * 16
|
47
|
+
# else
|
48
|
+
# define E(BASE, X) .balign 8; .org BASE + X * 8
|
49
|
+
# endif
|
46
50
|
#endif
|
47
51
|
|
48
52
|
/* ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
|
@@ -58,6 +62,7 @@
|
|
58
62
|
|
59
63
|
C(ffi_call_unix64):
|
60
64
|
L(UW0):
|
65
|
+
_CET_ENDBR
|
61
66
|
movq (%rsp), %r10 /* Load return address. */
|
62
67
|
leaq (%rdi, %rsi), %rax /* Find local stack base. */
|
63
68
|
movq %rdx, (%rax) /* Save flags. */
|
@@ -116,6 +121,11 @@ L(UW2):
|
|
116
121
|
movzbl %cl, %r10d
|
117
122
|
leaq L(store_table)(%rip), %r11
|
118
123
|
ja L(sa)
|
124
|
+
#ifdef __CET__
|
125
|
+
/* NB: Originally, each slot is 8 byte. 4 bytes of ENDBR64 +
|
126
|
+
4 bytes NOP padding double slot size to 16 bytes. */
|
127
|
+
addl %r10d, %r10d
|
128
|
+
#endif
|
119
129
|
leaq (%r11, %r10, 8), %r10
|
120
130
|
|
121
131
|
/* Prep for the structure cases: scratch area in redzone. */
|
@@ -125,57 +135,73 @@ L(UW2):
|
|
125
135
|
.balign 8
|
126
136
|
L(store_table):
|
127
137
|
E(L(store_table), UNIX64_RET_VOID)
|
138
|
+
_CET_ENDBR
|
128
139
|
ret
|
129
140
|
E(L(store_table), UNIX64_RET_UINT8)
|
141
|
+
_CET_ENDBR
|
130
142
|
movzbl %al, %eax
|
131
143
|
movq %rax, (%rdi)
|
132
144
|
ret
|
133
145
|
E(L(store_table), UNIX64_RET_UINT16)
|
146
|
+
_CET_ENDBR
|
134
147
|
movzwl %ax, %eax
|
135
148
|
movq %rax, (%rdi)
|
136
149
|
ret
|
137
150
|
E(L(store_table), UNIX64_RET_UINT32)
|
151
|
+
_CET_ENDBR
|
138
152
|
movl %eax, %eax
|
139
153
|
movq %rax, (%rdi)
|
140
154
|
ret
|
141
155
|
E(L(store_table), UNIX64_RET_SINT8)
|
156
|
+
_CET_ENDBR
|
142
157
|
movsbq %al, %rax
|
143
158
|
movq %rax, (%rdi)
|
144
159
|
ret
|
145
160
|
E(L(store_table), UNIX64_RET_SINT16)
|
161
|
+
_CET_ENDBR
|
146
162
|
movswq %ax, %rax
|
147
163
|
movq %rax, (%rdi)
|
148
164
|
ret
|
149
165
|
E(L(store_table), UNIX64_RET_SINT32)
|
166
|
+
_CET_ENDBR
|
150
167
|
cltq
|
151
168
|
movq %rax, (%rdi)
|
152
169
|
ret
|
153
170
|
E(L(store_table), UNIX64_RET_INT64)
|
171
|
+
_CET_ENDBR
|
154
172
|
movq %rax, (%rdi)
|
155
173
|
ret
|
156
174
|
E(L(store_table), UNIX64_RET_XMM32)
|
175
|
+
_CET_ENDBR
|
157
176
|
movd %xmm0, (%rdi)
|
158
177
|
ret
|
159
178
|
E(L(store_table), UNIX64_RET_XMM64)
|
179
|
+
_CET_ENDBR
|
160
180
|
movq %xmm0, (%rdi)
|
161
181
|
ret
|
162
182
|
E(L(store_table), UNIX64_RET_X87)
|
183
|
+
_CET_ENDBR
|
163
184
|
fstpt (%rdi)
|
164
185
|
ret
|
165
186
|
E(L(store_table), UNIX64_RET_X87_2)
|
187
|
+
_CET_ENDBR
|
166
188
|
fstpt (%rdi)
|
167
189
|
fstpt 16(%rdi)
|
168
190
|
ret
|
169
191
|
E(L(store_table), UNIX64_RET_ST_XMM0_RAX)
|
192
|
+
_CET_ENDBR
|
170
193
|
movq %rax, 8(%rsi)
|
171
194
|
jmp L(s3)
|
172
195
|
E(L(store_table), UNIX64_RET_ST_RAX_XMM0)
|
196
|
+
_CET_ENDBR
|
173
197
|
movq %xmm0, 8(%rsi)
|
174
198
|
jmp L(s2)
|
175
199
|
E(L(store_table), UNIX64_RET_ST_XMM0_XMM1)
|
200
|
+
_CET_ENDBR
|
176
201
|
movq %xmm1, 8(%rsi)
|
177
202
|
jmp L(s3)
|
178
203
|
E(L(store_table), UNIX64_RET_ST_RAX_RDX)
|
204
|
+
_CET_ENDBR
|
179
205
|
movq %rdx, 8(%rsi)
|
180
206
|
L(s2):
|
181
207
|
movq %rax, (%rsi)
|
@@ -227,6 +253,7 @@ ENDF(C(ffi_call_unix64))
|
|
227
253
|
|
228
254
|
C(ffi_closure_unix64_sse):
|
229
255
|
L(UW5):
|
256
|
+
_CET_ENDBR
|
230
257
|
subq $ffi_closure_FS, %rsp
|
231
258
|
L(UW6):
|
232
259
|
/* cfi_adjust_cfa_offset(ffi_closure_FS) */
|
@@ -250,6 +277,7 @@ ENDF(C(ffi_closure_unix64_sse))
|
|
250
277
|
|
251
278
|
C(ffi_closure_unix64):
|
252
279
|
L(UW8):
|
280
|
+
_CET_ENDBR
|
253
281
|
subq $ffi_closure_FS, %rsp
|
254
282
|
L(UW9):
|
255
283
|
/* cfi_adjust_cfa_offset(ffi_closure_FS) */
|
@@ -286,6 +314,11 @@ L(UW10):
|
|
286
314
|
movzbl %al, %r10d
|
287
315
|
leaq L(load_table)(%rip), %r11
|
288
316
|
ja L(la)
|
317
|
+
#ifdef __CET__
|
318
|
+
/* NB: Originally, each slot is 8 byte. 4 bytes of ENDBR64 +
|
319
|
+
4 bytes NOP padding double slot size to 16 bytes. */
|
320
|
+
addl %r10d, %r10d
|
321
|
+
#endif
|
289
322
|
leaq (%r11, %r10, 8), %r10
|
290
323
|
leaq ffi_closure_RED_RVALUE(%rsp), %rsi
|
291
324
|
jmp *%r10
|
@@ -293,51 +326,67 @@ L(UW10):
|
|
293
326
|
.balign 8
|
294
327
|
L(load_table):
|
295
328
|
E(L(load_table), UNIX64_RET_VOID)
|
329
|
+
_CET_ENDBR
|
296
330
|
ret
|
297
331
|
E(L(load_table), UNIX64_RET_UINT8)
|
332
|
+
_CET_ENDBR
|
298
333
|
movzbl (%rsi), %eax
|
299
334
|
ret
|
300
335
|
E(L(load_table), UNIX64_RET_UINT16)
|
336
|
+
_CET_ENDBR
|
301
337
|
movzwl (%rsi), %eax
|
302
338
|
ret
|
303
339
|
E(L(load_table), UNIX64_RET_UINT32)
|
340
|
+
_CET_ENDBR
|
304
341
|
movl (%rsi), %eax
|
305
342
|
ret
|
306
343
|
E(L(load_table), UNIX64_RET_SINT8)
|
344
|
+
_CET_ENDBR
|
307
345
|
movsbl (%rsi), %eax
|
308
346
|
ret
|
309
347
|
E(L(load_table), UNIX64_RET_SINT16)
|
348
|
+
_CET_ENDBR
|
310
349
|
movswl (%rsi), %eax
|
311
350
|
ret
|
312
351
|
E(L(load_table), UNIX64_RET_SINT32)
|
352
|
+
_CET_ENDBR
|
313
353
|
movl (%rsi), %eax
|
314
354
|
ret
|
315
355
|
E(L(load_table), UNIX64_RET_INT64)
|
356
|
+
_CET_ENDBR
|
316
357
|
movq (%rsi), %rax
|
317
358
|
ret
|
318
359
|
E(L(load_table), UNIX64_RET_XMM32)
|
360
|
+
_CET_ENDBR
|
319
361
|
movd (%rsi), %xmm0
|
320
362
|
ret
|
321
363
|
E(L(load_table), UNIX64_RET_XMM64)
|
364
|
+
_CET_ENDBR
|
322
365
|
movq (%rsi), %xmm0
|
323
366
|
ret
|
324
367
|
E(L(load_table), UNIX64_RET_X87)
|
368
|
+
_CET_ENDBR
|
325
369
|
fldt (%rsi)
|
326
370
|
ret
|
327
371
|
E(L(load_table), UNIX64_RET_X87_2)
|
372
|
+
_CET_ENDBR
|
328
373
|
fldt 16(%rsi)
|
329
374
|
fldt (%rsi)
|
330
375
|
ret
|
331
376
|
E(L(load_table), UNIX64_RET_ST_XMM0_RAX)
|
377
|
+
_CET_ENDBR
|
332
378
|
movq 8(%rsi), %rax
|
333
379
|
jmp L(l3)
|
334
380
|
E(L(load_table), UNIX64_RET_ST_RAX_XMM0)
|
381
|
+
_CET_ENDBR
|
335
382
|
movq 8(%rsi), %xmm0
|
336
383
|
jmp L(l2)
|
337
384
|
E(L(load_table), UNIX64_RET_ST_XMM0_XMM1)
|
385
|
+
_CET_ENDBR
|
338
386
|
movq 8(%rsi), %xmm1
|
339
387
|
jmp L(l3)
|
340
388
|
E(L(load_table), UNIX64_RET_ST_RAX_RDX)
|
389
|
+
_CET_ENDBR
|
341
390
|
movq 8(%rsi), %rdx
|
342
391
|
L(l2):
|
343
392
|
movq (%rsi), %rax
|
@@ -358,6 +407,7 @@ ENDF(C(ffi_closure_unix64))
|
|
358
407
|
|
359
408
|
C(ffi_go_closure_unix64_sse):
|
360
409
|
L(UW12):
|
410
|
+
_CET_ENDBR
|
361
411
|
subq $ffi_closure_FS, %rsp
|
362
412
|
L(UW13):
|
363
413
|
/* cfi_adjust_cfa_offset(ffi_closure_FS) */
|
@@ -381,6 +431,7 @@ ENDF(C(ffi_go_closure_unix64_sse))
|
|
381
431
|
|
382
432
|
C(ffi_go_closure_unix64):
|
383
433
|
L(UW15):
|
434
|
+
_CET_ENDBR
|
384
435
|
subq $ffi_closure_FS, %rsp
|
385
436
|
L(UW16):
|
386
437
|
/* cfi_adjust_cfa_offset(ffi_closure_FS) */
|
@@ -424,7 +475,12 @@ EHFrame0:
|
|
424
475
|
#endif
|
425
476
|
|
426
477
|
/* Simplify advancing between labels. Assume DW_CFA_advance_loc1 fits. */
|
427
|
-
#
|
478
|
+
#ifdef __CET__
|
479
|
+
/* Use DW_CFA_advance_loc2 when IBT is enabled. */
|
480
|
+
# define ADV(N, P) .byte 3; .2byte L(N)-L(P)
|
481
|
+
#else
|
482
|
+
# define ADV(N, P) .byte 2, L(N)-L(P)
|
483
|
+
#endif
|
428
484
|
|
429
485
|
.balign 8
|
430
486
|
L(CIE):
|