ffi 1.17.1 → 1.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +33 -0
- data/Gemfile +8 -3
- data/README.md +1 -0
- data/Rakefile +7 -4
- data/Steepfile +8 -0
- data/ext/ffi_c/DynamicLibrary.c +1 -1
- data/ext/ffi_c/Function.c +2 -0
- data/ext/ffi_c/MethodHandle.c +4 -2
- data/ext/ffi_c/libffi/.ci/Containerfile.ppc64le +12 -0
- data/ext/ffi_c/libffi/.ci/build.sh +38 -33
- data/ext/ffi_c/libffi/.ci/install.sh +46 -50
- data/ext/ffi_c/libffi/.ci/site.exp +6 -0
- data/ext/ffi_c/libffi/.gail-labels +44 -0
- data/ext/ffi_c/libffi/.github/workflows/build.yml +212 -333
- data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +101 -58
- data/ext/ffi_c/libffi/.github/workflows/label-new-issue.yaml +15 -0
- data/ext/ffi_c/libffi/.github/workflows/tarball.yml +55 -0
- data/ext/ffi_c/libffi/LICENSE +1 -1
- data/ext/ffi_c/libffi/Makefile.am +20 -15
- data/ext/ffi_c/libffi/Makefile.in +41 -54
- data/ext/ffi_c/libffi/README.md +40 -4
- data/ext/ffi_c/libffi/acinclude.m4 +6 -0
- data/ext/ffi_c/libffi/config.guess +80 -22
- data/ext/ffi_c/libffi/config.sub +161 -80
- data/ext/ffi_c/libffi/configure +1058 -1372
- data/ext/ffi_c/libffi/configure.ac +28 -14
- data/ext/ffi_c/libffi/configure.host +6 -6
- data/ext/ffi_c/libffi/doc/Makefile.in +4 -0
- data/ext/ffi_c/libffi/doc/libffi.texi +27 -4
- data/ext/ffi_c/libffi/doc/version.texi +4 -4
- data/ext/ffi_c/libffi/fficonfig.h.in +9 -9
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +1 -28
- data/ext/ffi_c/libffi/include/Makefile.in +4 -0
- data/ext/ffi_c/libffi/include/ffi.h.in +19 -1
- data/ext/ffi_c/libffi/include/ffi_cfi.h +2 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +17 -0
- data/ext/ffi_c/libffi/libffi.map.in +13 -1
- data/ext/ffi_c/libffi/libtool-version +1 -1
- data/ext/ffi_c/libffi/m4/asmcfi.m4 +28 -11
- data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +13 -3
- data/ext/ffi_c/libffi/man/Makefile.in +4 -0
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +7 -4
- data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +2 -2
- data/ext/ffi_c/libffi/src/aarch64/internal.h +63 -17
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +22 -12
- data/ext/ffi_c/libffi/src/arc/arcompact.S +2 -2
- data/ext/ffi_c/libffi/src/arc/ffi.c +6 -2
- data/ext/ffi_c/libffi/src/arm/sysv.S +1 -1
- data/ext/ffi_c/libffi/src/closures.c +3 -3
- data/ext/ffi_c/libffi/src/dlmalloc.c +1 -0
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +2 -4
- data/ext/ffi_c/libffi/src/mips/n32.S +4 -0
- data/ext/ffi_c/libffi/src/mips/o32.S +4 -0
- data/ext/ffi_c/libffi/src/or1k/ffi.c +2 -2
- data/ext/ffi_c/libffi/src/pa/linux.S +4 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +19 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +26 -19
- data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +26 -16
- data/ext/ffi_c/libffi/src/powerpc/internal.h +10 -0
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +47 -0
- data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +24 -0
- data/ext/ffi_c/libffi/src/prep_cif.c +1 -4
- data/ext/ffi_c/libffi/src/riscv/ffi.c +39 -16
- data/ext/ffi_c/libffi/src/riscv/internal.h +7 -0
- data/ext/ffi_c/libffi/src/riscv/sysv.S +24 -0
- data/ext/ffi_c/libffi/src/s390/ffi.c +28 -1
- data/ext/ffi_c/libffi/src/s390/internal.h +11 -0
- data/ext/ffi_c/libffi/src/s390/sysv.S +38 -0
- data/ext/ffi_c/libffi/src/sparc/ffi.c +16 -0
- data/ext/ffi_c/libffi/src/tramp.c +6 -1
- data/ext/ffi_c/libffi/src/types.c +23 -1
- data/ext/ffi_c/libffi/src/{wasm32 → wasm}/ffi.c +166 -315
- data/ext/ffi_c/libffi/src/{wasm32 → wasm}/ffitarget.h +17 -0
- data/ext/ffi_c/libffi/src/x86/ffi.c +4 -1
- data/ext/ffi_c/libffi/src/x86/ffi64.c +4 -1
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +0 -3
- data/ext/ffi_c/libffi/src/x86/sysv.S +1 -3
- data/ext/ffi_c/libffi/src/x86/sysv_intel.S +1 -3
- data/ext/ffi_c/libffi/testsuite/Makefile.am +6 -4
- data/ext/ffi_c/libffi/testsuite/Makefile.in +10 -4
- data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +4 -24
- data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +10 -27
- data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +6 -31
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +269 -256
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback2.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback3.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback4.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/longjmp.c +60 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/overread.c +54 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_int_float.c +88 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/x32.c +31 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_dbls_struct.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +1 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest.cc +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest_ffi_call.cc +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.threads/ffitest.h +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.threads/threads.exp +50 -0
- data/ext/ffi_c/libffi/testsuite/libffi.threads/tsan.c +74 -0
- data/ext/ffi_c/libffi.mk +5 -0
- data/ffi.gemspec +4 -5
- data/lib/ffi/autopointer.rb +6 -0
- data/lib/ffi/compat.rb +11 -0
- data/lib/ffi/function.rb +23 -0
- data/lib/ffi/library.rb +19 -3
- data/lib/ffi/struct_by_reference.rb +1 -1
- data/lib/ffi/version.rb +1 -1
- data/samples/hello_ractor.rb +9 -1
- data/samples/qsort_ractor.rb +9 -1
- data/sig/ffi/auto_pointer.rbs +1 -1
- data/sig/ffi/errno.rbs +8 -0
- data/sig/ffi/platform.rbs +49 -0
- data/sig/ffi/struct.rbs +2 -2
- data/sig/ffi/struct_by_reference.rbs +1 -1
- data/sig/ffi.rbs +4 -1
- data.tar.gz.sig +0 -0
- metadata +37 -83
- metadata.gz.sig +0 -0
- data/ext/ffi_c/libffi/.appveyor/site.exp +0 -16
- data/ext/ffi_c/libffi/.appveyor.yml +0 -84
- data/ext/ffi_c/libffi/.circleci/config.yml +0 -156
- data/ext/ffi_c/libffi/src/nios2/ffi.c +0 -304
- data/ext/ffi_c/libffi/src/nios2/ffitarget.h +0 -52
- data/ext/ffi_c/libffi/src/nios2/sysv.S +0 -136
- data/lib/ffi/tools/types_generator.rb +0 -137
- data/rakelib/ffi_gem_helper.rb +0 -65
- /data/ext/ffi_c/libffi/{.appveyor → .ci}/unix-noexec.exp +0 -0
|
@@ -81,20 +81,66 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
81
81
|
/* Helpers for writing assembly compatible with arm ptr auth */
|
|
82
82
|
#ifdef LIBFFI_ASM
|
|
83
83
|
|
|
84
|
-
#
|
|
85
|
-
|
|
86
|
-
#define
|
|
87
|
-
#define
|
|
88
|
-
#define
|
|
89
|
-
#define
|
|
90
|
-
#define
|
|
91
|
-
#
|
|
92
|
-
#define
|
|
93
|
-
#define
|
|
94
|
-
#define
|
|
95
|
-
|
|
96
|
-
#
|
|
97
|
-
#define
|
|
98
|
-
#
|
|
99
|
-
|
|
100
|
-
#
|
|
84
|
+
#if defined(HAVE_ARM64E_PTRAUTH)
|
|
85
|
+
/* ARM64E ABI For Darwin */
|
|
86
|
+
#define SIGN_LR pacibsp
|
|
87
|
+
#define SIGN_LR_WITH_REG(x) pacib lr, x
|
|
88
|
+
#define AUTH_LR_AND_RET retab
|
|
89
|
+
#define AUTH_LR_WITH_REG(x) autib lr, x
|
|
90
|
+
#define BRANCH_AND_LINK_TO_REG blraaz
|
|
91
|
+
#define SIGN_LR_LINUX_ONLY
|
|
92
|
+
#define BRANCH_TO_REG braaz
|
|
93
|
+
#define PAC_CFI_WINDOW_SAVE
|
|
94
|
+
#define GNU_PROPERTY_AARCH64_POINTER_AUTH 0
|
|
95
|
+
/* Linux PAC Support */
|
|
96
|
+
#elif defined(__ARM_FEATURE_PAC_DEFAULT)
|
|
97
|
+
#define GNU_PROPERTY_AARCH64_POINTER_AUTH (1 << 1)
|
|
98
|
+
#define PAC_CFI_WINDOW_SAVE cfi_window_save
|
|
99
|
+
#define TMP_REG x9
|
|
100
|
+
#define BRANCH_TO_REG br
|
|
101
|
+
#define BRANCH_AND_LINK_TO_REG blr
|
|
102
|
+
#define SIGN_LR_LINUX_ONLY SIGN_LR
|
|
103
|
+
/* Which key to sign with? */
|
|
104
|
+
#if (__ARM_FEATURE_PAC_DEFAULT & 1) == 1
|
|
105
|
+
/* Signed with A-key */
|
|
106
|
+
#define SIGN_LR hint #25 /* paciasp */
|
|
107
|
+
#define AUTH_LR hint #29 /* autiasp */
|
|
108
|
+
#else
|
|
109
|
+
/* Signed with B-key */
|
|
110
|
+
#define SIGN_LR hint #27 /* pacibsp */
|
|
111
|
+
#define AUTH_LR hint #31 /* autibsp */
|
|
112
|
+
#endif /* __ARM_FEATURE_PAC_DEFAULT */
|
|
113
|
+
#define AUTH_LR_WITH_REG(x) _auth_lr_with_reg x
|
|
114
|
+
.macro _auth_lr_with_reg modifier
|
|
115
|
+
mov TMP_REG, sp
|
|
116
|
+
mov sp, \modifier
|
|
117
|
+
AUTH_LR
|
|
118
|
+
mov sp, TMP_REG
|
|
119
|
+
.endm
|
|
120
|
+
#define SIGN_LR_WITH_REG(x) _sign_lr_with_reg x
|
|
121
|
+
.macro _sign_lr_with_reg modifier
|
|
122
|
+
mov TMP_REG, sp
|
|
123
|
+
mov sp, \modifier
|
|
124
|
+
SIGN_LR
|
|
125
|
+
mov sp, TMP_REG
|
|
126
|
+
.endm
|
|
127
|
+
#define AUTH_LR_AND_RET _auth_lr_and_ret modifier
|
|
128
|
+
.macro _auth_lr_and_ret modifier
|
|
129
|
+
AUTH_LR
|
|
130
|
+
ret
|
|
131
|
+
.endm
|
|
132
|
+
#undef TMP_REG
|
|
133
|
+
|
|
134
|
+
/* No Pointer Auth */
|
|
135
|
+
#else
|
|
136
|
+
#define SIGN_LR
|
|
137
|
+
#define SIGN_LR_WITH_REG(x)
|
|
138
|
+
#define AUTH_LR_AND_RET ret
|
|
139
|
+
#define AUTH_LR_WITH_REG(x)
|
|
140
|
+
#define BRANCH_AND_LINK_TO_REG blr
|
|
141
|
+
#define SIGN_LR_LINUX_ONLY
|
|
142
|
+
#define BRANCH_TO_REG br
|
|
143
|
+
#define PAC_CFI_WINDOW_SAVE
|
|
144
|
+
#define GNU_PROPERTY_AARCH64_POINTER_AUTH 0
|
|
145
|
+
#endif /* HAVE_ARM64E_PTRAUTH */
|
|
146
|
+
#endif /* LIBFFI_ASM */
|
|
@@ -74,6 +74,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
74
74
|
.text
|
|
75
75
|
.align 4
|
|
76
76
|
|
|
77
|
+
#if defined(__ARM_FEATURE_GCS_DEFAULT) && __ARM_FEATURE_GCS_DEFAULT == 1
|
|
78
|
+
#define GNU_PROPERTY_AARCH64_GCS (1<<2)
|
|
79
|
+
#else
|
|
80
|
+
#define GNU_PROPERTY_AARCH64_GCS 0 /* No GCS */
|
|
81
|
+
#endif
|
|
82
|
+
|
|
77
83
|
/* ffi_call_SYSV
|
|
78
84
|
extern void ffi_call_SYSV (void *stack, void *frame,
|
|
79
85
|
void (*fn)(void), void *rvalue,
|
|
@@ -89,30 +95,30 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
89
95
|
x5 closure
|
|
90
96
|
*/
|
|
91
97
|
|
|
92
|
-
cfi_startproc
|
|
93
98
|
CNAME(ffi_call_SYSV):
|
|
99
|
+
cfi_startproc
|
|
94
100
|
BTI_C
|
|
95
|
-
|
|
101
|
+
PAC_CFI_WINDOW_SAVE
|
|
102
|
+
/* Sign the lr with x1 since that is the CFA which is the modifer used in auth instructions */
|
|
96
103
|
SIGN_LR_WITH_REG(x1)
|
|
97
104
|
|
|
98
|
-
|
|
99
|
-
#if defined(HAVE_PTRAUTH) && defined(__APPLE__)
|
|
105
|
+
#if defined(HAVE_ARM64E_PTRAUTH) && defined(__APPLE__)
|
|
100
106
|
/* darwin's libunwind assumes that the cfa is the sp and that's the data
|
|
101
107
|
* used to sign the lr. In order to allow unwinding through this
|
|
102
108
|
* function it is necessary to point the cfa at the signing register.
|
|
103
109
|
*/
|
|
104
110
|
cfi_def_cfa(x1, 0);
|
|
105
|
-
#else
|
|
106
|
-
cfi_def_cfa(x1, 40);
|
|
107
111
|
#endif
|
|
112
|
+
/* Use a stack frame allocated by our caller. */
|
|
108
113
|
stp x29, x30, [x1]
|
|
114
|
+
cfi_def_cfa_register(x1)
|
|
115
|
+
cfi_rel_offset (x29, 0)
|
|
116
|
+
cfi_rel_offset (x30, 8)
|
|
109
117
|
mov x9, sp
|
|
110
118
|
str x9, [x1, #32]
|
|
111
119
|
mov x29, x1
|
|
112
|
-
mov sp, x0
|
|
113
120
|
cfi_def_cfa_register(x29)
|
|
114
|
-
|
|
115
|
-
cfi_rel_offset (x30, 8)
|
|
121
|
+
mov sp, x0
|
|
116
122
|
|
|
117
123
|
mov x9, x2 /* save fn */
|
|
118
124
|
mov x8, x3 /* install structure return */
|
|
@@ -326,6 +332,7 @@ CNAME(ffi_closure_SYSV_V):
|
|
|
326
332
|
cfi_startproc
|
|
327
333
|
BTI_C
|
|
328
334
|
SIGN_LR
|
|
335
|
+
PAC_CFI_WINDOW_SAVE
|
|
329
336
|
stp x29, x30, [sp, #-ffi_closure_SYSV_FS]!
|
|
330
337
|
cfi_adjust_cfa_offset (ffi_closure_SYSV_FS)
|
|
331
338
|
cfi_rel_offset (x29, 0)
|
|
@@ -347,10 +354,11 @@ CNAME(ffi_closure_SYSV_V):
|
|
|
347
354
|
#endif
|
|
348
355
|
|
|
349
356
|
.align 4
|
|
350
|
-
cfi_startproc
|
|
351
357
|
CNAME(ffi_closure_SYSV):
|
|
358
|
+
cfi_startproc
|
|
352
359
|
BTI_C
|
|
353
360
|
SIGN_LR
|
|
361
|
+
PAC_CFI_WINDOW_SAVE
|
|
354
362
|
stp x29, x30, [sp, #-ffi_closure_SYSV_FS]!
|
|
355
363
|
cfi_adjust_cfa_offset (ffi_closure_SYSV_FS)
|
|
356
364
|
cfi_rel_offset (x29, 0)
|
|
@@ -645,9 +653,11 @@ CNAME(ffi_go_closure_SYSV_V):
|
|
|
645
653
|
#endif
|
|
646
654
|
|
|
647
655
|
.align 4
|
|
648
|
-
cfi_startproc
|
|
649
656
|
CNAME(ffi_go_closure_SYSV):
|
|
657
|
+
cfi_startproc
|
|
650
658
|
BTI_C
|
|
659
|
+
SIGN_LR_LINUX_ONLY
|
|
660
|
+
PAC_CFI_WINDOW_SAVE
|
|
651
661
|
stp x29, x30, [sp, #-ffi_closure_SYSV_FS]!
|
|
652
662
|
cfi_adjust_cfa_offset (ffi_closure_SYSV_FS)
|
|
653
663
|
cfi_rel_offset (x29, 0)
|
|
@@ -688,7 +698,7 @@ CNAME(ffi_go_closure_SYSV):
|
|
|
688
698
|
.asciz "GNU";
|
|
689
699
|
.long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
|
|
690
700
|
.long 4;
|
|
691
|
-
.long GNU_PROPERTY_AARCH64_BTI;
|
|
701
|
+
.long GNU_PROPERTY_AARCH64_BTI | GNU_PROPERTY_AARCH64_POINTER_AUTH | GNU_PROPERTY_AARCH64_GCS;
|
|
692
702
|
.long 0;
|
|
693
703
|
.popsection;
|
|
694
704
|
#endif
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
#define LARG ldl
|
|
40
40
|
#define SARG stl
|
|
41
41
|
#define ADDPTR addl
|
|
42
|
-
#define MOVPTR
|
|
42
|
+
#define MOVPTR movl
|
|
43
43
|
#else
|
|
44
44
|
#define PTRS 4
|
|
45
45
|
#define FLTS 4
|
|
46
46
|
#define LARG ld
|
|
47
47
|
#define SARG st
|
|
48
48
|
#define ADDPTR add
|
|
49
|
-
#define MOVPTR
|
|
49
|
+
#define MOVPTR mov
|
|
50
50
|
#endif
|
|
51
51
|
|
|
52
52
|
#define FRAME_LEN (8 * PTRS + 16)
|
|
@@ -192,9 +192,10 @@ static void unmarshal_atom(call_builder *cb, int type, void *data) {
|
|
|
192
192
|
/* for arguments passed by reference returns the pointer, otherwise the arg is copied (up to MAXCOPYARG bytes) */
|
|
193
193
|
static void *unmarshal(call_builder *cb, ffi_type *type, int var, void *data) {
|
|
194
194
|
size_t realign[2];
|
|
195
|
-
void *pointer;
|
|
196
195
|
|
|
197
196
|
#if defined(__ARC64_ARCH64__)
|
|
197
|
+
void *pointer;
|
|
198
|
+
|
|
198
199
|
if (type->size > 2 * __SIZEOF_POINTER__) {
|
|
199
200
|
/* pass by reference */
|
|
200
201
|
unmarshal_atom(cb, FFI_TYPE_POINTER, (char*)&pointer);
|
|
@@ -348,7 +349,10 @@ ffi_prep_closure_loc (ffi_closure * closure, ffi_cif * cif,
|
|
|
348
349
|
void *user_data, void *codeloc)
|
|
349
350
|
{
|
|
350
351
|
uint32_t *tramp = (uint32_t *) & (closure->tramp[0]);
|
|
352
|
+
|
|
353
|
+
#if defined(__ARC64_ARCH64__)
|
|
351
354
|
size_t address_ffi_closure = (size_t) ffi_closure_asm;
|
|
355
|
+
#endif
|
|
352
356
|
|
|
353
357
|
switch (cif->abi)
|
|
354
358
|
{
|
|
@@ -367,7 +371,7 @@ ffi_prep_closure_loc (ffi_closure * closure, ffi_cif * cif,
|
|
|
367
371
|
FFI_ASSERT (tramp == codeloc);
|
|
368
372
|
tramp[0] = CODE_ENDIAN (0x200a1fc0); /* mov r8, pcl */
|
|
369
373
|
tramp[1] = CODE_ENDIAN (0x20200f80); /* j [long imm] */
|
|
370
|
-
tramp[2] = CODE_ENDIAN (ffi_closure_asm);
|
|
374
|
+
tramp[2] = CODE_ENDIAN ((uint32_t) ffi_closure_asm);
|
|
371
375
|
break;
|
|
372
376
|
#endif
|
|
373
377
|
|
|
@@ -164,7 +164,7 @@ ffi_tramp_is_present (__attribute__((unused)) void *ptr)
|
|
|
164
164
|
|
|
165
165
|
#include <mach/mach.h>
|
|
166
166
|
#include <pthread.h>
|
|
167
|
-
#ifdef
|
|
167
|
+
#ifdef HAVE_ARM64E_PTRAUTH
|
|
168
168
|
#include <ptrauth.h>
|
|
169
169
|
#endif
|
|
170
170
|
#include <stdio.h>
|
|
@@ -223,7 +223,7 @@ ffi_trampoline_table_alloc (void)
|
|
|
223
223
|
/* Remap the trampoline table on top of the placeholder page */
|
|
224
224
|
trampoline_page = config_page + PAGE_MAX_SIZE;
|
|
225
225
|
|
|
226
|
-
#ifdef
|
|
226
|
+
#ifdef HAVE_ARM64E_PTRAUTH
|
|
227
227
|
trampoline_page_template = (vm_address_t)(uintptr_t)ptrauth_auth_data((void *)&ffi_closure_trampoline_table_page, ptrauth_key_function_pointer, 0);
|
|
228
228
|
#else
|
|
229
229
|
trampoline_page_template = (vm_address_t)&ffi_closure_trampoline_table_page;
|
|
@@ -268,7 +268,7 @@ ffi_trampoline_table_alloc (void)
|
|
|
268
268
|
ffi_trampoline_table_entry *entry = &table->free_list_pool[i];
|
|
269
269
|
entry->trampoline =
|
|
270
270
|
(void *) (trampoline_page + (i * FFI_TRAMPOLINE_SIZE));
|
|
271
|
-
#ifdef
|
|
271
|
+
#ifdef HAVE_ARM64E_PTRAUTH
|
|
272
272
|
entry->trampoline = ptrauth_sign_unauthenticated(entry->trampoline, ptrauth_key_function_pointer, 0);
|
|
273
273
|
#endif
|
|
274
274
|
|
|
@@ -3388,6 +3388,7 @@ static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) {
|
|
|
3388
3388
|
mchunkptr tnext = chunk_plus_offset(sp, ssize);
|
|
3389
3389
|
mchunkptr p = tnext;
|
|
3390
3390
|
int nfences = 0;
|
|
3391
|
+
(void)nfences; // Suppress unused variable warning
|
|
3391
3392
|
|
|
3392
3393
|
/* reset top to new space */
|
|
3393
3394
|
init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE);
|
|
@@ -32,16 +32,14 @@
|
|
|
32
32
|
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
|
|
33
33
|
#endif
|
|
34
34
|
|
|
35
|
-
#ifdef
|
|
36
|
-
# include <asm/sgidefs.h>
|
|
37
|
-
#elif defined(__rtems__)
|
|
35
|
+
#ifdef __rtems__
|
|
38
36
|
/*
|
|
39
37
|
* Subprogram calling convention - copied from sgidefs.h
|
|
40
38
|
*/
|
|
41
39
|
#define _MIPS_SIM_ABI32 1
|
|
42
40
|
#define _MIPS_SIM_NABI32 2
|
|
43
41
|
#define _MIPS_SIM_ABI64 3
|
|
44
|
-
#elif !defined(__OpenBSD__) && !defined(__FreeBSD__)
|
|
42
|
+
#elif !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__linux__)
|
|
45
43
|
# include <sgidefs.h>
|
|
46
44
|
#endif
|
|
47
45
|
|
|
@@ -110,7 +110,7 @@ void* ffi_prep_args(char *stack, extended_cif *ecif)
|
|
|
110
110
|
|
|
111
111
|
extern void ffi_call_SYSV(unsigned,
|
|
112
112
|
extended_cif *,
|
|
113
|
-
void *(*)(
|
|
113
|
+
void *(*)(char *, extended_cif *),
|
|
114
114
|
unsigned *,
|
|
115
115
|
void (*fn)(void),
|
|
116
116
|
unsigned);
|
|
@@ -180,7 +180,7 @@ void ffi_closure_SYSV(unsigned long r3, unsigned long r4, unsigned long r5,
|
|
|
180
180
|
register int *r13 __asm__ ("r13");
|
|
181
181
|
|
|
182
182
|
ffi_closure* closure = (ffi_closure*) r13;
|
|
183
|
-
char *stack_args = sp;
|
|
183
|
+
char *stack_args = (char*) sp;
|
|
184
184
|
|
|
185
185
|
/* Lay the register arguments down in a continuous chunk of memory. */
|
|
186
186
|
unsigned register_args[6] =
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
#include "ffi.h"
|
|
32
32
|
#include "ffi_common.h"
|
|
33
33
|
#include "ffi_powerpc.h"
|
|
34
|
+
#include "internal.h"
|
|
35
|
+
#include <tramp.h>
|
|
34
36
|
|
|
35
37
|
#if HAVE_LONG_DOUBLE_VARIANT
|
|
36
38
|
/* Adjust ffi_type_longdouble. */
|
|
@@ -173,3 +175,20 @@ ffi_prep_go_closure (ffi_go_closure *closure,
|
|
|
173
175
|
closure->fun = fun;
|
|
174
176
|
return FFI_OK;
|
|
175
177
|
}
|
|
178
|
+
|
|
179
|
+
#ifdef FFI_EXEC_STATIC_TRAMP
|
|
180
|
+
void *
|
|
181
|
+
ffi_tramp_arch (size_t *tramp_size, size_t *map_size)
|
|
182
|
+
{
|
|
183
|
+
extern void *trampoline_code_table;
|
|
184
|
+
*tramp_size = PPC_TRAMP_SIZE;
|
|
185
|
+
*map_size = PPC_TRAMP_MAP_SIZE;
|
|
186
|
+
#if defined (_CALL_AIX) || _CALL_ELF == 1
|
|
187
|
+
/* The caller wants the entry point address of the trampoline code,
|
|
188
|
+
not the address of the function descriptor. */
|
|
189
|
+
return *(void **)trampoline_code_table;
|
|
190
|
+
#else
|
|
191
|
+
return &trampoline_code_table;
|
|
192
|
+
#endif
|
|
193
|
+
}
|
|
194
|
+
#endif
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
----------------------------------------------------------------------- */
|
|
30
30
|
|
|
31
31
|
#include "ffi.h"
|
|
32
|
+
#include <tramp.h>
|
|
32
33
|
|
|
33
34
|
#ifdef POWERPC64
|
|
34
35
|
#include "ffi_common.h"
|
|
@@ -820,32 +821,38 @@ ffi_prep_closure_loc_linux64 (ffi_closure *closure,
|
|
|
820
821
|
void *user_data,
|
|
821
822
|
void *codeloc)
|
|
822
823
|
{
|
|
823
|
-
#if _CALL_ELF == 2
|
|
824
|
-
unsigned int *tramp = (unsigned int *) &closure->tramp[0];
|
|
825
|
-
|
|
826
824
|
if (cif->abi < FFI_LINUX || cif->abi >= FFI_LAST_ABI)
|
|
827
825
|
return FFI_BAD_ABI;
|
|
828
826
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
827
|
+
#ifdef FFI_EXEC_STATIC_TRAMP
|
|
828
|
+
if (ffi_tramp_is_present(closure))
|
|
829
|
+
{
|
|
830
|
+
/* Initialize the static trampoline's parameters. */
|
|
831
|
+
void (*dest)(void) = ffi_closure_LINUX64;
|
|
832
|
+
ffi_tramp_set_parms (closure->ftramp, dest, closure);
|
|
833
|
+
}
|
|
834
|
+
else
|
|
835
|
+
#endif
|
|
836
|
+
{
|
|
837
|
+
#if _CALL_ELF == 2
|
|
838
|
+
unsigned int *tramp = (unsigned int *) &closure->tramp[0];
|
|
839
|
+
tramp[0] = 0xe96c0018; /* 0: ld 11,2f-0b(12) */
|
|
840
|
+
tramp[1] = 0xe98c0010; /* ld 12,1f-0b(12) */
|
|
841
|
+
tramp[2] = 0x7d8903a6; /* mtctr 12 */
|
|
842
|
+
tramp[3] = 0x4e800420; /* bctr */
|
|
833
843
|
/* 1: .quad function_addr */
|
|
834
844
|
/* 2: .quad context */
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
845
|
+
*(void **) &tramp[4] = (void *) ffi_closure_LINUX64;
|
|
846
|
+
*(void **) &tramp[6] = codeloc;
|
|
847
|
+
flush_icache ((char *) tramp, (char *) codeloc, 4 * 4);
|
|
838
848
|
#else
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
/* Copy function address and TOC from ffi_closure_LINUX64 OPD. */
|
|
845
|
-
memcpy (&tramp[0], (void **) ffi_closure_LINUX64, sizeof (void *));
|
|
846
|
-
tramp[1] = codeloc;
|
|
847
|
-
memcpy (&tramp[2], (void **) ffi_closure_LINUX64 + 1, sizeof (void *));
|
|
849
|
+
/* Copy function address and TOC from ffi_closure_LINUX64 OPD. */
|
|
850
|
+
void **tramp = (void **) &closure->tramp[0];
|
|
851
|
+
memcpy (&tramp[0], (void **) ffi_closure_LINUX64, sizeof (void *));
|
|
852
|
+
tramp[1] = codeloc;
|
|
853
|
+
memcpy (&tramp[2], (void **) ffi_closure_LINUX64 + 1, sizeof (void *));
|
|
848
854
|
#endif
|
|
855
|
+
}
|
|
849
856
|
|
|
850
857
|
closure->cif = cif;
|
|
851
858
|
closure->fun = fun;
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
----------------------------------------------------------------------- */
|
|
30
30
|
|
|
31
31
|
#include "ffi.h"
|
|
32
|
+
#include <tramp.h>
|
|
32
33
|
|
|
33
34
|
#ifndef POWERPC64
|
|
34
35
|
#include "ffi_common.h"
|
|
@@ -636,25 +637,34 @@ ffi_prep_closure_loc_sysv (ffi_closure *closure,
|
|
|
636
637
|
void *user_data,
|
|
637
638
|
void *codeloc)
|
|
638
639
|
{
|
|
639
|
-
unsigned int *tramp;
|
|
640
|
-
|
|
641
640
|
if (cif->abi < FFI_SYSV || cif->abi >= FFI_LAST_ABI)
|
|
642
641
|
return FFI_BAD_ABI;
|
|
643
642
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
/*
|
|
657
|
-
|
|
643
|
+
#ifdef FFI_EXEC_STATIC_TRAMP
|
|
644
|
+
if (ffi_tramp_is_present(closure))
|
|
645
|
+
{
|
|
646
|
+
/* Initialize the static trampoline's parameters. */
|
|
647
|
+
void (*dest)(void) = ffi_closure_SYSV;
|
|
648
|
+
ffi_tramp_set_parms (closure->ftramp, dest, closure);
|
|
649
|
+
}
|
|
650
|
+
else
|
|
651
|
+
#endif
|
|
652
|
+
{
|
|
653
|
+
unsigned int *tramp = (unsigned int *) &closure->tramp[0];
|
|
654
|
+
tramp[0] = 0x7c0802a6; /* mflr r0 */
|
|
655
|
+
tramp[1] = 0x429f0005; /* bcl 20,31,.+4 */
|
|
656
|
+
tramp[2] = 0x7d6802a6; /* mflr r11 */
|
|
657
|
+
tramp[3] = 0x7c0803a6; /* mtlr r0 */
|
|
658
|
+
tramp[4] = 0x800b0018; /* lwz r0,24(r11) */
|
|
659
|
+
tramp[5] = 0x816b001c; /* lwz r11,28(r11) */
|
|
660
|
+
tramp[6] = 0x7c0903a6; /* mtctr r0 */
|
|
661
|
+
tramp[7] = 0x4e800420; /* bctr */
|
|
662
|
+
*(void **) &tramp[8] = (void *) ffi_closure_SYSV; /* function */
|
|
663
|
+
*(void **) &tramp[9] = codeloc; /* context */
|
|
664
|
+
|
|
665
|
+
/* Flush the icache. */
|
|
666
|
+
flush_icache ((char *)tramp, (char *)codeloc, 8 * 4);
|
|
667
|
+
}
|
|
658
668
|
|
|
659
669
|
closure->cif = cif;
|
|
660
670
|
closure->fun = fun;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#ifdef FFI_EXEC_STATIC_TRAMP
|
|
2
|
+
/* For the trampoline code table mapping, a mapping size of 64K is chosen. */
|
|
3
|
+
#define PPC_TRAMP_MAP_SHIFT 16
|
|
4
|
+
#define PPC_TRAMP_MAP_SIZE (1 << PPC_TRAMP_MAP_SHIFT)
|
|
5
|
+
# ifdef __PCREL__
|
|
6
|
+
# define PPC_TRAMP_SIZE 24
|
|
7
|
+
# else
|
|
8
|
+
# define PPC_TRAMP_SIZE 40
|
|
9
|
+
# endif /* __PCREL__ */
|
|
10
|
+
#endif /* FFI_EXEC_STATIC_TRAMP */
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
#define LIBFFI_ASM
|
|
28
28
|
#include <fficonfig.h>
|
|
29
29
|
#include <ffi.h>
|
|
30
|
+
#include "internal.h"
|
|
30
31
|
|
|
31
32
|
.file "linux64_closure.S"
|
|
32
33
|
|
|
@@ -559,7 +560,53 @@ ffi_go_closure_linux64:
|
|
|
559
560
|
.size .ffi_go_closure_linux64,.-.ffi_go_closure_linux64
|
|
560
561
|
# endif
|
|
561
562
|
# endif
|
|
563
|
+
|
|
564
|
+
#ifdef FFI_EXEC_STATIC_TRAMP
|
|
565
|
+
.text
|
|
566
|
+
.align PPC_TRAMP_MAP_SHIFT
|
|
567
|
+
FFI_HIDDEN (trampoline_code_table)
|
|
568
|
+
.globl trampoline_code_table
|
|
569
|
+
# if _CALL_ELF == 2
|
|
570
|
+
.type trampoline_code_table,@function
|
|
571
|
+
trampoline_code_table:
|
|
572
|
+
.localentry trampoline_code_table,.-trampoline_code_table
|
|
573
|
+
# else
|
|
574
|
+
.section ".opd","aw"
|
|
575
|
+
.align 3
|
|
576
|
+
trampoline_code_table:
|
|
577
|
+
.quad .L.trampoline_code_table,.TOC.@tocbase,0
|
|
578
|
+
.type trampoline_code_table,@function
|
|
579
|
+
.text
|
|
580
|
+
.L.trampoline_code_table:
|
|
581
|
+
# endif
|
|
582
|
+
.rept PPC_TRAMP_MAP_SIZE / PPC_TRAMP_SIZE
|
|
583
|
+
#ifdef __PCREL__
|
|
584
|
+
pla %r2,PPC_TRAMP_MAP_SIZE
|
|
585
|
+
ld %r11,0(%r2)
|
|
586
|
+
ld %r12,8(%r2)
|
|
587
|
+
mtctr %r12
|
|
588
|
+
bctr
|
|
589
|
+
#else
|
|
590
|
+
mflr %r0
|
|
591
|
+
bcl 20,31,$+4
|
|
592
|
+
mflr %r11
|
|
593
|
+
addis %r11,%r11,PPC_TRAMP_MAP_SIZE@ha
|
|
594
|
+
mtlr %r0
|
|
595
|
+
ld %r12,(PPC_TRAMP_MAP_SIZE+0)@l(%r11)
|
|
596
|
+
mtctr %r12
|
|
597
|
+
ld %r11,(PPC_TRAMP_MAP_SIZE-8)@l(%r11)
|
|
598
|
+
bctr
|
|
599
|
+
nop
|
|
600
|
+
#endif
|
|
601
|
+
.endr
|
|
602
|
+
.align PPC_TRAMP_MAP_SHIFT
|
|
603
|
+
#if _CALL_ELF == 2
|
|
604
|
+
.size trampoline_code_table,.-trampoline_code_table
|
|
605
|
+
#else
|
|
606
|
+
.size trampoline_code_table,.-.L.trampoline_code_table
|
|
562
607
|
#endif
|
|
608
|
+
#endif /* FFI_EXEC_STATIC_TRAMP */
|
|
609
|
+
#endif /* POWERPC64 */
|
|
563
610
|
|
|
564
611
|
#if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2
|
|
565
612
|
.section .note.GNU-stack,"",@progbits
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
#define LIBFFI_ASM
|
|
28
28
|
#include <fficonfig.h>
|
|
29
29
|
#include <ffi.h>
|
|
30
|
+
#include "internal.h"
|
|
30
31
|
#include <powerpc/asm.h>
|
|
31
32
|
|
|
32
33
|
.file "ppc_closure.S"
|
|
@@ -391,6 +392,29 @@ ENTRY(ffi_go_closure_sysv)
|
|
|
391
392
|
.cfi_endproc
|
|
392
393
|
END(ffi_go_closure_sysv)
|
|
393
394
|
|
|
395
|
+
#ifdef FFI_EXEC_STATIC_TRAMP
|
|
396
|
+
.text
|
|
397
|
+
.align PPC_TRAMP_MAP_SHIFT
|
|
398
|
+
FFI_HIDDEN (trampoline_code_table)
|
|
399
|
+
.globl trampoline_code_table
|
|
400
|
+
.type trampoline_code_table,@function
|
|
401
|
+
trampoline_code_table:
|
|
402
|
+
.rept PPC_TRAMP_MAP_SIZE / PPC_TRAMP_SIZE
|
|
403
|
+
mflr %r0
|
|
404
|
+
bcl 20,31,$+4
|
|
405
|
+
mflr %r11
|
|
406
|
+
addis %r11,%r11,PPC_TRAMP_MAP_SIZE@ha
|
|
407
|
+
mtlr %r0
|
|
408
|
+
lwz %r0,(PPC_TRAMP_MAP_SIZE-4)@l(%r11)
|
|
409
|
+
mtctr %r0
|
|
410
|
+
lwz %r11,(PPC_TRAMP_MAP_SIZE-8)@l(%r11)
|
|
411
|
+
bctr
|
|
412
|
+
nop
|
|
413
|
+
.endr
|
|
414
|
+
.size trampoline_code_table,.-trampoline_code_table
|
|
415
|
+
.align PPC_TRAMP_MAP_SHIFT
|
|
416
|
+
#endif /* FFI_EXEC_STATIC_TRAMP */
|
|
417
|
+
|
|
394
418
|
#if defined __ELF__ && defined __linux__
|
|
395
419
|
.section .note.GNU-stack,"",@progbits
|
|
396
420
|
#endif
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* -----------------------------------------------------------------------
|
|
2
|
-
prep_cif.c - Copyright (c) 2011, 2012, 2021 Anthony Green
|
|
2
|
+
prep_cif.c - Copyright (c) 2011, 2012, 2021, 2025 Anthony Green
|
|
3
3
|
Copyright (c) 1996, 1998, 2007 Red Hat, Inc.
|
|
4
4
|
Copyright (c) 2022 Oracle and/or its affiliates.
|
|
5
5
|
|
|
@@ -158,9 +158,6 @@ ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi,
|
|
|
158
158
|
#endif
|
|
159
159
|
#ifdef XTENSA
|
|
160
160
|
&& (cif->rtype->size > 16)
|
|
161
|
-
#endif
|
|
162
|
-
#ifdef NIOS2
|
|
163
|
-
&& (cif->rtype->size > 8)
|
|
164
161
|
#endif
|
|
165
162
|
)
|
|
166
163
|
bytes = STACK_ARG_SIZE(sizeof(void*));
|