head	1.7;
access;
symbols
	netbsd-11-0-RC5:1.7
	netbsd-11-0-RC4:1.7
	netbsd-11-0-RC3:1.7
	netbsd-11-0-RC2:1.7
	netbsd-11-0-RC1:1.7
	perseant-exfatfs-base-20250801:1.7
	netbsd-11:1.7.0.76
	netbsd-11-base:1.7
	netbsd-10-1-RELEASE:1.7
	perseant-exfatfs-base-20240630:1.7
	perseant-exfatfs:1.7.0.74
	perseant-exfatfs-base:1.7
	netbsd-8-3-RELEASE:1.7
	netbsd-9-4-RELEASE:1.7
	netbsd-10-0-RELEASE:1.7
	netbsd-10-0-RC6:1.7
	netbsd-10-0-RC5:1.7
	netbsd-10-0-RC4:1.7
	netbsd-10-0-RC3:1.7
	netbsd-10-0-RC2:1.7
	netbsd-10-0-RC1:1.7
	netbsd-10:1.7.0.72
	netbsd-10-base:1.7
	netbsd-9-3-RELEASE:1.7
	cjep_sun2x-base1:1.7
	cjep_sun2x:1.7.0.70
	cjep_sun2x-base:1.7
	cjep_staticlib_x-base1:1.7
	netbsd-9-2-RELEASE:1.7
	cjep_staticlib_x:1.7.0.68
	cjep_staticlib_x-base:1.7
	netbsd-9-1-RELEASE:1.7
	phil-wifi-20200421:1.7
	phil-wifi-20200411:1.7
	is-mlppp:1.7.0.66
	is-mlppp-base:1.7
	phil-wifi-20200406:1.7
	netbsd-8-2-RELEASE:1.7
	netbsd-9-0-RELEASE:1.7
	netbsd-9-0-RC2:1.7
	netbsd-9-0-RC1:1.7
	phil-wifi-20191119:1.7
	netbsd-9:1.7.0.64
	netbsd-9-base:1.7
	phil-wifi-20190609:1.7
	netbsd-8-1-RELEASE:1.7
	netbsd-8-1-RC1:1.7
	pgoyette-compat-merge-20190127:1.7
	pgoyette-compat-20190127:1.7
	pgoyette-compat-20190118:1.7
	pgoyette-compat-1226:1.7
	pgoyette-compat-1126:1.7
	pgoyette-compat-1020:1.7
	pgoyette-compat-0930:1.7
	pgoyette-compat-0906:1.7
	netbsd-7-2-RELEASE:1.7
	pgoyette-compat-0728:1.7
	netbsd-8-0-RELEASE:1.7
	phil-wifi:1.7.0.62
	phil-wifi-base:1.7
	pgoyette-compat-0625:1.7
	netbsd-8-0-RC2:1.7
	pgoyette-compat-0521:1.7
	pgoyette-compat-0502:1.7
	pgoyette-compat-0422:1.7
	netbsd-8-0-RC1:1.7
	pgoyette-compat-0415:1.7
	pgoyette-compat-0407:1.7
	pgoyette-compat-0330:1.7
	pgoyette-compat-0322:1.7
	pgoyette-compat-0315:1.7
	netbsd-7-1-2-RELEASE:1.7
	pgoyette-compat:1.7.0.60
	pgoyette-compat-base:1.7
	netbsd-7-1-1-RELEASE:1.7
	matt-nb8-mediatek:1.7.0.58
	matt-nb8-mediatek-base:1.7
	perseant-stdc-iso10646:1.7.0.56
	perseant-stdc-iso10646-base:1.7
	netbsd-8:1.7.0.54
	netbsd-8-base:1.7
	prg-localcount2-base3:1.7
	prg-localcount2-base2:1.7
	prg-localcount2-base1:1.7
	prg-localcount2:1.7.0.52
	prg-localcount2-base:1.7
	pgoyette-localcount-20170426:1.7
	bouyer-socketcan-base1:1.7
	pgoyette-localcount-20170320:1.7
	netbsd-7-1:1.7.0.50
	netbsd-7-1-RELEASE:1.7
	netbsd-7-1-RC2:1.7
	netbsd-7-nhusb-base-20170116:1.7
	bouyer-socketcan:1.7.0.48
	bouyer-socketcan-base:1.7
	pgoyette-localcount-20170107:1.7
	netbsd-7-1-RC1:1.7
	pgoyette-localcount-20161104:1.7
	netbsd-7-0-2-RELEASE:1.7
	localcount-20160914:1.7
	netbsd-7-nhusb:1.7.0.46
	netbsd-7-nhusb-base:1.7
	pgoyette-localcount-20160806:1.7
	pgoyette-localcount-20160726:1.7
	pgoyette-localcount:1.7.0.44
	pgoyette-localcount-base:1.7
	netbsd-7-0-1-RELEASE:1.7
	netbsd-7-0:1.7.0.42
	netbsd-7-0-RELEASE:1.7
	netbsd-7-0-RC3:1.7
	netbsd-7-0-RC2:1.7
	netbsd-7-0-RC1:1.7
	netbsd-5-2-3-RELEASE:1.7
	netbsd-5-1-5-RELEASE:1.7
	netbsd-6-0-6-RELEASE:1.7
	netbsd-6-1-5-RELEASE:1.7
	netbsd-7:1.7.0.40
	netbsd-7-base:1.7
	yamt-pagecache-base9:1.7
	yamt-pagecache-tag8:1.7
	netbsd-6-1-4-RELEASE:1.7
	netbsd-6-0-5-RELEASE:1.7
	tls-earlyentropy:1.7.0.38
	tls-earlyentropy-base:1.7
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.7
	riastradh-drm2-base3:1.7
	netbsd-6-1-3-RELEASE:1.7
	netbsd-6-0-4-RELEASE:1.7
	netbsd-5-2-2-RELEASE:1.7
	netbsd-5-1-4-RELEASE:1.7
	netbsd-6-1-2-RELEASE:1.7
	netbsd-6-0-3-RELEASE:1.7
	netbsd-5-2-1-RELEASE:1.7
	netbsd-5-1-3-RELEASE:1.7
	netbsd-6-1-1-RELEASE:1.7
	riastradh-drm2-base2:1.7
	riastradh-drm2-base1:1.7
	riastradh-drm2:1.7.0.32
	riastradh-drm2-base:1.7
	netbsd-6-1:1.7.0.36
	netbsd-6-0-2-RELEASE:1.7
	netbsd-6-1-RELEASE:1.7
	netbsd-6-1-RC4:1.7
	netbsd-6-1-RC3:1.7
	agc-symver:1.7.0.34
	agc-symver-base:1.7
	netbsd-6-1-RC2:1.7
	netbsd-6-1-RC1:1.7
	yamt-pagecache-base8:1.7
	netbsd-5-2:1.7.0.30
	netbsd-6-0-1-RELEASE:1.7
	yamt-pagecache-base7:1.7
	netbsd-5-2-RELEASE:1.7
	netbsd-5-2-RC1:1.7
	matt-nb6-plus-nbase:1.7
	yamt-pagecache-base6:1.7
	netbsd-6-0:1.7.0.28
	netbsd-6-0-RELEASE:1.7
	netbsd-6-0-RC2:1.7
	tls-maxphys:1.7.0.26
	tls-maxphys-base:1.7
	matt-nb6-plus:1.7.0.24
	matt-nb6-plus-base:1.7
	netbsd-6-0-RC1:1.7
	yamt-pagecache-base5:1.7
	yamt-pagecache-base4:1.7
	netbsd-6:1.7.0.22
	netbsd-6-base:1.7
	netbsd-5-1-2-RELEASE:1.7
	netbsd-5-1-1-RELEASE:1.7
	yamt-pagecache-base3:1.7
	yamt-pagecache-base2:1.7
	yamt-pagecache:1.7.0.4
	yamt-pagecache-base:1.7
	cherry-xenmp:1.7.0.20
	cherry-xenmp-base:1.7
	bouyer-quota2-nbase:1.7
	bouyer-quota2:1.7.0.18
	bouyer-quota2-base:1.7
	matt-mips64-premerge-20101231:1.7
	matt-nb5-mips64-premerge-20101231:1.7
	matt-nb5-pq3:1.7.0.16
	matt-nb5-pq3-base:1.7
	netbsd-5-1:1.7.0.14
	netbsd-5-1-RELEASE:1.7
	netbsd-5-1-RC4:1.7
	matt-nb5-mips64-k15:1.7
	netbsd-5-1-RC3:1.7
	netbsd-5-1-RC2:1.7
	netbsd-5-1-RC1:1.7
	netbsd-5-0-2-RELEASE:1.7
	matt-nb5-mips64-premerge-20091211:1.7
	matt-premerge-20091211:1.7
	matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.7
	matt-nb4-mips64-k7-u2a-k9b:1.7
	matt-nb5-mips64-u1-k1-k5:1.7
	matt-nb5-mips64:1.7.0.12
	netbsd-5-0-1-RELEASE:1.7
	jym-xensuspend-nbase:1.7
	netbsd-5-0:1.7.0.10
	netbsd-5-0-RELEASE:1.7
	netbsd-5-0-RC4:1.7
	netbsd-5-0-RC3:1.7
	netbsd-5-0-RC2:1.7
	jym-xensuspend:1.7.0.8
	jym-xensuspend-base:1.7
	netbsd-5-0-RC1:1.7
	netbsd-5:1.7.0.6
	netbsd-5-base:1.7
	matt-mips64-base2:1.7
	matt-mips64:1.6.0.20
	netbsd-4-0-1-RELEASE:1.6
	wrstuden-revivesa-base-3:1.7
	wrstuden-revivesa-base-2:1.7
	wrstuden-fixsa-newbase:1.6
	wrstuden-revivesa-base-1:1.7
	yamt-pf42-base4:1.7
	yamt-pf42-base3:1.7
	hpcarm-cleanup-nbase:1.7
	yamt-pf42-baseX:1.6
	yamt-pf42-base2:1.7
	wrstuden-revivesa:1.7.0.2
	wrstuden-revivesa-base:1.7
	yamt-pf42:1.6.0.18
	yamt-pf42-base:1.6
	keiichi-mipv6:1.6.0.16
	keiichi-mipv6-base:1.6
	matt-armv6-nbase:1.6
	matt-armv6-prevmlocking:1.6
	wrstuden-fixsa-base-1:1.6
	netbsd-4-0:1.6.0.14
	netbsd-4-0-RELEASE:1.6
	cube-autoconf:1.6.0.12
	cube-autoconf-base:1.6
	netbsd-4-0-RC5:1.6
	netbsd-4-0-RC4:1.6
	netbsd-4-0-RC3:1.6
	netbsd-4-0-RC2:1.6
	netbsd-4-0-RC1:1.6
	matt-armv6:1.6.0.10
	matt-armv6-base:1.6
	matt-mips64-base:1.6
	hpcarm-cleanup:1.6.0.8
	hpcarm-cleanup-base:1.6
	netbsd-3-1-1-RELEASE:1.4
	netbsd-3-0-3-RELEASE:1.4
	wrstuden-fixsa:1.6.0.6
	wrstuden-fixsa-base:1.6
	abandoned-netbsd-4-base:1.6
	abandoned-netbsd-4:1.6.0.2
	netbsd-3-1:1.4.0.6
	netbsd-3-1-RELEASE:1.4
	netbsd-3-0-2-RELEASE:1.4
	netbsd-3-1-RC4:1.4
	netbsd-3-1-RC3:1.4
	netbsd-3-1-RC2:1.4
	netbsd-3-1-RC1:1.4
	netbsd-4:1.6.0.4
	netbsd-4-base:1.6
	netbsd-3-0-1-RELEASE:1.4
	netbsd-3-0:1.4.0.4
	netbsd-3-0-RELEASE:1.4
	netbsd-3-0-RC6:1.4
	netbsd-3-0-RC5:1.4
	netbsd-3-0-RC4:1.4
	netbsd-3-0-RC3:1.4
	netbsd-3-0-RC2:1.4
	netbsd-3-0-RC1:1.4
	netbsd-2-0-3-RELEASE:1.3.2.1
	netbsd-2-1:1.3.2.1.0.4
	netbsd-2-1-RELEASE:1.3.2.1
	netbsd-2-1-RC6:1.3.2.1
	netbsd-2-1-RC5:1.3.2.1
	netbsd-2-1-RC4:1.3.2.1
	netbsd-2-1-RC3:1.3.2.1
	netbsd-2-1-RC2:1.3.2.1
	netbsd-2-1-RC1:1.3.2.1
	netbsd-2-0-2-RELEASE:1.3.2.1
	netbsd-3:1.4.0.2
	netbsd-3-base:1.4
	netbsd-2-0-1-RELEASE:1.3.2.1
	netbsd-2:1.3.2.1.0.2
	netbsd-2-base:1.3.2.1
	netbsd-2-0-RELEASE:1.3.2.1
	netbsd-2-0-RC5:1.3.2.1
	netbsd-2-0-RC4:1.3.2.1
	netbsd-2-0-RC3:1.3.2.1
	netbsd-2-0-RC2:1.3.2.1
	netbsd-2-0-RC1:1.3.2.1
	netbsd-2-0:1.3.0.2
	netbsd-2-0-base:1.3
	netbsd-1-6-PATCH002-RELEASE:1.2
	netbsd-1-6-PATCH002:1.2
	netbsd-1-6-PATCH002-RC4:1.2
	netbsd-1-6-PATCH002-RC3:1.2
	netbsd-1-6-PATCH002-RC2:1.2
	netbsd-1-6-PATCH002-RC1:1.2
	netbsd-1-6-PATCH001:1.2
	netbsd-1-6-PATCH001-RELEASE:1.2
	netbsd-1-6-PATCH001-RC3:1.2
	netbsd-1-6-PATCH001-RC2:1.2
	netbsd-1-6-PATCH001-RC1:1.2
	fvdl_fs64_base:1.2
	netbsd-1-6-RELEASE:1.2
	netbsd-1-6-RC3:1.2
	netbsd-1-6-RC2:1.2
	netbsd-1-6-RC1:1.2
	netbsd-1-6:1.2.0.2
	netbsd-1-6-base:1.2;
