xref: /netbsd-src/external/gpl3/gcc/dist/libgcc/config/sh/crtn.S (revision 63aea4bd5b445e491ff0389fe27ec78b3099dba3)
1/* Copyright (C) 2000-2013 Free Software Foundation, Inc.
2   This file was adapted from glibc sources.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 3, or (at your option) any
9later version.
10
11GCC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14General Public License for more details.
15
16Under Section 7 of GPL version 3, you are granted additional
17permissions described in the GCC Runtime Library Exception, version
183.1, as published by the Free Software Foundation.
19
20You should have received a copy of the GNU General Public License and
21a copy of the GCC Runtime Library Exception along with this program;
22see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23<http://www.gnu.org/licenses/>.  */
24
25/* See an explanation about .init and .fini in crti.S.  */
26
27	.section .init
28#if __SHMEDIA__
29	add	r14, r63, r15
30	ld.q	r15, 0, r18
31	ptabs	r18, tr0
32	ld.q	r15, 8, r14
33	addi	r15, 16, r15
34	blink	tr0, r63
35#elif __SH5__ && ! __SHMEDIA__
36	mov	r14,r15
37	lds.l	@r14+,pr
38	mov.l	@r14,r14
39	rts
40	add	#8,r15
41#else
42	mov	r14,r15
43	lds.l	@r15+,pr
44	mov.l	@r15+,r14
45	rts
46#ifdef __ELF__
47	mov.l	@r15+,r12
48#else
49	nop
50#endif
51#endif /* __SHMEDIA__ */
52
53	.section .fini
54#if __SHMEDIA__
55	add	r14, r63, r15
56	ld.q	r15, 0, r18
57	ptabs	r18, tr0
58	ld.q	r15, 8, r14
59	addi	r15, 16, r15
60	blink	tr0, r63
61#elif __SH5__ && ! __SHMEDIA__
62	mov	r14,r15
63	lds.l	@r14+,pr
64	mov.l	@r14,r14
65	rts
66	add	#8,r15
67#else
68	mov	r14,r15
69	lds.l	@r15+,pr
70	mov.l	@r15+,r14
71	rts
72#ifdef __ELF__
73	mov.l	@r15+,r12
74#else
75	nop
76#endif
77#endif /* __SHMEDIA__ */
78