This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, try 2] Fix thiscall trampoline for x86


---
 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]