4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
29 / bootstrap routine for run-time linker
30 / we get control from exec which has loaded our text
and
31 / data into the process
' address space and created the process
34 / on entry, the process stack looks like this:
37 /_______________________# high addresses
39 /_______________________#
41 /_______________________#
46 /_______________________#
48 /_______________________#
53 /_______________________#
55 /_______________________#
56 / Argument # low addresses
59 /_______________________#
61 /_______________________# <- %ebp
79 .type __rtboot,@function
83 subl $EB_MAX_SIZE32,%esp / make room for a max sized boot vector
84 movl %esp,%esi / use esi as a pointer to &eb[0]
85 movl $EB_ARGV,0(%esi) / set up tag for argv
86 leal 4(%ebp),%eax / get address of argv
87 movl %eax,4(%esi) / put after tag
88 movl $EB_ENVP,8(%esi) / set up tag for envp
89 movl (%ebp),%eax / get # of args
90 addl $2,%eax / one for the zero & one for argc
91 leal (%ebp,%eax,4),%edi / now points past args & @ envp
92 movl %edi,12(%esi) / set envp
93 addl $-4,%edi / start loop at &env[-1]
94 .L00: addl $4,%edi / next
95 cmpl $0,(%edi) / search for 0 at end of env
97 addl $4,%edi / advance past 0
98 movl $EB_AUXV,16(%esi) / set up tag for auxv
99 movl %edi,20(%esi) / point to auxv
100 movl $EB_NULL,24(%esi) / set up NULL tag
101 call .L01 / only way to get IP into a register
102 .L01: popl %ebx / pop the IP we just "pushed"
103 leal s.EMPTY - .L01(%ebx),%eax
105 leal s.ZERO - .L01(%ebx),%eax
107 leal s.LDSO - .L01(%ebx),%eax
109 movl %esp,%edi / save pointer to strings
110 leal f.MUNMAP - .L01(%ebx),%eax
112 leal f.CLOSE - .L01(%ebx),%eax
114 leal f.SYSCONFIG - .L01(%ebx),%eax
116 leal f.FSTATAT - .L01(%ebx),%eax
118 leal f.MMAP - .L01(%ebx),%eax
120 leal f.OPENAT - .L01(%ebx),%eax
122 leal f.PANIC - .L01(%ebx),%eax
124 movl %esp,%ecx / save pointer to functions
126 pushl %ecx / address of functions
127 pushl %edi / address of strings
129 call __rtld / __rtld(&eb[0], strings, funcs)
130 movl %esi,%esp / restore the stack (but leaving boot vector)
131 jmp *%eax / transfer control to ld.so.1
132 .size __rtboot,.-__rtboot
135 s.LDSO: .string "/usr/lib/ld.so.1"
136 s.ZERO: .string "/dev/zero"
137 s.EMPTY: .string "(null)"
138 s.ERROR: .string ": no (or bad) /usr/lib/ld.so.1\n"
144 / Add using of argument string
145 pushl $l.ERROR - s.ERROR
148 leal s.ERROR - .L02(%ebx),%eax
156 movl $SYS_openat,%eax
162 movl $SYS_munmap,%eax
177 movl $SYS_fstatat,%eax
180 movl $SYS_sysconfig,%eax