Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / config / score / crti.asm
blobb1d3a2ba98be0f0231ece1c311918de4760e0417
1 # crti.asm for Sunplus S+CORE
3 # Copyright (C) 2005 Free Software Foundation, Inc.
5 # This file is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2, or (at your option) any
8 # later version.
10 # In addition to the permissions in the GNU General Public License, the
11 # Free Software Foundation gives you unlimited permission to link the
12 # compiled version of this file with other programs, and to distribute
13 # those programs without any restriction coming from the use of this
14 # file. (The General Public License restrictions do apply in other
15 # respects; for example, they cover modification of the file, and
16 # distribution when not linked into another program.)
18 # This file is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with GCC; see the file COPYING. If not, write to the Free
25 # Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
26 # 02110-1301, USA.
28 # As a special exception, if you link this library with files
29 # compiled with GCC to produce an executable, this does not cause
30 # the resulting executable to be covered by the GNU General Public License.
31 # This exception does not however invalidate any other reasons why
32 # the executable file might be covered by the GNU General Public License.
35 # This file makes a stack frame for the contents of the .init and
36 # .fini sections.
37 .extern _stack
39 #ifndef __pic__
40 .section .init, "ax", @progbits
41 .weak _start
42 .ent _start
43 .frame r0, 0, r3, 0
44 .mask 0x00000000, 0
45 _start:
46 la r28, _gp
47 la r8, __bss_start
48 la r9, __bss_end__
49 sub! r9, r8
50 srli! r9, 2
51 addi r9, -1
52 mtsr r9, sr0
53 li r9, 0
55 sw r9, [r8]+, 4
56 bcnz 1b
57 la r0, _stack
58 jl _init
59 la r4, _end
60 jl _init_argv
61 jl exit
62 .end _start
64 .weak _init_argv
65 .ent
66 .frame r0, 0, r3, 0
67 .mask 0x00000000, 0
68 _init_argv:
69 ldiu! r4, 0
70 ldiu! r5, 0
71 j main
72 .end _init_argv
74 .globl _init
75 .type _init, %function
76 _init:
77 addi r0, -32
78 sw r3, [r0, 20]
80 .section .fini, "ax", @progbits
81 .globl _fini
82 .type _fini, %function
83 _fini:
84 addi r0, -32
85 sw r3, [r0, 20]
86 #else
87 .section .init, "ax", @progbits
88 .set pic
89 .weak _start
90 .ent _start
91 .frame r0, 0, r3, 0
92 .mask 0x00000000, 0
93 _start:
94 mv r29, r3
95 bl 0f
97 .cpload r3
98 mv r3, r29
99 la r8, __bss_start
100 la r9, __bss_end__
101 sub! r9, r8
102 srli! r9, 2
103 addi r9, -1
104 mtsr r9, sr0
105 li r9, 0
107 sw r9, [r8]+, 4
108 bcnz 1b
109 la r0, _stack
110 bl _init
111 la r4, _end
112 la r29, _init_argv
113 brl r29
114 la r29, exit
115 brl r29
116 .end _start
118 .weak _init_argv
119 .ent _init_argv
120 .frame r0, 0, r3, 0
121 .mask 0x00000000, 0
122 _init_argv:
123 ldiu! r4, 0
124 ldiu! r5, 0
125 la r29, main
126 brl r29
127 .end _init_argv
129 .globl _init
130 .type _init, %function
131 _init:
132 addi r0, -32
133 sw r3, [r0, 20]
135 .section .fini, "ax", @progbits
136 .globl _fini
137 .type _fini, %function
138 _fini:
139 addi r0, -32
140 sw r3, [r0, 20]
142 #endif