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]

Re: libffi merge



On Jun 4, 2009, at 12:04 PM, Andrew Haley wrote:


x86 changes: merge from libffi -> gcc.

Timothy Wall, please check this one.


2008-02-03 Timothy Wall <twall@users.sf.net>


* src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL): Calculate jump return
offset based on code pointer, not data pointer.


2008-01-31 Timothy Wall <twall@users.sf.net>

       * testsuite/libffi.call/closure_stdcall.c: Add test for stdcall
       closures.
       * src/x86/ffitarget.h: Increase size of trampoline for stdcall
       closures.
       * src/x86/win32.S: Add assembly for stdcall closure.
       * src/x86/ffi.c: Initialize stdcall closure trampoline.

--- /home/aph/gcc/trunk/libffi/src/x86/ffi.c 2009-06-04 16:47:13.000000000 +0100
+++ ./src/x86/ffi.c 2008-04-03 19:57:34.000000000 +0100
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
- ffi.c - Copyright (c) 1996, 1998, 1999, 2001, 2007 Red Hat, Inc.
+ ffi.c - Copyright (c) 1996, 1998, 1999, 2001, 2007, 2008 Red Hat, Inc.
Copyright (c) 2002 Ranjit Mathew
Copyright (c) 2002 Bo Thorsen
Copyright (c) 2002 Roger Sayle
@@ -236,6 +236,10 @@
__attribute__ ((regparm(1)));
void FFI_HIDDEN ffi_closure_raw_SYSV (ffi_raw_closure *)
__attribute__ ((regparm(1)));
+#ifdef X86_WIN32
+void FFI_HIDDEN ffi_closure_STDCALL (ffi_closure *)
+ __attribute__ ((regparm(1)));
+#endif


/* This function is jumped to by the trampoline */

@@ -245,7 +249,7 @@
     void **respp;
     void *args;
{
-  // our various things...
+  /* our various things...  */
  ffi_cif       *cif;
  void         **arg_area;

@@ -311,13 +315,26 @@
({ unsigned char *__tramp = (unsigned char*)(TRAMP); \
   unsigned int  __fun = (unsigned int)(FUN); \
   unsigned int  __ctx = (unsigned int)(CTX); \
-   unsigned int  __dis = __fun - (__ctx + FFI_TRAMPOLINE_SIZE); \
+   unsigned int  __dis = __fun - (__ctx + 10);	\
   *(unsigned char*) &__tramp[0] = 0xb8; \
   *(unsigned int*)  &__tramp[1] = __ctx; /* movl __ctx, %eax */ \
   *(unsigned char *)  &__tramp[5] = 0xe9; \
   *(unsigned int*)  &__tramp[6] = __dis; /* jmp __fun  */ \
 })


The above change looks like it was missed in the gcc patch. While FFI_TRAMPOLINE_SIZE is "10", the offset added to __ctx is an instruction displacement, NOT the size of the trampoline.



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