Home | History | Annotate | Line # | Download | only in mips
rtld_start.S revision 1.2
      1 /*	$NetBSD: rtld_start.S,v 1.2 1998/04/09 04:45:08 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 	move	s1,a3			# save ps_strings pointer
     44 	jal	_C_LABEL(_rtld)		# v0 = _rtld(sp)
     45 	nop				# [BD if jal not expanded]
     46 	lw	a1, 4(sp)		# our atexit function
     47 	lw	a2, 8(sp)		# obj_main entry
     48 	addu	sp, sp,12		# readjust stack
     49 	move	a0,s0			# stack pointer
     50 	move	t9,v0
     51 	jr	t9			# _start(sp, cleanup, obj);
     52 	move	a3,s1			# restore ps_strings
     53 
     54 END(rtld_start)
     55 
     56 	.globl	_rtld_bind_start
     57 	.ent	_rtld_bind_start
     58 _rtld_bind_start:
     59 
     60 	move	v1,gp			# save old GP
     61 	add	t9,8			# modify T9 to point at .cpload
     62 	.cpload	t9
     63 	subu	sp,40			# save arguments and sp value in stack
     64 	.cprestore 32
     65 	sw	t7,36(sp)
     66 	sw	a0,12(sp)
     67 	sw	a1,16(sp)
     68 	sw	a2,20(sp)
     69 	sw	a3,24(sp)
     70 	sw	s0,28(sp)
     71 	move	s0,sp
     72 	move	a0,t8			# symbol index
     73 	move	a1,t7			# old RA
     74 	move	a2,v1			# old GP
     75 	move	a3,ra			# current RA
     76 	jal	_C_LABEL(_rtld_bind_mips)
     77 	nop
     78 	move	sp,s0
     79 	lw	ra,36(sp)
     80 	lw	a0,12(sp)
     81 	lw	a1,16(sp)
     82 	lw	a2,20(sp)
     83 	lw	a3,24(sp)
     84 	lw	s0,28(sp)
     85 	addu	sp,40
     86 	move	t9,v0
     87 	jr	t9
     88 	nop
     89 	.end	_rtld_bind_start
     90