summaryrefslogtreecommitdiffstats
path: root/js/src/ctypes/libffi-patches/arm64-darwin-variadic.patch
blob: f617a61744d8013485da4f5924e872380c027d7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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: