OSDN Git Service

07b71ea5c10db5cc16f13f369fe20b4d887ccc93
[pf3gnuchains/gcc-fork.git] / gcc / config / ia64 / crtend.asm
1 /* Copyright (C) 2000 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 .section .ctors,"aw","progbits"
20         .align  8
21 __CTOR_END__:
22         data8   0
23
24 .section .dtors,"aw","progbits"
25         .align 8
26 __DTOR_END__:
27         data8   0
28
29 .section .IA_64.unwind
30 __EH_FRAME_END__:
31
32 /*
33  * Fragment of the ELF _init routine that invokes our dtor cleanup.
34  *
35  * We make the call by indirection, because in large programs the 
36  * .fini and .init sections are not in range of the destination, and
37  * we cannot allow the linker to insert a stub at the end of this
38  * fragment of the _fini function.  Further, Itanium does not implement
39  * the long branch instructions, and we do not wish every program to
40  * trap to the kernel for emulation.
41  *
42  * Note that we require __do_global_ctors_aux to preserve the GP,
43  * so that the next fragment in .fini gets the right value.
44  */
45 .section .init,"ax","progbits"
46         { .mlx
47           movl r2 = @gprel(__do_global_ctors_aux#)
48           ;;
49         }
50         { .mii
51           nop.m 0
52           add r2 = r2, gp
53           ;;
54           mov b6 = r2
55         }
56         { .bbb
57           br.call.sptk.many b0 = b6
58           ;;
59         }
60
61 .text
62         .align 16
63         .proc __do_global_ctors_aux#
64 __do_global_ctors_aux:
65         /*
66                 for (loc0 = __CTOR_END__-1; *p != -1; --p)
67                   (*p) ();
68         */
69         { .mii
70           alloc loc4 = ar.pfs, 0, 5, 0, 0
71           addl loc0 = @ltoff(__CTOR_END__# - 8), gp
72           mov loc1 = b0
73           ;;
74         }
75         { .mmi
76           ld8 loc0 = [loc0]
77           ;;
78           ld8 loc3 = [loc0], -8
79           mov loc2 = gp
80           ;;
81         }
82         { .mfb
83           cmp.eq p6, p0 = -1, loc3
84 (p6)      br.cond.spnt.few 2f
85         }
86 0:
87         { .mmi
88           ld8 r15 = [loc3], 8
89           ;;
90           ld8 gp = [loc3]
91           mov b6 = r15
92         }
93         { .mfb
94           ld8 loc3 = [loc0], -8
95           br.call.sptk.many b0 = b6
96           ;;
97         }
98         { .mfb
99           cmp.ne p6, p0 = -1, loc3
100 (p6)      br.cond.sptk.few 0b
101         }
102 2:
103         { .mii
104           mov gp = loc2
105           mov b0 = loc1
106           mov ar.pfs = loc4
107         }
108         { .bbb
109           br.ret.sptk.many b0
110           ;;
111         }
112         .endp __do_global_ctors_aux#
113
114 .section .init,"ax","progbits"
115         { .mlx
116           movl r2 = @gprel(__do_frame_setup_aux#)
117           ;;
118         }
119         { .mii
120           nop.m 0
121           add r2 = r2, gp
122           ;;
123           mov b6 = r2
124         }
125         { .bbb
126           br.call.sptk.many b0 = b6
127           ;;
128         }
129
130 .text
131         .align 16
132         .proc   __do_frame_setup_aux#
133 __do_frame_setup_aux:
134         /*
135                 if (__register_frame_info_aux)
136                   __register_frame_info_aux(__EH_FRAME_END__)
137         */
138         alloc loc0 = ar.pfs, 0, 3, 1, 0
139         addl r14 = @ltoff(@fptr(__register_frame_info_aux#)), gp
140         mov loc1 = b0
141         ;;
142         ld8 r15 = [r14]
143         addl r16 = @ltoff(__EH_FRAME_END__#), gp
144         mov loc2 = gp
145         ;;
146         cmp.eq p6, p7 = 0, r15
147         (p6) br.cond.dptk 1f
148         ld8 r8 = [r15], 8
149         ld8 out0 = [r16]
150         ;;
151         ld8 gp = [r15]
152         mov b6 = r8
153         ;;
154         br.call.sptk.many b0 = b6
155         ;;
156 1:
157         mov gp = loc2
158         mov ar.pfs = loc0
159         mov b0 = loc1
160         br.ret.sptk.many b0
161         .endp   __do_frame_setup_aux#
162
163 .weak __register_frame_info_aux#