ffi 1.17.1 → 1.17.2

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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +8 -0
  4. data/Gemfile +3 -1
  5. data/Rakefile +1 -1
  6. data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +48 -60
  7. data/ext/ffi_c/libffi/Makefile.am +4 -3
  8. data/ext/ffi_c/libffi/Makefile.in +5 -25
  9. data/ext/ffi_c/libffi/README.md +19 -2
  10. data/ext/ffi_c/libffi/acinclude.m4 +6 -0
  11. data/ext/ffi_c/libffi/config.guess +80 -22
  12. data/ext/ffi_c/libffi/config.sub +161 -80
  13. data/ext/ffi_c/libffi/configure +968 -1266
  14. data/ext/ffi_c/libffi/configure.ac +9 -8
  15. data/ext/ffi_c/libffi/configure.host +0 -5
  16. data/ext/ffi_c/libffi/doc/Makefile.in +1 -0
  17. data/ext/ffi_c/libffi/doc/libffi.texi +3 -3
  18. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  19. data/ext/ffi_c/libffi/fficonfig.h.in +9 -9
  20. data/ext/ffi_c/libffi/include/Makefile.in +1 -0
  21. data/ext/ffi_c/libffi/include/ffi_cfi.h +2 -0
  22. data/ext/ffi_c/libffi/include/ffi_common.h +17 -0
  23. data/ext/ffi_c/libffi/man/Makefile.in +1 -0
  24. data/ext/ffi_c/libffi/src/aarch64/ffi.c +7 -4
  25. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +2 -2
  26. data/ext/ffi_c/libffi/src/aarch64/internal.h +63 -17
  27. data/ext/ffi_c/libffi/src/aarch64/sysv.S +16 -12
  28. data/ext/ffi_c/libffi/src/arc/arcompact.S +2 -2
  29. data/ext/ffi_c/libffi/src/arc/ffi.c +6 -2
  30. data/ext/ffi_c/libffi/src/closures.c +3 -3
  31. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -0
  32. data/ext/ffi_c/libffi/src/mips/ffitarget.h +2 -4
  33. data/ext/ffi_c/libffi/src/mips/n32.S +4 -0
  34. data/ext/ffi_c/libffi/src/mips/o32.S +4 -0
  35. data/ext/ffi_c/libffi/src/or1k/ffi.c +2 -2
  36. data/ext/ffi_c/libffi/src/powerpc/ffi.c +13 -0
  37. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +26 -19
  38. data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +26 -16
  39. data/ext/ffi_c/libffi/src/powerpc/internal.h +10 -0
  40. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +47 -0
  41. data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +24 -0
  42. data/ext/ffi_c/libffi/src/prep_cif.c +1 -4
  43. data/ext/ffi_c/libffi/src/s390/ffi.c +28 -1
  44. data/ext/ffi_c/libffi/src/s390/internal.h +11 -0
  45. data/ext/ffi_c/libffi/src/s390/sysv.S +38 -0
  46. data/ext/ffi_c/libffi/src/sparc/ffi.c +16 -0
  47. data/ext/ffi_c/libffi/src/wasm32/ffi.c +10 -262
  48. data/ext/ffi_c/libffi/src/x86/ffi.c +4 -1
  49. data/ext/ffi_c/libffi/src/x86/ffi64.c +4 -1
  50. data/ext/ffi_c/libffi/testsuite/Makefile.am +4 -3
  51. data/ext/ffi_c/libffi/testsuite/Makefile.in +5 -3
  52. data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +4 -24
  53. data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +8 -25
  54. data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +3 -28
  55. data/ext/ffi_c/libffi/testsuite/libffi.call/callback.c +2 -2
  56. data/ext/ffi_c/libffi/testsuite/libffi.call/callback2.c +2 -2
  57. data/ext/ffi_c/libffi/testsuite/libffi.call/callback3.c +2 -2
  58. data/ext/ffi_c/libffi/testsuite/libffi.call/callback4.c +2 -2
  59. data/ext/ffi_c/libffi/testsuite/libffi.call/overread.c +54 -0
  60. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_int_float.c +88 -0
  61. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +1 -0
  62. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +1 -0
  63. data/ext/ffi_c/libffi/testsuite/libffi.call/x32.c +31 -0
  64. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +1 -1
  65. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +1 -1
  66. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +1 -1
  67. data/lib/ffi/version.rb +1 -1
  68. data.tar.gz.sig +0 -0
  69. metadata +6 -6
  70. metadata.gz.sig +0 -0
  71. data/ext/ffi_c/libffi/.circleci/config.yml +0 -156
  72. data/ext/ffi_c/libffi/src/nios2/ffi.c +0 -304
  73. data/ext/ffi_c/libffi/src/nios2/ffitarget.h +0 -52
  74. data/ext/ffi_c/libffi/src/nios2/sysv.S +0 -136
