OSDN Git Service

* configure.in (ia64-linux) [tmake_file]: Add ia64/t-glibc.
[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 .sdata
30         .type dtor_ptr#,@object
31         .size dtor_ptr#,8
32 dtor_ptr:
33         data8   __DTOR_LIST__# + 8
34
35 #ifndef SHARED
36         .type __ia64_app_header#,@object
37         .size __ia64_app_header#,8
38         .global __ia64_app_header
39 __ia64_app_header:
40         data8   @segrel(.Lsegrel_ref#)
41 #endif
42
43         /* A handle for __cxa_finalize to manage c++ local destructors.  */
44         .global __dso_handle#
45         .type __dso_handle#,@object
46         .size __dso_handle#,8
47 #ifdef SHARED
48         .section .data
49 __dso_handle:
50         data8   __dso_handle#
51 #else
52         .section .bss
53 __dso_handle:
54         data8   0
55 #endif
56         .hidden __dso_handle#
57
58
59 /*
60  * Fragment of the ELF _fini routine that invokes our dtor cleanup.
61  *
62  * We make the call by indirection, because in large programs the 
63  * .fini and .init sections are not in range of the destination, and
64  * we cannot allow the linker to insert a stub at the end of this
65  * fragment of the _fini function.  Further, Itanium does not implement
66  * the long branch instructions, and we do not wish every program to
67  * trap to the kernel for emulation.
68  *
69  * Note that we require __do_global_dtors_aux to preserve the GP,
70  * so that the next fragment in .fini gets the right value.
71  */
72 .section .fini,"ax","progbits"
73         { .mlx
74           movl r2 = @gprel(__do_global_dtors_aux#)
75           ;;
76         }
77         { .mii
78           nop.m 0
79           add r2 = r2, gp
80           ;;
81           mov b6 = r2
82         }
83         { .bbb
84           br.call.sptk.many b0 = b6
85           ;;
86         }
87
88 #ifndef SHARED
89 /*
90  * Fragment of the ELF _init routine that sets up __ia64_app_header
91  */
92
93 .section .init,"ax","progbits"
94 .Lsegrel_ref:
95         { .mmi
96           addl r2 = @gprel(__ia64_app_header), gp
97           mov r16 = ip
98           ;;
99         }
100         { .mmi
101           ld8 r3 = [r2]
102           ;;
103           sub r16 = r16, r3
104           ;;
105         }
106         { .mfb
107           st8 [r2] = r16
108         }
109 #endif
110
111 .section .text
112         .align  16
113         .proc   __do_global_dtors_aux#
114 __do_global_dtors_aux:
115 #ifndef SHARED
116         { .mii
117           alloc loc3 = ar.pfs, 0, 4, 1, 0
118           addl loc0 = @gprel(dtor_ptr#), gp
119           mov loc1 = b0
120         }
121         { .mib
122           mov loc2 = gp
123           br.sptk.few 1f
124           ;;
125         }
126 #else
127         /*
128                 if (__cxa_finalize)
129                   __cxa_finalize(__dso_handle)
130         */
131         { .mii
132           alloc loc3 = ar.pfs, 0, 4, 1, 0
133           addl loc0 = @gprel(dtor_ptr#), gp
134           addl r16 = @ltoff(@fptr(__cxa_finalize#)), gp
135           ;;
136         }
137         { .mmi
138           ld8 r16 = [r16]
139           ;;
140           addl out0 = @ltoff(__dso_handle#), gp
141           cmp.ne p7, p0 = r0, r16
142           ;;
143         }
144         { .mmi
145           ld8 out0 = [out0]
146 (p7)      ld8 r18 = [r16], 8
147           mov loc1 = b0
148           ;;
149         }
150         { .mfi
151           mov loc2 = gp
152 (p7)      mov b6 = r18
153         }
154         {
155           .mfb
156 (p7)      ld8 gp = [r16]
157 (p7)      br.call.sptk.many b0 = b6
158         }
159         { .mfb
160           br.sptk.few 1f
161         }
162 #endif
163         /*
164                 do {
165                   dtor_ptr++;
166                   (*(dtor_ptr-1)) ();
167                 } while (dtor_ptr);
168         */
169 0:
170         { .mmi
171           st8 [loc0] = r15
172           ld8 r17 = [r16], 8
173           ;;
174         }
175         { .mib
176           ld8 gp = [r16]
177           mov b6 = r17
178           br.call.sptk.many b0 = b6
179         }
180 1:
181         { .mmi
182           ld8 r15 = [loc0]
183           ;;
184           ld8 r16 = [r15], 8
185           ;;
186         }
187         { .mfb
188           cmp.ne p6, p0 = r0, r16
189 (p6)      br.cond.sptk.few 0b
190         }
191         { .mii
192           mov gp = loc2
193           mov b0 = loc1
194           mov ar.pfs = loc3
195         }
196         { .bbb
197           br.ret.sptk.many b0
198           ;;
199         }
200         .endp   __do_global_dtors_aux#
201
202 #ifdef SHARED
203 .weak __cxa_finalize#
204 #endif