Daily bump.
[official-gcc.git] / libgcc / config / sh / crti.S
blob4df04c6c2e01cffa02b31e3c6ea748860de1b564
1 /* Copyright (C) 2000-2015 Free Software Foundation, Inc.
2    This file was adapted from glibc sources.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23 <http://www.gnu.org/licenses/>.  */
25 #include "crt.h"
27 /* The code in sections .init and .fini is supposed to be a single
28    regular function.  The function in .init is called directly from
29    start in crt1.S.  The function in .fini is atexit()ed in crt1.S
30    too.
32    crti.S contributes the prologue of a function to these sections,
33    and crtn.S comes up the epilogue.  STARTFILE_SPEC should list
34    crti.o before any other object files that might add code to .init
35    or .fini sections, and ENDFILE_SPEC should list crtn.o after any
36    such object files.  */
38         .section .init
39 /* The alignment below can't be smaller, otherwise the mova below
40    breaks.  Yes, we might align just the label, but then we'd be
41    exchanging an alignment here for one there, since the code fragment
42    below ensures 4-byte alignment on __ELF__.  */
43 #ifdef __ELF__
44         .p2align 2
45 #else
46         .p2align 1
47 #endif
48         .global  GLOBAL(_init)
49 GLOBAL(_init):
50 #if __SHMEDIA__
51         addi    r15, -16, r15
52         st.q    r15, 8, r14
53         st.q    r15, 0, r18
54         add     r15, r63, r14
55 #elif __SH5__ && ! __SHMEDIA__
56         mov     r15,r0
57         add     #-8,r15
58         mov.l   r14,@-r0
59         sts.l   pr,@-r0
60         mov     r15,r14
61         nop
62 #else
63 #ifdef __ELF__
64         mov.l   r12,@-r15
65         mova    0f,r0
66         mov.l   0f,r12
67 #endif
68         mov.l   r14,@-r15
69 #ifdef __ELF__
70         add     r0,r12
71 #endif
72         sts.l   pr,@-r15
73 #ifdef __ELF__
74         bra     1f
75 #endif
76         mov     r15,r14
77 #ifdef __ELF__
78 0:      .long   _GLOBAL_OFFSET_TABLE_
80 #endif
81 #endif /* __SHMEDIA__ */
83         .section .fini
84 /* The alignment below can't be smaller, otherwise the mova below
85    breaks.  Yes, we might align just the label, but then we'd be
86    exchanging an alignment here for one there, since the code fragment
87    below ensures 4-byte alignment on __ELF__.  */
88 #ifdef __ELF__
89         .p2align 2
90 #else
91         .p2align 1
92 #endif
93         .global  GLOBAL(_fini)
94 GLOBAL(_fini):  
95 #if __SHMEDIA__
96         addi    r15, -16, r15
97         st.q    r15, 8, r14
98         st.q    r15, 0, r18
99         add     r15, r63, r14
100 #elif __SH5__ && ! __SHMEDIA__
101         mov     r15,r0
102         add     #-8,r15
103         mov.l   r14,@-r0
104         sts.l   pr,@-r0
105         mov     r15,r14
106         nop
107 #else
108 #ifdef __ELF__
109         mov.l   r12,@-r15
110         mova    0f,r0
111         mov.l   0f,r12
112 #endif
113         mov.l   r14,@-r15
114 #ifdef __ELF__
115         add     r0,r12
116 #endif
117         sts.l   pr,@-r15
118 #ifdef __ELF__
119         bra     1f
120 #endif
121         mov     r15,r14
122 #ifdef __ELF__
123 0:      .long   _GLOBAL_OFFSET_TABLE_
125 #endif
126 #endif /* __SHMEDIA__ */