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 $
34 * SPARC run-time link editor entry points.
37 #define CRT_VERSION_SUN 1
39 .seg "text" ! [internal]
47 sethi %hi((__GLOBAL_OFFSET_TABLE_-(L.1B-.))),%l7
50 or %l7,%lo((__GLOBAL_OFFSET_TABLE_-(L.1B-.))),%l7
53 cmp %i0, CRT_VERSION_SUN ! is crtp passed in Sun style,
54 bne 1f ! ie. relative to stack frame ?
56 add %i1, %fp, %i1 ! if so, adjust to absolute address
58 ld [%i1], %o3 ! load base address (crtp->crt_ba)
59 ld [%l7], %o2 ! get __DYNAMIC address
61 add %o2, %o3, %o2 ! relocate and make it 3rd arg.
63 ld [%l7 + _rtld], %g1 ! get address of rtld()
64 add %g1, %o3, %g1 ! relocate
66 mov %i1, %o1 ! set up args, #2: crtp
67 call %g1 ! rtld(version, crtp, dp)
68 mov %i0, %o0 ! arg #1: version
72 .seg "data" ! [internal]
81 ! sethi %hi((__GLOBAL_OFFSET_TABLE_-(L.1C-.))),%l7
83 ! or %l7,%lo((__GLOBAL_OFFSET_TABLE_-(L.1C-.))),%l7
86 sub %i7, 4, %o0 ! get to jmpslot through pc
87 ld [%i7+4], %o1 ! get relocation index
88 sethi %hi(0x3fffff), %o2 ! -> reloc_index & 0x003fffff
89 or %o2, %lo(0x3fffff), %o2 ! [internal]
90 call _binder ! and call binder(jsp, reloc_index)
93 mov %o0, %g1 ! return value == function address
95 restore ! get rid of our context
97 restore ! and the jmpslot context
100 .seg "data" ! [internal]