Clean import of gcc-core-4.1.2.tar.bz2
[delight.git] / gcc-4.1.2 / gcc / config / ia64 / crtend.asm
blob66eaa01b5017e1004675872d1cd3456367591e1b
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)
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 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"
31 .align 8
32 __CTOR_END__:
33 data8 0
35 .section .dtors,"aw","progbits"
36 .align 8
37 __DTOR_END__:
38 data8 0
40 .section .jcr,"aw","progbits"
41 .align 8
42 __JCR_END__:
43 data8 0
45 #ifdef HAVE_INITFINI_ARRAY
46 .global __do_global_ctors_aux
47 .hidden __do_global_ctors_aux
48 #else /* !HAVE_INITFINI_ARRAY */
50 * Fragment of the ELF _init routine that invokes our dtor cleanup.
52 * We make the call by indirection, because in large programs the
53 * .fini and .init sections are not in range of the destination, and
54 * we cannot allow the linker to insert a stub at the end of this
55 * fragment of the _fini function. Further, Itanium does not implement
56 * the long branch instructions, and we do not wish every program to
57 * trap to the kernel for emulation.
59 * Note that we require __do_global_ctors_aux to preserve the GP,
60 * so that the next fragment in .fini gets the right value.
62 .section .init,"ax","progbits"
63 { .mlx
64 movl r2 = @pcrel(__do_global_ctors_aux - 16)
66 { .mii
67 mov r3 = ip
69 add r2 = r2, r3
72 { .mib
73 mov b6 = r2
74 br.call.sptk.many b0 = b6
77 #endif /* !HAVE_INITFINI_ARRAY */
79 .text
80 .align 32
81 .proc __do_global_ctors_aux
82 __do_global_ctors_aux:
83 .prologue
85 for (loc0 = __CTOR_END__-1; *p != -1; --p)
86 (*p) ();
88 .save ar.pfs, r34
89 alloc loc2 = ar.pfs, 0, 5, 0, 0
90 movl loc0 = @gprel(__CTOR_END__ - 8)
93 add loc0 = loc0, gp
95 ld8 loc3 = [loc0], -8
96 .save rp, loc1
97 mov loc1 = rp
98 .body
101 cmp.eq p6, p0 = -1, loc3
102 mov loc4 = gp
103 (p6) br.cond.spnt.few .exit
105 .loop: ld8 r15 = [loc3], 8
107 ld8 gp = [loc3]
108 mov b6 = r15
110 ld8 loc3 = [loc0], -8
111 nop 0
112 br.call.sptk.many rp = b6
115 cmp.ne p6, p0 = -1, loc3
116 nop 0
117 (p6) br.cond.sptk.few .loop
119 .exit: mov gp = loc3
120 mov rp = loc1
121 mov ar.pfs = loc2
123 br.ret.sptk.many rp
124 .endp __do_global_ctors_aux