OSDN Git Service

4cc868d8a991534722fb5dbc11f661fe8116247c
[pf3gnuchains/gcc-fork.git] / gcc / config / alpha / crtbegin.asm
1  # Copyright (C) 1996, 1998 Free Software Foundation, Inc.
2  #  Contributed by Richard Henderson (rth@tamu.edu)
3  #
4  # This file is free software; you can redistribute it and/or modify it
5  # under the terms of the GNU General Public License as published by the
6  # Free Software Foundation; either version 2, or (at your option) any
7  # later version.
8  # 
9  # In addition to the permissions in the GNU General Public License, the
10  # Free Software Foundation gives you unlimited permission to link the
11  # compiled version of this file with other programs, and to distribute
12  # those programs without any restriction coming from the use of this
13  # file.  (The General Public License restrictions do apply in other
14  # respects; for example, they cover modification of the file, and
15  # distribution when not linked into another program.)
16  # 
17  # This file is distributed in the hope that it will be useful, but
18  # WITHOUT ANY WARRANTY; without even the implied warranty of
19  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  # General Public License for more details.
21  # 
22  # You should have received a copy of the GNU General Public License
23  # along with this program; see the file COPYING.  If not, write to
24  # the Free Software Foundation, 59 Temple Place - Suite 330,
25  # Boston, MA 02111-1307, USA.
26  # 
27  #    As a special exception, if you link this library with files
28  #    compiled with GCC to produce an executable, this does not cause
29  #    the resulting executable to be covered by the GNU General Public License.
30  #    This exception does not however invalidate any other reasons why
31  #    the executable file might be covered by the GNU General Public License.
32
33  #
34  # Heads of the constructor/destructor lists.
35  #
36
37  # The __*TOR_LIST__ symbols are not global because when this file is used
38  # in a shared library, we do not want the symbol to fall over to the
39  # application's lists.
40
41 .section .ctors,"aw"
42
43         .align 3
44 __CTOR_LIST__:
45         .quad -1
46
47 .section .dtors,"aw"
48
49         .align 3
50 __DTOR_LIST__:
51         .quad -1
52
53 .section .eh_frame,"aw"
54 __EH_FRAME_BEGIN__:
55
56  #
57  # Fragment of the ELF _fini routine that invokes our dtor cleanup.
58  #
59
60 .section .fini,"ax"
61
62         # Since the bits of the _fini function are spread across many
63         # object files, each potentially with its own GP, we must
64         # assume we need to load ours.  Further, our .fini section
65         # can easily be more than 4MB away from our .text bits so we
66         # can't use bsr.
67
68         br      $29,1f
69 1:      ldgp    $29,0($29)
70         jsr     $26,__do_global_dtors_aux
71
72         # Must match the alignment we got from crti.o else we get
73         # zero-filled holes in our _fini function and then SIGILL.
74         .align 3
75
76  #
77  # Fragment of the ELF _init routine that sets up the frame info.
78  #
79
80 .section .init,"ax"
81        br      $29,1f
82 1:     ldgp    $29,0($29)
83        jsr     $26,__do_frame_setup
84        .align 3
85
86  #
87  # Invoke our destructors in order.
88  #
89
90 .section .sdata
91
92  # Support recursive calls to exit.
93         .type dtor_ptr,@object
94         .size dtor_ptr,8
95 dtor_ptr:
96         .quad   __DTOR_LIST__ + 8
97
98  # A globally unique widget for c++ local destructors to hang off.
99         .global __dso_handle
100         .type __dso_handle,@object
101         .size __dso_handle,8
102 #ifdef SHARED
103 .section .data
104         .align 3
105 __dso_handle:
106         .quad   __dso_handle
107 #else
108 .section .bss
109         .align 3
110 __dso_handle:
111         .zero 8
112 #endif
113
114 .text
115
116         .align 3
117         .ent __do_global_dtors_aux
118
119 __do_global_dtors_aux:
120         ldgp    $29,0($27)
121         lda     $30,-16($30)
122         .frame  $30,16,$26,0
123         stq     $9,8($30)
124         stq     $26,0($30)
125         .mask   0x4000200,-16
126         .prologue 1
127
128 #ifdef SHARED
129         # Do c++ local destructors.
130         lda     $1,__cxa_finalize
131         beq     $1,0f
132         lda     $16,__dso_handle
133         jsr     $26,__cxa_finalize
134         ldgp    $29,0($26)
135 #endif
136
137 0:      lda     $9,dtor_ptr
138         br      2f
139 1:      stq     $1,0($9)
140         jsr     $26,($27)
141         ldgp    $29,0($26)
142 2:      ldq     $1,0($9)
143         ldq     $27,0($1)
144         addq    $1,8,$1
145         bne     $27,1b
146
147         # Remove our frame info.
148         lda     $1,__deregister_frame_info
149         beq     $1,3f
150         lda     $16,__EH_FRAME_BEGIN__
151         jsr     $26,__deregister_frame_info
152         ldgp    $29,0($26)
153
154 3:      ldq     $26,0($30)
155         ldq     $9,8($30)
156         lda     $30,16($30)
157         ret
158
159         .end __do_global_dtors_aux
160
161  #
162  # Install our frame info.
163  #
164
165  # ??? How can we rationally keep this size correct?
166
167 .section .bss
168         .type frame_object,@object
169         .size frame_object, 48
170         .align 3
171 frame_object:
172         .zero 48
173
174 .text 
175
176         .align 3
177         .ent __do_frame_setup
178
179 __do_frame_setup:
180         ldgp    $29,0($27)
181         lda     $30,-16($30)
182         .frame  $30,16,$26,0
183         stq     $26,0($30)
184         .mask   0x4000000,-16
185         .prologue 1
186
187         lda     $1,__register_frame_info
188         beq     $1,0f
189         lda     $16,__EH_FRAME_BEGIN__
190         lda     $17,frame_object
191         jsr     $26,__register_frame_info
192         ldgp    $29,0($26)
193
194         ldq     $26,0($30)
195 0:      lda     $30,16($30)
196         ret
197
198         .end __do_frame_setup
199
200 .weak __register_frame_info
201 .weak __deregister_frame_info
202 #ifdef SHARED
203 .weak __cxa_finalize
204 #endif