According to the man page, -mpreferred-stack-boundary allows one to specify what the stack is aligned at. "Attempt to keep the stack boundary aligned to a 2 raised to num byte boundary. If -mpreferred-stack-boundary is not specified, the default is 4 (16 bytes or 128 bits)." Example: # gcc -mpreferred-stack-boundary=7 -mstackrealign testme.c -o ttt3.s -S In ttt3.s you will see: main: leal 4(%esp), %ecx andl $-16, %esp pushl -4(%ecx) Expected: main: leal 4(%esp), %ecx andl $-128, %esp pushl -4(%ecx) No matter which value is passed to -mpreferred-stack-boundary (if it's larger than 4), it will always align the stack to 16 bytes. Fix (diff according to svn): diff -urN gcc/gcc/config/i386/i386.c stack-boundary-fix/gcc/config/i386/i386.c --- gcc/gcc/config/i386/i386.c 2007-09-19 00:37:00.000000000 +0200 +++ stack-boundary-fix/gcc/config/i386/i386.c 2007-09-19 01:06:57.000000000 +0200 @@ -6242,7 +6242,7 @@ /* Align the stack. */ emit_insn (gen_andsi3 (stack_pointer_rtx, stack_pointer_rtx, - GEN_INT (-16))); + GEN_INT (-(cfun->preferred_stack_boundary/BITS_PER_UNIT)))); /* And here we cheat like madmen with the unwind info. We force the cfa register back to sp+4, which is exactly what it was at the
Created attachment 14222 [details] Patch against latest version in svn