Print this page
6507 i386 makecontext(3c) needs to 16-byte align the stack

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/common/i386/crt1.s
          +++ new/usr/src/lib/common/i386/crt1.s
↓ open down ↓ 153 lines elided ↑ open up ↑
 154  154   * the argv array to the start of the argv array.
 155  155   */
 156  156  
 157  157          movl    8(%ebp),%eax            /* argc */
 158  158          movl    _environ, %edx          /* fixed bug 4302802 */
 159  159          testl   %edx, %edx              /* check if _enviorn==0 */
 160  160          jne     1f                      /* fixed bug 4203802 */
 161  161          leal    16(%ebp,%eax,4),%edx    /* envp */
 162  162          movl    %edx,_environ           /* copy to _environ */
 163  163  1:
      164 +        /*
      165 +         * The stack needs to be 16-byte aligned with a 4-byte bias.  See
      166 +         * comment in lib/libc/i386/gen/makectxt.c.
      167 +         *
      168 +         * Note: If you change it, you need to change it in the following
      169 +         * files as well:
      170 +         *
      171 +         *  - lib/libc/i386/threads/machdep.c
      172 +         *  - lib/libc/i386/gen/makectxt.c
      173 +         *  - lib/common/i386/crti.s
      174 +         */
 164  175          andl    $-16,%esp       /* make main() and exit() be called with */
 165      -        subl    $4,%esp         /* a 16-byte aligned stack pointer */
      176 +        subl    $4,%esp         /* a properly aligned stack pointer */
 166  177          pushl   %edx
 167  178          leal    12(%ebp),%edx   /* argv */
 168  179          movl    %edx,___Argv
 169  180          pushl   %edx
 170  181          pushl   %eax            /* argc */
 171  182          call    __fpstart
 172  183          call    __fsr           /* support for ftrap/fround/fprecision  */
 173  184          call    _init
 174  185          call    main            /* main(argc,argv,envp) */
 175  186          movl    %eax,(%esp)     /* return value from main, for exit() */
↓ open down ↓ 30 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX