summaryrefslogtreecommitdiff
path: root/src/aarch64
diff options
context:
space:
mode:
authorOle André Vadla Ravnås <oleavr@gmail.com>2020-03-10 02:05:42 +0100
committerGitHub <noreply@github.com>2020-03-09 21:05:42 -0400
commit4c7bde32ea3af479babdf527d94f241282951cb9 (patch)
treee3e69f65c1bc15d5673954de929a12dd7b34c3ff /src/aarch64
parent211e929df4388a6724b0dba4df4e3a1283dc49e9 (diff)
downloadlibffi-4c7bde32ea3af479babdf527d94f241282951cb9.tar.gz
Port to iOS/arm64e (#548)
Diffstat (limited to 'src/aarch64')
-rw-r--r--src/aarch64/ffi.c6
-rw-r--r--src/aarch64/sysv.S15
2 files changed, 19 insertions, 2 deletions
diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c
index 1ebf43c..4cc5925 100644
--- a/src/aarch64/ffi.c
+++ b/src/aarch64/ffi.c
@@ -62,6 +62,9 @@ struct call_context
#if FFI_EXEC_TRAMPOLINE_TABLE
#ifdef __MACH__
+#ifdef HAVE_PTRAUTH
+#include <ptrauth.h>
+#endif
#include <mach/vm_param.h>
#endif
@@ -789,6 +792,9 @@ ffi_prep_closure_loc (ffi_closure *closure,
#if FFI_EXEC_TRAMPOLINE_TABLE
#ifdef __MACH__
+#ifdef HAVE_PTRAUTH
+ codeloc = ptrauth_strip (codeloc, ptrauth_key_asia);
+#endif
void **config = (void **)((uint8_t *)codeloc - PAGE_MAX_SIZE);
config[0] = closure;
config[1] = start;
diff --git a/src/aarch64/sysv.S b/src/aarch64/sysv.S
index 6761ee1..a345439 100644
--- a/src/aarch64/sysv.S
+++ b/src/aarch64/sysv.S
@@ -58,6 +58,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#define PTR_SIZE 8
#endif
+#if FFI_EXEC_TRAMPOLINE_TABLE && defined(__MACH__) && defined(HAVE_PTRAUTH)
+# define BR(r) braaz r
+# define BLR(r) blraaz r
+#else
+# define BR(r) br r
+# define BLR(r) blr r
+#endif
+
.text
.align 4
@@ -111,7 +119,7 @@ CNAME(ffi_call_SYSV):
/* Deallocate the context, leaving the stacked arguments. */
add sp, sp, #CALL_CONTEXT_SIZE
- blr x9 /* call fn */
+ BLR(x9) /* call fn */
ldp x3, x4, [x29, #16] /* reload rvalue and flags */
@@ -271,6 +279,9 @@ CNAME(ffi_closure_SYSV):
bl CNAME(ffi_closure_SYSV_inner)
/* Load the return value as directed. */
+#if FFI_EXEC_TRAMPOLINE_TABLE && defined(__MACH__) && defined(HAVE_PTRAUTH)
+ autiza x1
+#endif
adr x1, 0f
and w0, w0, #AARCH64_RET_MASK
add x1, x1, x0, lsl #3
@@ -365,7 +376,7 @@ CNAME(ffi_closure_trampoline_table_page):
.rept PAGE_MAX_SIZE / FFI_TRAMPOLINE_SIZE
adr x16, -PAGE_MAX_SIZE
ldp x17, x16, [x16]
- br x16
+ BR(x16)
nop /* each entry in the trampoline config page is 2*sizeof(void*) so the trampoline itself cannot be smaller that 16 bytes */
.endr