locks; strict;
comment	@# @;


1.7
date	2008.04.28.20.23.03;	author martin;	state Exp;
branches;
next	1.6;

1.6
date	2006.01.11.22.24.34;	author uwe;	state Exp;
branches
	1.6.18.1;
next	1.5;

1.5
date	2006.01.11.22.05.27;	author uwe;	state Exp;
branches;
next	1.4;

1.4
date	2004.09.14.21.34.01;	author uwe;	state Exp;
branches;
next	1.3;

1.3
date	2003.06.30.00.50.47;	author marcus;	state Exp;
branches
	1.3.2.1;
next	1.2;

1.2
date	2002.02.04.18.18.51;	author thorpej;	state Exp;
branches
	1.2.2.1;
next	1.1;

1.1
date	2002.02.03.23.34.43;	author thorpej;	state Exp;
branches;
next	;

1.6.18.1
date	2008.05.18.12.30.44;	author yamt;	state Exp;
branches;
next	;

1.3.2.1
date	2004.09.16.03.24.42;	author jmc;	state Exp;
branches;
next	;

1.2.2.1
date	2004.05.28.08.31.22;	author tron;	state Exp;
branches;
next	;


desc
@@


1.7
log
@Remove clause 3 and 4 from TNF licenses
@
text
@/*	$NetBSD: rtld_start.S,v 1.6 2006/01/11 22:24:34 uwe Exp $	*/

