* Re: [rfa:ppc] Fix PPC/NBSD struct return; Was: userdef.exp regression for ppc?
2002-06-01 10:21 ` [rfa:ppc] Fix PPC/NBSD struct return; Was: " Andrew Cagney
@ 2002-06-01 15:03 ` Jason R Thorpe
2002-06-02 11:15 ` Jason R Thorpe
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Jason R Thorpe @ 2002-06-01 15:03 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Michael Elizabeth Chastain, gdb-patches
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).
Hm. At a quick glance, I didn't see any changes wrt. struct return
in NetBSD's 2.91 or 2.95 vintage compilers. I'll look into this further
on Monday.
>
> The old code, for reasons I'm not sure, was failing to detect NetBSD and
> hence was failing ot set it.
>
> Andrew
>
> 2002-06-01 Andrew Cagney <ac131313@redhat.com>
>
> * ppcnbsd-tdep.c (ppcnbsd_init_abi): Don't set
> use_struct_convention to sysv_abi_broken_use_struct_convention.
>
> Index: ppcnbsd-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/ppcnbsd-tdep.c,v
> retrieving revision 1.1
> diff -p -r1.1 ppcnbsd-tdep.c
> *** ppcnbsd-tdep.c 28 May 2002 18:43:07 -0000 1.1
> --- ppcnbsd-tdep.c 1 Jun 2002 17:07:37 -0000
> *************** ppcnbsd_init_abi (struct gdbarch_info in
> *** 203,211 ****
> /* Until November 2001, gcc was not complying to the SYSV ABI for
> returning structures less than or equal to 8 bytes in size. It was
> returning everything in memory. When this was corrected, it wasn't
> ! fixed for native platforms. */
> set_gdbarch_use_struct_convention (gdbarch,
> ppc_sysv_abi_broken_use_struct_convention);
>
> set_solib_svr4_fetch_link_map_offsets (gdbarch,
> nbsd_ilp32_solib_svr4_fetch_link_map_offsets);
> --- 203,217 ----
> /* Until November 2001, gcc was not complying to the SYSV ABI for
> returning structures less than or equal to 8 bytes in size. It was
> returning everything in memory. When this was corrected, it wasn't
> ! fixed for native platforms.
> !
> ! However, NetBSD 1.5.x uses gcc version egcs-2.91.66 19990314
> ! (egcs-1.1.2 release) with local patches and that has a fixed
> ! struct convention. */
> ! #if 0
> set_gdbarch_use_struct_convention (gdbarch,
> ppc_sysv_abi_broken_use_struct_convention);
> + #endif
>
> set_solib_svr4_fetch_link_map_offsets (gdbarch,
> nbsd_ilp32_solib_svr4_fetch_link_map_offsets);
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [rfa:ppc] Fix PPC/NBSD struct return; Was: userdef.exp regression for ppc?
2002-06-01 10:21 ` [rfa:ppc] Fix PPC/NBSD struct return; Was: " Andrew Cagney
2002-06-01 15:03 ` Jason R Thorpe
@ 2002-06-02 11:15 ` Jason R Thorpe
2002-06-02 11:51 ` Jason R Thorpe
2002-06-02 13:29 ` Jason R Thorpe
3 siblings, 0 replies; 9+ messages in thread
From: Jason R Thorpe @ 2002-06-02 11:15 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Michael Elizabeth Chastain, gdb-patches
On Sat, Jun 01, 2002 at 01:21:52PM -0400, Andrew Cagney wrote:
> The old code, for reasons I'm not sure, was failing to detect NetBSD and
> hence was failing ot set it.
The reason the old code didn't detect NetBSD is because it wasn't looking
for the .note sections that NetBSD uses to identify its binaries. The
generic OS ABI code does understand NetBSD's .note sections.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [rfa:ppc] Fix PPC/NBSD struct return; Was: userdef.exp regression for ppc?
2002-06-01 10:21 ` [rfa:ppc] Fix PPC/NBSD struct return; Was: " Andrew Cagney
2002-06-01 15:03 ` Jason R Thorpe
2002-06-02 11:15 ` Jason R Thorpe
@ 2002-06-02 11:51 ` Jason R Thorpe
2002-06-02 12:24 ` Zack Weinberg
2002-06-02 13:29 ` Jason R Thorpe
3 siblings, 1 reply; 9+ messages in thread
From: Jason R Thorpe @ 2002-06-02 11:51 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Michael Elizabeth Chastain, gdb-patches, gcc
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>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [rfa:ppc] Fix PPC/NBSD struct return; Was: userdef.exp regression for ppc?
2002-06-02 11:51 ` Jason R Thorpe
@ 2002-06-02 12:24 ` Zack Weinberg
0 siblings, 0 replies; 9+ messages in thread
From: Zack Weinberg @ 2002-06-02 12:24 UTC (permalink / raw)
To: Jason R Thorpe, Andrew Cagney, Michael Elizabeth Chastain,
gdb-patches, gcc
On Sun, Jun 02, 2002 at 11:51:05AM -0700, Jason R Thorpe wrote:
> 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:
[...]
> ...does indeed produce code that appears to follow the SVR4 ABI rules:
[...]
> 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'm a little confused here. Are you saying that the 2.9x native GCC
for NetBSD followed the SVR4 spec, returning small structures in
registers, but 3.1 and -current don't (because I incorrectly thought
the earlier compilers used the AIX convention)? If so, the fix should
be as simple as removing the
/* For backward compatibility, we must continue to use the AIX
structure return convention. */
#undef DRAFT_V4_STRUCT_RET
#define DRAFT_V4_STRUCT_RET 1
from gcc/config/rs6000/netbsd.h...
zw
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [rfa:ppc] Fix PPC/NBSD struct return; Was: userdef.exp regression for ppc?
2002-06-01 10:21 ` [rfa:ppc] Fix PPC/NBSD struct return; Was: " Andrew Cagney
` (2 preceding siblings ...)
2002-06-02 11:51 ` Jason R Thorpe
@ 2002-06-02 13:29 ` Jason R Thorpe
2002-06-03 6:13 ` Andrew Cagney
3 siblings, 1 reply; 9+ messages in thread
From: Jason R Thorpe @ 2002-06-02 13:29 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Michael Elizabeth Chastain, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 398 bytes --]
On Sat, Jun 01, 2002 at 01:21:52PM -0400, Andrew Cagney wrote:
> The old code, for reasons I'm not sure, was failing to detect NetBSD and
> hence was failing ot set it.
Here is the patch I checked in.
* ppcnbsd-tdep.c (ppcnbsd_init_abi): Don't set
use_struct_convention to ppc_sysv_abi_broken_use_struct_convention.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
[-- Attachment #2: ppc-patch --]
[-- Type: text/plain, Size: 908 bytes --]
Index: ppcnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppcnbsd-tdep.c,v
retrieving revision 1.1
diff -u -r1.1 ppcnbsd-tdep.c
--- ppcnbsd-tdep.c 28 May 2002 18:43:07 -0000 1.1
+++ ppcnbsd-tdep.c 2 Jun 2002 20:26:01 -0000
@@ -200,12 +200,6 @@
ppcnbsd_init_abi (struct gdbarch_info info,
struct gdbarch *gdbarch)
{
- /* Until November 2001, gcc was not complying to the SYSV ABI for
- returning structures less than or equal to 8 bytes in size. It was
- returning everything in memory. When this was corrected, it wasn't
- fixed for native platforms. */
- set_gdbarch_use_struct_convention (gdbarch,
- ppc_sysv_abi_broken_use_struct_convention);
set_solib_svr4_fetch_link_map_offsets (gdbarch,
nbsd_ilp32_solib_svr4_fetch_link_map_offsets);
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [rfa:ppc] Fix PPC/NBSD struct return; Was: userdef.exp regression for ppc?
2002-06-02 13:29 ` Jason R Thorpe
@ 2002-06-03 6:13 ` Andrew Cagney
0 siblings, 0 replies; 9+ messages in thread
From: Andrew Cagney @ 2002-06-03 6:13 UTC (permalink / raw)
To: Jason R Thorpe; +Cc: Michael Elizabeth Chastain, gdb-patches
> Here is the patch I checked in.
>
> * ppcnbsd-tdep.c (ppcnbsd_init_abi): Don't set
> use_struct_convention to ppc_sysv_abi_broken_use_struct_convention.
>
Can I suggest adding a comment to the C file that contains the results
of your research? That way, those that follow won't try to put it back
again :-)
Andrew
^ permalink raw reply [flat|nested] 9+ messages in thread