summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorian Weimer <fw@deneb.enyo.de>2019-02-19 12:55:11 +0100
committerAnthony Green <green@moxielogic.com>2019-02-19 06:55:11 -0500
commit44a6c28545186d78642487927952844156fc7ab5 (patch)
tree428b32c0a035c845acbd347c189f255424e07fd8 /src
parent042ef8c314a946ef1cd58c6e10cd74e403ef5bf9 (diff)
downloadlibffi-44a6c28545186d78642487927952844156fc7ab5.tar.gz
aarch64: Flush code mapping in addition to data mapping (#471)
This needs a new function, ffi_data_to_code_pointer, to translate from data pointers to code pointers. Fixes issue #470.
Diffstat (limited to 'src')
-rw-r--r--src/aarch64/ffi.c4
-rw-r--r--src/closures.c13
2 files changed, 17 insertions, 0 deletions
diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c
index c48c549..188acf2 100644
--- a/src/aarch64/ffi.c
+++ b/src/aarch64/ffi.c
@@ -773,6 +773,10 @@ ffi_prep_closure_loc (ffi_closure *closure,
*(UINT64 *)(tramp + 16) = (uintptr_t)start;
ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE);
+
+ /* Also flush the cache for code mapping. */
+ unsigned char *tramp_code = ffi_data_to_code_pointer (tramp);
+ ffi_clear_cache (tramp_code, tramp_code + FFI_TRAMPOLINE_SIZE);
#endif
closure->cif = cif;
diff --git a/src/closures.c b/src/closures.c
index 15e6e0f..e9e058e 100644
--- a/src/closures.c
+++ b/src/closures.c
@@ -921,6 +921,13 @@ ffi_closure_alloc (size_t size, void **code)
return ptr;
}
+void *
+ffi_data_to_code_pointer (void *data)
+{
+ msegmentptr seg = segment_holding (gm, data);
+ return add_segment_exec_offset (data, seg);
+}
+
/* Release a chunk of memory allocated with ffi_closure_alloc. If
FFI_CLOSURE_FREE_CODE is nonzero, the given address can be the
writable or the executable address given. Otherwise, only the
@@ -960,6 +967,12 @@ ffi_closure_free (void *ptr)
free (ptr);
}
+void *
+ffi_data_to_code_pointer (void *data)
+{
+ return data;
+}
+
# endif /* ! FFI_MMAP_EXEC_WRIT */
#endif /* FFI_CLOSURES */