1*7c478bd9Sstevel@tonic-gate! #ident "%Z%%M% %I% %E% SMI" 2*7c478bd9Sstevel@tonic-gate! 3*7c478bd9Sstevel@tonic-gate! Copyright 2005 Sun Microsystems, Inc. All rights reserved. 4*7c478bd9Sstevel@tonic-gate! Use is subject to license terms. 5*7c478bd9Sstevel@tonic-gate! 6*7c478bd9Sstevel@tonic-gate! CDDL HEADER START 7*7c478bd9Sstevel@tonic-gate! 8*7c478bd9Sstevel@tonic-gate! The contents of this file are subject to the terms of the 9*7c478bd9Sstevel@tonic-gate! Common Development and Distribution License, Version 1.0 only 10*7c478bd9Sstevel@tonic-gate! (the "License"). You may not use this file except in compliance 11*7c478bd9Sstevel@tonic-gate! with the License. 12*7c478bd9Sstevel@tonic-gate! 13*7c478bd9Sstevel@tonic-gate! You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 14*7c478bd9Sstevel@tonic-gate! or http://www.opensolaris.org/os/licensing. 15*7c478bd9Sstevel@tonic-gate! See the License for the specific language governing permissions 16*7c478bd9Sstevel@tonic-gate! and limitations under the License. 17*7c478bd9Sstevel@tonic-gate! 18*7c478bd9Sstevel@tonic-gate! When distributing Covered Code, include this CDDL HEADER in each 19*7c478bd9Sstevel@tonic-gate! file and include the License file at usr/src/OPENSOLARIS.LICENSE. 20*7c478bd9Sstevel@tonic-gate! If applicable, add the following below this CDDL HEADER, with the 21*7c478bd9Sstevel@tonic-gate! fields enclosed by brackets "[]" replaced with your own identifying 22*7c478bd9Sstevel@tonic-gate! information: Portions Copyright [yyyy] [name of copyright owner] 23*7c478bd9Sstevel@tonic-gate! 24*7c478bd9Sstevel@tonic-gate! CDDL HEADER END 25*7c478bd9Sstevel@tonic-gate! 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate! SPARC support routines for 4.x compatibility dynamic linker. 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h> ! N.B.: although this is the 4.x 30*7c478bd9Sstevel@tonic-gate#include <sys/syscall.h> ! compatibility stuff, it actually 31*7c478bd9Sstevel@tonic-gate ! runs only on the SVR4 base, and 32*7c478bd9Sstevel@tonic-gate ! is compiled in an SVR4 .h environment 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate! ld.so bootstrap. Called from crt0 of a dynamically linked program with: 35*7c478bd9Sstevel@tonic-gate! %i0: version number (always 1) 36*7c478bd9Sstevel@tonic-gate! %i1: address of crt0 structure, which contains: 37*7c478bd9Sstevel@tonic-gate! +0 base address of where we are mapped 38*7c478bd9Sstevel@tonic-gate! +4 open file descriptor for /dev/zero 39*7c478bd9Sstevel@tonic-gate! +8 open file descriptor for ld.so 40*7c478bd9Sstevel@tonic-gate! +c a.out _DYNAMIC address 41*7c478bd9Sstevel@tonic-gate! +10 environment strings 42*7c478bd9Sstevel@tonic-gate! +14 break address for adb/dbx 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gatestart_rtld: 45*7c478bd9Sstevel@tonic-gate save %sp,-SA(MINFRAME),%sp ! build frame 46*7c478bd9Sstevel@tonic-gateL1: 47*7c478bd9Sstevel@tonic-gate call 1f ! get absolute address of _GOT_ 48*7c478bd9Sstevel@tonic-gate nop 49*7c478bd9Sstevel@tonic-gate1: 50*7c478bd9Sstevel@tonic-gate sethi %hi(__GLOBAL_OFFSET_TABLE_ - (L1 - 1b)), %l7 51*7c478bd9Sstevel@tonic-gateL2: 52*7c478bd9Sstevel@tonic-gate or %l7, %lo(__GLOBAL_OFFSET_TABLE_ - (L1 - L2)), %l7 53*7c478bd9Sstevel@tonic-gate add %l7, %o7, %l7 54*7c478bd9Sstevel@tonic-gate mov %i0, %o0 ! pass version through 55*7c478bd9Sstevel@tonic-gate add %fp, %i1, %l0 ! get interface pointer 56*7c478bd9Sstevel@tonic-gate mov %l0, %o1 ! ptr to interface structure 57*7c478bd9Sstevel@tonic-gate ld [%l0], %l2 ! address where ld.so is mapped in 58*7c478bd9Sstevel@tonic-gate ld [%l7], %l1 ! ptr to ld.so first entry in globtable 59*7c478bd9Sstevel@tonic-gate add %l2, %l1, %o2 ! relocate ld.so _DYNAMIC 60*7c478bd9Sstevel@tonic-gate add %fp, 0xd8, %o3 ! point to arg count (is it safe?) 61*7c478bd9Sstevel@tonic-gate ld [%l7 + _rtld], %g1 ! manually fix pic reference to rtld 62*7c478bd9Sstevel@tonic-gate add %g1, %l2, %g1 ! by adding offset to GOT entry 63*7c478bd9Sstevel@tonic-gate jmpl %g1, %o7 ! go there 64*7c478bd9Sstevel@tonic-gate nop ! delay 65*7c478bd9Sstevel@tonic-gate mov 0,%o0 66*7c478bd9Sstevel@tonic-gate mov %o0,%i0 67*7c478bd9Sstevel@tonic-gate ret 68*7c478bd9Sstevel@tonic-gate restore 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate! 72*7c478bd9Sstevel@tonic-gate! aout_reloc_write 73*7c478bd9Sstevel@tonic-gate! Update a relocation offset, the value replaces any original 74*7c478bd9Sstevel@tonic-gate! value in the relocation offset. 75*7c478bd9Sstevel@tonic-gate! 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate .global _aout_reloc_write 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate_aout_reloc_write: 80*7c478bd9Sstevel@tonic-gate st %o1, [%o0] ! Store value in the offset 81*7c478bd9Sstevel@tonic-gate retl 82*7c478bd9Sstevel@tonic-gate iflush %o0 ! Flush instruction memory 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate! Special system call stubs to save system call overhead 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate .global _open, _mmap, _munmap, _read, _write, _lseek, _close 88*7c478bd9Sstevel@tonic-gate .global _fstat, _sysconfig, __exit 89*7c478bd9Sstevel@tonic-gate_open: 90*7c478bd9Sstevel@tonic-gate ba __syscall 91*7c478bd9Sstevel@tonic-gate mov SYS_open, %g1 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate_mmap: 94*7c478bd9Sstevel@tonic-gate sethi %hi(0x80000000), %g1 ! MAP_NEW 95*7c478bd9Sstevel@tonic-gate or %g1, %o3, %o3 96*7c478bd9Sstevel@tonic-gate ba __syscall 97*7c478bd9Sstevel@tonic-gate mov SYS_mmap, %g1 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate_munmap: 100*7c478bd9Sstevel@tonic-gate ba __syscall 101*7c478bd9Sstevel@tonic-gate mov SYS_munmap, %g1 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate_read: 104*7c478bd9Sstevel@tonic-gate ba __syscall 105*7c478bd9Sstevel@tonic-gate mov SYS_read, %g1 106*7c478bd9Sstevel@tonic-gate 107*7c478bd9Sstevel@tonic-gate_write: 108*7c478bd9Sstevel@tonic-gate ba __syscall 109*7c478bd9Sstevel@tonic-gate mov SYS_write, %g1 110*7c478bd9Sstevel@tonic-gate 111*7c478bd9Sstevel@tonic-gate_lseek: 112*7c478bd9Sstevel@tonic-gate ba __syscall 113*7c478bd9Sstevel@tonic-gate mov SYS_lseek, %g1 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate_close: 116*7c478bd9Sstevel@tonic-gate ba __syscall 117*7c478bd9Sstevel@tonic-gate mov SYS_close, %g1 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate_fstat: 120*7c478bd9Sstevel@tonic-gate ba __syscall 121*7c478bd9Sstevel@tonic-gate mov SYS_fstat, %g1 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate_sysconfig: 124*7c478bd9Sstevel@tonic-gate ba __syscall 125*7c478bd9Sstevel@tonic-gate mov SYS_sysconfig, %g1 126*7c478bd9Sstevel@tonic-gate 127*7c478bd9Sstevel@tonic-gate__exit: 128*7c478bd9Sstevel@tonic-gate mov SYS_exit, %g1 129*7c478bd9Sstevel@tonic-gate 130*7c478bd9Sstevel@tonic-gate__syscall: 131*7c478bd9Sstevel@tonic-gate t 0x8 ! call the system call 132*7c478bd9Sstevel@tonic-gate bcs __err_exit ! test for error 133*7c478bd9Sstevel@tonic-gate nop 134*7c478bd9Sstevel@tonic-gate retl ! return 135*7c478bd9Sstevel@tonic-gate nop 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate__err_exit: 138*7c478bd9Sstevel@tonic-gate retl ! return 139*7c478bd9Sstevel@tonic-gate mov -1, %o0 140