This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
[SPARC v8] Make ffi compatible with Solaris Studio aggregate return ABI
- From: Ginn Chen <ginn dot chen at oracle dot com>
- To: libffi-discuss at sourceware dot org
- Date: Mon, 27 Dec 2010 14:40:56 +0800
- Subject: [SPARC v8] Make ffi compatible with Solaris Studio aggregate return ABI
SPARC V8 Manual has:
"When a procedure expecting an aggregate return value from a called function is
compiled, an UNIMP instruction is placed after the delay-slot instruction
following the CALL to the function in question. The immediate field in this
UNIMP instruction contains the low-order twelve bits of the size (in bytes) of
the area allocated by the caller for the aggregate value expected to be
returned."
The function compiled by gcc doesn't check the UNIMP instruction, it simply copy the returning struct and jump to %i7+12.
The same function compiled by Solaris Studio, checks the struct size in UNIMP instruction, if it matches the returning struct it will copy the value and jump to %i7+12,
if not it will do nothing and jump to %i7+8.
So simply adding a nop in v8.S doesn't work with libraries compiled by Solaris Studio.
e.g. if I compile testsuite/cls_8byte.c with Solaris Studio, it will not pass the test.
I have a patch to alloc some executable space and make the call with exact struct size there.
The patch is at:
https://bugzilla.mozilla.org/show_bug.cgi?id=583206
I have tested it on Solaris with both gcc and Solaris Studio.
Please review it.
Thanks,
Ginn