ffi 1.12.1 → 1.13.1
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 +47 -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/Struct.c +47 -51
- data/ext/ffi_c/Struct.h +12 -6
- data/ext/ffi_c/StructLayout.c +20 -14
- 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 +16 -20
- 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 +6 -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-dragonflybsd/types.conf +4 -22
- 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 +9 -4
- 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
@@ -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):
|
@@ -48,6 +48,7 @@
|
|
48
48
|
SEH(.seh_proc ffi_call_win64)
|
49
49
|
C(ffi_call_win64):
|
50
50
|
cfi_startproc
|
51
|
+
_CET_ENDBR
|
51
52
|
/* Set up the local stack frame and install it in rbp/rsp. */
|
52
53
|
movq (%rsp), %rax
|
53
54
|
movq %rbp, (arg1)
|
@@ -80,7 +81,7 @@ C(ffi_call_win64):
|
|
80
81
|
cmpl $FFI_TYPE_SMALL_STRUCT_4B, %ecx
|
81
82
|
leaq (%r10, %rcx, 8), %r10
|
82
83
|
ja 99f
|
83
|
-
jmp
|
84
|
+
_CET_NOTRACK jmp *%r10
|
84
85
|
|
85
86
|
/* Below, we're space constrained most of the time. Thus we eschew the
|
86
87
|
modern "mov, pop, ret" sequence (5 bytes) for "leave, ret" (2 bytes). */
|
@@ -176,6 +177,7 @@ E(0b, FFI_TYPE_SMALL_STRUCT_4B)
|
|
176
177
|
SEH(.seh_proc ffi_go_closure_win64)
|
177
178
|
C(ffi_go_closure_win64):
|
178
179
|
cfi_startproc
|
180
|
+
_CET_ENDBR
|
179
181
|
/* Save all integer arguments into the incoming reg stack space. */
|
180
182
|
movq %rcx, 8(%rsp)
|
181
183
|
movq %rdx, 16(%rsp)
|
@@ -196,6 +198,7 @@ C(ffi_go_closure_win64):
|
|
196
198
|
SEH(.seh_proc ffi_closure_win64)
|
197
199
|
C(ffi_closure_win64):
|
198
200
|
cfi_startproc
|
201
|
+
_CET_ENDBR
|
199
202
|
/* Save all integer arguments into the incoming reg stack space. */
|
200
203
|
movq %rcx, 8(%rsp)
|
201
204
|
movq %rdx, 16(%rsp)
|
data/ffi.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.rdoc_options = %w[--exclude=ext/ffi_c/.*\.o$ --exclude=ffi_c\.(bundle|so)$]
|
35
35
|
s.license = 'BSD-3-Clause'
|
36
36
|
s.require_paths << 'ext/ffi_c'
|
37
|
-
s.required_ruby_version = '>= 2.
|
37
|
+
s.required_ruby_version = '>= 2.3'
|
38
38
|
s.add_development_dependency 'rake', '~> 13.0'
|
39
39
|
s.add_development_dependency 'rake-compiler', '~> 1.0'
|
40
40
|
s.add_development_dependency 'rake-compiler-dock', '~> 1.0'
|
data/lib/ffi.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
if
|
1
|
+
if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
|
2
2
|
Object.send(:remove_const, :FFI) if defined?(::FFI)
|
3
3
|
begin
|
4
4
|
require RUBY_VERSION.split('.')[0, 2].join('.') + '/ffi_c'
|
@@ -8,7 +8,15 @@ if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
|
|
8
8
|
|
9
9
|
require 'ffi/ffi'
|
10
10
|
|
11
|
-
elsif
|
11
|
+
elsif RUBY_ENGINE == 'jruby' && Gem::Version.new(RUBY_ENGINE_VERSION) >= Gem::Version.new("9.3.pre")
|
12
|
+
JRuby::Util.load_ext("org.jruby.ext.ffi.FFIService")
|
13
|
+
require 'ffi/ffi'
|
14
|
+
|
15
|
+
elsif RUBY_ENGINE == 'truffleruby' && Gem::Version.new(RUBY_ENGINE_VERSION) >= Gem::Version.new("20.1.0-dev-a")
|
16
|
+
require 'truffleruby/ffi_backend'
|
17
|
+
require 'ffi/ffi'
|
18
|
+
|
19
|
+
else
|
12
20
|
# Remove the ffi gem dir from the load path, then reload the internal ffi implementation
|
13
21
|
$LOAD_PATH.delete(File.dirname(__FILE__))
|
14
22
|
$LOAD_PATH.delete(File.join(File.dirname(__FILE__), 'ffi'))
|
data/lib/ffi/library.rb
CHANGED
@@ -394,7 +394,11 @@ module FFI
|
|
394
394
|
options = Hash.new
|
395
395
|
options[:convention] = ffi_convention
|
396
396
|
options[:enums] = @ffi_enums if defined?(@ffi_enums)
|
397
|
-
|
397
|
+
ret_type = find_type(ret)
|
398
|
+
if ret_type == Type::STRING
|
399
|
+
raise TypeError, ":string is not allowed as return type of callbacks"
|
400
|
+
end
|
401
|
+
cb = FFI::CallbackInfo.new(ret_type, native_params, options)
|
398
402
|
|
399
403
|
# Add to the symbol -> type map (unless there was no name)
|
400
404
|
unless name.nil?
|
data/lib/ffi/platform.rb
CHANGED
@@ -61,7 +61,7 @@ module FFI
|
|
61
61
|
CPU = RbConfig::CONFIG['host_cpu']
|
62
62
|
|
63
63
|
ARCH = case CPU.downcase
|
64
|
-
when /amd64|x86_64/
|
64
|
+
when /amd64|x86_64|x64/
|
65
65
|
"x86_64"
|
66
66
|
when /i?86|x86|i86pc/
|
67
67
|
"i386"
|
@@ -129,7 +129,11 @@ module FFI
|
|
129
129
|
end
|
130
130
|
|
131
131
|
LIBC = if IS_WINDOWS
|
132
|
-
RbConfig::CONFIG['
|
132
|
+
if RbConfig::CONFIG['host_os'] =~ /mingw/i
|
133
|
+
RbConfig::CONFIG['RUBY_SO_NAME'].split('-')[-2] + '.dll'
|
134
|
+
else
|
135
|
+
"ucrtbase.dll"
|
136
|
+
end
|
133
137
|
elsif IS_GNU
|
134
138
|
GNU_LIBC
|
135
139
|
elsif OS == 'cygwin'
|