summaryrefslogtreecommitdiff
path: root/src/x86/ffiw64.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/x86/ffiw64.c')
-rw-r--r--src/x86/ffiw64.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/x86/ffiw64.c b/src/x86/ffiw64.c
index b68f69c..034dffd 100644
--- a/src/x86/ffiw64.c
+++ b/src/x86/ffiw64.c
@@ -196,13 +196,15 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure,
void *user_data,
void *codeloc)
{
- static const unsigned char trampoline[16] = {
- /* leaq -0x7(%rip),%r10 # 0x0 */
- 0x4c, 0x8d, 0x15, 0xf9, 0xff, 0xff, 0xff,
- /* jmpq *0x3(%rip) # 0x10 */
- 0xff, 0x25, 0x03, 0x00, 0x00, 0x00,
- /* nopl (%rax) */
- 0x0f, 0x1f, 0x00
+ static const unsigned char trampoline[FFI_TRAMPOLINE_SIZE - 8] = {
+ /* endbr64 */
+ 0xf3, 0x0f, 0x1e, 0xfa,
+ /* leaq -0xb(%rip),%r10 # 0x0 */
+ 0x4c, 0x8d, 0x15, 0xf5, 0xff, 0xff, 0xff,
+ /* jmpq *0x7(%rip) # 0x18 */
+ 0xff, 0x25, 0x07, 0x00, 0x00, 0x00,
+ /* nopl 0(%rax) */
+ 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
};
char *tramp = closure->tramp;
@@ -216,7 +218,7 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure,
}
memcpy (tramp, trampoline, sizeof(trampoline));
- *(UINT64 *)(tramp + 16) = (uintptr_t)ffi_closure_win64;
+ *(UINT64 *)(tramp + sizeof (trampoline)) = (uintptr_t)ffi_closure_win64;
closure->cif = cif;
closure->fun = fun;