ARM stack alignment on hand called functions

Richard Earnshaw rearnsha@arm.com
Wed Nov 20 08:21:00 GMT 2002


> ----- Original Message -----
> From: "Richard Earnshaw" <rearnsha@arm.com>
> > 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.
> 
> But in this case, the issue isn't with passing arguments but rather with
> returning them.  Earlier in hand_function_call() (in valops.c), there is
> some code where if a structure is being returned, we enlarge the stack by
> the size of the structure.  This is what wasn't aligned.  For example, if
> you called 'fun2()', which returns a 2 byte structure, the type length was
> '2' which is how much the stack pointer is out.  This way, when we write the
> stack at the start of the called function, our sp is misaligned.  The frame
> pointer is fine so the function gets the arguments alright, it's just
> writing stack variables and return values to the stack that is buggered.
> I'm looking at this and thinking, it just gives a little padding on the
> stack to maintain alignment.
> 

Then I'm not sure I understand exactly what your problem is.  If you show 
me the actual patch, rather than just trying to describe it, then perhaps 
that will be more clear.

R.



More information about the Gdb mailing list