1 /* $NetBSD: rtld_start.S,v 1.7 2008/04/28 20:23:03 martin Exp $ */
4 * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <machine/asm.h>
37 .type .rtld_start,@function
43 mov.l @(4,r0),r4 /* _DYNAMIC@GOTOFF */
44 add r2,r4 /* _DYNAMIC */
45 mov.l @(12,r0),r1 /* _rtld_relocate_nonplt_self offset */
46 mov.l @(8,r0),r0 /* _DYNAMIC@GOT */
48 mov.l @(r0,r2),r0 /* where linker thinks _DYNAMIC is */
49 sub r0,r5 /* compute relocation base */
50 bsrf r1 /* _rtld_relocate_nonplt_self(dynp, relocbase) */
51 mov.l r5,@-r15 /* save relocbase */
54 mov.l @r15+,r5 /* restore relocbase */
55 add #-8,r15 /* room for values returned by _rtld */
58 bsrf r0 /* _rtld(sp, relocbase) */
59 mov.l r9,@-r15 /* save ps_strings */
61 mov.l @r15+,r9 /* restore ps_strings */
63 mov.l @r15+,r7 /* from _rtld: exit procedure */
64 mov.l @r15+,r8 /* from _rtld: main object */
66 mov.l @r15,r4 /* restore argc */
68 mov r15,r5 /* restore argv */
71 mov r4,r6 /* restore envp */
74 jmp @r0 /* entry point returned by _rtld */
78 2: .long _GLOBAL_OFFSET_TABLE_
81 .long _rtld_relocate_nonplt_self-4b
82 .size .rtld_start,.-.rtld_start
85 .globl _rtld_bind_start
86 .type _rtld_bind_start,@function
87 _rtld_bind_start: /* r0 = obj, r1 = reloff */
88 mov.l r2,@-r15 /* save registers */
98 mov r0,r4 /* copy of obj */
100 bsrf r0 /* call the binder */
101 mov r1,r5 /* copy of reloff */
103 lds.l @r15+,pr /* restore registers */
114 2: .long _rtld_bind-4b
115 .size _rtld_bind_start,.-_rtld_bind_start