Commit d9abffeabe4f38bac12b864146cf974ede814411

hjl-tools 2020-02-22T06:32:22

x86: Fix ffi_prep_closure_loc (#542) Since FFI_TRAMPOLINE_SIZE is increased by 4 bytes to add ENDBR32, adjust jump displacement by 4 bytes.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/x86/ffi.c b/src/x86/ffi.c
index e247322..346e784 100644
--- a/src/x86/ffi.c
+++ b/src/x86/ffi.c
@@ -566,7 +566,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
 
   /* jmp dest */
   tramp[9] = 0xe9;
-  *(unsigned *)(tramp + 10) = (unsigned)dest - ((unsigned)codeloc + 10);
+  *(unsigned *)(tramp + 10) = (unsigned)dest - ((unsigned)codeloc + 14);
 
   closure->cif = cif;
   closure->fun = fun;