This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: ARM stack alignment on hand called functions
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: "Kris Warkentin" <kewarken at qnx dot com>
- Cc: Richard dot Earnshaw at arm dot com, gdb at sources dot redhat dot com
- Date: Wed, 20 Nov 2002 18:37:32 +0000
- Subject: Re: ARM stack alignment on hand called functions
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> The problem arises only with functions which return structures whose size is
> not evenly divisible by 4. Below is what I did to solve it.
>
> Index: arm-tdep.c
> ===================================================================
> RCS file: /product/tools/gdb/gdb/arm-tdep.c,v
> retrieving revision 1.9
> retrieving revision 1.10
> diff -c -r1.9 -r1.10
> *** arm-tdep.c 20 Sep 2002 17:11:31 -0000 1.9
> --- arm-tdep.c 19 Nov 2002 18:33:37 -0000 1.10
> ***************
> *** 1480,1485 ****
> --- 1480,1486 ----
> }
> }
>
> + sp = (sp + 3) & ~3;
> /* Return adjusted stack pointer. */
> return sp;
> }
>
OK, but with this change the alignment is being done *after* any arguments
that have to go onto the stack have been pushed. It should happen
*before*. What happens if you have?
struct f { char a; char b; char c;};
struct f g = {1,2,3};
struct f h (int a, int b, int c, int d, int e)
{
g.c = e;
return g;
}
and then call h from within the debugger. Is g.c set correctly?
My guess is that it won't, because the integer value for e will have been
pushed onto the stack incorrectly.
R.