PPC stack alignment
rob windgassen
rwindgas@xs4all.nl
Fri Sep 3 18:16:00 GMT 2004
Depending on the ABI, the stack pointer shall be 16-bytes (Sys V PPC ABI) or
8-bytes (PPC EABI) aligned.
libgloss/rs6000/crt0.S however has the following code fragment
/* set up initial stack frame */
addi sp,sp,-4 /* make sure we don't overwrite debug mem */
whenever a __stack symbol is defined, e.g. in a linker script, and it is
aligned properly, the -4 in above code will break the stack pointer
alignment.
Although nothing seems to break on the platforms I've used, accesses to
64-bit doubles allocated on the stack may cross cache lines, page
boundaries and cause unaligned bus accesses, i.e. this can be inefficient.
Is it the responsibility for the linker script to define a __stack symbol in
a way that corrects for the above -4 or is this a shortcoming of crt0.S ?
--
Rob Windgassen
--
When you are looking for a tough bug, you're likely to find a bunch other
ones.
More information about the Newlib
mailing list