From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6263 invoked by alias); 20 Nov 2002 15:29:22 -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 6255 invoked from network); 20 Nov 2002 15:29:19 -0000 Received: from unknown (HELO hub.ott.qnx.com) (209.226.137.76) by sources.redhat.com with SMTP; 20 Nov 2002 15:29:19 -0000 Received: from smtp.ott.qnx.com (smtp.ott.qnx.com [10.0.2.158]) by hub.ott.qnx.com (8.9.3/8.9.3) with ESMTP id KAA20754 for ; Wed, 20 Nov 2002 10:25:22 -0500 Received: from catdog ([10.4.2.2]) by smtp.ott.qnx.com (8.8.8/8.6.12) with SMTP id KAA09439 for ; Wed, 20 Nov 2002 10:19:49 -0500 Message-ID: <18ac01c290a9$8cde3200$0202040a@catdog> From: "Kris Warkentin" To: Subject: ARM stack alignment on hand called functions Date: Wed, 20 Nov 2002 07:29:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-SW-Source: 2002-11/txt/msg00252.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? cheers, Kris struct struct1 { char a;}; struct struct2 { char a, b;}; struct struct3 { char a, b, c; }; ... struct struct1 foo1 = {'1'}, L1; struct struct2 foo2 = { 'a', 'b'}, L2; struct struct3 foo3 = { 'A', 'B', 'C'}, L3; ... struct struct1 fun1() { return foo1; } struct struct2 fun2() { return foo2; } ... void Fun1(struct struct1 foo1) { L1 = foo1; } void Fun2(struct struct2 foo2) { L2 = foo2; } ....