@@ -2,7 +2,7 @@ dnl Process this with autoconf to create configure
2
2
 
3
3
  AC_PREREQ([2.71])
4
4
 
5
- AC_INIT([libffi],[3.4.6],[http://github.com/libffi/libffi/issues])
5
+ AC_INIT([libffi],[3.4.8],[http://github.com/libffi/libffi/issues])
6
6
  AC_CONFIG_HEADERS([fficonfig.h])
7
7
 
8
8
  AC_CANONICAL_TARGET
@@ -42,7 +42,7 @@ AC_PROG_EGREP
42
42
  LT_INIT
43
43
  AC_CONFIG_MACRO_DIR([m4])
44
44
 
45
- AC_CHECK_TOOL(READELF, readelf)
45
+ AC_CHECK_TOOLS([READELF], [readelf greadelf])
46
46
 
47
47
  # Test for 64-bit build.
48
48
  AC_CHECK_SIZEOF([size_t])
@@ -171,7 +171,7 @@ case "$TARGET" in
171
171
  libffi_cv_as_s390_zarch=no
172
172
  echo 'void foo(void) { bar(); bar(); }' > conftest.c
173
173
  if $CC $CFLAGS -S conftest.c > /dev/null 2>&1; then
174
- if grep -q brasl conftest.s; then
174
+ if $GREP -q brasl conftest.s; then
175
175
  libffi_cv_as_s390_zarch=yes
176
176
  fi
177
177
  fi
@@ -189,17 +189,17 @@ AC_CACHE_CHECK([whether compiler supports pointer authentication],
189
189
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
190
190
  #ifdef __clang__
191
191
  # if __has_feature(ptrauth_calls)
192
- # define HAVE_PTRAUTH 1
192
+ # define HAVE_ARM64E_PTRAUTH 1
193
193
  # endif
194
194
  #endif
195
195
 
196
- #ifndef HAVE_PTRAUTH
196
+ #ifndef HAVE_ARM64E_PTRAUTH
197
197
  # error Pointer authentication not supported
198
198
  #endif
199
199
  ]])],[libffi_cv_as_ptrauth=yes],[libffi_cv_as_ptrauth=no])
200
200
  ])
201
201
  if test "x$libffi_cv_as_ptrauth" = xyes; then
202
- AC_DEFINE(HAVE_PTRAUTH, 1,
202
+ AC_DEFINE(HAVE_ARM64E_PTRAUTH, 1,
203
203
  [Define if your compiler supports pointer authentication.])
204
204
  fi
205
205
 
@@ -277,7 +277,7 @@ if test "x$GCC" = "xyes"; then
277
277
  libffi_cv_ro_eh_frame=yes
278
278
  echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
279
279
  if $CC $CFLAGS -c -fpic -fexceptions $libffi_cv_no_lto -o conftest.o conftest.c > /dev/null 2>&1; then
280
- if $READELF -WS conftest.o 2>/dev/null | grep -q -n 'eh_frame .* WA'; then
280
+ if $READELF -WS conftest.o 2>/dev/null | $GREP -q -n 'eh_frame .* WA'; then
281
281
  libffi_cv_ro_eh_frame=no
282
282
  fi
283
283
  fi
@@ -382,7 +382,8 @@ case "$target" in
382
382
  [Define this if you want statically defined trampolines])
383
383
  fi
384
384
  ;;
