Print this page
7324 stack needs to be sufficiently aligned for SSE before init_array are called

@@ -25,11 +25,10 @@
  *
  *
  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
-#pragma ident   "%Z%%M% %I%     %E% SMI"
 
 /*
  * Bootstrap routine for run-time linker.
  * We get control from exec which has loaded our text and
  * data into the process' address space and created the process

@@ -93,15 +92,21 @@
         .globl  _setup
         .globl  _GLOBAL_OFFSET_TABLE_
         .type   _rt_boot,@function
         .align  4
 
+        / init is called from the _init symbol in the CRT, however .init_array
+        / are called "naturally" from call_init.  Because of that, we need the
+        / stack aligned here so that initializers called via _array sections may
+        / safely use SIMD instructions.
 _rt_alias:
         jmp     .get_ip                 / in case we were invoked from libc.so
 _rt_boot:
         movl    %esp,%ebp               / save for referencing args
         subl    $EB_MAX_SIZE32,%esp     / make room for a max sized boot vector
+        andl    $-16,%esp
+        subl    $8,%esp
         movl    %esp,%esi               / use esi as a pointer to &eb[0]
         movl    $EB_ARGV,0(%esi)        / set up tag for argv
         leal    4(%ebp),%eax            / get address of argv
         movl    %eax,4(%esi)            / put after tag
         movl    $EB_ENVP,8(%esi)        / set up tag for envp