OSDN Git Service

* config/i386/i386.c (ix86_expand_setcc): Don't use method 0
[pf3gnuchains/gcc-fork.git] / gcc / config / alpha / crtbegin.asm
1 /*
2  * Copyright (C) 1996, 1998, 2000 Free Software Foundation, Inc.
3  *  Contributed by Richard Henderson (rth@tamu.edu)
4  *
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.)
17  * 
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.
22  * 
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.
27  * 
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.
33  */
34
35 #include "auto-host.h"
36
37
38 /*
39  * Heads of the constructor/destructor lists.
40  */
41
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.  */
45
46 .section .ctors,"aw"
47
48         .align 3
49 __CTOR_LIST__:
50         .quad -1
51
52 .section .dtors,"aw"
53
54         .align 3
55 __DTOR_LIST__:
56         .quad -1
57
58 .section .eh_frame,"aw"
59 __EH_FRAME_BEGIN__:
60
61 /*
62  * Fragment of the ELF _fini routine that invokes our dtor cleanup.
63  */
64
65 .section .fini,"ax"
66
67         /* Since the bits of the _fini function are spread across many
68            object files, each potentially with its own GP, we must
69            assume we need to load ours.  Further, our .fini section
70            can easily be more than 4MB away from our .text bits so we
71            can't use bsr.  */
72
73         br      $29,1f
74 1:      ldgp    $29,0($29)
75         jsr     $26,__do_global_dtors_aux
76
77         /* Must match the alignment we got from crti.o else we get
78            zero-filled holes in our _fini function and then SIGILL.  */
79         .align 3
80
81 /*
82  * Fragment of the ELF _init routine that sets up the frame info.
83  */
84
85 .section .init,"ax"
86        br      $29,1f
87 1:     ldgp    $29,0($29)
88        jsr     $26,__do_frame_setup
89        .align 3
90
91 /*
92  * Invoke our destructors in order.
93  */
94
95 .section .sdata
96
97 /* Support recursive calls to exit.  */
98         .type dtor_ptr,@object
99         .size dtor_ptr,8
100 dtor_ptr:
101         .quad   __DTOR_LIST__ + 8
102
103 /* A globally unique widget for c++ local destructors to hang off.
104
105    This has a unique value in every dso; in the main program its
106    value is zero.  The object should be protected.  This means the
107    instance in any dso or the main program is not used in any other
108    dso.  The dynamic linker takes care of this.  */
109  
110         .global __dso_handle
111         .type __dso_handle,@object
112         .size __dso_handle,8
113 #ifdef SHARED
114 .section .data
115         .align 3
116 __dso_handle:
117         .quad   __dso_handle
118 #else
119 .section .bss
120         .align 3
121 __dso_handle:
122         .zero 8
123 #endif
124 #ifdef HAVE_GAS_HIDDEN
125         .hidden __dso_handle
126 #endif
127
128 .text
129
130         .align 3
131         .ent __do_global_dtors_aux
132
133 __do_global_dtors_aux:
134         ldgp    $29,0($27)
135         lda     $30,-16($30)
136         .frame  $30,16,$26,0
137         stq     $9,8($30)
138         stq     $26,0($30)
139         .mask   0x4000200,-16
140         .prologue 1
141
142 #ifdef SHARED
143         /* Do c++ local destructors.  */
144         lda     $1,__cxa_finalize
145         beq     $1,0f
146         lda     $16,__dso_handle
147         jsr     $26,__cxa_finalize
148         ldgp    $29,0($26)
149 #endif
150
151 0:      lda     $9,dtor_ptr
152         br      2f
153 1:      stq     $1,0($9)
154         jsr     $26,($27)
155         ldgp    $29,0($26)
156 2:      ldq     $1,0($9)
157         ldq     $27,0($1)
158         addq    $1,8,$1
159         bne     $27,1b
160
161         /* Remove our frame info.  */
162         lda     $1,__deregister_frame_info
163         beq     $1,3f
164         lda     $16,__EH_FRAME_BEGIN__
165         jsr     $26,__deregister_frame_info
166         ldgp    $29,0($26)
167
168 3:      ldq     $26,0($30)
169         ldq     $9,8($30)
170         lda     $30,16($30)
171         ret
172
173         .end __do_global_dtors_aux
174
175 /*
176  * Install our frame info.
177  */
178
179 /* ??? How can we rationally keep this size correct?  */
180
181 .section .bss
182         .type frame_object,@object
183         .size frame_object, 48
184         .align 3
185 frame_object:
186         .zero 48
187
188 .text 
189
190         .align 3
191         .ent __do_frame_setup
192
193 __do_frame_setup:
194         ldgp    $29,0($27)
195         lda     $30,-16($30)
196         .frame  $30,16,$26,0
197         stq     $26,0($30)
198         .mask   0x4000000,-16
199         .prologue 1
200
201         lda     $1,__register_frame_info
202         beq     $1,0f
203         lda     $16,__EH_FRAME_BEGIN__
204         lda     $17,frame_object
205         jsr     $26,__register_frame_info
206         ldgp    $29,0($26)
207
208         ldq     $26,0($30)
209 0:      lda     $30,16($30)
210         ret
211
212         .end __do_frame_setup
213
214 .weak __register_frame_info
215 .weak __deregister_frame_info
216 #ifdef SHARED
217 .weak __cxa_finalize
218 #endif