From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3015 invoked by alias); 28 Nov 2002 10:45:15 -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 3005 invoked from network); 28 Nov 2002 10:45:12 -0000 Received: from unknown (HELO Cantor.suse.de) (213.95.15.193) by sources.redhat.com with SMTP; 28 Nov 2002 10:45:12 -0000 Received: from Hermes.suse.de (Charybdis.suse.de [213.95.15.201]) by Cantor.suse.de (Postfix) with ESMTP id 235181470B; Thu, 28 Nov 2002 11:45:12 +0100 (MET) X-Authentication-Warning: sykes.suse.de: schwab set sender to schwab@suse.de using -f To: Richard.Earnshaw@arm.com Cc: gdb-patches@sources.redhat.com Subject: Re: [rfa?] Add frame_align(); Was: ARM stack alignment on hand called functions References: <200211281040.gASAeCC03374@pc960.cambridge.arm.com> X-Yow: Now I'm being INVOLUNTARILY shuffled closer to the CLAM DIP with the BROKEN PLASTIC FORKS in it!! From: Andreas Schwab Date: Thu, 28 Nov 2002 02:45:00 -0000 In-Reply-To: <200211281040.gASAeCC03374@pc960.cambridge.arm.com> (Richard Earnshaw's message of "Thu, 28 Nov 2002 10:40:11 +0000") Message-ID: User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.3.50 (ia64-suse-linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-SW-Source: 2002-11/txt/msg00710.txt.bz2 Richard Earnshaw writes: |> > Richard Earnshaw writes: |> > |> > |> > +/* Ensure that the ARM's stack pointer has the correct alignment for a |> > |> > + new frame. */ |> > |> > +static CORE_ADDR |> > |> > +arm_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr) |> > |> > +{ |> > |> > + return (addr & -16); |> > |> > +} |> > |> |> > |> Yuck, two's complement assumption. |> > |> > No, -16 is implicitly cast to bfd_vma, which is unsigned, and this |> > operation is completely defined independent of the representation of |> > signed integers. |> |> Hmm, strictly speaking you are correct. I don't have to like it though, |> and it means that the code is heavily dependent on the non-obvious fact |> that addr is an unsigned type to get the correct behaviour (if bfd_vma |> were to be changed to a signed type then this code would quietly break). |> |> So I'll change my comment to: |> |> Yuck, implicit cast of negative number to unsigned. Note that ~0xf is even worse. If sizeof(int) < sizeof(bfd_vma) then you get the wrong value, because ~0xf is _zero_ extended to bfd_vma. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."