xref: /minix/libexec/ld.elf_so/arch/m68k/rtld_start.S (revision 84d9c625)
1/*	$NetBSD: rtld_start.S,v 1.10 2013/07/18 21:57:42 matt Exp $	*/
2
3/*-
4 * Copyright (c) 1999, 2002, 2003 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Klaus Klein and by Charles M. Hannum.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
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.
18 *
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.
30 */
31
32#include <machine/asm.h>
33
34	.text
35	.align	4
36	.globl	.rtld_start
37	.type	.rtld_start,@function
38.rtld_start:
39	subql	#8,%sp			| storage for obj and cleanup
40
41	GOT_SETUP(%a0)
42	LEA_LCL(_DYNAMIC,%a1)
43
44	movel	%a1,%a5
45	subl	(%a0),%a5
46
47	movel	%a5,-(%sp)		| relocbase
48	movel	%a1,-(%sp)		| &_DYNAMIC
49	jbsr	_rtld_relocate_nonplt_self@PLTPC
50	addql	#8,%sp			| pop arguments
51
52	movel	%a5,-(%sp)		| relocbase
53	pea	4(%sp)			| sp
54	jbsr	_rtld@PLTPC		| entry = _rtld(sp, relocbase)
55	addql	#8,%sp			| pop arguments
56
57	moveal	(%sp)+,%a1		| cleanup
58	moveal	(%sp)+,%a0		| obj
59	moveal	%d0,%a3
60	jmp	(%a3)			| Go for it!
61	.size	.rtld_start,.-.rtld_start
62
63	.align	4
64	.globl	_rtld_bind_start
65	.type	_rtld_bind_start,@function
66_rtld_bind_start:
67	INTERRUPT_SAVEREG
68	movel	20(%sp),-(%sp)		| push reloff
69	movel	(16+4)(%sp),-(%sp)	| push obj
70	jbsr	_rtld_bind@PLTPC	| %a0 = _rtld_bind(obj, reloff)
71	addql	#8,%sp			| pop args
72#ifdef __SVR4_ABI__
73	movel	%a0,(16+4)(%sp)		| write fake `return' address over obj
74#else
75	movel	%d0,(16+4)(%sp)		| write fake `return' address over obj
76#endif
77	INTERRUPT_RESTOREREG		| restore caller-saved registers
78	addql	#4,%sp			| skip reloff
79	rts				| `return' right into function
80	.size	_rtld_bind_start,.-_rtld_bind_start
81