From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10534 invoked by alias); 28 Nov 2002 10:57:41 -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 10502 invoked from network); 28 Nov 2002 10:57:33 -0000 Received: from unknown (HELO fw-cam.cambridge.arm.com) (193.131.176.3) by sources.redhat.com with SMTP; 28 Nov 2002 10:57:33 -0000 Received: by fw-cam.cambridge.arm.com; id KAA10781; Thu, 28 Nov 2002 10:57:18 GMT Received: from unknown(172.16.1.2) by fw-cam.cambridge.arm.com via smap (V5.5) id xma010416; Thu, 28 Nov 02 10:56:43 GMT Received: from pc960.cambridge.arm.com (pc960.cambridge.arm.com [10.1.205.4]) by cam-admin0.cambridge.arm.com (8.9.3/8.9.3) with ESMTP id KAA21893; Thu, 28 Nov 2002 10:56:42 GMT Received: from pc960.cambridge.arm.com (rearnsha@localhost) by pc960.cambridge.arm.com (8.11.6/8.9.3) with ESMTP id gASAugP02119; Thu, 28 Nov 2002 10:56:42 GMT Message-Id: <200211281056.gASAugP02119@pc960.cambridge.arm.com> X-Authentication-Warning: pc960.cambridge.arm.com: rearnsha owned process doing -bs To: Andreas Schwab cc: Richard.Earnshaw@arm.com, gdb-patches@sources.redhat.com Reply-To: Richard.Earnshaw@arm.com Organization: ARM Ltd. X-Telephone: +44 1223 400569 (direct+voicemail), +44 1223 400400 (switchbd) X-Fax: +44 1223 400410 X-Address: ARM Ltd., 110 Fulbourn Road, Cherry Hinton, Cambridge CB1 9NJ. Subject: Re: [rfa?] Add frame_align(); Was: ARM stack alignment on hand called functions In-reply-to: Your message of "Thu, 28 Nov 2002 11:45:09 +0100." Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Date: Thu, 28 Nov 2002 02:57:00 -0000 From: Richard Earnshaw X-SW-Source: 2002-11/txt/msg00711.txt.bz2 > Richard Earnshaw writes: >=20 > |> > Richard Earnshaw writes: > |> >=20 > |> > |> > +/* Ensure that the ARM's stack pointer has the correct alignme= nt for a > |> > |> > + new frame. */ > |> > |> > +static CORE_ADDR > |> > |> > +arm_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr) > |> > |> > +{ > |> > |> > + return (addr & -16); > |> > |> > +} > |> > |>=20 > |> > |> Yuck, two's complement assumption. > |> >=20 > |> > No, -16 is implicitly cast to bfd_vma, which is unsigned, and this > |> > operation is completely defined independent of the representation of > |> > signed integers. > |>=20 > |> Hmm, strictly speaking you are correct. I don't have to like it thoug= h,=20 > |> and it means that the code is heavily dependent on the non-obvious fac= t=20 > |> that addr is an unsigned type to get the correct behaviour (if bfd_vma= =20 > |> were to be changed to a signed type then this code would quietly break= ). > |>=20 > |> So I'll change my comment to: > |>=20 > |> Yuck, implicit cast of negative number to unsigned. >=20 > 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. But not if you write ~(bfd_vma)0xf R.