4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
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]
23 * Copyright (c) 1988 AT&T
27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
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
37 * On entry, the process stack looks like this:
40 * #_______________________# high addresses
42 * #_______________________#
44 * #_______________________#
49 * #_______________________#
51 * #_______________________#
56 * #_______________________#
58 * #_______________________#
59 * # Argument # low addresses
62 * #_______________________#
64 * #_______________________# <- %ebp
67 * We must calculate the address at which ld.so was loaded,
68 * find the addr of the dynamic section of ld.so, of argv[0], and of
69 * the process' environment pointers - and pass the thing to _setup
70 * to handle. We then call _rtld - on return we jump to the entry
71 * point for the a.out.
81 .globl _GLOBAL_OFFSET_TABLE_
82 .type _rt_boot,@function
85 / init is called from the _init symbol in the CRT
, however
.init_array
86 / are called
"naturally" from call_init. Because of that
, we need the
87 / stack aligned here so that initializers called via _array sections may
88 / safely use SIMD instructions.
90 jmp
.get_ip / in case we were invoked from libc.so
92 movl
%esp
,%ebp
/ save for referencing args
93 subl $EB_MAX_SIZE32
,%esp
/ make room for
a max sized boot vector
96 movl
%esp
,%esi
/ use esi as
a pointer to
&eb
[0]
97 movl $EB_ARGV
,0(%esi
) / set up tag for argv
98 leal
4(%ebp
),%eax
/ get address of argv
99 movl
%eax
,4(%esi
) / put after tag
100 movl $EB_ENVP
,8(%esi
) / set up tag for envp
101 movl
(%ebp
),%eax
/ get
# of args
102 addl $
2,%eax
/ one for the zero
& one for argc
103 leal
(%ebp
,%eax
,4),%edi
/ now points past args
& @ envp
104 movl
%edi
,12(%esi
) / set envp
105 .L0: addl $4,%edi / next
106 cmpl $
0,-4(%edi
) / search for
0 at end of env
108 movl $EB_AUXV
,16(%esi
) / set up tag for auxv
109 movl
%edi
,20(%esi
) / point to auxv
110 movl $EB_NULL
,24(%esi
) / set up NULL tag
112 call
.L1 / only way to get IP into a register
114 popl
%ebx
/ pop the IP we just
"pushed"
115 addl $_GLOBAL_OFFSET_TABLE_+
[.-.L1],%ebx
116 pushl
(%ebx
) / address of dynamic structure
117 pushl
%esi
/ push
&eb
[0]
119 call _setup@PLT
/ _setup
(&eb
[0], _DYNAMIC
)
120 movl
%ebp
,%esp
/ release stack frame
122 movl atexit_fini@GOT
(%ebx
), %edx
123 jmp
*%eax
/ transfer control to
a.out
124 .size _rt_boot,.-_rt_boot