[Zlib-devel] HEADS UP: Apparent bad compilation under (just released) GCC 4.5.0
John Bowler
jbowler at frontiernet.net
Wed May 12 00:42:01 EDT 2010
From: Török Edwin
>How do you know if the platform guarantees 16-byte alignment or not?
>I tried to follow that discussion on bugzilla, and lost track who is
>right, who is wrong and which ABI applies in this case on Linux.
I think I can summarize:
1) GCC running on Linux derived systems does not *by default* guarantee alignment better than 32 bit (4 byte), even if it is explicitly requested by the data types.
2) On those (GCC/Linux) systems it is absolutely necessary with GCC 4.4 and 4.5 to specify '-mstackrealign' when compiling any code that attempts to exploit better than 32 bit alignment.
This includes code that uses the SSE registers via SSE instructions, even though GCC knows full well that this code requires 128bit/16 byte alignment.
X86 assembler code done using compiler intrinsics must ensure, if the compiler is GCC on a Linux system, that stack objects are 16 byte aligned, either by declaring them as such *and* compiling with -mstackrealign or by explicitly doing the alignment ((ptr + 15) & ~15).
Simpler: on x86 don’t rely on >4 byte alignment with GCC, don't permit GCC to use SSE optimizations and never use -O3.
John Bowler <jbowler at acm.org>
More information about the Zlib-devel
mailing list