Commit fc8c8c1e2c31321b38dc079e549bc7748da4159d

Anthony Green 2022-06-25T11:06:00

Fix ILP32 for aarch64

diff --git a/README.md b/README.md
index 8750f32..99ee834 100644
--- a/README.md
+++ b/README.md
@@ -200,6 +200,7 @@ See the git log for details at http://github.com/libffi/libffi.
         Fix x32 static trampolines.
         All struct args are passed by value, regardless of size.
         Add support for Loongson's LoonArch64 architecture.
+        Fix ILP32 aarch64 support.
 
     3.4.2 Jun-28-21
         Add static trampoline support for Linux on x86_64 and ARM64.
diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c
index f421536..76d2938 100644
--- a/src/aarch64/ffi.c
+++ b/src/aarch64/ffi.c
@@ -1027,9 +1027,18 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
             {
               /* Replace Composite type of size greater than 16 with a
                   pointer.  */
+#ifdef __ILP32__
+             UINT64 avalue_tmp;
+             memcpy (&avalue_tmp,
+                  allocate_int_to_reg_or_stack (context, &state,
+                                               stack, sizeof (void *)),
+                  sizeof (UINT64));
+             avalue[i] = (void *)(UINT32)avalue_tmp;
+#else
               avalue[i] = *(void **)
               allocate_int_to_reg_or_stack (context, &state, stack,
                                          sizeof (void *));
+#endif
             }
           else
             {