This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
PPC stack alignment
- From: rob windgassen <rwindgas at xs4all dot nl>
- To: newlib at sources dot redhat dot com
- Date: Wed, 25 Aug 2004 22:53:17 +0200
- Subject: PPC stack alignment
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.