summaryrefslogtreecommitdiff
path: root/src/aarch64
diff options
context:
space:
mode:
authorPaul Monson <paulmon@users.noreply.github.com>2019-08-07 11:57:45 -0700
committerAnthony Green <green@moxielogic.com>2019-08-07 14:57:45 -0400
commitc2a6859012d928b67a83619bd5087674a96b9254 (patch)
tree391b6fe88d9d3f75301f59face9d6051e8c4f1dd /src/aarch64
parente0b4f84fb71c6760068c9d1306e77c9382e76d8d (diff)
downloadlibffi-c2a6859012d928b67a83619bd5087674a96b9254.tar.gz
fix mingw build and crashing bugs for Python Windows ARM64 (#496)
* fix mingw build and crashing bugs for Python Windows ARM64 * Fix issues found in PR review
Diffstat (limited to 'src/aarch64')
-rw-r--r--src/aarch64/ffi.c12
-rw-r--r--src/aarch64/ffitarget.h4
-rw-r--r--src/aarch64/win64_armasm.S18
3 files changed, 23 insertions, 11 deletions
diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c
index 4225f72..1ebf43c 100644
--- a/src/aarch64/ffi.c
+++ b/src/aarch64/ffi.c
@@ -666,7 +666,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
{
int elems = 4 - (h & 3);
#ifdef _M_ARM64 /* for handling armasm calling convention */
- if (cif->isVariadic)
+ if (cif->is_variadic)
{
if (state.ngrn + elems <= N_X_ARG_REG)
{
@@ -808,7 +808,13 @@ ffi_prep_closure_loc (ffi_closure *closure,
ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE);
/* Also flush the cache for code mapping. */
+#ifdef _M_ARM64
+ // Not using dlmalloc.c for Windows ARM64 builds
+ // so calling ffi_data_to_code_pointer() isn't necessary
+ unsigned char *tramp_code = tramp;
+ #else
unsigned char *tramp_code = ffi_data_to_code_pointer (tramp);
+ #endif
ffi_clear_cache (tramp_code, tramp_code + FFI_TRAMPOLINE_SIZE);
#endif
@@ -909,7 +915,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
{
n = 4 - (h & 3);
#ifdef _M_ARM64 /* for handling armasm calling convention */
- if (cif->isVariadic)
+ if (cif->is_variadic)
{
if (state.ngrn + n <= N_X_ARG_REG)
{
@@ -948,7 +954,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
avalue[i] = allocate_to_stack(&state, stack,
ty->alignment, s);
}
-#ifdef _M_ARM64 /* for handling armasm calling convention */
+#ifdef _M_ARM64 /* for handling armasm calling convention */
}
#endif /* for handling armasm calling convention */
}
diff --git a/src/aarch64/ffitarget.h b/src/aarch64/ffitarget.h
index 32c4f08..ecb6d2d 100644
--- a/src/aarch64/ffitarget.h
+++ b/src/aarch64/ffitarget.h
@@ -69,6 +69,10 @@ typedef enum ffi_abi
#define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE
#endif
+#ifdef _M_ARM64
+#define FFI_EXTRA_CIF_FIELDS unsigned is_variadic
+#endif
+
/* ---- Internal ---- */
#if defined (__APPLE__)
diff --git a/src/aarch64/win64_armasm.S b/src/aarch64/win64_armasm.S
index 906ceff..8ebc444 100644
--- a/src/aarch64/win64_armasm.S
+++ b/src/aarch64/win64_armasm.S
@@ -57,12 +57,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
x5 closure
*/
- NESTED_ENTRY ffi_call_SYSV
- /* Use a stack frame allocated by our caller. */
- PROLOG_NOP stp x29, x30, [x1, #32]
- /* For unwind information, Windows has to store fp and lr */
+ NESTED_ENTRY ffi_call_SYSV_fake
+
+ /* For unwind information, Windows has to store fp and lr */
PROLOG_SAVE_REG_PAIR x29, x30, #-32!
-
+
+ ALTERNATE_ENTRY ffi_call_SYSV
+ /* Use a stack frame allocated by our caller. */
+ stp x29, x30, [x1]
mov x29, x1
mov sp, x0
@@ -97,8 +99,8 @@ ffi_call_SYSV_L1
/* Partially deconstruct the stack frame. */
mov sp, x29
- ldp x29, x30, [x29, #32]
-
+ ldp x29, x30, [x29]
+
/* Save the return value as directed. */
adr x5, ffi_call_SYSV_return
and w4, w4, #AARCH64_RET_MASK
@@ -177,7 +179,7 @@ ffi_call_SYSV_return
nop
- NESTED_END ffi_call_SYSV
+ NESTED_END ffi_call_SYSV_fake
/* ffi_closure_SYSV