diff options
author | Ole André Vadla Ravnås <oleavr@gmail.com> | 2021-03-24 12:16:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-24 07:16:12 -0400 |
commit | 1aeb26714ec30649f5d9de5b4884a4ac46f5f474 (patch) | |
tree | c8a6636d111b97739b437c0b346c19f62be8d7e9 /src | |
parent | e92c81a549924c80d70666ecbe5ed0c2fcd7963a (diff) | |
download | libffi-1aeb26714ec30649f5d9de5b4884a4ac46f5f474.tar.gz |
x86: Fix thiscall and fastcall stack cleanup behavior (#611)
These are meant to use callee clean-up.
Diffstat (limited to 'src')
-rw-r--r-- | src/x86/ffi.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/x86/ffi.c b/src/x86/ffi.c index 26dbc05..24431c1 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -538,10 +538,17 @@ ffi_closure_inner (struct closure_frame *frame, char *stack) frame->fun (cif, rvalue, avalue, frame->user_data); - if (cabi == FFI_STDCALL) - return flags + (cif->bytes << X86_RET_POP_SHIFT); - else - return flags; + switch (cabi) + { + case FFI_STDCALL: + return flags | (cif->bytes << X86_RET_POP_SHIFT); + case FFI_THISCALL: + case FFI_FASTCALL: + return flags | ((cif->bytes - (narg_reg * FFI_SIZEOF_ARG)) + << X86_RET_POP_SHIFT); + default: + return flags; + } } ffi_status @@ -558,12 +565,12 @@ ffi_prep_closure_loc (ffi_closure* closure, switch (cif->abi) { case FFI_SYSV: - case FFI_THISCALL: - case FFI_FASTCALL: case FFI_MS_CDECL: dest = ffi_closure_i386; break; case FFI_STDCALL: + case FFI_THISCALL: + case FFI_FASTCALL: case FFI_PASCAL: dest = ffi_closure_STDCALL; break; |