/*-
 * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Marcus Comstedt.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include <machine/asm.h>

	.text
	.align	2
	.globl	.rtld_start
	.type	.rtld_start,@@function

.rtld_start:
	mova	2f,r0
	mov.l	@@r0,r2
	add	r0,r2		/* GOT */
	mov.l	@@(4,r0),r4	/* _DYNAMIC@@GOTOFF */
	add	r2,r4		/* _DYNAMIC */
	mov.l	@@(12,r0),r1	/* _rtld_relocate_nonplt_self offset */
	mov.l	@@(8,r0),r0	/* _DYNAMIC@@GOT */
	mov	r4,r5
	mov.l	@@(r0,r2),r0	/* where linker thinks _DYNAMIC is */
	sub	r0,r5		/* compute relocation base */
	bsrf	r1		/* _rtld_relocate_nonplt_self(dynp, relocbase) */
	 mov.l	r5,@@-r15	/* save relocbase */

4:
	mov.l	@@r15+,r5	/* restore relocbase */
	add	#-8,r15		/* room for values returned by _rtld */
	mov	r15,r4
	mov.l	1f,r0
	bsrf	r0		/* _rtld(sp, relocbase) */
	 mov.l	r9,@@-r15	/* save ps_strings */
3:
	mov.l	@@r15+,r9	/* restore ps_strings */

	mov.l	@@r15+,r7	/* from _rtld: exit procedure */
	mov.l	@@r15+,r8	/* from _rtld: main object */

	mov.l	@@r15,r4		/* restore argc */

	mov	r15,r5		/* restore argv */
	add	#4,r5

	mov	r4,r6		/* restore envp */
	shll2	r6
	add	r15,r6
	jmp	@@r0		/* entry point returned by _rtld */
	 add	#8,r6
	.align	2
1:	.long	_rtld-3b
2:	.long	_GLOBAL_OFFSET_TABLE_
	.long	_DYNAMIC@@GOTOFF
	.long	_DYNAMIC@@GOT
	.long	_rtld_relocate_nonplt_self-4b
	.size	.rtld_start,.-.rtld_start

	.align	2
	.globl	_rtld_bind_start
	.type	_rtld_bind_start,@@function
_rtld_bind_start:		/* r0 = obj, r1 = reloff */
	mov.l	r2,@@-r15	/* save registers */
	mov.l	r3,@@-r15
	mov.l	r4,@@-r15
	mov.l	r5,@@-r15
	mov.l	r6,@@-r15
	mov.l	r7,@@-r15
	sts.l	mach,@@-r15
	sts.l	macl,@@-r15
	sts.l	pr,@@-r15

	mov	r0,r4		/* copy of obj */
	mov.l	2f,r0
	bsrf	r0		/* call the binder */
	 mov	r1,r5		/* copy of reloff */
4:
	lds.l	@@r15+,pr	/* restore registers */
	lds.l	@@r15+,macl
	lds.l	@@r15+,mach
	mov.l	@@r15+,r7
	mov.l	@@r15+,r6
	mov.l	@@r15+,r5
	mov.l	@@r15+,r4
	mov.l	@@r15+,r3
	jmp	@@r0
	 mov.l	@@r15+,r2
	.align	2
