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