1 /* Copyright (C) 2000-2024 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"
38 .type dtor_ptr,@object
41 data8 @gprel(__DTOR_LIST__ + 8)
43 /* A handle for __cxa_finalize to manage c++ local destructors. */
45 .type __dso_handle,@object
60 #if HAVE_INITFINI_ARRAY_SUPPORT
62 .section .fini_array, "a"
63 data8 @fptr(__do_global_dtors_aux)
65 .section .init_array, "a"
66 data8 @fptr(__do_global_ctors_aux)
68 #else /* !HAVE_INITFINI_ARRAY_SUPPORT */
70 * Fragment of the ELF _fini routine that invokes our dtor cleanup.
72 * We make the call by indirection, because in large programs the
73 * .fini and .init sections are not in range of the destination, and
74 * we cannot allow the linker to insert a stub at the end of this
75 * fragment of the _fini function. Further, Itanium does not implement
76 * the long branch instructions, and we do not wish every program to
77 * trap to the kernel for emulation.
79 * Note that we require __do_global_dtors_aux to preserve the GP,
80 * so that the next fragment in .fini gets the right value.
82 .section .fini,"ax","progbits"
84 movl r2 = @pcrel(__do_global_dtors_aux - 16)
95 br.call.sptk.many b0 = b6
97 #endif /* !HAVE_INITFINI_ARRAY_SUPPORT */
101 .proc __do_global_dtors_aux
102 __do_global_dtors_aux:
106 alloc loc3 = ar.pfs, 0, 4, 1, 0
107 addl loc0 = @gprel(dtor_ptr), gp
118 __cxa_finalize(__dso_handle)
121 alloc loc3 = ar.pfs, 0, 4, 1, 0
122 addl loc0 = @gprel(dtor_ptr), gp
123 addl r16 = @ltoff(@fptr(__cxa_finalize)), gp
128 addl out0 = @ltoff(__dso_handle), gp
129 cmp.ne p7, p0 = r0, r16
133 (p7) ld8 r18 = [r16], 8
145 (p7) br.call.sptk.many rp = b6
159 st8 [loc0] = r15 // update dtor_ptr (in memory)
160 ld8 r17 = [r16], 8 // r17 <- dtor's entry-point
164 ld8 gp = [r16] // gp <- dtor's gp
166 br.call.sptk.many rp = b6
168 .entry: ld8 r15 = [loc0] // r15 <- dtor_ptr (gp-relative)
170 add r16 = r15, loc2 // r16 <- dtor_ptr (absolute)
174 ld8 r16 = [r16] // r16 <- pointer to dtor's fdesc
179 cmp.ne p6, p0 = r0, r16
180 (p6) br.cond.sptk.few .loop
182 .endp __do_global_dtors_aux
187 .weak _Jv_RegisterClasses