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 alias ld.so. Control arrives here either directly
30 ! from exec
() upon invocation of
a dynamically linked program specifying our
31 ! alias as its interpreter.
33 ! On entry
, the stack appears as
:
35 !_______________________
! high addresses
40 !_______________________
!
42 !_______________________
!
47 !_______________________
!
49 !_______________________
!
54 !_______________________
!
56 !_______________________
!
57 ! Argument
! low addresses
60 !_______________________
!
63 !_______________________
!<- %sp
+64
66 !_______________________
! <- %sp
68 #include <sys/asm_linkage.h>
69 #include <sys/param.h>
70 #include <sys/syscall.h>
72 #include "alias_boot.h"
79 .local f.PANIC, f.OPENAT, f.MMAP, f.FSTATAT, f.SYSCONFIG
80 .local f.CLOSE, f.EXIT, f.MUNMAP
81 .type __rtboot, #function
84 ! Create
a stack frame
, perform PIC set up. If we
're a "normal" start, we have
85 ! to determine a bunch of things from our "environment" and construct an ELF
86 ! boot attribute value vector. Otherwise, it's already been done
and we can
90 save
%sp
, -SA
(MINFRAME
+ (EB_MAX
* 8) + ((S_MAX
+ F_MAX
) * 4)), %sp
92 call
2f
! get PIC for PIC work
94 ! Set up pointers to __rtld parameters. eb
[], strings
[] and funcs
[] are on
95 ! the stack. Note that we will call ld.so with an entry vector that causes
96 ! it to use the stack frame we have.
98 add %sp
, MINFRAME
, %o0
! &eb
[0]
100 add %o0
, (EB_MAX
* 8), %o1
! &strings
[0] == &eb
[EB_MAX
]
101 add %o1
, (S_MAX
* 4), %o2
! &funcs
[0] == &strings
[S_MAX
]
102 set EB_ARGV
, %l0
! code for this entry
103 st %l0
, [%o0
] ! store it
104 add %fp
, 68, %l0
! argument vector is at
%fp+
68
105 st %l0
, [%o0
+ 4] ! store that
106 ld [%fp
+ 64], %l1
! get argument count
107 inc
%l1
! account for last element of
0
108 sll
%l1
, 2, %l1
! multiply by
4
109 add %l0
, %l1
, %l0
! and get address of first env ptr
110 st %l0
, [%o0
+ 12] ! store it in the vector
111 set EB_ENVP
, %l1
! code for environment base
112 st %l1
, [%o0
+ 8] ! store it
113 set EB_AUXV
, %l1
! get code for auxiliary vector
114 st %l1
, [%o0
+ 16] ! store it
116 ld [%l0
], %l1
! get an entry
117 tst
%l1
! are we at
a "0" entry in environment?
118 bne 2b ! no
, go back
and look again
119 add %l0
, 4, %l0
! incrementing pointer in delay
120 st %l0
, [%o0
+ 20] ! store aux vector pointer
121 set EB_NULL
, %l0
! set up for the last pointer
122 st %l0
, [%o0
+ 24] ! and store it
124 ! Initialize strings
and functions as appropriate
127 set
(s.
/**/n
- 1b), %l0; \
129 st %l0
, [%o1
+ (n
/**/_S
* 4)]
131 set
(f.
/**/n
- 1b), %l0; \
133 st %l0
, [%o2
+ (n
/**/_F
* 4)]
146 ! Call the startup function to get the real loader in here.
148 call __rtld
! call it
149 mov
%o0
, %l0
! and save
&eb
[0] for later
151 ! On return
, jump to the function in
%o0
, passing
&eb
[0] in
%o0
153 jmpl
%o0
, %g0
! call main program
154 mov
%l0
, %i0
! set up parameter
159 save
%sp
, -SA
(MINFRAME
), %sp
! make
a frame
160 mov
%i0
, %o1
! set up pointer
161 clr
%o2
! set up character counter
162 1: ! loop over all characters
163 ldub
[%i0
+ %o2
], %o0
! get byte
164 tst
%o0
! end of string?
166 inc
%o2
! increment count
167 call f.WRITE
! write
(2, buf
, %o2
)
171 mov l.ERROR
, %o2
! same with constant message
173 set
(s.ERROR
- 2b), %o1
! get PC-relative address
174 add %o7
, %o1
, %o1
! and now make it absolute
175 call f.WRITE
! write it out
176 mov
2, %o0
! to standard error
185 sethi
%hi
(0x80000000), %g1
! MAP_NEW
216 mov SYS_sysconfig
, %g1
222 t 0x8 ! call the system call
223 bcs __err_exit
! test for error
234 s.LDSO
: .asciz "/usr/lib/ld.so.1"
235 s.ZERO
: .asciz "/dev/zero"
236 s.EMPTY
:.asciz "(null)"
237 s.ERROR
:.asciz ": no (or bad) /usr/lib/ld.so.1\n"
240 .size __rtboot, . - __rtboot
242 ! During construction
-- the assembly output of _rtld.c2s is placed here.