diff --git a/chapter05/gcc-pass1.xml b/chapter05/gcc-pass1.xml index 1ac142dde..d5051f0bd 100644 --- a/chapter05/gcc-pass1.xml +++ b/chapter05/gcc-pass1.xml @@ -80,12 +80,37 @@ esac -i.orig gcc/config/i386/t-linux64 - Make -mstackrealign a default for 32bit - objects: + Make -mstackrealign + a default for 32bit objects: sed '/STACK_REALIGN_DEFAULT/s/0/(!TARGET_64BIT \&\& TARGET_SSE)/' \ -i gcc/config/i386/i386.h + + Adding the -mstackrealign flag by default + helps to overcome issues with old binaries which cannot be + recompiled on the actual OS. + + + + Today the x86-32 SysV psABI (used by all Linux programs) + mandates a 16-byte alignment of the stack frame, so the routines + using SSE will save/load SSE vectors onto/from the stack using a + movaps instruction (which only works with + aligned addresses, but faster than its counterpart allowing + unaligned addresses, movups). + + But some really old x86-32 Linux binaries (compiled about + 15 years ago), and all Windows x86-32 binaries which might be + run via Wine or Steam + only aligns the + stack frame to 4-byte. Thus, when it calls a SSE routine in LFS + built without -mstackrealign, the + movdqa instruction fails with a General + Protection Error and the Linux kernel terminates the process + with a SIGSEGV. + + The GCC documentation recommends building GCC in a dedicated build directory: