This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
[PATCH, try 2] Fix thiscall trampoline for x86
- From: Peter Rosin <peda at lysator dot liu dot se>
- To: libffi-discuss at sourceware dot org
- Cc: Kai Tietz <ktietz at redhat dot com>, Peter Rosin <peda at lysator dot liu dot se>
- Date: Wed, 21 Mar 2012 23:16:12 +0100
- Subject: [PATCH, try 2] Fix thiscall trampoline for x86
- References: <1332367920-13716-1-git-send-email-peda@lysator.liu.se>
---
ChangeLog | 5 ++++-
src/x86/ffi.c | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
That patch was broken. Sorry about the duplicate.
Cheers,
Peter
diff --git a/ChangeLog b/ChangeLog
index 32577f1..449ec5c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
-2012-03-21 Peter Rosin <peda@lysator.liu.se>
+2012-03-21 Peter Rosin <peda@lysator.liu.se>
+
+ * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_THISCALL): Use the correct
+ distance (__dis) between the call site and the destination.
* testsuite/libffi.call/float_va.c (float_va_fn): Use %f when
printing doubles (%lf is for long doubles).
diff --git a/src/x86/ffi.c b/src/x86/ffi.c
index 9343c26..ea5a83c 100644
--- a/src/x86/ffi.c
+++ b/src/x86/ffi.c
@@ -593,7 +593,7 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
unsigned int __fun = (unsigned int)(FUN); \
unsigned int __ctx = (unsigned int)(CTX); \
- unsigned int __dis = __fun - (__ctx + 22); \
+ unsigned int __dis = __fun - (__ctx + 49); \
unsigned short __size = (unsigned short)(SIZE); \
*(unsigned int *) &__tramp[0] = 0x8324048b; /* mov (%esp), %eax */ \
*(unsigned int *) &__tramp[4] = 0x4c890cec; /* sub $12, %esp */ \
--
1.7.9