385
- *arm*-*-linux-* | aarch64*-*-linux-* | i*86-*-linux-* | x86_64-*-linux-* | loongarch*-*-linux-*)
385
+ *arm*-*-linux-* | aarch64*-*-linux-* | i*86-*-linux-* | x86_64-*-linux-* \
386
+ | loongarch*-*-linux-* | s390x*-linux-* | powerpc*-linux-*)
386
387
  AC_DEFINE(FFI_EXEC_STATIC_TRAMP, 1,
387
388
  [Define this if you want statically defined trampolines])
388
389
  ;;
@@ -185,11 +185,6 @@ case "${host}" in
185
185
  TARGET=MIPS; TARGETDIR=mips
186
186
  ;;
187
187
 
188
- nios2*-linux*)
189
- TARGET=NIOS2; TARGETDIR=nios2
190
- SOURCES="ffi.c sysv.S"
191
- ;;
192
-
193
188
  or1k*-*-*)
194
189
  TARGET=OR1K; TARGETDIR=or1k
195
190
  SOURCES="ffi.c sysv.S"
@@ -297,6 +297,7 @@ ac_ct_AR = @ac_ct_AR@
297
297
  ac_ct_CC = @ac_ct_CC@
298
298
  ac_ct_CXX = @ac_ct_CXX@
299
299
  ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
300
+ ac_ct_READELF = @ac_ct_READELF@
300
301
  am__include = @am__include@
301
302
  am__leading_dot = @am__leading_dot@
302
303
  am__quote = @am__quote@
@@ -263,14 +263,14 @@ int main()
263
263
  &ffi_type_sint, args) == FFI_OK)
264
264
  @{
265
265
  s = "Hello World!";
266
- ffi_call(&cif, puts, &rc, values);
266
+ ffi_call(&cif, (void(*)())puts, &rc, values);
267
267
  /* rc now holds the result of the call to puts */
268
268
 
269
269
  /* values holds a pointer to the function's arg, so to
270
270
  call puts() again all we need to do is change the
271
271
  value of s */
272
272
  s = "This is cool!";
273
- ffi_call(&cif, puts, &rc, values);
273
+ ffi_call(&cif, (void(*)())puts, &rc, values);
274
274
  @}
275
275
 
276
276
  return 0;
@@ -627,7 +627,7 @@ Here is the corresponding code to describe this struct to
627
627
 
628
628
  tm_type.size = tm_type.alignment = 0;
629
629
  tm_type.type = FFI_TYPE_STRUCT;
630
- tm_type.elements = &tm_type_elements;
630
+ tm_type.elements = tm_type_elements;
631
631
 
632
632
  for (i = 0; i < 9; i++)
633
633
  tm_type_elements[i] = &ffi_type_sint;
@@ -1,4 +1,4 @@
1
- @set UPDATED 15 February 2024
2
- @set UPDATED-MONTH February 2024
3
- @set EDITION 3.4.6
4
- @set VERSION 3.4.6
1
+ @set UPDATED 27 March 2025
2
+ @set UPDATED-MONTH March 2025
3
+ @set EDITION 3.4.8
4
+ @set VERSION 3.4.8
@@ -31,6 +31,9 @@
31
31
  /* Define to 1 if you have the <alloca.h> header file. */
32
32
  #undef HAVE_ALLOCA_H
33
33
 
34
+ /* Define if your compiler supports pointer authentication. */
35
+ #undef HAVE_ARM64E_PTRAUTH
36
+
34
37
  /* Define if your assembler supports .cfi_* directives. */
35
38
  #undef HAVE_AS_CFI_PSEUDO_OP
36
39
 
@@ -65,15 +68,12 @@
65
68
  /* Define if you support more than one size of the long double type */
66
69
  #undef HAVE_LONG_DOUBLE_VARIANT
67
70
 
68
- /* Define to 1 if you have the 'memcpy' function. */
71
+ /* Define to 1 if you have the `memcpy' function. */
69
72
  #undef HAVE_MEMCPY
70
73
 
71
- /* Define to 1 if you have the 'memfd_create' function. */
74
+ /* Define to 1 if you have the `memfd_create' function. */
72
75
  #undef HAVE_MEMFD_CREATE
73
76
 
