[SPARC v8] Make ffi compatible with Solaris Studio aggregate return ABI

Ginn Chen ginn.chen@oracle.com
Mon Dec 27 06:41:00 GMT 2010


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  



More information about the Libffi-discuss mailing list