summaryrefslogtreecommitdiffstats
path: root/js/src/ctypes/libffi-patches
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/ctypes/libffi-patches
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/ctypes/libffi-patches')
-rw-r--r--js/src/ctypes/libffi-patches/03-asan.patch92
-rw-r--r--js/src/ctypes/libffi-patches/arm64-darwin-variadic.patch34
-rw-r--r--js/src/ctypes/libffi-patches/long-double.patch88
-rw-r--r--js/src/ctypes/libffi-patches/mingw-clang.patch27
4 files changed, 241 insertions, 0 deletions
diff --git a/js/src/ctypes/libffi-patches/03-asan.patch b/js/src/ctypes/libffi-patches/03-asan.patch
new file mode 100644
index 0000000000..f5222ab9e1
--- /dev/null
+++ b/js/src/ctypes/libffi-patches/03-asan.patch
@@ -0,0 +1,92 @@
+diff --git a/js/src/ctypes/libffi/src/x86/ffi64.c b/js/src/ctypes/libffi/src/x86/ffi64.c
+index dec331c958c21..b7c7d5218eb14 100644
+--- a/js/src/ctypes/libffi/src/x86/ffi64.c
++++ b/js/src/ctypes/libffi/src/x86/ffi64.c
+@@ -549,16 +549,26 @@ ffi_prep_cif_machdep (ffi_cif *cif)
+ flags |= UNIX64_FLAG_XMM_ARGS;
+
+ cif->flags = flags;
+ cif->bytes = (unsigned) FFI_ALIGN (bytes, 8);
+
+ return FFI_OK;
+ }
+
++#ifndef __SANITIZE_ADDRESS__
++# ifdef __clang__
++# if __has_feature(address_sanitizer)
++# define __SANITIZE_ADDRESS__
++# endif
++# endif
++#endif
++#ifdef __SANITIZE_ADDRESS__
++__attribute__((noinline,no_sanitize_address))
++#endif
+ static void
+ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
+ void **avalue, void *closure)
+ {
+ enum x86_64_reg_class classes[MAX_CLASSES];
+ char *stack, *argp;
+ ffi_type **arg_types;
+ int gprcount, ssecount, ngpr, nsse, i, avn, flags;
+diff --git a/js/src/ctypes/libffi/src/x86/ffiw64.c b/js/src/ctypes/libffi/src/x86/ffiw64.c
+index b68f69ccf68a0..5250e3052df1f 100644
+--- a/js/src/ctypes/libffi/src/x86/ffiw64.c
++++ b/js/src/ctypes/libffi/src/x86/ffiw64.c
+@@ -102,16 +102,26 @@ EFI64(ffi_prep_cif_machdep)(ffi_cif *cif)
+ n += (flags == FFI_TYPE_STRUCT);
+ if (n < 4)
+ n = 4;
+ cif->bytes = n * 8;
+
+ return FFI_OK;
+ }
+
++#ifndef __SANITIZE_ADDRESS__
++# ifdef __clang__
++# if __has_feature(address_sanitizer)
++# define __SANITIZE_ADDRESS__
++# endif
++# endif
++#endif
++#ifdef __SANITIZE_ADDRESS__
++__attribute__((noinline,no_sanitize_address))
++#endif
+ static void
+ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
+ void **avalue, void *closure)
+ {
+ int i, j, n, flags;
+ UINT64 *stack;
+ size_t rsize;
+ struct win64_call_frame *frame;
+diff --git a/js/src/ctypes/libffi/src/x86/ffi.c b/js/src/ctypes/libffi/src/x86/ffi.c
+--- a/js/src/ctypes/libffi/src/x86/ffi.c
++++ b/js/src/ctypes/libffi/src/x86/ffi.c
+@@ -250,16 +250,26 @@ static const struct abi_params abi_param
+ #define FFI_DECLARE_FASTCALL __declspec(fastcall)
+ #endif
+ #else
+ #define FFI_DECLARE_FASTCALL
+ #endif
+
+ extern void FFI_DECLARE_FASTCALL ffi_call_i386(struct call_frame *, char *) FFI_HIDDEN;
+
++#ifndef __SANITIZE_ADDRESS__
++# ifdef __clang__
++# if __has_feature(address_sanitizer)
++# define __SANITIZE_ADDRESS__
++# endif
++# endif
++#endif
++#ifdef __SANITIZE_ADDRESS__
++__attribute__((noinline,no_sanitize_address))
++#endif
+ static void
+ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
+ void **avalue, void *closure)
+ {
+ size_t rsize, bytes;
+ struct call_frame *frame;
+ char *stack, *argp;
+ ffi_type **arg_types;
diff --git a/js/src/ctypes/libffi-patches/arm64-darwin-variadic.patch b/js/src/ctypes/libffi-patches/arm64-darwin-variadic.patch
new file mode 100644
index 0000000000..f617a61744
--- /dev/null
+++ b/js/src/ctypes/libffi-patches/arm64-darwin-variadic.patch
@@ -0,0 +1,34 @@
+https://github.com/libffi/libffi/pull/577.
+
+diff --git a/js/src/ctypes/libffi/src/aarch64/ffi.c b/js/src/ctypes/libffi/src/aarch64/ffi.c
+index 1ebf43c192afe..a0a8c69dacf8b 100644
+--- a/js/src/ctypes/libffi/src/aarch64/ffi.c
++++ b/js/src/ctypes/libffi/src/aarch64/ffi.c
+@@ -638,22 +638,23 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
+ if (state.ngrn < N_X_ARG_REG)
+ context->x[state.ngrn++] = ext;
+ else
+ {
+ void *d = allocate_to_stack (&state, stack, ty->alignment, s);
+ state.ngrn = N_X_ARG_REG;
+ /* Note that the default abi extends each argument
+ to a full 64-bit slot, while the iOS abi allocates
+- only enough space. */
++ only enough space, except for variadic arguments. */
+ #ifdef __APPLE__
+- memcpy(d, a, s);
+-#else
+- *(ffi_arg *)d = ext;
++ if (!state.allocating_variadic)
++ memcpy(d, a, s);
++ else
+ #endif
++ *(ffi_arg *)d = ext;
+ }
+ }
+ break;
+
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_LONGDOUBLE:
+ case FFI_TYPE_STRUCT:
diff --git a/js/src/ctypes/libffi-patches/long-double.patch b/js/src/ctypes/libffi-patches/long-double.patch
new file mode 100644
index 0000000000..06ff5816b2
--- /dev/null
+++ b/js/src/ctypes/libffi-patches/long-double.patch
@@ -0,0 +1,88 @@
+https://github.com/libffi/libffi/pull/580
+
+diff --git a/js/src/ctypes/libffi/src/x86/win64.S b/js/src/ctypes/libffi/src/x86/win64.S
+index 2c334c82f9b2d..a54459f077c91 100644
+--- a/js/src/ctypes/libffi/src/x86/win64.S
++++ b/js/src/ctypes/libffi/src/x86/win64.S
+@@ -25,17 +25,17 @@
+
+ /* This macro allows the safe creation of jump tables without an
+ actual table. The entry points into the table are all 8 bytes.
+ The use of ORG asserts that we're at the correct location. */
+ /* ??? The clang assembler doesn't handle .org with symbolic expressions. */
+ #if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__))
+ # define E(BASE, X) .balign 8
+ #else
+-# define E(BASE, X) .balign 8; .org BASE + X * 8
++# define E(BASE, X) .balign 8; .org BASE + (X) * 8
+ #endif
+
+ .text
+
+ /* ffi_call_win64 (void *stack, struct win64_call_frame *frame, void *r10)
+
+ Bit o trickiness here -- FRAME is the base of the stack frame
+ for this function. This has been allocated by ffi_call. We also
+@@ -102,17 +102,18 @@ E(0b, FFI_TYPE_INT)
+ movq %rax, (%r8)
+ epilogue
+ E(0b, FFI_TYPE_FLOAT)
+ movss %xmm0, (%r8)
+ epilogue
+ E(0b, FFI_TYPE_DOUBLE)
+ movsd %xmm0, (%r8)
+ epilogue
+-E(0b, FFI_TYPE_LONGDOUBLE)
++// FFI_TYPE_LONGDOUBLE may be FFI_TYPE_DOUBLE but we need a different value here.
++E(0b, FFI_TYPE_DOUBLE + 1)
+ call PLT(C(abort))
+ E(0b, FFI_TYPE_UINT8)
+ movzbl %al, %eax
+ movq %rax, (%r8)
+ epilogue
+ E(0b, FFI_TYPE_SINT8)
+ movsbq %al, %rax
+ jmp 98f
+diff --git a/js/src/ctypes/libffi/src/x86/win64_intel.S b/js/src/ctypes/libffi/src/x86/win64_intel.S
+index 7df78b30e42c6..970a4f997a981 100644
+--- a/js/src/ctypes/libffi/src/x86/win64_intel.S
++++ b/js/src/ctypes/libffi/src/x86/win64_intel.S
+@@ -24,17 +24,17 @@
+
+ /* This macro allows the safe creation of jump tables without an
+ actual table. The entry points into the table are all 8 bytes.
+ The use of ORG asserts that we're at the correct location. */
+ /* ??? The clang assembler doesn't handle .org with symbolic expressions. */
+ #if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__))
+ # define E(BASE, X) ALIGN 8
+ #else
+-# define E(BASE, X) ALIGN 8; ORG BASE + X * 8
++# define E(BASE, X) ALIGN 8; ORG BASE + (X) * 8
+ #endif
+
+ .CODE
+ extern PLT(C(abort)):near
+ extern C(ffi_closure_win64_inner):near
+
+ /* ffi_call_win64 (void *stack, struct win64_call_frame *frame, void *r10)
+
+@@ -102,17 +102,18 @@ E(0b, FFI_TYPE_INT)
+ mov qword ptr [r8], rax; movq %rax, (%r8)
+ epilogue
+ E(0b, FFI_TYPE_FLOAT)
+ movss dword ptr [r8], xmm0 ; movss %xmm0, (%r8)
+ epilogue
+ E(0b, FFI_TYPE_DOUBLE)
+ movsd qword ptr[r8], xmm0; movsd %xmm0, (%r8)
+ epilogue
+-E(0b, FFI_TYPE_LONGDOUBLE)
++// FFI_TYPE_LONGDOUBLE may be FFI_TYPE_DOUBLE but we need a different value here.
++E(0b, FFI_TYPE_DOUBLE + 1)
+ call PLT(C(abort))
+ E(0b, FFI_TYPE_UINT8)
+ movzx eax, al ;movzbl %al, %eax
+ mov qword ptr[r8], rax; movq %rax, (%r8)
+ epilogue
+ E(0b, FFI_TYPE_SINT8)
+ movsx rax, al ; movsbq %al, %rax
+ jmp L98
diff --git a/js/src/ctypes/libffi-patches/mingw-clang.patch b/js/src/ctypes/libffi-patches/mingw-clang.patch
new file mode 100644
index 0000000000..1fac7db0a3
--- /dev/null
+++ b/js/src/ctypes/libffi-patches/mingw-clang.patch
@@ -0,0 +1,27 @@
+https://github.com/libffi/libffi/pull/579
+
+diff --git a/js/src/ctypes/libffi/src/x86/sysv.S b/js/src/ctypes/libffi/src/x86/sysv.S
+index 7c9598c93c984..b73492795d6d0 100644
+--- a/js/src/ctypes/libffi/src/x86/sysv.S
++++ b/js/src/ctypes/libffi/src/x86/sysv.S
+@@ -51,18 +51,18 @@
+ #ifdef __ELF__
+ # define ENDF(X) .type X,@function; .size X, . - X
+ #else
+ # define ENDF(X)
+ #endif
+
+ /* Handle win32 fastcall name mangling. */
+ #ifdef X86_WIN32
+-# define ffi_call_i386 @ffi_call_i386@8
+-# define ffi_closure_inner @ffi_closure_inner@8
++# define ffi_call_i386 "@ffi_call_i386@8"
++# define ffi_closure_inner "@ffi_closure_inner@8"
+ #else
+ # define ffi_call_i386 C(ffi_call_i386)
+ # define ffi_closure_inner C(ffi_closure_inner)
+ #endif
+
+ /* This macro allows the safe creation of jump tables without an
+ actual table. The entry points into the table are all 8 bytes.
+ The use of ORG asserts that we're at the correct location. */