xref: /minix3/lib/csu/arch/sh3/crtbegin.S (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc/*	$NetBSD: crtbegin.S,v 1.3 2013/09/12 15:36:14 joerg Exp $	*/
2f14fb602SLionel Sambuc/*-
3f14fb602SLionel Sambuc * Copyright (c) 2012 Valeriy E. Ushakov
4f14fb602SLionel Sambuc * All rights reserved.
5f14fb602SLionel Sambuc *
6f14fb602SLionel Sambuc * Redistribution and use in source and binary forms, with or without
7f14fb602SLionel Sambuc * modification, are permitted provided that the following conditions
8f14fb602SLionel Sambuc * are met:
9f14fb602SLionel Sambuc *
10f14fb602SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
11f14fb602SLionel Sambuc *    notice, this list of conditions and the following disclaimer.
12f14fb602SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
13f14fb602SLionel Sambuc *    notice, this list of conditions and the following disclaimer in
14f14fb602SLionel Sambuc *    the documentation and/or other materials provided with the
15f14fb602SLionel Sambuc *    distribution.
16f14fb602SLionel Sambuc *
17f14fb602SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18f14fb602SLionel Sambuc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19f14fb602SLionel Sambuc * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20f14fb602SLionel Sambuc * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
21f14fb602SLionel Sambuc * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22f14fb602SLionel Sambuc * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
23f14fb602SLionel Sambuc * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24f14fb602SLionel Sambuc * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25f14fb602SLionel Sambuc * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26f14fb602SLionel Sambuc * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
27f14fb602SLionel Sambuc * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28f14fb602SLionel Sambuc * SUCH DAMAGE.
29f14fb602SLionel Sambuc */
30f14fb602SLionel Sambuc
31f14fb602SLionel Sambuc#include <machine/asm.h>
32f14fb602SLionel Sambuc
33*84d9c625SLionel SambucRCSID("$NetBSD: crtbegin.S,v 1.3 2013/09/12 15:36:14 joerg Exp $")
34f14fb602SLionel Sambuc
35f14fb602SLionel Sambuc	.section	.ctors, "aw", @progbits
36f14fb602SLionel Sambuc	.p2align 2
37f14fb602SLionel Sambuc__CTOR_LIST__:
38f14fb602SLionel Sambuc	.long -1
39f14fb602SLionel Sambuc
40f14fb602SLionel Sambuc	.section	.dtors, "aw", @progbits
41f14fb602SLionel Sambuc	.p2align 2
42f14fb602SLionel Sambuc__DTOR_LIST__:
43f14fb602SLionel Sambuc	.long -1
44f14fb602SLionel Sambuc
45f14fb602SLionel Sambuc	.section	.eh_frame, "a", @progbits
46f14fb602SLionel Sambuc	.p2align 2
47f14fb602SLionel Sambuc__EH_FRAME_LIST__:
48f14fb602SLionel Sambuc
49f14fb602SLionel Sambuc	.section	.jcr, "aw", @progbits
50f14fb602SLionel Sambuc	.p2align 2
51f14fb602SLionel Sambuc__JCR_LIST__:
52f14fb602SLionel Sambuc
53f14fb602SLionel Sambuc	.section	.data.rel, "aw", @progbits
54f14fb602SLionel Sambuc	.p2align 2
55f14fb602SLionel Sambuc	.globl	__dso_handle
56f14fb602SLionel Sambuc	.hidden	__dso_handle
57f14fb602SLionel Sambuc	.type	__dso_handle, @object
58f14fb602SLionel Sambuc	.size	__dso_handle, 4
59f14fb602SLionel Sambuc__dso_handle:
60f14fb602SLionel Sambuc#ifdef SHARED
61f14fb602SLionel Sambuc	.long	__dso_handle
62f14fb602SLionel Sambuc#else
63f14fb602SLionel Sambuc	.long	0
64f14fb602SLionel Sambuc#endif
65f14fb602SLionel Sambuc
66f14fb602SLionel Sambuc__dwarf_eh_object:
67f14fb602SLionel Sambuc	.zero	32
68f14fb602SLionel Sambuc
69f14fb602SLionel Sambuc__initialized:
70f14fb602SLionel Sambuc	.zero	1
71f14fb602SLionel Sambuc__finished:
72f14fb602SLionel Sambuc	.zero	1
73f14fb602SLionel Sambuc
74f14fb602SLionel Sambuc	.text
75f14fb602SLionel Sambuc	.weak	__cxa_finalize
76f14fb602SLionel Sambuc	.weak	__deregister_frame_info
77f14fb602SLionel Sambuc	.weak	__register_frame_info
78f14fb602SLionel Sambuc	.weak	_Jv_RegisterClasses
79f14fb602SLionel Sambuc
80f14fb602SLionel Sambuc/*
81f14fb602SLionel Sambuc * A bit of CPP syntactic sugar for accessing variables.
82f14fb602SLionel Sambuc *
83f14fb602SLionel Sambuc * For PIC we are obliged to use @(r0, r12) since r12 has the GOT
84f14fb602SLionel Sambuc * address and only r0 can be used in @(r0, Rm) addressing mode, so we
85f14fb602SLionel Sambuc * always load variable address to r0.
86f14fb602SLionel Sambuc */
87*84d9c625SLionel Sambuc#ifdef __PIC__
88f14fb602SLionel Sambuc#define VAR_DATUM(var)	var@GOTOFF
89f14fb602SLionel Sambuc#define FUNC_DATUM(f)	f@GOT
90f14fb602SLionel Sambuc#define R0VAR		(r0, r12)
91f14fb602SLionel Sambuc#else
92f14fb602SLionel Sambuc#define VAR_DATUM(var)	var
93f14fb602SLionel Sambuc#define FUNC_DATUM(f)	f
94f14fb602SLionel Sambuc#define R0VAR		r0
95f14fb602SLionel Sambuc#endif
96f14fb602SLionel Sambuc
97f14fb602SLionel Sambuc
98f14fb602SLionel Sambuc__do_global_ctors_aux:
99f14fb602SLionel Sambuc        mov.l   r8, @-sp
100f14fb602SLionel Sambuc        mov.l   r9, @-sp
101*84d9c625SLionel Sambuc#ifdef __PIC__
102f14fb602SLionel Sambuc        mov.l   r12, @-sp
103f14fb602SLionel Sambuc        mov.l   .Lc_got, r12
104f14fb602SLionel Sambuc        mova    .Lc_got, r0
105f14fb602SLionel Sambuc        add     r0, r12
106f14fb602SLionel Sambuc#endif
107f14fb602SLionel Sambuc        mov.l   r14, @-sp
108f14fb602SLionel Sambuc        sts.l   pr, @-sp
109f14fb602SLionel Sambuc	mov     sp, r14
110f14fb602SLionel Sambuc
111f14fb602SLionel Sambuc	!! if (__initialized) return;
112f14fb602SLionel Sambuc	mov.l	.Lc___initialized, r0
113f14fb602SLionel Sambuc	mov.b	@R0VAR, r1
114f14fb602SLionel Sambuc	tst	r1, r1
115f14fb602SLionel Sambuc	bf	.Lc_return
116f14fb602SLionel Sambuc
117f14fb602SLionel Sambuc	!! __initialized = 1;
118f14fb602SLionel Sambuc	mov	#1, r1
119f14fb602SLionel Sambuc	mov.b	r1, @R0VAR
120f14fb602SLionel Sambuc
121f14fb602SLionel Sambuc
122f14fb602SLionel Sambuc	!! if (__register_frame_info)
123f14fb602SLionel Sambuc	!!     __register_frame_info(&__EH_FRAME_LIST__[0], &__dwarf_eh_object)
124*84d9c625SLionel Sambuc#ifdef __PIC__
125f14fb602SLionel Sambuc	mov.l	.Lc___register_frame_info_GOT, r0
126f14fb602SLionel Sambuc	mov.l	@R0VAR, r1
127f14fb602SLionel Sambuc	tst	r1, r1
128f14fb602SLionel Sambuc	bt	.Lc___register_frame_info_done
129f14fb602SLionel Sambuc	mov.l	.Lc___register_frame_info, r0
130f14fb602SLionel Sambuc	mov.l	.Lc___EH_FRAME_LIST__, r4
131f14fb602SLionel Sambuc	mov.l	.Lc___dwarf_eh_object, r5
132f14fb602SLionel Sambuc	add	r12, r4
133f14fb602SLionel Sambuc.Lc___register_frame_info_call:
134f14fb602SLionel Sambuc	CALL	r0
135f14fb602SLionel Sambuc	 add	r12, r5
136f14fb602SLionel Sambuc#else /* !PIC */
137f14fb602SLionel Sambuc	mov.l	.Lc___register_frame_info, r0
138f14fb602SLionel Sambuc	tst	r0, r0
139f14fb602SLionel Sambuc	bt	.Lc___register_frame_info_done
140f14fb602SLionel Sambuc	mov.l	.Lc___EH_FRAME_LIST__, r4
141f14fb602SLionel Sambuc	mov.l	.Lc___dwarf_eh_object, r5
142f14fb602SLionel Sambuc	CALL	r0
143f14fb602SLionel Sambuc	 nop
144f14fb602SLionel Sambuc#endif
145f14fb602SLionel Sambuc.Lc___register_frame_info_done:
146f14fb602SLionel Sambuc
147f14fb602SLionel Sambuc	!!  if (_Jv_RegisterClasses && __JCR_LIST__[0])
148f14fb602SLionel Sambuc	!!      _Jv_RegisterClasses(&__JCR_LIST__[0]);
149*84d9c625SLionel Sambuc#ifdef __PIC__
150f14fb602SLionel Sambuc	mov.l	.Lc__Jv_RegisterClasses_GOT, r0
151f14fb602SLionel Sambuc	mov.l	@R0VAR, r1
152f14fb602SLionel Sambuc	tst	r1, r1
153f14fb602SLionel Sambuc	bt	.Lc__Jv_RegisterClasses_done
154f14fb602SLionel Sambuc
155f14fb602SLionel Sambuc	mov.l	.Lc___JCR_LIST__, r0
156f14fb602SLionel Sambuc	mov.l	@R0VAR, r1
157f14fb602SLionel Sambuc	tst	r1, r1
158f14fb602SLionel Sambuc	bt	.Lc__Jv_RegisterClasses_done
159f14fb602SLionel Sambuc
160f14fb602SLionel Sambuc	mov.l	.Lc__Jv_RegisterClasses, r2
161f14fb602SLionel Sambuc	mov	r0, r4
162f14fb602SLionel Sambuc.Lc__Jv_RegisterClasses_call:
163f14fb602SLionel Sambuc	CALL	r2
164f14fb602SLionel Sambuc	 add	r12, r4
165f14fb602SLionel Sambuc
166f14fb602SLionel Sambuc#else /* !PIC */
167f14fb602SLionel Sambuc	mov.l	.Lc__Jv_RegisterClasses, r2
168f14fb602SLionel Sambuc	tst	r2, r2
169f14fb602SLionel Sambuc	bt	.Lc__Jv_RegisterClasses_done
170f14fb602SLionel Sambuc
171f14fb602SLionel Sambuc	mov.l	.Lc___JCR_LIST__, r0
172f14fb602SLionel Sambuc	mov.l	@R0VAR, r1
173f14fb602SLionel Sambuc	tst	r1, r1
174f14fb602SLionel Sambuc	bt	.Lc__Jv_RegisterClasses_done
175f14fb602SLionel Sambuc
176f14fb602SLionel Sambuc	mov	r0, r4
177f14fb602SLionel Sambuc.Lc__Jv_RegisterClasses_call:
178f14fb602SLionel Sambuc	CALL	r2
179f14fb602SLionel Sambuc	 add	r12, r4
180f14fb602SLionel Sambuc#endif
181f14fb602SLionel Sambuc.Lc__Jv_RegisterClasses_done:
182f14fb602SLionel Sambuc
183f14fb602SLionel Sambuc
184f14fb602SLionel Sambuc	!! call all constructors on __CTOR_LIST__ in reverse order
185f14fb602SLionel Sambuc	mov.l	.Lc___CTOR_LIST_END__, r8
186*84d9c625SLionel Sambuc#ifdef __PIC__
187f14fb602SLionel Sambuc	add	r12, r8
188f14fb602SLionel Sambuc#endif
189f14fb602SLionel Sambuc	add	#-4, r8
190f14fb602SLionel Sambuc	mov.l	@r8, r9
191f14fb602SLionel Sambuc	not	r9, r0		! sentinel at __CTOR_LIST__[0] is -1
192f14fb602SLionel Sambuc.Lc_ctor_list_loop:
193f14fb602SLionel Sambuc	tst	r0, r0
194f14fb602SLionel Sambuc	bt.s	.Lc_ctor_list_done
195f14fb602SLionel Sambuc	 add	#-4, r8
196f14fb602SLionel Sambuc	jsr	@r9
197f14fb602SLionel Sambuc	 mov.l	@r8, r9
198f14fb602SLionel Sambuc	bra	.Lc_ctor_list_loop
199f14fb602SLionel Sambuc	 not	r9, r0
200f14fb602SLionel Sambuc.Lc_ctor_list_done:
201f14fb602SLionel Sambuc
202f14fb602SLionel Sambuc.Lc_return:
203f14fb602SLionel Sambuc	mov	r14, sp
204f14fb602SLionel Sambuc	lds.l	@sp+, pr
205f14fb602SLionel Sambuc	mov.l	@sp+, r14
206*84d9c625SLionel Sambuc#ifdef __PIC__
207f14fb602SLionel Sambuc	mov.l	@sp+, r12
208f14fb602SLionel Sambuc#endif
209f14fb602SLionel Sambuc	mov.l	@sp+, r9
210f14fb602SLionel Sambuc	rts
211f14fb602SLionel Sambuc	 mov.l	@sp+, r8
212f14fb602SLionel Sambuc
213f14fb602SLionel Sambuc	.p2align 2
214f14fb602SLionel Sambuc.Lc_got:
215f14fb602SLionel Sambuc	PIC_GOT_DATUM
216f14fb602SLionel Sambuc.Lc___initialized:
217f14fb602SLionel Sambuc	.long	VAR_DATUM(__initialized)
218*84d9c625SLionel Sambuc#ifdef __PIC__
219f14fb602SLionel Sambuc.Lc___register_frame_info_GOT:
220f14fb602SLionel Sambuc	.long	__register_frame_info@GOT
221f14fb602SLionel Sambuc#endif
222f14fb602SLionel Sambuc.Lc___register_frame_info:
223f14fb602SLionel Sambuc	CALL_DATUM(__register_frame_info, .Lc___register_frame_info_call)
224f14fb602SLionel Sambuc.Lc___EH_FRAME_LIST__:
225f14fb602SLionel Sambuc	.long	VAR_DATUM(__EH_FRAME_LIST__)
226f14fb602SLionel Sambuc.Lc___dwarf_eh_object:
227f14fb602SLionel Sambuc	.long	VAR_DATUM(__dwarf_eh_object)
228*84d9c625SLionel Sambuc#ifdef __PIC__
229f14fb602SLionel Sambuc.Lc__Jv_RegisterClasses_GOT:
230f14fb602SLionel Sambuc	.long	_Jv_RegisterClasses@GOT
231f14fb602SLionel Sambuc#endif
232f14fb602SLionel Sambuc.Lc__Jv_RegisterClasses:
233f14fb602SLionel Sambuc	CALL_DATUM(_Jv_RegisterClasses, .Lc__Jv_RegisterClasses_call)
234f14fb602SLionel Sambuc.Lc___JCR_LIST__:
235f14fb602SLionel Sambuc	.long	VAR_DATUM(__JCR_LIST__)
236f14fb602SLionel Sambuc.Lc___CTOR_LIST_END__:
237f14fb602SLionel Sambuc	.long	VAR_DATUM(__CTOR_LIST_END__)
238f14fb602SLionel Sambuc
239f14fb602SLionel Sambuc
240f14fb602SLionel Sambuc__do_global_dtors_aux:
241f14fb602SLionel Sambuc        mov.l   r8, @-sp
242f14fb602SLionel Sambuc        mov.l   r9, @-sp
243*84d9c625SLionel Sambuc#ifdef __PIC__
244f14fb602SLionel Sambuc        mov.l   r12, @-sp
245f14fb602SLionel Sambuc        mov.l   .Ld_got, r12
246f14fb602SLionel Sambuc        mova    .Ld_got, r0
247f14fb602SLionel Sambuc        add     r0, r12
248f14fb602SLionel Sambuc#endif
249f14fb602SLionel Sambuc        mov.l   r14, @-sp
250f14fb602SLionel Sambuc        sts.l   pr, @-sp
251f14fb602SLionel Sambuc	mov     sp, r14
252f14fb602SLionel Sambuc
253f14fb602SLionel Sambuc	!! if (__finished) return;
254f14fb602SLionel Sambuc	mov.l	.Ld___finished, r0
255f14fb602SLionel Sambuc	mov.b	@R0VAR, r1
256f14fb602SLionel Sambuc	tst	r1, r1
257f14fb602SLionel Sambuc	bf	.Ld_return
258f14fb602SLionel Sambuc
259f14fb602SLionel Sambuc	!! __finished = 1;
260f14fb602SLionel Sambuc	mov	#1, r1
261f14fb602SLionel Sambuc	mov.b	r1, @R0VAR
262f14fb602SLionel Sambuc
263f14fb602SLionel Sambuc#ifdef SHARED /* implies PIC */
264f14fb602SLionel Sambuc	!! if (__cxa_finalize)
265f14fb602SLionel Sambuc	!!     __cxa_finalize(&__dso_handle);
266f14fb602SLionel Sambuc	mov.l	.Ld___cxa_finalize_GOT, r0
267f14fb602SLionel Sambuc	mov.l	@R0VAR, r1
268f14fb602SLionel Sambuc	tst	r1, r1
269f14fb602SLionel Sambuc	bt	.Ld___cxa_finalize_done
270f14fb602SLionel Sambuc	mov.l	.Ld___cxa_finalize, r0
271f14fb602SLionel Sambuc	mov.l	.Ld___dso_handle, r4
272f14fb602SLionel Sambuc.Ld___cxa_finalize_call:
273f14fb602SLionel Sambuc	CALL	r0
274f14fb602SLionel Sambuc	 add	r12, r4
275f14fb602SLionel Sambuc.Ld___cxa_finalize_done:
276f14fb602SLionel Sambuc#endif	/* SHARED */
277f14fb602SLionel Sambuc
278f14fb602SLionel Sambuc	!! call all destructors on __DTOR_LIST__
279f14fb602SLionel Sambuc	mov.l	.Ld___DTOR_LIST__, r8
280*84d9c625SLionel Sambuc#ifdef __PIC__
281f14fb602SLionel Sambuc	add	r12, r8
282f14fb602SLionel Sambuc#endif
283f14fb602SLionel Sambuc	add	#4, r8		! skip first entry that we know to be -1
284f14fb602SLionel Sambuc	mov.l	@r8+, r9
285f14fb602SLionel Sambuc	tst	r9, r9
286f14fb602SLionel Sambuc.Ld_dtor_list_loop:
287f14fb602SLionel Sambuc	bt	.Ld_dtor_list_done
288f14fb602SLionel Sambuc	jsr	@r9
289f14fb602SLionel Sambuc	 mov.l	@r8+, r9
290f14fb602SLionel Sambuc	bra	.Ld_dtor_list_loop
291f14fb602SLionel Sambuc	 tst	r9, r9
292f14fb602SLionel Sambuc.Ld_dtor_list_done:
293f14fb602SLionel Sambuc
294f14fb602SLionel Sambuc	!! if (__deregister_frame_info)
295f14fb602SLionel Sambuc	!!     __deregister_frame_info(&__EH_FRAME_LIST__[0]);
296*84d9c625SLionel Sambuc#ifdef __PIC__
297f14fb602SLionel Sambuc	mov.l	.Ld___deregister_frame_info_GOT, r0
298f14fb602SLionel Sambuc	mov.l	@R0VAR, r1
299f14fb602SLionel Sambuc	tst	r1, r1
300f14fb602SLionel Sambuc	bt	.Ld___deregister_frame_info_done
301f14fb602SLionel Sambuc	mov.l	.Ld___deregister_frame_info, r0
302f14fb602SLionel Sambuc	mov.l	.Ld___EH_FRAME_LIST__, r4
303f14fb602SLionel Sambuc.Ld___deregister_frame_info_call:
304f14fb602SLionel Sambuc	CALL	r0
305f14fb602SLionel Sambuc	 add	r12, r4
306f14fb602SLionel Sambuc#else /* !PIC */
307f14fb602SLionel Sambuc	mov.l	.Ld___deregister_frame_info, r0
308f14fb602SLionel Sambuc	tst	r0, r0
309f14fb602SLionel Sambuc	bt	.Ld___deregister_frame_info_done
310f14fb602SLionel Sambuc	mov.l	.Ld___EH_FRAME_LIST__, r4
311f14fb602SLionel Sambuc	CALL	r0
312f14fb602SLionel Sambuc	 nop
313f14fb602SLionel Sambuc#endif
314f14fb602SLionel Sambuc.Ld___deregister_frame_info_done:
315f14fb602SLionel Sambuc
316f14fb602SLionel Sambuc.Ld_return:
317f14fb602SLionel Sambuc	mov	r14, sp
318f14fb602SLionel Sambuc	lds.l	@sp+, pr
319f14fb602SLionel Sambuc	mov.l	@sp+, r14
320*84d9c625SLionel Sambuc#ifdef __PIC__
321f14fb602SLionel Sambuc	mov.l	@sp+, r12
322f14fb602SLionel Sambuc#endif
323f14fb602SLionel Sambuc	mov.l	@sp+, r9
324f14fb602SLionel Sambuc	rts
325f14fb602SLionel Sambuc	 mov.l	@sp+, r8
326f14fb602SLionel Sambuc
327f14fb602SLionel Sambuc	.p2align 2
328f14fb602SLionel Sambuc.Ld_got:
329f14fb602SLionel Sambuc	PIC_GOT_DATUM
330f14fb602SLionel Sambuc.Ld___finished:
331f14fb602SLionel Sambuc	.long	VAR_DATUM(__finished)
332f14fb602SLionel Sambuc#ifdef SHARED /* implies PIC */
333f14fb602SLionel Sambuc.Ld___cxa_finalize_GOT:
334f14fb602SLionel Sambuc	.long	__cxa_finalize@GOT
335f14fb602SLionel Sambuc.Ld___cxa_finalize:
336f14fb602SLionel Sambuc	CALL_DATUM(__cxa_finalize, .Ld___cxa_finalize_call)
337f14fb602SLionel Sambuc.Ld___dso_handle:
338f14fb602SLionel Sambuc	.long	VAR_DATUM(__dso_handle)
339f14fb602SLionel Sambuc#endif
340f14fb602SLionel Sambuc.Ld___DTOR_LIST__:
341f14fb602SLionel Sambuc	.long	VAR_DATUM(__DTOR_LIST__)
342*84d9c625SLionel Sambuc#ifdef __PIC__
343f14fb602SLionel Sambuc.Ld___deregister_frame_info_GOT:
344f14fb602SLionel Sambuc	.long	__deregister_frame_info@GOT
345f14fb602SLionel Sambuc#endif
346f14fb602SLionel Sambuc.Ld___deregister_frame_info:
347f14fb602SLionel Sambuc	CALL_DATUM(__deregister_frame_info, .Ld___deregister_frame_info_call)
348f14fb602SLionel Sambuc.Ld___EH_FRAME_LIST__:
349f14fb602SLionel Sambuc	.long	VAR_DATUM(__EH_FRAME_LIST__)
350f14fb602SLionel Sambuc
351f14fb602SLionel Sambuc
352f14fb602SLionel Sambuc
353f14fb602SLionel Sambuc#define _CALL_INIT_FINI_FUNCTION(func)					\
354f14fb602SLionel Sambuc	mov.l	1f, r1;							\
355f14fb602SLionel Sambuc	mova	2f, r0;							\
356f14fb602SLionel Sambuc0:	braf	r1;	/* NB: branch, not call ... */			\
357f14fb602SLionel Sambuc	 lds	r0, pr;	/* skip the following .long when returning */	\
358f14fb602SLionel Sambuc	.p2align 2;							\
359f14fb602SLionel Sambuc1:	.long func - (0b+4);						\
360f14fb602SLionel Sambuc2:	;
361f14fb602SLionel Sambuc
362f14fb602SLionel Sambuc	.section	.init, "ax", @progbits
363f14fb602SLionel Sambuc	_CALL_INIT_FINI_FUNCTION(__do_global_ctors_aux)
364f14fb602SLionel Sambuc
365f14fb602SLionel Sambuc	.section	.fini, "ax", @progbits
366f14fb602SLionel Sambuc	_CALL_INIT_FINI_FUNCTION(__do_global_dtors_aux)
367