1 /* Copyright
(C
) 2000, 2001, 2003, 2005 Free Software Foundation
, Inc.
2 Contributed by Jes Sorensen
, <Jes.Sorensen
@cern.
ch>
4 This file is part of GCC.
6 GCC is free software
; you can redistribute it and/or modify
7 it under the terms of the GNU General
Public License as published by
8 the Free Software Foundation
; either version 2, or (at your option)
11 GCC is distributed
in the hope that it will be useful
,
12 but WITHOUT ANY WARRANTY
; without even the implied warranty of
13 MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General
Public License for more details.
16 You should have received a copy of the GNU General
Public License
17 along with GCC
; see the file COPYING. If not, write to
18 the Free Software Foundation
, 51 Franklin Street
, Fifth Floor
,
19 Boston
, MA
02110-1301, USA.
*/
21 /* As a special exception
, if you link
this library with other files
,
22 some of which are compiled with GCC
, to produce an executable
,
23 this library does
not by itself cause the resulting executable
24 to be covered by the GNU General
Public License.
25 This exception does
not however invalidate any other reasons why
26 the executable file might be covered by the GNU General
Public License.
*/
28 #
include "auto-host.h"
30 .
section .ctors
,"aw","progbits"
35 .
section .dtors
,"aw","progbits"
40 .
section .jcr
,"aw","progbits"
45 .
type dtor_ptr
,@object
48 data8
@gprel(__DTOR_LIST__
+ 8)
50 /* A handle for __cxa_finalize to manage c
++ local destructors.
*/
52 .
type __dso_handle
,@object
67 #ifdef HAVE_INITFINI_ARRAY
69 .
section .fini_array
, "a"
70 data8
@fptr(__do_global_dtors_aux
)
72 .
section .init_array
, "a"
73 data8
@fptr(__do_jv_register_classes
)
74 data8
@fptr(__do_global_ctors_aux
)
76 #else
/* !HAVE_INITFINI_ARRAY
*/
78 * Fragment of the ELF _fini routine that invokes our dtor cleanup.
80 * We make the
call by indirection
, because
in large programs the
81 * .fini
and .init sections are
not in range of the destination
, and
82 * we cannot allow the linker to insert a stub at the
end of
this
83 * fragment of the _fini function. Further
, Itanium does
not implement
84 * the long branch instructions
, and we do
not wish every program to
85 * trap to the kernel for emulation.
87 * Note that we require __do_global_dtors_aux to preserve the GP
,
88 * so that the next fragment
in .fini gets the right value.
90 .
section .fini
,"ax","progbits"
92 movl r2 = @pcrel(__do_global_dtors_aux - 16)
103 br.call.sptk.many b0 = b6
106 /* Likewise for _init.
*/
108 .
section .init
,"ax","progbits"
110 movl r2 = @pcrel(__do_jv_register_classes - 16)
121 br.call.sptk.many b0 = b6
123 #endif
/* !HAVE_INITFINI_ARRAY
*/
127 .
proc __do_global_dtors_aux
128 __do_global_dtors_aux:
132 alloc loc3
= ar.pfs
, 0, 4, 1, 0
133 addl loc0
= @gprel(dtor_ptr
), gp
144 __cxa_finalize
(__dso_handle
)
147 alloc loc3
= ar.pfs
, 0, 4, 1, 0
148 addl loc0
= @gprel(dtor_ptr
), gp
149 addl r16
= @ltoff(@fptr(__cxa_finalize
)), gp
154 addl out0
= @ltoff(__dso_handle
), gp
155 cmp.ne p7
, p0
= r0
, r16
159 (p7
) ld8 r18
= [r16
], 8
171 (p7
) br.
call.sptk.many rp
= b6
185 st8
[loc0
] = r15
// update dtor_ptr
(in memory
)
186 ld8 r17
= [r16
], 8 // r17
<- dtor
's entry-point
190 ld8 gp = [r16] // gp <- dtor's gp
192 br.
call.sptk.many rp
= b6
194 .
entry: ld8 r15
= [loc0
] // r15
<- dtor_ptr
(gp
-relative
)
196 add r16
= r15
, loc2
// r16
<- dtor_ptr
(absolute
)
200 ld8 r16
= [r16
] // r16
<- pointer to dtor
's fdesc
205 cmp.ne p6, p0 = r0, r16
206 (p6) br.cond.sptk.few .loop
208 .endp __do_global_dtors_aux
211 .proc __do_jv_register_classes
212 __do_jv_register_classes:
215 alloc loc1 = ar.pfs, 0, 3, 1, 0
216 movl out0 = @gprel(__JCR_LIST__)
219 addl r14 = @ltoff(@fptr(_Jv_RegisterClasses)), gp
228 cmp.ne p6, p0 = r0, r0
231 cmp.eq.or p6, p0 = r0, r14
232 cmp.eq.or p6, p0 = r0, r15
233 (p6) br.ret.sptk.many rp
242 br.call.sptk.many rp = b6
252 .endp __do_jv_register_classes
257 .weak _Jv_RegisterClasses