Update copyright.
[official-gcc.git] / gcc / config / alpha / crtbegin.asm
blob96725b003b5a8e306d51af9baa16c0a0858dc428
1 /*
2 * Copyright (C) 1996, 1998, 2000 Free Software Foundation, Inc.
3 * Contributed by Richard Henderson (rth@tamu.edu)
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.
9 *
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 this program; see the file COPYING. If not, write to
25 * the Free Software Foundation, 59 Temple Place - Suite 330,
26 * Boston, MA 02111-1307, 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 #include "auto-host.h"
39 * Heads of the constructor/destructor lists.
42 /* The __*TOR_LIST__ symbols are not global because when this file is used
43 in a shared library, we do not want the symbol to fall over to the
44 application's lists. */
46 .section .ctors,"aw"
47 .align 3
48 __CTOR_LIST__:
49 .quad -1
51 .section .dtors,"aw"
52 .align 3
53 __DTOR_LIST__:
54 .quad -1
56 .section .jcr,"aw"
57 .align 3
58 __JCR_LIST__:
60 .section .eh_frame,"aw"
61 __EH_FRAME_BEGIN__:
64 * Fragment of the ELF _fini routine that invokes our dtor cleanup.
67 .section .fini,"ax"
69 /* Since the bits of the _fini function are spread across many
70 object files, each potentially with its own GP, we must
71 assume we need to load ours. Further, our .fini section
72 can easily be more than 4MB away from our .text bits so we
73 can't use bsr. */
75 br $29,1f
76 1: ldgp $29,0($29)
77 jsr $26,__do_global_dtors_aux
79 /* Must match the alignment we got from crti.o else we get
80 zero-filled holes in our _fini function and then SIGILL. */
81 .align 3
84 * Fragment of the ELF _init routine that sets up the frame info.
87 .section .init,"ax"
88 br $29,1f
89 1: ldgp $29,0($29)
90 jsr $26,__do_frame_setup
91 .align 3
94 * Invoke our destructors in order.
97 .section .sdata
99 /* Support recursive calls to exit. */
100 .type dtor_ptr,@object
101 .size dtor_ptr,4
102 dtor_ptr:
103 .gprel32 __DTOR_LIST__ + 8
105 /* A globally unique widget for c++ local destructors to hang off.
107 This has a unique value in every dso; in the main program its
108 value is zero. The object should be protected. This means the
109 instance in any dso or the main program is not used in any other
110 dso. The dynamic linker takes care of this. */
112 .global __dso_handle
113 .type __dso_handle,@object
114 .size __dso_handle,8
115 #ifdef SHARED
116 .section .data
117 .align 3
118 __dso_handle:
119 .quad __dso_handle
120 #else
121 .section .bss
122 .align 3
123 __dso_handle:
124 .zero 8
125 #endif
126 #ifdef HAVE_GAS_HIDDEN
127 .hidden __dso_handle
128 #endif
130 .text
132 .align 3
133 .ent __do_global_dtors_aux
135 __do_global_dtors_aux:
136 ldgp $29,0($27)
137 lda $30,-16($30)
138 .frame $30,16,$26,0
139 stq $9,8($30)
140 stq $26,0($30)
141 .mask 0x4000200,-16
142 .prologue 1
144 #ifdef SHARED
145 /* Do c++ local destructors. */
146 lda $1,__cxa_finalize
147 beq $1,0f
148 lda $16,__dso_handle
149 jsr $26,__cxa_finalize
150 ldgp $29,0($26)
151 #endif
153 0: lda $9,dtor_ptr
154 br 2f
155 1: stl $1,0($9)
156 jsr $26,($27)
157 ldgp $29,0($26)
158 2: ldl $1,0($9)
159 addq $1,$29,$2
160 ldq $27,0($2)
161 addl $1,8,$1
162 bne $27,1b
164 /* Remove our frame info. */
165 lda $1,__deregister_frame_info
166 beq $1,3f
167 lda $16,__EH_FRAME_BEGIN__
168 jsr $26,__deregister_frame_info
169 ldgp $29,0($26)
171 3: ldq $26,0($30)
172 ldq $9,8($30)
173 lda $30,16($30)
176 .end __do_global_dtors_aux
179 * Install our frame info; register java classes, if any.
182 .section .bss
183 .type frame_object,@object
184 .size frame_object, 48
185 .align 3
186 frame_object:
187 .zero 48
189 .text
191 .align 3
192 .ent __do_frame_setup
194 __do_frame_setup:
195 ldgp $29,0($27)
196 lda $30,-16($30)
197 .frame $30,16,$26,0
198 stq $26,0($30)
199 .mask 0x4000000,-16
200 .prologue 1
202 lda $1,__register_frame_info
203 beq $1,0f
204 lda $16,__EH_FRAME_BEGIN__
205 lda $17,frame_object
206 jsr $26,__register_frame_info
207 ldgp $29,0($26)
209 0: lda $1,_Jv_RegisterClasses
210 lda $16,__JCR_LIST__
211 beq $1,0f
212 ldq $2,8($16)
213 beq $2,0f
214 jsr $26,_Jv_RegisterClasses
215 ldgp $29,0($26)
217 0: ldq $26,0($30)
218 lda $30,16($30)
221 .end __do_frame_setup
223 .weak __register_frame_info
224 .weak __deregister_frame_info
225 #ifdef SHARED
226 .weak __cxa_finalize
227 #endif
228 .weak _Jv_RegisterClasses