Blame SOURCES/libffi-rh1652930.patch

e78612
Also flush the code alias mapping when creating a closure.  It seems
e78612
that this is necessary on some aarch64 implementations.  The existing
e78612
code only flashes the writable mapping.
e78612
e78612
diff -rup a/include/ffi_common.h b/include/ffi_common.h
e78612
--- a/include/ffi_common.h	2014-04-25 13:45:13.000000000 -0400
e78612
+++ b/include/ffi_common.h	2019-06-14 14:12:04.387499160 -0400
e78612
@@ -82,6 +82,10 @@ ffi_status ffi_prep_cif_machdep(ffi_cif
e78612
 ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
e78612
 	 unsigned int nfixedargs, unsigned int ntotalargs);
e78612
 
e78612
+/* Translate a data pointer to a code pointer.  Needed for closures on
e78612
+   some targets.  */
e78612
+void *ffi_data_to_code_pointer (void *data) FFI_HIDDEN;
e78612
+
e78612
 /* Extended cif, used in callback from assembly routine */
e78612
 typedef struct
e78612
 {
e78612
Only in b/include: ffi_common.h.orig
e78612
diff -rup a/src/aarch64/ffi.c b/src/aarch64/ffi.c
e78612
--- a/src/aarch64/ffi.c	2019-06-14 14:11:03.485469505 -0400
e78612
+++ b/src/aarch64/ffi.c	2019-06-14 14:12:04.392499162 -0400
e78612
@@ -926,6 +926,10 @@ ffi_prep_closure_loc (ffi_closure* closu
e78612
   FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_SYSV, codeloc,
e78612
 		       cif->aarch64_flags);
e78612
 
e78612
+  /* Also clear the cache on the executable alias mapping.  */
e78612
+  unsigned char *code = ffi_data_to_code_pointer (&closure->tramp[0]);
e78612
+  ffi_clear_cache (code, code + FFI_TRAMPOLINE_SIZE);
e78612
+
e78612
   closure->cif  = cif;
e78612
   closure->user_data = user_data;
e78612
   closure->fun  = fun;
e78612
Only in b/src/aarch64: ffi.c.orig
e78612
diff -rup a/src/closures.c b/src/closures.c
e78612
--- a/src/closures.c	2014-05-11 09:54:19.000000000 -0400
e78612
+++ b/src/closures.c	2019-06-14 14:12:04.396499164 -0400
e78612
@@ -597,6 +597,13 @@ ffi_closure_alloc (size_t size, void **c
e78612
   return ptr;
e78612
 }
e78612
 
e78612
+void *
e78612
+ffi_data_to_code_pointer (void *data)
e78612
+{
e78612
+  msegmentptr seg = segment_holding (gm, data);
e78612
+  return add_segment_exec_offset (data, seg);
e78612
+}
e78612
+
e78612
 /* Release a chunk of memory allocated with ffi_closure_alloc.  If
e78612
    FFI_CLOSURE_FREE_CODE is nonzero, the given address can be the
e78612
    writable or the executable address given.  Otherwise, only the
e78612
@@ -656,5 +663,11 @@ ffi_closure_free (void *ptr)
e78612
   free (ptr);
e78612
 }
e78612
 
e78612
+void *
e78612
+ffi_data_to_code_pointer (void *data)
e78612
+{
e78612
+  return data;
e78612
+}
e78612
+
e78612
 # endif /* ! FFI_MMAP_EXEC_WRIT */
e78612
 #endif /* FFI_CLOSURES */