OSDN Git Service

insure eabi destructors get called
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / eabi.asm
1 /*
2  * special support for eabi
3  *
4  *   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
5  *   Written By Michael Meissner
6  * 
7  * This file is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation; either version 2, or (at your option) any
10  * later version.
11  * 
12  * In addition to the permissions in the GNU General Public License, the
13  * Free Software Foundation gives you unlimited permission to link the
14  * compiled version of this file with other programs, and to distribute
15  * those programs without any restriction coming from the use of this
16  * file.  (The General Public License restrictions do apply in other
17  * respects; for example, they cover modification of the file, and
18  * distribution when not linked into another program.)
19  * 
20  * This file is distributed in the hope that it will be useful, but
21  * WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23  * General Public License for more details.
24  * 
25  * You should have received a copy of the GNU General Public License
26  * along with this program; see the file COPYING.  If not, write to
27  * the Free Software Foundation, 59 Temple Place - Suite 330,
28  * Boston, MA 02111-1307, USA.
29  * 
30  *    As a special exception, if you link this library with files
31  *    compiled with GCC to produce an executable, this does not cause
32  *    the resulting executable to be covered by the GNU General Public License.
33  *    This exception does not however invalidate any other reasons why
34  *    the executable file might be covered by the GNU General Public License.
35  */ 
36
37 /* Do any initializations needed for the eabi environment */
38
39         .file   "eabi.asm"
40         .section ".text"
41         #include "ppc-asm.h"
42
43          .section ".got2","aw"
44 .LCTOC1 = . /* +32768 */
45
46 /* Table of addresses */
47 .Ltable = .-.LCTOC1
48         .long   .LCTOC1                         /* address we are really at */
49
50 .Lgot = .-.LCTOC1
51         .long   _GLOBAL_OFFSET_TABLE_           /* normal GOT address */
52
53 .Lgots = .-.LCTOC1
54         .long   __GOT_START__                   /* start of .got section */
55
56 .Lgote = .-.LCTOC1
57         .long   __GOT_END__                     /* end of .got section */
58
59 .Lgot2s = .-.LCTOC1
60         .long   __GOT2_START__                  /* -mrelocatable GOT pointers start */
61
62 .Lgot2e = .-.LCTOC1
63         .long   __GOT2_END__                    /* -mrelocatable GOT pointers end */
64
65 .Lfixups = .-.LCTOC1
66         .long   __FIXUP_START__                 /* start of .fixup section */
67
68 .Lfixupe = .-.LCTOC1
69         .long   __FIXUP_END__                   /* end of .fixup section */
70
71 .Lctors = .-.LCTOC1
72         .long   __CTOR_LIST__                   /* start of .ctor section */
73
74 .Lctore = .-.LCTOC1
75         .long   __CTOR_END__                    /* end of .ctor section */
76
77 .Ldtors = .-.LCTOC1
78         .long   __DTOR_LIST__                   /* start of .dtor section */
79
80 .Ldtore = .-.LCTOC1
81         .long   __DTOR_END__                    /* end of .dtor section */
82
83 .Linit = .-.LCTOC1
84         .long   .Linit_p                        /* address of variable to say we've been called */
85
86         .data
87 .Linit_p:
88         .long   0
89
90         .text
91 .Lptr:
92         .long   .LCTOC1-.Laddr                  /* PC relative pointer to .got2 */
93
94 FUNC_START(__eabi)
95         mflr    0
96         bl      .Laddr                          /* get current address */
97 .Laddr:
98         mflr    12                              /* real address of .Laddr */
99         lwz     11,(.Lptr-.Laddr)(12)           /* linker generated address of .LCTOC1 */
100         add     11,11,12                        /* correct to real pointer */
101         lwz     12,.Ltable(11)                  /* get linker's idea of where .Laddr is */
102         lwz     10,.Linit(11)                   /* address of init flag */
103         subf.   12,12,11                        /* calculate difference */
104         mtlr    0                               /* restore link register */
105         lwzx    9,10,12                         /* done flag */
106         cmplwi  2,9,0                           /* init flag != 0? */
107         bnelr   2                               /* return now, if we've been called already */
108         stwx    1,10,12                         /* store a non-zero value in the done flag */
109         bne     0,.Lreloc                       /* skip if we need to relocate */
110
111 /* Only load up register 2 if there is a .got section */
112
113         lwz     3,.Lgots(11)                    /* start of .got section */
114         lwz     4,.Lgote(11)                    /* end of .got section */
115         cmpw    1,3,4                           /* .got section non-empty? */
116         bc      12,6,.Ldone
117
118 /* Normal program, load up register 2 */
119
120         lwz     2,.Lgot(11)                     /* normal GOT address (obsolete in register 2) */
121         mr      13,2                            /* also same as _SDA_BASE_ (V.4 small data ptr) */
122         b       FUNC_NAME(__do_global_ctors)    /* do any C++ global constructors (which returns to caller) */
123
124 /* We need to relocate the .got2 pointers.  Don't load register 2 */
125
126 .Lreloc:
127         lwz     3,.Lgot2s(11)                   /* GOT pointers start */
128         lwz     4,.Lgot2e(11)                   /* GOT pointers end */
129         add     3,12,3                          /* adjust pointers */
130         add     4,12,4
131
132         cmpw    1,3,4                           /* any pointers to adjust */
133         bc      12,6,.Lctor
134
135 .Lloop:
136         lwz     5,0(3)                          /* next pointer */
137         add     5,5,12                          /* adjust */
138         stw     5,0(3)
139         addi    3,3,4                           /* bump to next word */
140         cmpw    1,3,4                           /* more pointers to adjust? */
141         bc      4,6,.Lloop
142
143 /* Fixup the .ctor section for static constructors */
144
145 .Lctor:
146         lwz     3,.Lctors(11)                   /* constructors pointers start */
147         lwz     4,.Lctore(11)                   /* constructors pointers end */
148
149         cmpw    1,3,4                           /* any pointers to adjust */
150         bc      12,6,.Ldtor
151
152 .Lcloop:
153         lwz     5,0(3)                          /* next pointer */
154         add     5,5,12                          /* adjust */
155         stw     5,0(3)
156         addi    3,3,4                           /* bump to next word */
157         cmpw    1,3,4                           /* more pointers to adjust? */
158         bc      4,6,.Lcloop
159
160 /* Fixup the .dtor section for static destructors */
161
162 .Ldtor:
163         lwz     3,.Ldtors(11)                   /* destructors pointers start */
164         lwz     4,.Ldtore(11)                   /* destructors pointers end */
165
166         cmpw    1,3,4                           /* any pointers to adjust */
167         bc      12,6,.Lfix
168
169 .Ldloop:
170         lwz     5,0(3)                          /* next pointer */
171         add     5,5,12                          /* adjust */
172         stw     5,0(3)
173         addi    3,3,4                           /* bump to next word */
174         cmpw    1,3,4                           /* more pointers to adjust? */
175         bc      4,6,.Ldloop
176
177 /* Fixup any user initialized pointers now (the compiler drops pointers to */
178 /* each of the relocs that it does in the .fixup section).  */
179
180 .Lfix:
181         lwz     3,.Lfixups(11)                  /* fixup pointers start */
182         lwz     4,.Lfixupe(11)                  /* fixup pointers end */
183
184         cmpw    1,3,4                           /* any user pointers to adjust */
185         bc      12,6,.Ldone
186
187 .Lfloop:
188         lwz     5,0(3)                          /* next pointer */
189         add     5,5,12                          /* adjust pointer */
190         lwz     6,0(5)                          /* get the pointer it points to */
191         stw     5,0(3)                          /* store adjusted pointer */
192         add     6,6,12                          /* adjust */
193         stw     6,0(5)
194         addi    3,3,4                           /* bump to next word */
195         cmpw    1,3,4                           /* more pointers to adjust? */
196         bc      4,6,.Lfloop
197
198 /* Done adjusting pointers, return */
199
200 .Ldone:
201         b       FUNC_NAME(__do_global_ctors)    /* do any C++ global constructors (which returns to caller) */
202 FUNC_END(__eabi)
203
204 /* Routines for saving floating point registers, called by the compiler. */
205 /* Called with r11 pointing to the stack header word of the caller of the */
206 /* function, just beyond the end of the floating point save area. */
207
208 FUNC_START(_savefpr_14) stfd    14,-144(11)     /* save fp registers */
209 FUNC_START(_savefpr_15) stfd    15,-136(11)
210 FUNC_START(_savefpr_16) stfd    16,-128(11)
211 FUNC_START(_savefpr_17) stfd    17,-120(11)
212 FUNC_START(_savefpr_18) stfd    18,-112(11)
213 FUNC_START(_savefpr_19) stfd    19,-104(11)
214 FUNC_START(_savefpr_20) stfd    20,-96(11)
215 FUNC_START(_savefpr_21) stfd    21,-88(11)
216 FUNC_START(_savefpr_22) stfd    22,-80(11)
217 FUNC_START(_savefpr_23) stfd    23,-72(11)
218 FUNC_START(_savefpr_24) stfd    24,-64(11)
219 FUNC_START(_savefpr_25) stfd    25,-56(11)
220 FUNC_START(_savefpr_26) stfd    26,-48(11)
221 FUNC_START(_savefpr_27) stfd    27,-40(11)
222 FUNC_START(_savefpr_28) stfd    28,-32(11)
223 FUNC_START(_savefpr_29) stfd    29,-24(11)
224 FUNC_START(_savefpr_30) stfd    30,-16(11)
225 FUNC_START(_savefpr_31) stfd    31,-8(11)
226                         blr
227 FUNC_END(_savefpr_31)
228 FUNC_END(_savefpr_30)
229 FUNC_END(_savefpr_29)
230 FUNC_END(_savefpr_28)
231 FUNC_END(_savefpr_27)
232 FUNC_END(_savefpr_26)
233 FUNC_END(_savefpr_25)
234 FUNC_END(_savefpr_24)
235 FUNC_END(_savefpr_23)
236 FUNC_END(_savefpr_22)
237 FUNC_END(_savefpr_21)
238 FUNC_END(_savefpr_20)
239 FUNC_END(_savefpr_19)
240 FUNC_END(_savefpr_18)
241 FUNC_END(_savefpr_17)
242 FUNC_END(_savefpr_16)
243 FUNC_END(_savefpr_15)
244 FUNC_END(_savefpr_14)
245
246 /* Routines for saving integer registers, called by the compiler. */
247 /* Called with r11 pointing to the stack header word of the caller of the */
248 /* function, just beyond the end of the integer save area. */
249
250 FUNC_START(_savegpr_14) stw     14,-72(11)      /* save gp registers */
251 FUNC_START(_savegpr_15) stw     15,-68(11)
252 FUNC_START(_savegpr_16) stw     16,-64(11)
253 FUNC_START(_savegpr_17) stw     17,-60(11)
254 FUNC_START(_savegpr_18) stw     18,-56(11)
255 FUNC_START(_savegpr_19) stw     19,-52(11)
256 FUNC_START(_savegpr_20) stw     20,-48(11)
257 FUNC_START(_savegpr_21) stw     21,-44(11)
258 FUNC_START(_savegpr_22) stw     22,-40(11)
259 FUNC_START(_savegpr_23) stw     23,-36(11)
260 FUNC_START(_savegpr_24) stw     24,-32(11)
261 FUNC_START(_savegpr_25) stw     25,-28(11)
262 FUNC_START(_savegpr_26) stw     26,-24(11)
263 FUNC_START(_savegpr_27) stw     27,-20(11)
264 FUNC_START(_savegpr_28) stw     28,-16(11)
265 FUNC_START(_savegpr_29) stw     29,-12(11)
266 FUNC_START(_savegpr_30) stw     30,-8(11)
267 FUNC_START(_savegpr_31) stw     31,-4(11)
268                         blr
269 FUNC_END(_savegpr_31)
270 FUNC_END(_savegpr_30)
271 FUNC_END(_savegpr_29)
272 FUNC_END(_savegpr_28)
273 FUNC_END(_savegpr_27)
274 FUNC_END(_savegpr_26)
275 FUNC_END(_savegpr_25)
276 FUNC_END(_savegpr_24)
277 FUNC_END(_savegpr_23)
278 FUNC_END(_savegpr_22)
279 FUNC_END(_savegpr_21)
280 FUNC_END(_savegpr_20)
281 FUNC_END(_savegpr_19)
282 FUNC_END(_savegpr_18)
283 FUNC_END(_savegpr_17)
284 FUNC_END(_savegpr_16)
285 FUNC_END(_savegpr_15)
286 FUNC_END(_savegpr_14)
287
288 /* Routines for restoring floating point registers, called by the compiler. */
289 /* Called with r11 pointing to the stack header word of the caller of the */
290 /* function, just beyond the end of the floating point save area. */
291
292 FUNC_START(_restfpr_14) lfd     14,-144(11)     /* restore fp registers */
293 FUNC_START(_restfpr_15) lfd     15,-136(11)
294 FUNC_START(_restfpr_16) lfd     16,-128(11)
295 FUNC_START(_restfpr_17) lfd     17,-120(11)
296 FUNC_START(_restfpr_18) lfd     18,-112(11)
297 FUNC_START(_restfpr_19) lfd     19,-104(11)
298 FUNC_START(_restfpr_20) lfd     20,-96(11)
299 FUNC_START(_restfpr_21) lfd     21,-88(11)
300 FUNC_START(_restfpr_22) lfd     22,-80(11)
301 FUNC_START(_restfpr_23) lfd     23,-72(11)
302 FUNC_START(_restfpr_24) lfd     24,-64(11)
303 FUNC_START(_restfpr_25) lfd     25,-56(11)
304 FUNC_START(_restfpr_26) lfd     26,-48(11)
305 FUNC_START(_restfpr_27) lfd     27,-40(11)
306 FUNC_START(_restfpr_28) lfd     28,-32(11)
307 FUNC_START(_restfpr_29) lfd     29,-24(11)
308 FUNC_START(_restfpr_30) lfd     30,-16(11)
309 FUNC_START(_restfpr_31) lfd     31,-8(11)
310                         blr
311 FUNC_END(_restfpr_31)
312 FUNC_END(_restfpr_30)
313 FUNC_END(_restfpr_29)
314 FUNC_END(_restfpr_28)
315 FUNC_END(_restfpr_27)
316 FUNC_END(_restfpr_26)
317 FUNC_END(_restfpr_25)
318 FUNC_END(_restfpr_24)
319 FUNC_END(_restfpr_23)
320 FUNC_END(_restfpr_22)
321 FUNC_END(_restfpr_21)
322 FUNC_END(_restfpr_20)
323 FUNC_END(_restfpr_19)
324 FUNC_END(_restfpr_18)
325 FUNC_END(_restfpr_17)
326 FUNC_END(_restfpr_16)
327 FUNC_END(_restfpr_15)
328 FUNC_END(_restfpr_14)
329
330 /* Routines for restoring integer registers, called by the compiler. */
331 /* Called with r11 pointing to the stack header word of the caller of the */
332 /* function, just beyond the end of the integer restore area. */
333
334 FUNC_START(_restgpr_14) lwz     14,-72(11)      /* restore gp registers */
335 FUNC_START(_restgpr_15) lwz     15,-68(11)
336 FUNC_START(_restgpr_16) lwz     16,-64(11)
337 FUNC_START(_restgpr_17) lwz     17,-60(11)
338 FUNC_START(_restgpr_18) lwz     18,-56(11)
339 FUNC_START(_restgpr_19) lwz     19,-52(11)
340 FUNC_START(_restgpr_20) lwz     20,-48(11)
341 FUNC_START(_restgpr_21) lwz     21,-44(11)
342 FUNC_START(_restgpr_22) lwz     22,-40(11)
343 FUNC_START(_restgpr_23) lwz     23,-36(11)
344 FUNC_START(_restgpr_24) lwz     24,-32(11)
345 FUNC_START(_restgpr_25) lwz     25,-28(11)
346 FUNC_START(_restgpr_26) lwz     26,-24(11)
347 FUNC_START(_restgpr_27) lwz     27,-20(11)
348 FUNC_START(_restgpr_28) lwz     28,-16(11)
349 FUNC_START(_restgpr_29) lwz     29,-12(11)
350 FUNC_START(_restgpr_30) lwz     30,-8(11)
351 FUNC_START(_restgpr_31) lwz     31,-4(11)
352                         blr
353 FUNC_END(_restgpr_31)
354 FUNC_END(_restgpr_30)
355 FUNC_END(_restgpr_29)
356 FUNC_END(_restgpr_28)
357 FUNC_END(_restgpr_27)
358 FUNC_END(_restgpr_26)
359 FUNC_END(_restgpr_25)
360 FUNC_END(_restgpr_24)
361 FUNC_END(_restgpr_23)
362 FUNC_END(_restgpr_22)
363 FUNC_END(_restgpr_21)
364 FUNC_END(_restgpr_20)
365 FUNC_END(_restgpr_19)
366 FUNC_END(_restgpr_18)
367 FUNC_END(_restgpr_17)
368 FUNC_END(_restgpr_16)
369 FUNC_END(_restgpr_15)
370 FUNC_END(_restgpr_14)
371
372 /* Routines for restoring floating point registers, called by the compiler. */
373 /* Called with r11 pointing to the stack header word of the caller of the */
374 /* function, just beyond the end of the floating point save area. */
375 /* In addition to restoring the fp registers, it will return to the caller's */
376 /* caller */
377
378 FUNC_START(_restfpr_14_x)       lfd     14,-144(11)     /* restore fp registers */
379 FUNC_START(_restfpr_15_x)       lfd     15,-136(11)
380 FUNC_START(_restfpr_16_x)       lfd     16,-128(11)
381 FUNC_START(_restfpr_17_x)       lfd     17,-120(11)
382 FUNC_START(_restfpr_18_x)       lfd     18,-112(11)
383 FUNC_START(_restfpr_19_x)       lfd     19,-104(11)
384 FUNC_START(_restfpr_20_x)       lfd     20,-96(11)
385 FUNC_START(_restfpr_21_x)       lfd     21,-88(11)
386 FUNC_START(_restfpr_22_x)       lfd     22,-80(11)
387 FUNC_START(_restfpr_23_x)       lfd     23,-72(11)
388 FUNC_START(_restfpr_24_x)       lfd     24,-64(11)
389 FUNC_START(_restfpr_25_x)       lfd     25,-56(11)
390 FUNC_START(_restfpr_26_x)       lfd     26,-48(11)
391 FUNC_START(_restfpr_27_x)       lfd     27,-40(11)
392 FUNC_START(_restfpr_28_x)       lfd     28,-32(11)
393 FUNC_START(_restfpr_29_x)       lfd     29,-24(11)
394 FUNC_START(_restfpr_30_x)       lfd     30,-16(11)
395 FUNC_START(_restfpr_31_x)       lwz     0,4(11)
396                                 lfd     31,-8(11)
397                                 mtlr    0
398                                 mr      1,11
399                                 blr
400 FUNC_END(_restfpr_31_x)
401 FUNC_END(_restfpr_30_x)
402 FUNC_END(_restfpr_29_x)
403 FUNC_END(_restfpr_28_x)
404 FUNC_END(_restfpr_27_x)
405 FUNC_END(_restfpr_26_x)
406 FUNC_END(_restfpr_25_x)
407 FUNC_END(_restfpr_24_x)
408 FUNC_END(_restfpr_23_x)
409 FUNC_END(_restfpr_22_x)
410 FUNC_END(_restfpr_21_x)
411 FUNC_END(_restfpr_20_x)
412 FUNC_END(_restfpr_19_x)
413 FUNC_END(_restfpr_18_x)
414 FUNC_END(_restfpr_17_x)
415 FUNC_END(_restfpr_16_x)
416 FUNC_END(_restfpr_15_x)
417 FUNC_END(_restfpr_14_x)
418
419 /* Routines for restoring integer registers, called by the compiler. */
420 /* Called with r11 pointing to the stack header word of the caller of the */
421 /* function, just beyond the end of the integer restore area. */
422
423 FUNC_START(_restgpr_14_x)       lwz     14,-72(11)      /* restore gp registers */
424 FUNC_START(_restgpr_15_x)       lwz     15,-68(11)
425 FUNC_START(_restgpr_16_x)       lwz     16,-64(11)
426 FUNC_START(_restgpr_17_x)       lwz     17,-60(11)
427 FUNC_START(_restgpr_18_x)       lwz     18,-56(11)
428 FUNC_START(_restgpr_19_x)       lwz     19,-52(11)
429 FUNC_START(_restgpr_20_x)       lwz     20,-48(11)
430 FUNC_START(_restgpr_21_x)       lwz     21,-44(11)
431 FUNC_START(_restgpr_22_x)       lwz     22,-40(11)
432 FUNC_START(_restgpr_23_x)       lwz     23,-36(11)
433 FUNC_START(_restgpr_24_x)       lwz     24,-32(11)
434 FUNC_START(_restgpr_25_x)       lwz     25,-28(11)
435 FUNC_START(_restgpr_26_x)       lwz     26,-24(11)
436 FUNC_START(_restgpr_27_x)       lwz     27,-20(11)
437 FUNC_START(_restgpr_28_x)       lwz     28,-16(11)
438 FUNC_START(_restgpr_29_x)       lwz     29,-12(11)
439 FUNC_START(_restgpr_30_x)       lwz     30,-8(11)
440 FUNC_START(_restgpr_31_x)       lwz     0,4(11)
441                                 lwz     31,-4(11)
442                                 mtlr    0
443                                 mr      1,11
444                                 blr
445 FUNC_END(_restgpr_31_x)
446 FUNC_END(_restgpr_30_x)
447 FUNC_END(_restgpr_29_x)
448 FUNC_END(_restgpr_28_x)
449 FUNC_END(_restgpr_27_x)
450 FUNC_END(_restgpr_26_x)
451 FUNC_END(_restgpr_25_x)
452 FUNC_END(_restgpr_24_x)
453 FUNC_END(_restgpr_23_x)
454 FUNC_END(_restgpr_22_x)
455 FUNC_END(_restgpr_21_x)
456 FUNC_END(_restgpr_20_x)
457 FUNC_END(_restgpr_19_x)
458 FUNC_END(_restgpr_18_x)
459 FUNC_END(_restgpr_17_x)
460 FUNC_END(_restgpr_16_x)
461 FUNC_END(_restgpr_15_x)
462 FUNC_END(_restgpr_14_x)