Small ChangeLog tweak.
[official-gcc.git] / libgcc / config / ia64 / crtend.S
blob019297b80d091867f28dd9b4c6822a73b9a95de6
1 /* Copyright (C) 2000-2017 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)
9    any later version.
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"
28         .align  8
29 __CTOR_END__:
30         data8   0
32 .section .dtors,"aw","progbits"
33         .align 8
34 __DTOR_END__:
35         data8   0
37 #if HAVE_INITFINI_ARRAY_SUPPORT
38         .global __do_global_ctors_aux
39         .hidden __do_global_ctors_aux
40 #else /* !HAVE_INITFINI_ARRAY_SUPPORT */
42  * Fragment of the ELF _init routine that invokes our dtor cleanup.
43  *
44  * We make the call by indirection, because in large programs the 
45  * .fini and .init sections are not in range of the destination, and
46  * we cannot allow the linker to insert a stub at the end of this
47  * fragment of the _fini function.  Further, Itanium does not implement
48  * the long branch instructions, and we do not wish every program to
49  * trap to the kernel for emulation.
50  *
51  * Note that we require __do_global_ctors_aux to preserve the GP,
52  * so that the next fragment in .fini gets the right value.
53  */
54 .section .init,"ax","progbits"
55         { .mlx
56           movl r2 = @pcrel(__do_global_ctors_aux - 16)
57         }
58         { .mii
59           mov r3 = ip
60           ;;
61           add r2 = r2, r3
62           ;;
63         }
64         { .mib
65           mov b6 = r2
66           br.call.sptk.many b0 = b6
67           ;;
68         }
69 #endif /* !HAVE_INITFINI_ARRAY_SUPPORT */
71 .text
72         .align 32
73         .proc __do_global_ctors_aux
74 __do_global_ctors_aux:
75         .prologue
76         /*
77                 for (loc0 = __CTOR_END__-1; *p != -1; --p)
78                   (*p) ();
79         */
80         .save ar.pfs, r34
81         alloc loc2 = ar.pfs, 0, 5, 0, 0
82         movl loc0 = @gprel(__CTOR_END__ - 8)
83         ;;
85         add loc0 = loc0, gp
86         ;;
87         ld8 loc3 = [loc0], -8
88         .save rp, loc1
89         mov loc1 = rp
90         .body
91         ;;
93         cmp.eq p6, p0 = -1, loc3
94         mov loc4 = gp
95 (p6)    br.cond.spnt.few .exit
97 .loop:  ld8 r15 = [loc3], 8
98         ;;
99         ld8 gp = [loc3]
100         mov b6 = r15
102         ld8 loc3 = [loc0], -8
103         nop 0
104         br.call.sptk.many rp = b6
105         ;;
107         cmp.ne p6, p0 = -1, loc3
108         nop 0
109 (p6)    br.cond.sptk.few .loop
111 .exit:  mov gp = loc3
112         mov rp = loc1
113         mov ar.pfs = loc2
115         br.ret.sptk.many rp
116         .endp __do_global_ctors_aux