2 * Copyright (c) 1993 Paul Kranenburg
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Paul Kranenburg.
16 * 4. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * $FreeBSD: src/gnu/usr.bin/ld/sparc/mdprologue.S,v 1.7 1999/08/27 23:36:05 peter Exp $
31 * $DragonFly: src/gnu/usr.bin/ld/sparc/Attic/mdprologue.S,v 1.2 2003/06/17 04:25:46 dillon Exp $
35 * SPARC run-time link editor entry points.
38 #define CRT_VERSION_SUN 1
40 .seg "text" ! [internal]
48 sethi %hi((__GLOBAL_OFFSET_TABLE_-(L.1B-.))),%l7
51 or %l7,%lo((__GLOBAL_OFFSET_TABLE_-(L.1B-.))),%l7
54 cmp %i0, CRT_VERSION_SUN ! is crtp passed in Sun style,
55 bne 1f ! ie. relative to stack frame ?
57 add %i1, %fp, %i1 ! if so, adjust to absolute address
59 ld [%i1], %o3 ! load base address (crtp->crt_ba)
60 ld [%l7], %o2 ! get __DYNAMIC address
62 add %o2, %o3, %o2 ! relocate and make it 3rd arg.
64 ld [%l7 + _rtld], %g1 ! get address of rtld()
65 add %g1, %o3, %g1 ! relocate
67 mov %i1, %o1 ! set up args, #2: crtp
68 call %g1 ! rtld(version, crtp, dp)
69 mov %i0, %o0 ! arg #1: version
73 .seg "data" ! [internal]
82 ! sethi %hi((__GLOBAL_OFFSET_TABLE_-(L.1C-.))),%l7
84 ! or %l7,%lo((__GLOBAL_OFFSET_TABLE_-(L.1C-.))),%l7
87 sub %i7, 4, %o0 ! get to jmpslot through pc
88 ld [%i7+4], %o1 ! get relocation index
89 sethi %hi(0x3fffff), %o2 ! -> reloc_index & 0x003fffff
90 or %o2, %lo(0x3fffff), %o2 ! [internal]
91 call _binder ! and call binder(jsp, reloc_index)
94 mov %o0, %g1 ! return value == function address
96 restore ! get rid of our context
98 restore ! and the jmpslot context
101 .seg "data" ! [internal]