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


  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  *      Copyright (c) 1988 AT&T
  24  *        All Rights Reserved
  25  *
  26  *
  27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  */
  30 #pragma ident   "%Z%%M% %I%     %E% SMI"
  31 
  32 /*
  33  * Bootstrap routine for run-time linker.
  34  * We get control from exec which has loaded our text and
  35  * data into the process' address space and created the process
  36  * stack.
  37  *
  38  * On entry, the process stack looks like this:
  39  *
  40  *      #                       # <- %esp
  41  *      #_______________________#  high addresses
  42  *      #       strings         #
  43  *      #_______________________#
  44  *      #       0 word          #
  45  *      #_______________________#
  46  *      #       Auxiliary       #
  47  *      #       entries         #
  48  *      #       ...             #
  49  *      #       (size varies)   #
  50  *      #_______________________#


  78 extern  void            atexit_fini();
  79 void
  80 main()
  81 {
  82         (void) _setup();
  83         atexit_fini();
  84 }
  85 
  86 #else
  87 
  88 #include        <link.h>
  89 
  90         .file   "boot.s"
  91         .text
  92         .globl  _rt_boot
  93         .globl  _setup
  94         .globl  _GLOBAL_OFFSET_TABLE_
  95         .type   _rt_boot,@function
  96         .align  4
  97 




  98 _rt_alias:
  99         jmp     .get_ip                 / in case we were invoked from libc.so
 100 _rt_boot:
 101         movl    %esp,%ebp               / save for referencing args
 102         subl    $EB_MAX_SIZE32,%esp     / make room for a max sized boot vector


 103         movl    %esp,%esi               / use esi as a pointer to &eb[0]
 104         movl    $EB_ARGV,0(%esi)        / set up tag for argv
 105         leal    4(%ebp),%eax            / get address of argv
 106         movl    %eax,4(%esi)            / put after tag
 107         movl    $EB_ENVP,8(%esi)        / set up tag for envp
 108         movl    (%ebp),%eax             / get # of args
 109         addl    $2,%eax                 / one for the zero & one for argc
 110         leal    (%ebp,%eax,4),%edi      / now points past args & @ envp
 111         movl    %edi,12(%esi)           / set envp
 112 .L0:    addl    $4,%edi                 / next
 113         cmpl    $0,-4(%edi)             / search for 0 at end of env
 114         jne     .L0
 115         movl    $EB_AUXV,16(%esi)       / set up tag for auxv
 116         movl    %edi,20(%esi)           / point to auxv
 117         movl    $EB_NULL,24(%esi)       / set up NULL tag
 118 .get_ip:
 119         call    .L1                     / only way to get IP into a register
 120 .L1:
 121         popl    %ebx                    / pop the IP we just "pushed"
 122         addl    $_GLOBAL_OFFSET_TABLE_+[.-.L1],%ebx


  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  *      Copyright (c) 1988 AT&T
  24  *        All Rights Reserved
  25  *
  26  *
  27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  */

  30 
  31 /*
  32  * Bootstrap routine for run-time linker.
  33  * We get control from exec which has loaded our text and
  34  * data into the process' address space and created the process
  35  * stack.
  36  *
  37  * On entry, the process stack looks like this:
  38  *
  39  *      #                       # <- %esp
  40  *      #_______________________#  high addresses
  41  *      #       strings         #
  42  *      #_______________________#
  43  *      #       0 word          #
  44  *      #_______________________#
  45  *      #       Auxiliary       #
  46  *      #       entries         #
  47  *      #       ...             #
  48  *      #       (size varies)   #
  49  *      #_______________________#


  77 extern  void            atexit_fini();
  78 void
  79 main()
  80 {
  81         (void) _setup();
  82         atexit_fini();
  83 }
  84 
  85 #else
  86 
  87 #include        <link.h>
  88 
  89         .file   "boot.s"
  90         .text
  91         .globl  _rt_boot
  92         .globl  _setup
  93         .globl  _GLOBAL_OFFSET_TABLE_
  94         .type   _rt_boot,@function
  95         .align  4
  96 
  97         / init is called from the _init symbol in the CRT, however .init_array
  98         / are called "naturally" from call_init.  Because of that, we need the
  99         / stack aligned here so that initializers called via _array sections may
 100         / safely use SIMD instructions.
 101 _rt_alias:
 102         jmp     .get_ip                 / in case we were invoked from libc.so
 103 _rt_boot:
 104         movl    %esp,%ebp               / save for referencing args
 105         subl    $EB_MAX_SIZE32,%esp     / make room for a max sized boot vector
 106         andl    $-16,%esp
 107         subl    $8,%esp
 108         movl    %esp,%esi               / use esi as a pointer to &eb[0]
 109         movl    $EB_ARGV,0(%esi)        / set up tag for argv
 110         leal    4(%ebp),%eax            / get address of argv
 111         movl    %eax,4(%esi)            / put after tag
 112         movl    $EB_ENVP,8(%esi)        / set up tag for envp
 113         movl    (%ebp),%eax             / get # of args
 114         addl    $2,%eax                 / one for the zero & one for argc
 115         leal    (%ebp,%eax,4),%edi      / now points past args & @ envp
 116         movl    %edi,12(%esi)           / set envp
 117 .L0:    addl    $4,%edi                 / next
 118         cmpl    $0,-4(%edi)             / search for 0 at end of env
 119         jne     .L0
 120         movl    $EB_AUXV,16(%esi)       / set up tag for auxv
 121         movl    %edi,20(%esi)           / point to auxv
 122         movl    $EB_NULL,24(%esi)       / set up NULL tag
 123 .get_ip:
 124         call    .L1                     / only way to get IP into a register
 125 .L1:
 126         popl    %ebx                    / pop the IP we just "pushed"
 127         addl    $_GLOBAL_OFFSET_TABLE_+[.-.L1],%ebx