From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11538 invoked by alias); 2 Jun 2002 18:51:06 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 11524 invoked from network); 2 Jun 2002 18:51:06 -0000 Received: from unknown (HELO dr-evil.shagadelic.org) (208.176.2.162) by sources.redhat.com with SMTP; 2 Jun 2002 18:51:06 -0000 Received: by dr-evil.shagadelic.org (Postfix, from userid 7518) id C89EC9869; Sun, 2 Jun 2002 11:51:05 -0700 (PDT) Date: Sun, 02 Jun 2002 11:51:00 -0000 From: Jason R Thorpe To: Andrew Cagney Cc: Michael Elizabeth Chastain , gdb-patches@sources.redhat.com, gcc@gcc.gnu.org Subject: Re: [rfa:ppc] Fix PPC/NBSD struct return; Was: userdef.exp regression for ppc? Message-ID: <20020602115105.E27682@dr-evil.shagadelic.org> Mail-Followup-To: Jason R Thorpe , Andrew Cagney , Michael Elizabeth Chastain , gdb-patches@sources.redhat.com, gcc@gcc.gnu.org References: <200206011546.g51FkMj30586@duracef.shout.net> <3CF902B0.50405@cygnus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3CF902B0.50405@cygnus.com>; from ac131313@cygnus.com on Sat, Jun 01, 2002 at 01:21:52PM -0400 Organization: Wasabi Systems, Inc. X-SW-Source: 2002-06/txt/msg00030.txt.bz2 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