2:	.long	_rtld_bind-4b
	.size	_rtld_bind_start,.-_rtld_bind_start

	.end
@


1.6
log
@Add some comments.
@
text
@d1 1
a1 1
/*	$NetBSD: rtld_start.S,v 1.5 2006/01/11 22:05:27 uwe Exp $	*/
a17 7
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *        This product includes software developed by the NetBSD
 *        Foundation, Inc. and its contributors.
 * 4. Neither the name of The NetBSD Foundation nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
@


1.6.18.1
log
@sync with head.
@
text
@d1 1
a1 1
/*	$NetBSD: rtld_start.S,v 1.6 2006/01/11 22:24:34 uwe Exp $	*/
d18 7
@


1.5
log
@Kill trailing whitespace.
Indent delay slots.
@
text
@d1 1
a1 1
/*	$NetBSD: rtld_start.S,v 1.4 2004/09/14 21:34:01 uwe Exp $	*/
d50 1
a50 1
	mov.l	@@(4,r0),r4
d52 2
a53 2
	mov.l	@@(12,r0),r1
	mov.l	@@(8,r0),r0
d55 1
a55 1
	mov.l	@@(r0,r2),r0	/* Where linker thinks _DYNAMIC is */
d58 1
a58 1
	 mov.l	r5,@@-r15	/* delay slot: save relocbase */
