OSDN Git Service

Fix glibc make check failure.
[pf3gnuchains/gcc-fork.git] / gcc / config / ia64 / crtbegin.asm
1 /* Copyright (C) 2000 Free Software Foundation, Inc.
2    Contributed by Jes Sorensen, <Jes.Sorensen@cern.ch>
3
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public License as
6    published by the Free Software Foundation; either version 2 of the
7    License, or (at your option) any later version.
8
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13
14    You should have received a copy of the GNU Library General Public
15    License along with the GNU C Library; see the file COPYING.LIB.  If not,
16    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17    Boston, MA 02111-1307, USA.  */
18
19 .section .ctors,"aw","progbits"
20         .align  8
21 __CTOR_LIST__:
22         data8   -1
23
24 .section .dtors,"aw","progbits"
25         .align  8
26 __DTOR_LIST__:
27         data8   -1
28
29 .section .IA_64.unwind
30         .align  8
31 __EH_FRAME_BEGIN__:
32
33 .section .sdata
34         .type dtor_ptr#,@object
35         .size dtor_ptr#,8
36 dtor_ptr:
37         data8   __DTOR_LIST__# + 8
38
39         .type segrel_ofs#,@object
40         .size segrel_ofs#,8
41 segrel_ofs:
42         data8   @segrel(.Lsegrel_ref#)
43
44         /* A handle for __cxa_finalize to manage c++ local destructors.  */
45         .global __dso_handle#
46         .type __dso_handle#,@object
47         .size __dso_handle#,8
48 #ifdef SHARED
49         .section .data
50 __dso_handle:
51         data8   __dso_handle#
52 #else
53         .section .bss
54 __dso_handle:
55         data8   0
56 #endif
57         .hidden __dso_handle#
58
59         /* The frame object.  */
60         /* ??? How can we rationally keep this size correct?  */
61 .section .bss
62         .type frame_object#,@object
63         .size frame_object#,64
64         .align 8
65 frame_object:
66         .zero 64
67
68 /*
69  * Fragment of the ELF _fini routine that invokes our dtor cleanup.
70  *
71  * We make the call by indirection, because in large programs the 
72  * .fini and .init sections are not in range of the destination, and
73  * we cannot allow the linker to insert a stub at the end of this
74  * fragment of the _fini function.  Further, Itanium does not implement
75  * the long branch instructions, and we do not wish every program to
76  * trap to the kernel for emulation.
77  *
78  * Note that we require __do_global_dtors_aux to preserve the GP,
79  * so that the next fragment in .fini gets the right value.
80  */
81 .section .fini,"ax","progbits"
82         { .mlx
83           movl r2 = @gprel(__do_global_dtors_aux#)
84           ;;
85         }
86         { .mii
87           nop.m 0
88           add r2 = r2, gp
89           ;;
90           mov b6 = r2
91         }
92         { .bbb
93           br.call.sptk.many b0 = b6
94           ;;
95         }
96
97 /*
98  * Fragment of the ELF _init routine that sets up the frame info.
99  */
100
101 .section .init,"ax","progbits"
102         { .mlx
103           movl r2 = @gprel(__do_frame_setup#)
104           ;;
105         }
106         { .mii
107           nop.m 0
108           add r2 = r2, gp
109           ;;
110           mov b6 = r2
111         }
112         { .bbb
113           br.call.sptk.many b0 = b6
114           ;;
115         }
116
117 .section .text
118         .align  16
119         .proc   __do_global_dtors_aux#
120 __do_global_dtors_aux:
121 #ifndef SHARED
122         { .mii
123           alloc loc3 = ar.pfs, 0, 4, 1, 0
124           addl loc0 = @gprel(dtor_ptr#), gp
125           mov loc1 = b0
126         }
127         { .mib
128           mov loc2 = gp
129           br.sptk.few 1f
130           ;;
131         }
132 #else
133         /*
134                 if (__cxa_finalize)
135                   __cxa_finalize(__dso_handle)
136         */
137         { .mii
138           alloc loc3 = ar.pfs, 0, 4, 1, 0
139           addl loc0 = @gprel(dtor_ptr#), gp
140           addl r16 = @ltoff(@fptr(__cxa_finalize#)), gp
141           ;;
142         }
143         { .mmi
144           ld8 r16 = [r16]
145           ;;
146           addl out0 = @ltoff(__dso_handle#), gp
147           cmp.ne p7, p0 = r0, r16
148           ;;
149         }
150         { .mmi
151           ld8 out0 = [out0]
152 (p7)      ld8 r18 = [r16], 8
153           mov loc1 = b0
154           ;;
155         }
156         { .mfi
157           mov loc2 = gp
158 (p7)      mov b6 = r18
159         }
160         {
161           .mfb
162 (p7)      ld8 gp = [r16]
163 (p7)      br.call.sptk.many b0 = b6
164         }
165         { .mfb
166           br.sptk.few 1f
167         }
168 #endif
169         /*
170                 do {
171                   dtor_ptr++;
172                   (*(dtor_ptr-1)) ();
173                 } while (dtor_ptr);
174         */
175 0:
176         { .mmi
177           st8 [loc0] = r15
178           ld8 r17 = [r16], 8
179           ;;
180         }
181         { .mib
182           ld8 gp = [r16]
183           mov b6 = r17
184           br.call.sptk.many b0 = b6
185         }
186 1:
187         { .mmi
188           ld8 r15 = [loc0]
189           ;;
190           ld8 r16 = [r15], 8
191           ;;
192         }
193         { .mfb
194           cmp.ne p6, p0 = r0, r16
195 (p6)      br.cond.sptk.few 0b
196         }
197         /*
198                 if (__deregister_frame_info)
199                   __deregister_frame_info(__EH_FRAME_BEGIN__)
200         */
201         { .mmi
202           mov gp = loc2
203           ;;
204           addl r16 = @ltoff(@fptr(__deregister_frame_info#)), gp
205           addl out0 = @ltoff(__EH_FRAME_BEGIN__#), gp
206           ;;
207         }
208         { .mmi
209           ld8 r16 = [r16]
210           ld8 out0 = [out0]
211           ;;
212         }
213         { .mmi
214           cmp.ne p7, p0 = r0, r16
215           ;;
216 (p7)      ld8 r18 = [r16], 8
217           ;;
218         }
219         { .mib
220 (p7)      ld8 gp = [r16]
221 (p7)      mov b6 = r18
222 (p7)      br.call.sptk.many b0 = b6
223         }
224         { .mii
225           mov gp = loc2
226           mov b0 = loc1
227           mov ar.pfs = loc3
228         }
229         { .bbb
230           br.ret.sptk.many b0
231           ;;
232         }
233         .endp   __do_global_dtors_aux#
234
235         .proc   __do_frame_setup#
236 __do_frame_setup:
237         /*
238                 if (__register_frame_info)
239                   __register_frame_info(__EH_FRAME_BEGIN__)
240         */
241         { .mii
242           alloc loc2 = ar.pfs, 0, 3, 2, 0
243           addl r16 = @ltoff(@fptr(__register_frame_info#)), gp
244           addl out0 = @ltoff(__EH_FRAME_BEGIN__#), gp
245         }
246         /* frame_object.pc_base = segment_base_offset;
247            pc_base is at offset 0 within frame_object.  */
248 .Lsegrel_ref:
249         { .mmi
250           addl out1 = @ltoff(frame_object#), gp
251           ;;
252           addl r2 = @gprel(segrel_ofs#), gp
253           mov r3 = ip
254           ;;
255         }
256         { .mmi
257           ld8 r2 = [r2]
258           ld8 r16 = [r16]
259           mov loc0 = b0
260           ;;
261         }
262         { .mii
263           ld8 out1 = [out1]
264           cmp.ne p7, p0 = r0, r16
265           sub r3 = r3, r2
266           ;;
267         }
268         { .mmi
269           st8 [out1] = r3 
270 (p7)      ld8 r18 = [r16], 8
271           mov loc1 = gp
272           ;;
273         }
274         { .mfb
275           ld8 out0 = [out0]  
276         }
277         { .mib
278 (p7)      ld8 gp = [r16]
279 (p7)      mov b6 = r18
280 (p7)      br.call.sptk.many b0 = b6
281         }
282         { .mii
283           mov gp = loc1
284           mov b0 = loc0
285           mov ar.pfs = loc2
286         }
287         { .bbb
288           br.ret.sptk.many b0
289           ;;
290         }
291         .endp   __do_frame_setup#
292
293 #ifdef SHARED
294 .weak __cxa_finalize#
295 #endif
296 .weak __deregister_frame_info#
297 .weak __register_frame_info#