From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 903 invoked by alias); 4 Oct 2006 20:26:45 -0000 Received: (qmail 891 invoked by uid 22791); 4 Oct 2006 20:26:44 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Wed, 04 Oct 2006 20:26:42 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1GVDKA-0001fg-2T; Wed, 04 Oct 2006 16:26:38 -0400 Date: Wed, 04 Oct 2006 20:26:00 -0000 From: Daniel Jacobowitz To: Janani Janakiraman Cc: gdb-patches@sourceware.org, pgilliam@us.ibm.com, David Edelsohn , Alan Modra Subject: Re: [patch] Pushing Inferior Function Arguments onto Stack on PowerPC64 machines Message-ID: <20061004202638.GA6253@nevyn.them.org> Mail-Followup-To: Janani Janakiraman , gdb-patches@sourceware.org, pgilliam@us.ibm.com, David Edelsohn , Alan Modra References: <20061004191056.GA4000@nevyn.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-10/txt/msg00020.txt.bz2 On Wed, Oct 04, 2006 at 02:44:56PM -0500, Janani Janakiraman wrote: > > Sorry about the email address goofup. Was trying to use a new account so > that HTML tags don't get in the way. > Have to figure that out later. > > From reading the PPC64 Platform ABI at > http://www.freestandards.org/spec/ELF/ppc64/PPC-elf64abi-1.9.html > ( see section 3.1.7) it appears that on Big Endian machines, > values are left aligned. But looks like GCC has different rules and right > aligns the values which are put on the > registers. This matches Andrew Cagney comment in the code, that says that > ABI specifies that the values > should be left aligned. But like I said in my earlier note, GCC appears to > want the values to be > right aligned. Would appreciate another set of eyes looking at it as I > don't have too much experience > in this area. I'm going to CC a couple of people who are hopefully much more familiar with PowerPC64 ABI issues than I am. Alan, David, could one of you take a quick look at this? The problematic code is in gdb/ppc-sysv-tdep.c, in the function ppc64_sysv_abi_push_dummy_call. It has to do with the passing of aggregates with non-word-sized tails. > Daniel Jacobowitz wrote on 10/04/2006 02:10:56 PM: > > > On Wed, Oct 04, 2006 at 03:00:34PM -0400, janani@linux.ibm.com wrote: > > > I am new to this, so my interpretation might not be completely > > > accurate, but the way I read the note below ( a snippet from the GNU > > > GCC Manual about passing function arguments in registers) is that > > > since PPC64 is big endian, even though the default is to pad downward > > > (i.e. right align), if the size if greater than the size of an int, > > > you need to pad upward (left align). > > > > You're trying to answer the wrong question :-) > > > > It's not "what does GCC do", but "what does the platform ABI say we > > should do". Is GCC conforming to the ABI? Is the ABI wrong, or out of > > date, or was Andrew's reading of it wrong, or... > > > > There could be a real problem here, so it's important that we > > understand what is _supposed_ to happen before we make a change. > > If GCC is violating the ABI, then either GCC or the ABI may need to be > > updated. If GDB is misinterpreting the ABI, then just GDB needs to be > > changed. > > > > -- > > Daniel Jacobowitz > > CodeSourcery > > > ! /* WARNING: cagney/2003-09-21: As best I can > > ! tell, the ABI specifies that the value > should > > ! be left aligned. Unfortunately, GCC > doesn't > > ! do this - it instead right aligns even > sized > > ! values and puts odd sized values on the > > ! stack. Work around that by putting both > a > > ! left and right aligned value into the > > ! register (hopefully no one notices :-^). > > ! Arrrgh! */ > > ! /* Left aligned (8 byte values such as > pointers > > ! fill the buffer). */ > > ! memcpy (regval, val + byte, len); > > ! /* Right aligned (but only if even). */ > > ! if (len == 1 || len == 2 || len == 4) > > ! memcpy (regval + tdep->wordsize - len, > > Janani Janakiraman -- Daniel Jacobowitz CodeSourcery