d62 1
a62 1
	add	#-8,r15		/* Make room for return args */
d70 2
a71 2
	mov.l	@@r15+,r7	/* arg: cleanup */
	mov.l	@@r15+,r8	/* arg: obj */
d81 1
a81 1
	jmp	@@r0
@


1.4
log
@Preserve r2 in _rtld_bind_start - in r2 functions that return
aggregate types are passed the address of the memory area to store the
returned result to.

Fixes PR port-sh3/26949.
@
text
@d1 1
a1 1
/*	$NetBSD: rtld_start.S,v 1.3 2003/06/30 00:50:47 marcus Exp $	*/
d58 1
a58 1
	mov.l	r5,@@-r15	/* delay slot: save relocbase */
d60 1
a60 1
4:	
d66 1
a66 1
	mov.l	r9,@@-r15	/* save ps_strings */
d69 1
a69 1
	
d82 1
a82 1
	add	#8,r6
d90 1
a90 1
	
d108 2
a109 2
	mov	r1,r5		/* copy of reloff */
4:	
d119 1
a119 1
	mov.l	@@r15+,r2
@


1.3
log
@Updated to work with current rtld code.
@
text
@d1 1
a1 1
/*	$NetBSD: rtld_start.S,v 1.2 2002/02/04 18:18:51 thorpej Exp $	*/
d95 2
a96 1
	mov.l	r3,@@-r15	/* save registers */
d117 1
d119 1
a119 1
	mov.l	@@r15+,r3
@


