This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: libffi stdcall patch/trampolines
- From: Timothy Wall <twalljava at dev dot java dot net>
- To: Anthony Green <green at redhat dot com>
- Cc: libffi-discuss at sourceware dot org
- Date: Thu, 31 Jan 2008 21:54:08 -0500
- Subject: Re: libffi stdcall patch/trampolines
- References: <6B999E51-9D23-4444-A35C-97DCF30F1380@dev.java.net>
On Jan 31, 2008, at 9:44 PM, Timothy Wall wrote:
The distinction is much more critical here, where the target
instruction is *not* at the end of the trampoline, but at the same
10-byte offset as the previous template. The trampoline itself is
bigger.
#define FFI_INIT_TRAMPOLINE_STDCALL(TRAMP,FUN,CTX,SIZE) \
({ unsigned char *__tramp = (unsigned char*)(TRAMP); \
unsigned int __fun = (unsigned int)(FUN); \
unsigned int __ctx = (unsigned int)(CTX); \
unsigned int __dis = __fun - ((unsigned int) __tramp +
FFI_TRAMPOLINE_SIZE);
One other thing; the displacement should be calculated from __ctx,
not __tramp, since the former is the location in executable memory,
while the latter is the location in writable memory.