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 stdcall patch/trampolines



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.



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