From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23151 invoked by alias); 20 Nov 2002 15:58:14 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 22677 invoked from network); 20 Nov 2002 15:57:41 -0000 Received: from unknown (HELO fw-cam.cambridge.arm.com) (193.131.176.3) by sources.redhat.com with SMTP; 20 Nov 2002 15:57:41 -0000 Received: by fw-cam.cambridge.arm.com; id PAA26613; Wed, 20 Nov 2002 15:57:31 GMT Received: from unknown(172.16.1.2) by fw-cam.cambridge.arm.com via smap (V5.5) id xma025465; Wed, 20 Nov 02 15:56:38 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 PAA16597; Wed, 20 Nov 2002 15:56:37 GMT Received: from pc960.cambridge.arm.com (rearnsha@localhost) by pc960.cambridge.arm.com (8.11.6/8.9.3) with ESMTP id gAKFubQ13945; Wed, 20 Nov 2002 15:56:37 GMT Message-Id: <200211201556.gAKFubQ13945@pc960.cambridge.arm.com> X-Authentication-Warning: pc960.cambridge.arm.com: rearnsha owned process doing -bs To: "Kris Warkentin" cc: gdb@sources.redhat.com, Richard.Earnshaw@arm.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: ARM stack alignment on hand called functions In-reply-to: Your message of "Wed, 20 Nov 2002 10:29:00 EST." <18ac01c290a9$8cde3200$0202040a@catdog> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 20 Nov 2002 07:58:00 -0000 From: Richard Earnshaw X-SW-Source: 2002-11/txt/msg00256.txt.bz2 > Hi, > > I was chasing a bug that was uncovered by the gdb dejagnu regression suite > on QNX 6 with gdb 5.2.1. The problem was in the file 'structs.c' which > follows the pattern below. > > If I break on main and then do something like 'call fun1()', the inferior > would die with a SIGBUS. As long as I called functions whose structures > were divisible by 4, like fun4(), fun12(), etc., it was fine. I chased it > down to stack pointer alignment: the value stuffed into sp when it executed > the dummy frame was not aligned on a 4 byte boundary. > > Initially I had tried defining STACK_ALIGN() but it seemed to cause other > problems to pop up. For example, 'call Fun1(foo1)' would fail with a > SIGBUS. My final fix which seems to work well was just to add sp = (sp + 3) > & ~3 at the end of arm_push_arguments() in arm-tdep.c just before it returns > sp. Looking at the code for mips_push_arguments though, it seems like this > might be a little simplistic since there is quite a lot of alignment code in > there. > > Can anyone comment on the correctness of this fix? No, I don't think this is correct, since it will mean that the structure starts at an unaligned address. Instead the space allocated for the structure on the stack should be rounded up to a word and then the structure copied into that space with an aligned starting point. R.