3 ! The contents of this file are subject to the terms of the
4 ! Common Development
and Distribution License
(the
"License").
5 ! You may
not use this file except in compliance with the License.
7 ! You can obtain
a copy of the license at usr
/src
/OPENSOLARIS.LICENSE
8 ! or http
://www.opensolaris.org
/os
/licensing.
9 ! See the License for the specific language governing permissions
10 ! and limitations under the License.
12 ! When distributing Covered Code
, include this CDDL HEADER in each
13 ! file
and include the License file at usr
/src
/OPENSOLARIS.LICENSE.
14 ! If applicable
, add the following below this CDDL HEADER
, with the
15 ! fields enclosed by brackets
"[]" replaced with your own identifying
16 ! information
: Portions Copyright
[yyyy
] [name of copyright owner
]
20 ! Copyright
2010 Sun Microsystems
, Inc. All rights reserved.
21 ! Use is subject to license terms.
23 ! SPARC support routines for
4.x compatibility dynamic linker.
25 #include <sys/asm_linkage.h> ! N.B.: although this is the 4.x
26 #include <sys/syscall.h> ! compatibility stuff, it actually
27 ! runs only on the SVR4 base
, and
28 ! is compiled in an SVR4
.h environment
30 #define AT_FDCWD 0xffd19553
32 ! ld.so bootstrap. Called from crt0 of
a dynamically linked program with
:
33 ! %i0
: version number
(always
1)
34 ! %i1
: address of crt0 structure
, which contains
:
35 ! +0 base address of where we are mapped
36 ! +4 open file descriptor for
/dev
/zero
37 ! +8 open file descriptor for ld.so
38 ! +c
a.out _DYNAMIC address
39 ! +10 environment strings
40 ! +14 break address for adb
/dbx
43 save
%sp
,-SA
(MINFRAME
),%sp
! build frame
45 call
1f
! get absolute address of _GOT_
48 sethi
%hi
(__GLOBAL_OFFSET_TABLE_
- (L1
- 1b)), %l7
50 or %l7
, %lo
(__GLOBAL_OFFSET_TABLE_
- (L1
- L2
)), %l7
52 mov
%i0
, %o0
! pass version through
53 add %fp
, %i1
, %l0
! get interface pointer
54 mov
%l0
, %o1
! ptr to interface structure
55 ld [%l0
], %l2
! address where ld.so is mapped in
56 ld [%l7
], %l1
! ptr to ld.so first entry in globtable
57 add %l2
, %l1
, %o2
! relocate ld.so _DYNAMIC
58 add %fp
, 0xd8, %o3
! point to arg count
(is it safe?
)
59 ld [%l7
+ _rtld
], %g1
! manually fix pic reference to rtld
60 add %g1
, %l2
, %g1
! by adding offset to GOT entry
61 jmpl
%g1
, %o7
! go there
71 ! Update
a relocation offset
, the value replaces any original
72 ! value in the relocation offset.
75 .global _aout_reloc_write
78 st %o1
, [%o0
] ! Store value in the offset
80 iflush
%o0
! Flush instruction memory
83 ! Special system call stubs to save system call overhead
85 .global _open, _mmap, _munmap, _read, _write, _lseek, _close
86 .global _fstat, _sysconfig, __exit
87 _open
: ! open
(path
, oflags
, mode
) =>
88 mov
%o2
, %o3
! openat
(AT_FDCWD
, path
, oflag
, mode
)
91 sethi
%hi
(AT_FDCWD
), %o0
92 or %o0
, %lo
(AT_FDCWD
), %o0
97 sethi
%hi
(0x80000000), %g1
! MAP_NEW
122 _fstat
: ! fstat
(fd, statb
) =>
123 mov
%g0
, %o3
! fstatat
(fd, NULL
, statb
, 0)
131 mov SYS_sysconfig
, %g1
137 t 0x8 ! call the system call
138 bcs __err_exit
! test for error