[fpc-devel] Stack alignment on i386

Jonas Maebe jonas.maebe at elis.ugent.be
Sun Dec 18 14:05:00 CET 2011


On 18 Dec 2011, at 13:37, Den Jean wrote:

> However current fpc 2.4.4 does not align the stack as such.
> I do not know if this correct or not when reading things like:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838#c8
> http://groups.google.com/group/ia32-abi/browse_thread/thread/4f9b3e5069943bf1
> 
> I tried to change alignment with {$CODEALIGN 16} but this didn't work.

That's because it changes the alignment of procedures (code), rather than that of the stack. You cannot change this setting via a switch, it's hardcoded in the compiler as part of the ABI.

Changing this will also require quite a few changes in the RTL as well to be safe (e.g., in case cmem is used and if the glibc memory manager one day would use sse), because the RTL contains lots of assembler code that doesn't care at all about stack alignment. The places where there's an {$ifndef darwin} in i386-specific files can probably help, since Darwin/i386 also requires a 16-byte aligned stack. The assembler startup code for Linux/i386 probably also needs to be adapted.

Overall, it's not a trivial change to make properly.


Jonas


More information about the fpc-devel mailing list