Diff below makes sure we properly align the stack for executing SSE
instructions on i386 like we already do on amd64.  Our GCC already
generates code in main() to do this, but other compilers (including
certain versions of GCC as pointed out to me by Jeorg Sonnenberger)
might not.

ok?

Index: crt0.c
===================================================================
RCS file: /cvs/src/lib/csu/i386/crt0.c,v
retrieving revision 1.13
diff -u -p -r1.13 crt0.c
--- crt0.c      4 Aug 2005 16:33:05 -0000       1.13
+++ crt0.c      26 Jul 2011 09:53:29 -0000
@@ -56,15 +56,20 @@ __asm(".text\n"
 "      .globl  _start\n"
 "_start:\n"
 "__start:\n"
-"      pushl   %ebx                    #ps_strings\n"
+"      movl    %esp,%ebp\n"
+"      subl    $12,%esp                # align stack\n"
+"      andl    $~15,%esp\n"
+"      addl    $12,%esp\n"
+"      pushl   %ebx                    # ps_strings\n"
 "      pushl   %ecx                    # obj\n"
 "      pushl   %edx                    # cleanup\n"
-"      movl    12(%esp),%eax\n"
-"      leal    20(%esp,%eax,4),%ecx\n"
-"      leal    16(%esp),%edx\n"
+"      movl    0(%ebp),%eax\n"
+"      leal    8(%ebp,%eax,4),%ecx\n"
+"      leal    4(%ebp),%edx\n"
 "      pushl   %ecx\n"
 "      pushl   %edx\n"
 "      pushl   %eax\n"
+"      xorl    %ebp,%ebp               # mark deepest stack frame\n"
 "      call    ___start ");
 
 void

Reply via email to