1.3.2.1
log
@Pullup rev 1.4 (requested by uwe in ticket #848)

Preserve r2 in _rtld_bind_start - in r2 functions that return
aggregate types are passed the address of the memory area to store the
returned result to. PR#26949
@
text
@d1 1
a1 1
/*	$NetBSD: rtld_start.S,v 1.3 2003/06/30 00:50:47 marcus Exp $	*/
d95 1
a95 2
	mov.l	r2,@@-r15	/* save registers */
	mov.l	r3,@@-r15
d116 1
a117 2
	jmp	@@r0
	mov.l	@@r15+,r2
@


1.2
log
@Whitespace cleanup.
@
text
@d1 1
a1 1
/*	$NetBSD: rtld_start.S,v 1.1 2002/02/03 23:34:43 thorpej Exp $	*/
d47 12
d60 2
a61 31
	/* relocate GOT, so that we can use global function calls in rtld.c */

	mova	1f,r0
	mov.l	@@r0,r1
	add	r1,r0		/* r0 = _GLOBAL_OFFSET_TABLE_ */

	mov.l	2f,r1
	add	r0,r1		/* r1 = GOT end */
	mov.l	3f,r2
	mov.l	@@(r0,r2),r3	/* r3 = where the linker thinks GOT end is */
	mov	r1,r2
	sub	r3,r2		/* r2 = displacement */
4:
	mov.l	@@r0+,r3		/* add displacement to all GOT entries */
	cmp/hs	r1,r0
	add	#-4,r0
	add	r2,r3
	mov.l	r3,@@r0
	bf/s	4b
	add	#4,r0

	bra	4f		/* all done */
	nop	
		
	.align	2
1:	.long	_GLOBAL_OFFSET_TABLE_
2:	.long	_DYNAMIC@@GOTOFF
3:	.long	_DYNAMIC@@GOT

			
4:
d65 1
a65 2
	add	#(1f-3f),r0
	bsrf	r0		/* _rtld(sp) */
d84 5
a88 1
1:	.long	_rtld-.
d94 1
a94 1
_rtld_bind_start:		/* r0 = flag, r1 = reloff, r2 = obj */
d104 1
a105 2
	add	#(2f-4f),r0
	mov	r2,r4		/* copy of obj */
d107 1
a107 1
	mov	r1,r5		/* copy of relobj */
d119 1
a119 1
2:	.long	_rtld_bind-.
@


1.2.2.1
log
@Apply patch (request by skrll in ticket #1702):
Bring "ld.elf_so" (mostly) in sync with NetBSD-current:
- MI and MD (e.g. under NetBSD-alpha) performance improvements
- RTLD_SELF, RTLD_NEXT, RTLD_DEFAULT support
- much better structured code
- closes PR bin/25464
@
text
@d1 1
a1 1
/*	$NetBSD: rtld_start.S,v 1.3 2003/06/30 00:50:47 marcus Exp $	*/
a46 12
	mova	2f,r0
	mov.l	@@r0,r2
	add	r0,r2		/* GOT */
	mov.l	@@(4,r0),r4
	add	r2,r4		/* _DYNAMIC */
	mov.l	@@(12,r0),r1
	mov.l	@@(8,r0),r0
	mov	r4,r5
	mov.l	@@(r0,r2),r0	/* Where linker thinks _DYNAMIC is */
	sub	r0,r5		/* compute relocation base */
	bsrf	r1		/* _rtld_relocate_nonplt_self(dynp, relocbase) */
	mov.l	r5,@@-r15	/* delay slot: save relocbase */
d48 31
a78 2
4:	
	mov.l	@@r15+,r5	/* restore relocbase */
d82 2
a83 1
	bsrf	r0		/* _rtld(sp, relocbase) */
d102 1
a102 5
1:	.long	_rtld-3b
2:	.long	_GLOBAL_OFFSET_TABLE_
	.long	_DYNAMIC@@GOTOFF
	.long	_DYNAMIC@@GOT
	.long	_rtld_relocate_nonplt_self-4b
d108 1
a108 1
_rtld_bind_start:		/* r0 = obj, r1 = reloff */
a117 1
	mov	r0,r4		/* copy of obj */
d119 2
d122 1
a122 1
	mov	r1,r5		/* copy of reloff */
d134 1
a134 1
2:	.long	_rtld_bind-4b
@


1.1
log
@Add support for dynamic linking on the SuperH.  From Marcus Comstedt,
with some bug fixes (namely, don't forget to consider the addend when
processing relocations) from me.
@
text
@d1 1
a1 1
/*	$NetBSD$	*/
d52 1
a52 1
	add	r1,r0	/* r0 = _GLOBAL_OFFSET_TABLE_ */
d55 1
a55 1
	add	r0,r1	/* r1 = GOT end */
d59 1
a59 1
	sub	r3,r2	/* r2 = displacement */
d79 1
a79 1
	add	#-8,r15			/* Make room for return args */
d83 2
a84 2
	bsrf	r0			/* _rtld(sp) */
	mov.l	r9,@@-r15		/* save ps_strings */
d86 1
a86 1
	mov.l	@@r15+,r9		/* restore ps_strings */
d88 2
a89 2
	mov.l	@@r15+,r7		/* arg: cleanup */
	mov.l	@@r15+,r8		/* arg: obj */
d91 1
a91 1
	mov.l	@@r15,r4			/* restore argc */
d93 1
a93 1
	mov	r15,r5			/* restore argv */
d96 1
a96 1
	mov	r4,r6			/* restore envp */
d108 1
a108 1
_rtld_bind_start:	/* r0 = flag, r1 = reloff, r2 = obj */
@
