1 /* Copyright (C) 2000, 2001, 2003, 2005, 2009 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 3, 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 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 #include "auto-host.h"
27 .section .ctors,"aw","progbits"
32 .section .dtors,"aw","progbits"
37 .section .jcr,"aw","progbits"
42 .type dtor_ptr,@object
45 data8 @gprel(__DTOR_LIST__ + 8)
47 /* A handle for __cxa_finalize to manage c++ local destructors. */
49 .type __dso_handle,@object
64 #ifdef HAVE_INITFINI_ARRAY
66 .section .fini_array, "a"
67 data8 @fptr(__do_global_dtors_aux)
69 .section .init_array, "a"
70 data8 @fptr(__do_jv_register_classes)
71 data8 @fptr(__do_global_ctors_aux)
73 #else /* !HAVE_INITFINI_ARRAY */
75 * Fragment of the ELF _fini routine that invokes our dtor cleanup.
77 * We make the call by indirection, because in large programs the
78 * .fini and .init sections are not in range of the destination, and
79 * we cannot allow the linker to insert a stub at the end of this
80 * fragment of the _fini function. Further, Itanium does not implement
81 * the long branch instructions, and we do not wish every program to
82 * trap to the kernel for emulation.
84 * Note that we require __do_global_dtors_aux to preserve the GP,
85 * so that the next fragment in .fini gets the right value.
87 .section .fini,"ax","progbits"
89 movl r2 = @pcrel(__do_global_dtors_aux - 16)
100 br.call.sptk.many b0 = b6
103 /* Likewise for _init. */
105 .section .init,"ax","progbits"
107 movl r2 = @pcrel(__do_jv_register_classes - 16)
118 br.call.sptk.many b0 = b6
120 #endif /* !HAVE_INITFINI_ARRAY */
124 .proc __do_global_dtors_aux
125 __do_global_dtors_aux:
129 alloc loc3 = ar.pfs, 0, 4, 1, 0
130 addl loc0 = @gprel(dtor_ptr), gp
141 __cxa_finalize(__dso_handle)
144 alloc loc3 = ar.pfs, 0, 4, 1, 0
145 addl loc0 = @gprel(dtor_ptr), gp
146 addl r16 = @ltoff(@fptr(__cxa_finalize)), gp
151 addl out0 = @ltoff(__dso_handle), gp
152 cmp.ne p7, p0 = r0, r16
156 (p7) ld8 r18 = [r16], 8
168 (p7) br.call.sptk.many rp = b6
182 st8 [loc0] = r15 // update dtor_ptr (in memory)
183 ld8 r17 = [r16], 8 // r17 <- dtor's entry-point
187 ld8 gp = [r16] // gp <- dtor's gp
189 br.call.sptk.many rp = b6
191 .entry: ld8 r15 = [loc0] // r15 <- dtor_ptr (gp-relative)
193 add r16 = r15, loc2 // r16 <- dtor_ptr (absolute)
197 ld8 r16 = [r16] // r16 <- pointer to dtor's fdesc
202 cmp.ne p6, p0 = r0, r16
203 (p6) br.cond.sptk.few .loop
205 .endp __do_global_dtors_aux
208 .proc __do_jv_register_classes
209 __do_jv_register_classes:
212 alloc loc1 = ar.pfs, 0, 3, 1, 0
213 movl out0 = @gprel(__JCR_LIST__)
216 addl r14 = @ltoff(@fptr(_Jv_RegisterClasses)), gp
225 cmp.ne p6, p0 = r0, r0
228 cmp.eq.or p6, p0 = r0, r14
229 cmp.eq.or p6, p0 = r0, r15
230 (p6) br.ret.sptk.many rp
239 br.call.sptk.many rp = b6
249 .endp __do_jv_register_classes
254 .weak _Jv_RegisterClasses