This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
[PATCH] Linux/PPC64 closures
- From: Marcus Comstedt <marcus at mc dot pp dot se>
- To: libffi-discuss at sourceware dot org
- Date: Mon, 21 Jul 2008 23:30:08 +0200
- Subject: [PATCH] Linux/PPC64 closures
Hi again.
Well, since there were no replies to my previous post, I take it
that there are no objections to the suggestion that r2 should be
used as the closure pointer instead of r11 in the Linux/PPC64
closures, for increased portability?
Hence, I'm attaching a patch to make that change. With this patch,
libffi closures work fine with IBM JDK 1.6.0.1. This patch is against
libffi-3.0.4, but I expect it to apply cleanly to HEAD as well.
// Marcus
--- ffi.c.orig 2008-07-21 15:25:18.824488484 +0200
+++ ffi.c 2008-07-21 15:50:13.993833184 +0200
@@ -945,7 +945,8 @@ ffi_prep_closure_loc (ffi_closure *closu
FFI_ASSERT (cif->abi == FFI_LINUX64);
/* Copy function address and TOC from ffi_closure_LINUX64. */
memcpy (tramp, (char *) ffi_closure_LINUX64, 16);
- tramp[2] = codeloc;
+ tramp[2] = tramp[1];
+ tramp[1] = codeloc;
#else
unsigned int *tramp;
--- linux64_closure.S.orig 2008-07-21 15:25:30.721951140 +0200
+++ linux64_closure.S 2008-07-21 15:50:24.635580536 +0200
@@ -17,6 +17,10 @@ ffi_closure_LINUX64:
.text
.ffi_closure_LINUX64:
.LFB1:
+ # copy r2 to r11 and load TOC into r2
+ mr %r11, %r2
+ ld %r2, 16(%r11)
+
# save general regs into parm save area
std %r3, 48(%r1)
std %r4, 56(%r1)