Am 18.12.2011 14:05, schrieb Jonas Maebe:

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.

Hmm... I have thought a bit. Do you (or someone else) think it's feasible (and useful) to add a "procedure modifier" that allows you to specify the stack alignment that should be used when calling that procedure? (of course this modifier should be considered as "from great power comes great responsibilty" ^^)

Regards,
Sven

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to