rtld_start.S revision 1.1 1 /* $NetBSD: rtld_start.S,v 1.1 1998/03/25 04:12:32 mhitch Exp $ */
2
3 /*
4 * Copyright 1997 Michael L. Hitch <mhitch (at) montana.edu>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #include <machine/regdef.h>
31 #include <mips/asm.h>
32
33 LEAF(rtld_start)
34 .set noreorder
35
36 .cpload t9
37 addu sp, sp, -12 # adjust stack pointer
38 .cprestore 0 # 0(sp) for gp
39 # 4(sp) for atexit
40 # 8(sp) for obj_main
41 move s0,a0 # save stack pointer from a0
42 addu a0, sp, 4 # _rtld argument
43 jal _C_LABEL(_rtld) # v0 = _rtld(sp)
44 move s1,a3 # save ps_strings pointer
45 lw a1, 4(sp) # our atexit function
46 lw a2, 8(sp) # obj_main entry
47 addu sp, sp,12 # readjust stack
48 move a0,s0 # stack pointer
49 move t9,v0
50 jr t9 # _start(sp, cleanup, obj);
51 move a3,s1 # restore ps_strings
52
53 END(rtld_start)
54
55 .globl _rtld_bind_start
56 .ent _rtld_bind_start
57 _rtld_bind_start:
58
59 move v1,gp # save old GP
60 add t9,8 # modify T9 to point at .cpload
61 .cpload t9
62 subu sp,40 # save arguments and sp value in stack
63 .cprestore 32
64 sw t7,36(sp)
65 sw a0,12(sp)
66 sw a1,16(sp)
67 sw a2,20(sp)
68 sw a3,24(sp)
69 sw s0,28(sp)
70 move s0,sp
71 move a0,t8 # symbol index
72 move a1,t7 # old RA
73 move a2,v1 # old GP
74 move a3,ra # current RA
75 jal _C_LABEL(_rtld_bind_mips)
76 nop
77 move sp,s0
78 lw ra,36(sp)
79 lw a0,12(sp)
80 lw a1,16(sp)
81 lw a2,20(sp)
82 lw a3,24(sp)
83 lw s0,28(sp)
84 addu sp,40
85 move t9,v0
86 jr t9
87 nop
88 .end _rtld_bind_start
89