x86: Fix ffi_prep_closure_loc (#542)
authorhjl-tools <hjl.tools@gmail.com>
Sat, 22 Feb 2020 14:32:22 +0000 (06:32 -0800)
committerGitHub <noreply@github.com>
Sat, 22 Feb 2020 14:32:22 +0000 (09:32 -0500)
Since FFI_TRAMPOLINE_SIZE is increased by 4 bytes to add ENDBR32, adjust
jump displacement by 4 bytes.

src/x86/ffi.c

index e2473220484e4d08dcfeae66abc3cea8977fe2e7..346e784e15de56478c850dd5ff0013685ddfcc0c 100644 (file)
@@ -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;