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.
30 #pragma ident "%Z%%M% %I% %E% SMI"
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
38 * On entry, the process stack looks like this:
41 * #_______________________# high addresses
43 * #_______________________#
45 * #_______________________#
50 * #_______________________#
52 * #_______________________#
57 * #_______________________#
59 * #_______________________#
60 * # Argument # low addresses
63 * #_______________________#
65 * #_______________________# <- %rbp
68 * We must calculate the address at which ld.so was loaded,
69 * find the addr of the dynamic section of ld.so, of argv[0], and of
70 * the process' environment pointers - and pass the thing to _setup
71 * to handle. We then call _rtld - on return we jump to the entry
72 * point for the a.out.
82 .globl _GLOBAL_OFFSET_TABLE_
83 .type _rt_boot,@function
87 / in case we were invoked from libc.so
90 / save for referencing args
92 / make room for
a max sized boot vector
93 subq $EB_MAX_SIZE64
,%rsp
94 / use esi as
a pointer to
&eb
[0]
102 / set up tag for envp
103 movq $EB_ENVP
,16(%rsi
)
106 / one for the zero
& one for argc
108 / now points past args
& @ envp
109 leaq
(%rbp
,%rax
,8),%rdi
114 / search for
0 at end of env
117 / set up tag for auxv
118 movq $EB_AUXV
,32(%rsi
)
122 movq $EB_NULL
,48(%rsi
)
124 / arg1
- address of
&eb
[0]
127 leaq _GLOBAL_OFFSET_TABLE_
(%rip
), %rbx
128 / addq $_GLOBAL_OFFSET_TABLE_
, %rbx
130 // addq $
[.L2-.L1], %rbx
135 / _setup
(&eb
[0], _DYNAMIC
)
137 / release stack frame
140 movq atexit_fini@GOTPCREL
(%rip
), %rdx
141 / transfer control to
a.out
143 .size _rt_boot,.-_rt_boot