74
- /* Define if your compiler supports pointer authentication. */
75
- #undef HAVE_PTRAUTH
76
-
77
77
  /* Define if .eh_frame sections should be read-only. */
78
78
  #undef HAVE_RO_EH_FRAME
79
79
 
@@ -131,16 +131,16 @@
131
131
  /* Define to the version of this package. */
132
132
  #undef PACKAGE_VERSION
133
133
 
134
- /* The size of 'double', as computed by sizeof. */
134
+ /* The size of `double', as computed by sizeof. */
135
135
  #undef SIZEOF_DOUBLE
136
136
 
137
- /* The size of 'long double', as computed by sizeof. */
137
+ /* The size of `long double', as computed by sizeof. */
138
138
  #undef SIZEOF_LONG_DOUBLE
139
139
 
140
- /* The size of 'size_t', as computed by sizeof. */
140
+ /* The size of `size_t', as computed by sizeof. */
141
141
  #undef SIZEOF_SIZE_T
142
142
 
143
- /* Define to 1 if all of the C89 standard headers exist (not just the ones
143
+ /* Define to 1 if all of the C90 standard headers exist (not just the ones
144
144
  required in a freestanding environment). This macro is provided for
145
145
  backward compatibility; new code need not use it. */
146
146
  #undef STDC_HEADERS
@@ -275,6 +275,7 @@ ac_ct_AR = @ac_ct_AR@
275
275
  ac_ct_CC = @ac_ct_CC@
276
276
  ac_ct_CXX = @ac_ct_CXX@
277
277
  ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
278
+ ac_ct_READELF = @ac_ct_READELF@
278
279
  am__include = @am__include@
279
280
  am__leading_dot = @am__leading_dot@
280
281
  am__quote = @am__quote@
@@ -49,6 +49,7 @@
49
49
  # define cfi_personality(enc, exp) .cfi_personality enc, exp
50
50
  # define cfi_lsda(enc, exp) .cfi_lsda enc, exp
51
51
  # define cfi_escape(...) .cfi_escape __VA_ARGS__
52
+ # define cfi_window_save .cfi_window_save
52
53
 
53
54
  #else
54
55
 
@@ -71,6 +72,7 @@
71
72
  # define cfi_personality(enc, exp)
72
73
  # define cfi_lsda(enc, exp)
73
74
  # define cfi_escape(...)
75
+ # define cfi_window_save
74
76
 
75
77
  #endif /* HAVE_AS_CFI_PSEUDO_OP */
76
78
  #endif /* FFI_CFI_H */
@@ -83,6 +83,23 @@ char *alloca ();
83
83
  #include <stdio.h>
84
84
  #endif
85
85
 
86
+ #ifndef __SANITIZE_ADDRESS__
87
+ # ifdef __clang__
88
+ # if __has_feature(address_sanitizer)
89
+ # define FFI_ASAN
90
+ # endif
91
+ # endif
92
+ #endif
93
+ #ifdef __SANITIZE_ADDRESS__
94
+ #define FFI_ASAN
95
+ #endif
96
+
97
+ #ifdef FFI_ASAN
98
+ #define FFI_ASAN_NO_SANITIZE __attribute__((no_sanitize_address))
99
+ #else
100
+ #define FFI_ASAN_NO_SANITIZE
101
+ #endif
102
+
86
103
  #ifdef FFI_DEBUG
87
104
  NORETURN void ffi_assert(const char *expr, const char *file, int line);
88
105
  void ffi_stop_here(void);
@@ -259,6 +259,7 @@ ac_ct_AR = @ac_ct_AR@
259
259
  ac_ct_CC = @ac_ct_CC@
260
260
  ac_ct_CXX = @ac_ct_CXX@
261
261
  ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
262
+ ac_ct_READELF = @ac_ct_READELF@
262
263
  am__include = @am__include@
263
264
  am__leading_dot = @am__leading_dot@
264
265
  am__quote = @am__quote@
@@ -63,7 +63,7 @@ struct call_context
63
63
  #if FFI_EXEC_TRAMPOLINE_TABLE
64
64
 
65
65
  #ifdef __MACH__
66
- #ifdef HAVE_PTRAUTH
66
+ #ifdef HAVE_ARM64E_PTRAUTH
67
67
  #include <ptrauth.h>
