OSDN Git Service

2004-09-16 Frank Ch. Eigler <fche@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / config / ia64 / crtend.asm
1 /* Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
2    Contributed by Jes Sorensen, <Jes.Sorensen@cern.ch>
3
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public License as
6    published by the Free Software Foundation; either version 2 of the
7    License, or (at your option) any later version.
8
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13
14    You should have received a copy of the GNU Library General Public
15    License along with the GNU C Library; see the file COPYING.LIB.  If not,
16    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17    Boston, MA 02111-1307, USA.  */
18
19 #include "auto-host.h"
20
21 .section .ctors,"aw","progbits"
22         .align  8
23 __CTOR_END__:
24         data8   0
25
26 .section .dtors,"aw","progbits"
27         .align 8
28 __DTOR_END__:
29         data8   0
30
31 .section .jcr,"aw","progbits"
32         .align 8
33 __JCR_END__:
34         data8   0
35
36 #ifdef HAVE_INITFINI_ARRAY
37         .global __do_global_ctors_aux
38         .hidden __do_global_ctors_aux
39 #else /* !HAVE_INITFINI_ARRAY */
40 /*
41  * Fragment of the ELF _init routine that invokes our dtor cleanup.
42  *
43  * We make the call by indirection, because in large programs the 
44  * .fini and .init sections are not in range of the destination, and
45  * we cannot allow the linker to insert a stub at the end of this
46  * fragment of the _fini function.  Further, Itanium does not implement
47  * the long branch instructions, and we do not wish every program to
48  * trap to the kernel for emulation.
49  *
50  * Note that we require __do_global_ctors_aux to preserve the GP,
51  * so that the next fragment in .fini gets the right value.
52  */
53 .section .init,"ax","progbits"
54         { .mlx
55           movl r2 = @pcrel(__do_global_ctors_aux - 16)
56         }
57         { .mii
58           mov r3 = ip
59           ;;
60           add r2 = r2, r3
61           ;;
62         }
63         { .mib
64           mov b6 = r2
65           br.call.sptk.many b0 = b6
66           ;;
67         }
68 #endif /* !HAVE_INITFINI_ARRAY */
69
70 .text
71         .align 32
72         .proc __do_global_ctors_aux
73 __do_global_ctors_aux:
74         .prologue
75         /*
76                 for (loc0 = __CTOR_END__-1; *p != -1; --p)
77                   (*p) ();
78         */
79         .save ar.pfs, r34
80         alloc loc2 = ar.pfs, 0, 5, 0, 0
81         movl loc0 = @gprel(__CTOR_END__ - 8)
82         ;;
83
84         add loc0 = loc0, gp
85         ;;
86         ld8 loc3 = [loc0], -8
87         .save rp, loc1
88         mov loc1 = rp
89         .body
90         ;;
91
92         cmp.eq p6, p0 = -1, loc3
93         mov loc4 = gp
94 (p6)    br.cond.spnt.few .exit
95
96 .loop:  ld8 r15 = [loc3], 8
97         ;;
98         ld8 gp = [loc3]
99         mov b6 = r15
100
101         ld8 loc3 = [loc0], -8
102         nop 0
103         br.call.sptk.many rp = b6
104         ;;
105
106         cmp.ne p6, p0 = -1, loc3
107         nop 0
108 (p6)    br.cond.sptk.few .loop
109
110 .exit:  mov gp = loc3
111         mov rp = loc1
112         mov ar.pfs = loc2
113
114         br.ret.sptk.many rp
115         .endp __do_global_ctors_aux