[rfa:ppc] Fix PPC/NBSD struct return; Was: userdef.exp regression for ppc?
Jason R Thorpe
thorpej@wasabisystems.com
Sun Jun 2 11:51:00 GMT 2002
On Sat, Jun 01, 2002 at 01:21:52PM -0400, Andrew Cagney wrote:
> Yep! The attached fixes it. Looks like PPC/NetBSD's custom GCC has a
> fixed struct return (I'm pretty sure that mainline GCC is broken).
Hmmmmm, both our 2.91 and 2.95 based compilers use:
#define RETURN_IN_MEMORY(TYPE) \
(TYPE_MODE (TYPE) == BLKmode \
&& (DEFAULT_ABI != ABI_SOLARIS || int_size_in_bytes (TYPE) > 8))
...and don't override this anywhere. The DEFAULT_ABI ends up as ABI_V4,
and not ABI_SOLARIS, so we definitely should be using the AIX structure
return convention there.
However, the following:
struct test_struct {
int a;
int b;
};
static struct test_struct test_struct = { 1,2 };
struct test_struct
test(void)
{
return test_struct;
}
...does indeed produce code that appears to follow the SVR4 ABI rules:
.file "test.c"
gcc2_compiled.:
.section ".sdata","aw"
.align 2
.type test_struct,@object
.size test_struct,8
test_struct:
.long 1
.long 2
.section ".text"
.align 2
.globl test
.type test,@function
test:
lis 9,test_struct@ha
la 9,test_struct@l(9)
lwz 3,0(9)
lwz 4,4(9)
blr
.Lfe1:
.size test,.Lfe1-test
.ident "GCC: (GNU) 2.95.3 20010315 (release) (NetBSD nb1)"
...and adding another member to the structure (this making it > 8 bytes)
produces an in-memory return:
.file "test.c"
gcc2_compiled.:
.section ".data"
.align 2
.type test_struct,@object
.size test_struct,12
test_struct:
.long 1
.long 2
.space 4
.section ".text"
.align 2
.globl test
.type test,@function
test:
lis 9,test_struct@ha
la 11,test_struct@l(9)
lwz 10,test_struct@l(9)
lwz 8,8(11)
lwz 0,4(11)
stw 10,0(3)
stw 0,4(3)
stw 8,8(3)
blr
.Lfe1:
.size test,.Lfe1-test
.ident "GCC: (GNU) 2.95.3 20010315 (release) (NetBSD nb1)"
AHA! I see why. In the 2.91 and 2.95 compilers, config/netbsd.h
defines DEFAULT_PCC_STRUCT_RETURN to 0, which causes GCC's
aggregate_value_p() to effecively give the SVR4 ABI semantics.
Yes, gcc 3.1 and gcc-current are definitely broken in this regard for
NetBSD, then (I haven't had a chance to do much gcc work on powerpc-netbsd,
but I'm obviously going to have to pay a bit more attention to it now).
I'll fix that up soon, and will simply remove the broken abi struct return
stuff from ppcnbsd-tdep.c.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
More information about the Gdb-patches
mailing list