68
68
  #endif
69
69
  #include <mach/vm_param.h>
@@ -645,7 +645,10 @@ extern void ffi_call_SYSV (struct call_context *context, void *frame,
645
645
  void *closure) FFI_HIDDEN;
646
646
 
647
647
  /* Call a function with the provided arguments and capture the return
648
- value. */
648
+ value.
649
+ n.b. ffi_call_SYSV will steal the alloca'd `stack` variable here for use
650
+ _as its own stack_ - so we need to compile this function without ASAN */
651
+ FFI_ASAN_NO_SANITIZE
649
652
  static void
650
653
  ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
651
654
  void **avalue, void *closure)
@@ -682,7 +685,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
682
685
  else if (flags & AARCH64_RET_NEED_COPY)
683
686
  rsize = 16;
684
687
 
685
- /* Allocate consectutive stack for everything we'll need.
688
+ /* Allocate consecutive stack for everything we'll need.
686
689
  The frame uses 40 bytes for: lr, fp, rvalue, flags, sp */
687
690
  context = alloca (sizeof(struct call_context) + stack_bytes + 40 + rsize);
688
691
  stack = context + 1;
@@ -877,7 +880,7 @@ ffi_prep_closure_loc (ffi_closure *closure,
877
880
 
878
881
  #if FFI_EXEC_TRAMPOLINE_TABLE
879
882
  # ifdef __MACH__
880
- # ifdef HAVE_PTRAUTH
883
+ # ifdef HAVE_ARM64E_PTRAUTH
881
884
  codeloc = ptrauth_auth_data(codeloc, ptrauth_key_function_pointer, 0);
882
885
  # endif
883
886
  void **config = (void **)((uint8_t *)codeloc - PAGE_MAX_SIZE);
@@ -83,8 +83,8 @@ typedef enum ffi_abi
83
83
 
84
84
  #if defined (__APPLE__)
85
85
  #define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs
86
- #elif !defined(_WIN32)
87
- /* iOS and Windows reserve x18 for the system. Disable Go closures until
86
+ #elif !defined(_WIN32) && !defined(__ANDROID__)
87
+ /* iOS, Windows and Android reserve x18 for the system. Disable Go closures until
88
88
  a new static chain is chosen. */
89
89
  #define FFI_GO_CLOSURES 1
90
90
  #endif
@@ -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
- #ifdef HAVE_PTRAUTH
85
- #define SIGN_LR pacibsp
86
- #define SIGN_LR_WITH_REG(x) pacib lr, x
87
- #define AUTH_LR_AND_RET retab
88
- #define AUTH_LR_WITH_REG(x) autib lr, x
89
- #define BRANCH_AND_LINK_TO_REG blraaz
90
- #define BRANCH_TO_REG braaz
91
- #else
92
- #define SIGN_LR
93
- #define SIGN_LR_WITH_REG(x)
94
- #define AUTH_LR_AND_RET ret
95
- #define AUTH_LR_WITH_REG(x)
96
- #define BRANCH_AND_LINK_TO_REG blr
97
- #define BRANCH_TO_REG br
98
- #endif
99
-
100
- #endif
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 */
@@ -89,30 +89,30 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
89
89
  x5 closure
90
90
  */
91
91
 
92
- cfi_startproc
93
92
  CNAME(ffi_call_SYSV):
93
+ cfi_startproc
94
94
  BTI_C
95
- /* Sign the lr with x1 since that is where it will be stored */
95
+ PAC_CFI_WINDOW_SAVE
96
+ /* Sign the lr with x1 since that is the CFA which is the modifer used in auth instructions */
96
97
  SIGN_LR_WITH_REG(x1)
97
98
 
98
- /* Use a stack frame allocated by our caller. */
99
- #if defined(HAVE_PTRAUTH) && defined(__APPLE__)
99
+ #if defined(HAVE_ARM64E_PTRAUTH) && defined(__APPLE__)
100
100
  /* darwin's libunwind assumes that the cfa is the sp and that's the data
101
101
  * used to sign the lr. In order to allow unwinding through this
102
102
  * function it is necessary to point the cfa at the signing register.
103
103
  */
104
104
  cfi_def_cfa(x1, 0);
105
- #else
106
- cfi_def_cfa(x1, 40);
107
105
  #endif
106
+ /* Use a stack frame allocated by our caller. */
108
107
  stp x29, x30, [x1]
108
+ cfi_def_cfa_register(x1)
109
+ cfi_rel_offset (x29, 0)
110
+ cfi_rel_offset (x30, 8)
109
111
  mov x9, sp
110
112
  str x9, [x1, #32]
111
113
  mov x29, x1
112
- mov sp, x0
113
114
  cfi_def_cfa_register(x29)
114
- cfi_rel_offset (x29, 0)
115
- cfi_rel_offset (x30, 8)
115
+ mov sp, x0
116
116
 
117
117
  mov x9, x2 /* save fn */
118
118
  mov x8, x3 /* install structure return */
@@ -326,6 +326,7 @@ CNAME(ffi_closure_SYSV_V):
326
326
  cfi_startproc
327
327
  BTI_C
328
328
  SIGN_LR
329
+ PAC_CFI_WINDOW_SAVE
329
330
  stp x29, x30, [sp, #-ffi_closure_SYSV_FS]!
330
331
  cfi_adjust_cfa_offset (ffi_closure_SYSV_FS)
331
332
  cfi_rel_offset (x29, 0)
@@ -347,10 +348,11 @@ CNAME(ffi_closure_SYSV_V):
347
348
  #endif
348
349
 
349
350
  .align 4
350
- cfi_startproc
351
351
  CNAME(ffi_closure_SYSV):
352
+ cfi_startproc
352
353
  BTI_C
353
354
  SIGN_LR
355
+ PAC_CFI_WINDOW_SAVE
354
356
  stp x29, x30, [sp, #-ffi_closure_SYSV_FS]!
355
357
  cfi_adjust_cfa_offset (ffi_closure_SYSV_FS)
356
358
  cfi_rel_offset (x29, 0)
@@ -645,9 +647,11 @@ CNAME(ffi_go_closure_SYSV_V):
645
647
  #endif
646
648
 
647
649
  .align 4
648
- cfi_startproc
649
650
  CNAME(ffi_go_closure_SYSV):
651
+ cfi_startproc
650
652
  BTI_C
653
+ SIGN_LR_LINUX_ONLY
654
+ PAC_CFI_WINDOW_SAVE
651
655
  stp x29, x30, [sp, #-ffi_closure_SYSV_FS]!
652
656
  cfi_adjust_cfa_offset (ffi_closure_SYSV_FS)
653
657
  cfi_rel_offset (x29, 0)
@@ -688,7 +692,7 @@ CNAME(ffi_go_closure_SYSV):
688
692
  .asciz "GNU";
689
693
  .long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
690
694
  .long 4;
691
- .long GNU_PROPERTY_AARCH64_BTI;
695
+ .long GNU_PROPERTY_AARCH64_BTI | GNU_PROPERTY_AARCH64_POINTER_AUTH;
692
696
  .long 0;
693
697
  .popsection;
694
698
  #endif
@@ -39,14 +39,14 @@
39
39
  #define LARG ldl
40
40
  #define SARG stl
41
41
  #define ADDPTR addl
42
- #define MOVPTR movl_s
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 mov_s
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 HAVE_PTRAUTH
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 HAVE_PTRAUTH
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 HAVE_PTRAUTH
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 __linux__
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
 
@@ -821,3 +821,7 @@ cls_epilogue:
821
821
  #endif /* __GNUC__ */
822
822
 
823
823
  #endif
824
+
825
+ #if defined __ELF__ && defined __linux__
826
+ .section .note.GNU-stack,"",%progbits
827
+ #endif
@@ -559,3 +559,7 @@ $LASFDE2:
559
559
  $LEFDE2:
560
560
 
561
561
  #endif
562
+
563
+ #if defined __ELF__ && defined __linux__
564
+ .section .note.GNU-stack,"",%progbits
565
+ #endif
@@ -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 *(*)(int *, extended_cif *),
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,14 @@ 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
+ return &trampoline_code_table;
187
+ }
188
+ #endif