From: "Kris Warkentin" <kewarken@qnx.com>
To: <gdb@sources.redhat.com>
Subject: ARM stack alignment on hand called functions
Date: Wed, 20 Nov 2002 07:29:00 -0000 [thread overview]
Message-ID: <18ac01c290a9$8cde3200$0202040a@catdog> (raw)
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;
}
....
next reply other threads:[~2002-11-20 15:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-20 7:29 Kris Warkentin [this message]
2002-11-20 7:58 ` Richard Earnshaw
2002-11-20 8:10 ` Kris Warkentin
2002-11-20 8:21 ` Richard Earnshaw
2002-11-20 8:26 ` Kris Warkentin
2002-11-20 9:18 ` Andrew Cagney
2002-11-20 9:35 ` Kris Warkentin
2002-11-26 14:01 ` Andrew Cagney
2002-11-27 1:18 ` Richard Earnshaw
2002-11-20 10:37 ` Richard Earnshaw
2002-11-20 10:59 ` Kris Warkentin
2002-11-20 11:40 ` Kris Warkentin
2002-11-21 2:58 ` Richard Earnshaw
[not found] <200211272021.PAA04606@hub.ott.qnx.com>
2002-11-27 13:13 ` Kris Warkentin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='18ac01c290a9$8cde3200$0202040a@catdog' \
--to=kewarken@qnx.com \
--cc=gdb@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox