2 * special support for eabi
4 * Copyright (C) 1995, 1996, 1998, 2000 Free Software Foundation, Inc.
5 * Written By Michael Meissner
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
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.)
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.
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.
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.
37 /* Do any initializations needed for the eabi environment */
45 .LCTOC1 = . /* +32768 */
47 /* Table of addresses */
49 .long .LCTOC1 /* address we are really at */
52 .long _SDA_BASE_ /* address of the first small data area */
55 .long __SDATA_START__ /* start of .sdata/.sbss section */
58 .long __SBSS_END__ /* end of .sdata/.sbss section */
61 .long _SDA2_BASE_ /* address of the second small data area */
64 .long __SDATA2_START__ /* start of .sdata2/.sbss2 section */
67 .long __SBSS2_END__ /* end of .sdata2/.sbss2 section */
71 .long __GOT_START__ /* Global offset table start */
74 .long _GLOBAL_OFFSET_TABLE_-4 /* end of GOT ptrs before BLCL + 3 reserved words */
77 .long _GLOBAL_OFFSET_TABLE_+12 /* start of GOT ptrs after BLCL + 3 reserved words */
80 .long __GOT_END__ /* Global offset table end */
83 .long __GOT2_START__ /* -mrelocatable GOT pointers start */
86 .long __GOT2_END__ /* -mrelocatable GOT pointers end */
89 .long __FIXUP_START__ /* start of .fixup section */
92 .long __FIXUP_END__ /* end of .fixup section */
95 .long __CTOR_LIST__ /* start of .ctor section */
98 .long __CTOR_END__ /* end of .ctor section */
101 .long __DTOR_LIST__ /* start of .dtor section */
104 .long __DTOR_END__ /* end of .dtor section */
106 .Lexcepts = .-.LCTOC1
107 .long __EXCEPT_START__ /* start of .gcc_except_table section */
109 .Lexcepte = .-.LCTOC1
110 .long __EXCEPT_END__ /* end of .gcc_except_table section */
113 .long .Linit_p /* address of variable to say we've been called */
118 .long .LCTOC1-.Laddr /* PC relative pointer to .got2 */
130 /* Eliminate -mrelocatable code if not -mrelocatable, so that this file can
131 be assembled with other assemblers than GAS, such as the Solaris PowerPC
135 addis 10,0,.Linit_p@ha /* init flag */
136 addis 11,0,.LCTOC1@ha /* load address of .LCTOC1 */
137 lwz 9,.Linit_p@l(10) /* init flag */
139 cmplwi 2,9,0 /* init flag != 0? */
140 bnelr 2 /* return now, if we've been called already */
141 stw 1,.Linit_p@l(10) /* store a non-zero value in the done flag */
143 #else /* -mrelocatable */
145 bl .Laddr /* get current address */
147 mflr 12 /* real address of .Laddr */
148 lwz 11,(.Lptr-.Laddr)(12) /* linker generated address of .LCTOC1 */
149 add 11,11,12 /* correct to real pointer */
150 lwz 12,.Ltable(11) /* get linker's idea of where .Laddr is */
151 lwz 10,.Linit(11) /* address of init flag */
152 subf. 12,12,11 /* calculate difference */
153 lwzx 9,10,12 /* done flag */
154 cmplwi 2,9,0 /* init flag != 0? */
155 mtlr 0 /* restore in case branch was taken */
156 bnelr 2 /* return now, if we've been called already */
157 stwx 1,10,12 /* store a non-zero value in the done flag */
158 beq+ 0,.Lsdata /* skip if we don't need to relocate */
160 /* We need to relocate the .got2 pointers. */
162 lwz 3,.Lgot2s(11) /* GOT2 pointers start */
163 lwz 4,.Lgot2e(11) /* GOT2 pointers end */
164 add 3,12,3 /* adjust pointers */
166 bl FUNC_NAME(__eabi_convert) /* convert pointers in .got2 section */
168 /* Fixup the .ctor section for static constructors */
170 lwz 3,.Lctors(11) /* constructors pointers start */
171 lwz 4,.Lctore(11) /* constructors pointers end */
172 bl FUNC_NAME(__eabi_convert) /* convert constructors */
174 /* Fixup the .dtor section for static destructors */
176 lwz 3,.Ldtors(11) /* destructors pointers start */
177 lwz 4,.Ldtore(11) /* destructors pointers end */
178 bl FUNC_NAME(__eabi_convert) /* convert destructors */
180 /* Fixup the .gcc_except_table section for G++ exceptions */
182 lwz 3,.Lexcepts(11) /* exception table pointers start */
183 lwz 4,.Lexcepte(11) /* exception table pointers end */
184 bl FUNC_NAME(__eabi_convert) /* convert exceptions */
186 /* Fixup the addresses in the GOT below _GLOBAL_OFFSET_TABLE_-4 */
188 lwz 3,.Lgots(11) /* GOT table pointers start */
189 lwz 4,.Lgotm1(11) /* GOT table pointers below _GLOBAL_OFFSET_TABLE-4 */
190 bl FUNC_NAME(__eabi_convert) /* convert lower GOT */
192 /* Fixup the addresses in the GOT above _GLOBAL_OFFSET_TABLE_+12 */
194 lwz 3,.Lgotm2(11) /* GOT table pointers above _GLOBAL_OFFSET_TABLE+12 */
195 lwz 4,.Lgote(11) /* GOT table pointers end */
196 bl FUNC_NAME(__eabi_convert) /* convert lower GOT */
198 /* Fixup any user initialized pointers now (the compiler drops pointers to */
199 /* each of the relocs that it does in the .fixup section). */
202 lwz 3,.Lfixups(11) /* fixup pointers start */
203 lwz 4,.Lfixupe(11) /* fixup pointers end */
204 bl FUNC_NAME(__eabi_uconvert) /* convert user initialized pointers */
207 mtlr 0 /* restore link register */
208 #endif /* _RELOCATABLE */
210 /* Only load up register 13 if there is a .sdata and/or .sbss section */
211 lwz 3,.Lsdas(11) /* start of .sdata/.sbss section */
212 lwz 4,.Lsdae(11) /* end of .sdata/.sbss section */
213 cmpw 1,3,4 /* .sdata/.sbss section non-empty? */
214 beq- 1,.Lsda2l /* skip loading r13 */
216 lwz 13,.Lsda(11) /* load r13 with _SDA_BASE_ address */
218 /* Only load up register 2 if there is a .sdata2 and/or .sbss2 section */
221 lwz 3,.Lsda2s(11) /* start of .sdata/.sbss section */
222 lwz 4,.Lsda2e(11) /* end of .sdata/.sbss section */
223 cmpw 1,3,4 /* .sdata/.sbss section non-empty? */
224 beq+ 1,.Ldone /* skip loading r2 */
226 lwz 2,.Lsda2(11) /* load r2 with _SDA2_BASE_ address */
228 /* Done adjusting pointers, return by way of doing the C++ global constructors. */
231 b FUNC_NAME(__init) /* do any C++ global constructors (which returns to caller) */
234 /* Special subroutine to convert a bunch of pointers directly.
235 r0 has original link register
236 r3 has low pointer to convert
237 r4 has high pointer to convert
238 r5 .. r10 are scratch registers
239 r11 has the address of .LCTOC1 in it.
240 r12 has the value to add to each pointer
241 r13 .. r31 are unchanged */
243 FUNC_START(__eabi_convert)
244 cmplw 1,3,4 /* any pointers to convert? */
245 subf 5,3,4 /* calculate number of words to convert */
246 bclr 4,4 /* return if no pointers */
249 addi 3,3,-4 /* start-4 for use with lwzu */
253 lwzu 6,4(3) /* pointer to convert */
255 beq- .Lcvt2 /* if pointer is null, don't convert */
257 add 6,6,12 /* convert pointer */
263 FUNC_END(__eabi_convert)
265 /* Special subroutine to convert the pointers the user has initialized. The
266 compiler has placed the address of the initialized pointer into the .fixup
269 r0 has original link register
270 r3 has low pointer to convert
271 r4 has high pointer to convert
272 r5 .. r10 are scratch registers
273 r11 has the address of .LCTOC1 in it.
274 r12 has the value to add to each pointer
275 r13 .. r31 are unchanged */
277 FUNC_START(__eabi_uconvert)
278 cmplw 1,3,4 /* any pointers to convert? */
279 subf 5,3,4 /* calculate number of words to convert */
280 bclr 4,4 /* return if no pointers */
283 addi 3,3,-4 /* start-4 for use with lwzu */
287 lwzu 6,4(3) /* next pointer to pointer to convert */
288 add 6,6,12 /* adjust pointer */
289 lwz 7,0(6) /* get the pointer it points to */
290 stw 6,0(3) /* store adjusted pointer */
291 add 7,7,12 /* adjust */
296 FUNC_END(__eabi_uconvert)
298 /* Routines for saving floating point registers, called by the compiler. */
299 /* Called with r11 pointing to the stack header word of the caller of the */
300 /* function, just beyond the end of the floating point save area. */
302 FUNC_START(_savefpr_14) stfd 14,-144(11) /* save fp registers */
303 FUNC_START(_savefpr_15) stfd 15,-136(11)
304 FUNC_START(_savefpr_16) stfd 16,-128(11)
305 FUNC_START(_savefpr_17) stfd 17,-120(11)
306 FUNC_START(_savefpr_18) stfd 18,-112(11)
307 FUNC_START(_savefpr_19) stfd 19,-104(11)
308 FUNC_START(_savefpr_20) stfd 20,-96(11)
309 FUNC_START(_savefpr_21) stfd 21,-88(11)
310 FUNC_START(_savefpr_22) stfd 22,-80(11)
311 FUNC_START(_savefpr_23) stfd 23,-72(11)
312 FUNC_START(_savefpr_24) stfd 24,-64(11)
313 FUNC_START(_savefpr_25) stfd 25,-56(11)
314 FUNC_START(_savefpr_26) stfd 26,-48(11)
315 FUNC_START(_savefpr_27) stfd 27,-40(11)
316 FUNC_START(_savefpr_28) stfd 28,-32(11)
317 FUNC_START(_savefpr_29) stfd 29,-24(11)
318 FUNC_START(_savefpr_30) stfd 30,-16(11)
319 FUNC_START(_savefpr_31) stfd 31,-8(11)
321 FUNC_END(_savefpr_31)
322 FUNC_END(_savefpr_30)
323 FUNC_END(_savefpr_29)
324 FUNC_END(_savefpr_28)
325 FUNC_END(_savefpr_27)
326 FUNC_END(_savefpr_26)
327 FUNC_END(_savefpr_25)
328 FUNC_END(_savefpr_24)
329 FUNC_END(_savefpr_23)
330 FUNC_END(_savefpr_22)
331 FUNC_END(_savefpr_21)
332 FUNC_END(_savefpr_20)
333 FUNC_END(_savefpr_19)
334 FUNC_END(_savefpr_18)
335 FUNC_END(_savefpr_17)
336 FUNC_END(_savefpr_16)
337 FUNC_END(_savefpr_15)
338 FUNC_END(_savefpr_14)
340 /* Routines for saving integer registers, called by the compiler. */
341 /* Called with r11 pointing to the stack header word of the caller of the */
342 /* function, just beyond the end of the integer save area. */
344 FUNC_START(_savegpr_14) stw 14,-72(11) /* save gp registers */
345 FUNC_START(_savegpr_15) stw 15,-68(11)
346 FUNC_START(_savegpr_16) stw 16,-64(11)
347 FUNC_START(_savegpr_17) stw 17,-60(11)
348 FUNC_START(_savegpr_18) stw 18,-56(11)
349 FUNC_START(_savegpr_19) stw 19,-52(11)
350 FUNC_START(_savegpr_20) stw 20,-48(11)
351 FUNC_START(_savegpr_21) stw 21,-44(11)
352 FUNC_START(_savegpr_22) stw 22,-40(11)
353 FUNC_START(_savegpr_23) stw 23,-36(11)
354 FUNC_START(_savegpr_24) stw 24,-32(11)
355 FUNC_START(_savegpr_25) stw 25,-28(11)
356 FUNC_START(_savegpr_26) stw 26,-24(11)
357 FUNC_START(_savegpr_27) stw 27,-20(11)
358 FUNC_START(_savegpr_28) stw 28,-16(11)
359 FUNC_START(_savegpr_29) stw 29,-12(11)
360 FUNC_START(_savegpr_30) stw 30,-8(11)
361 FUNC_START(_savegpr_31) stw 31,-4(11)
363 FUNC_END(_savegpr_31)
364 FUNC_END(_savegpr_30)
365 FUNC_END(_savegpr_29)
366 FUNC_END(_savegpr_28)
367 FUNC_END(_savegpr_27)
368 FUNC_END(_savegpr_26)
369 FUNC_END(_savegpr_25)
370 FUNC_END(_savegpr_24)
371 FUNC_END(_savegpr_23)
372 FUNC_END(_savegpr_22)
373 FUNC_END(_savegpr_21)
374 FUNC_END(_savegpr_20)
375 FUNC_END(_savegpr_19)
376 FUNC_END(_savegpr_18)
377 FUNC_END(_savegpr_17)
378 FUNC_END(_savegpr_16)
379 FUNC_END(_savegpr_15)
380 FUNC_END(_savegpr_14)
382 /* Routines for restoring floating point registers, called by the compiler. */
383 /* Called with r11 pointing to the stack header word of the caller of the */
384 /* function, just beyond the end of the floating point save area. */
386 FUNC_START(_restfpr_14) lfd 14,-144(11) /* restore fp registers */
387 FUNC_START(_restfpr_15) lfd 15,-136(11)
388 FUNC_START(_restfpr_16) lfd 16,-128(11)
389 FUNC_START(_restfpr_17) lfd 17,-120(11)
390 FUNC_START(_restfpr_18) lfd 18,-112(11)
391 FUNC_START(_restfpr_19) lfd 19,-104(11)
392 FUNC_START(_restfpr_20) lfd 20,-96(11)
393 FUNC_START(_restfpr_21) lfd 21,-88(11)
394 FUNC_START(_restfpr_22) lfd 22,-80(11)
395 FUNC_START(_restfpr_23) lfd 23,-72(11)
396 FUNC_START(_restfpr_24) lfd 24,-64(11)
397 FUNC_START(_restfpr_25) lfd 25,-56(11)
398 FUNC_START(_restfpr_26) lfd 26,-48(11)
399 FUNC_START(_restfpr_27) lfd 27,-40(11)
400 FUNC_START(_restfpr_28) lfd 28,-32(11)
401 FUNC_START(_restfpr_29) lfd 29,-24(11)
402 FUNC_START(_restfpr_30) lfd 30,-16(11)
403 FUNC_START(_restfpr_31) lfd 31,-8(11)
405 FUNC_END(_restfpr_31)
406 FUNC_END(_restfpr_30)
407 FUNC_END(_restfpr_29)
408 FUNC_END(_restfpr_28)
409 FUNC_END(_restfpr_27)
410 FUNC_END(_restfpr_26)
411 FUNC_END(_restfpr_25)
412 FUNC_END(_restfpr_24)
413 FUNC_END(_restfpr_23)
414 FUNC_END(_restfpr_22)
415 FUNC_END(_restfpr_21)
416 FUNC_END(_restfpr_20)
417 FUNC_END(_restfpr_19)
418 FUNC_END(_restfpr_18)
419 FUNC_END(_restfpr_17)
420 FUNC_END(_restfpr_16)
421 FUNC_END(_restfpr_15)
422 FUNC_END(_restfpr_14)
424 /* Routines for restoring integer registers, called by the compiler. */
425 /* Called with r11 pointing to the stack header word of the caller of the */
426 /* function, just beyond the end of the integer restore area. */
428 FUNC_START(_restgpr_14) lwz 14,-72(11) /* restore gp registers */
429 FUNC_START(_restgpr_15) lwz 15,-68(11)
430 FUNC_START(_restgpr_16) lwz 16,-64(11)
431 FUNC_START(_restgpr_17) lwz 17,-60(11)
432 FUNC_START(_restgpr_18) lwz 18,-56(11)
433 FUNC_START(_restgpr_19) lwz 19,-52(11)
434 FUNC_START(_restgpr_20) lwz 20,-48(11)
435 FUNC_START(_restgpr_21) lwz 21,-44(11)
436 FUNC_START(_restgpr_22) lwz 22,-40(11)
437 FUNC_START(_restgpr_23) lwz 23,-36(11)
438 FUNC_START(_restgpr_24) lwz 24,-32(11)
439 FUNC_START(_restgpr_25) lwz 25,-28(11)
440 FUNC_START(_restgpr_26) lwz 26,-24(11)
441 FUNC_START(_restgpr_27) lwz 27,-20(11)
442 FUNC_START(_restgpr_28) lwz 28,-16(11)
443 FUNC_START(_restgpr_29) lwz 29,-12(11)
444 FUNC_START(_restgpr_30) lwz 30,-8(11)
445 FUNC_START(_restgpr_31) lwz 31,-4(11)
447 FUNC_END(_restgpr_31)
448 FUNC_END(_restgpr_30)
449 FUNC_END(_restgpr_29)
450 FUNC_END(_restgpr_28)
451 FUNC_END(_restgpr_27)
452 FUNC_END(_restgpr_26)
453 FUNC_END(_restgpr_25)
454 FUNC_END(_restgpr_24)
455 FUNC_END(_restgpr_23)
456 FUNC_END(_restgpr_22)
457 FUNC_END(_restgpr_21)
458 FUNC_END(_restgpr_20)
459 FUNC_END(_restgpr_19)
460 FUNC_END(_restgpr_18)
461 FUNC_END(_restgpr_17)
462 FUNC_END(_restgpr_16)
463 FUNC_END(_restgpr_15)
464 FUNC_END(_restgpr_14)
466 /* Routines for restoring floating point registers, called by the compiler. */
467 /* Called with r11 pointing to the stack header word of the caller of the */
468 /* function, just beyond the end of the floating point save area. */
469 /* In addition to restoring the fp registers, it will return to the caller's */
472 FUNC_START(_restfpr_14_x) lfd 14,-144(11) /* restore fp registers */
473 FUNC_START(_restfpr_15_x) lfd 15,-136(11)
474 FUNC_START(_restfpr_16_x) lfd 16,-128(11)
475 FUNC_START(_restfpr_17_x) lfd 17,-120(11)
476 FUNC_START(_restfpr_18_x) lfd 18,-112(11)
477 FUNC_START(_restfpr_19_x) lfd 19,-104(11)
478 FUNC_START(_restfpr_20_x) lfd 20,-96(11)
479 FUNC_START(_restfpr_21_x) lfd 21,-88(11)
480 FUNC_START(_restfpr_22_x) lfd 22,-80(11)
481 FUNC_START(_restfpr_23_x) lfd 23,-72(11)
482 FUNC_START(_restfpr_24_x) lfd 24,-64(11)
483 FUNC_START(_restfpr_25_x) lfd 25,-56(11)
484 FUNC_START(_restfpr_26_x) lfd 26,-48(11)
485 FUNC_START(_restfpr_27_x) lfd 27,-40(11)
486 FUNC_START(_restfpr_28_x) lfd 28,-32(11)
487 FUNC_START(_restfpr_29_x) lfd 29,-24(11)
488 FUNC_START(_restfpr_30_x) lfd 30,-16(11)
489 FUNC_START(_restfpr_31_x) lwz 0,4(11)
494 FUNC_END(_restfpr_31_x)
495 FUNC_END(_restfpr_30_x)
496 FUNC_END(_restfpr_29_x)
497 FUNC_END(_restfpr_28_x)
498 FUNC_END(_restfpr_27_x)
499 FUNC_END(_restfpr_26_x)
500 FUNC_END(_restfpr_25_x)
501 FUNC_END(_restfpr_24_x)
502 FUNC_END(_restfpr_23_x)
503 FUNC_END(_restfpr_22_x)
504 FUNC_END(_restfpr_21_x)
505 FUNC_END(_restfpr_20_x)
506 FUNC_END(_restfpr_19_x)
507 FUNC_END(_restfpr_18_x)
508 FUNC_END(_restfpr_17_x)
509 FUNC_END(_restfpr_16_x)
510 FUNC_END(_restfpr_15_x)
511 FUNC_END(_restfpr_14_x)
513 /* Routines for restoring integer registers, called by the compiler. */
514 /* Called with r11 pointing to the stack header word of the caller of the */
515 /* function, just beyond the end of the integer restore area. */
517 FUNC_START(_restgpr_14_x) lwz 14,-72(11) /* restore gp registers */
518 FUNC_START(_restgpr_15_x) lwz 15,-68(11)
519 FUNC_START(_restgpr_16_x) lwz 16,-64(11)
520 FUNC_START(_restgpr_17_x) lwz 17,-60(11)
521 FUNC_START(_restgpr_18_x) lwz 18,-56(11)
522 FUNC_START(_restgpr_19_x) lwz 19,-52(11)
523 FUNC_START(_restgpr_20_x) lwz 20,-48(11)
524 FUNC_START(_restgpr_21_x) lwz 21,-44(11)
525 FUNC_START(_restgpr_22_x) lwz 22,-40(11)
526 FUNC_START(_restgpr_23_x) lwz 23,-36(11)
527 FUNC_START(_restgpr_24_x) lwz 24,-32(11)
528 FUNC_START(_restgpr_25_x) lwz 25,-28(11)
529 FUNC_START(_restgpr_26_x) lwz 26,-24(11)
530 FUNC_START(_restgpr_27_x) lwz 27,-20(11)
531 FUNC_START(_restgpr_28_x) lwz 28,-16(11)
532 FUNC_START(_restgpr_29_x) lwz 29,-12(11)
533 FUNC_START(_restgpr_30_x) lwz 30,-8(11)
534 FUNC_START(_restgpr_31_x) lwz 0,4(11)
539 FUNC_END(_restgpr_31_x)
540 FUNC_END(_restgpr_30_x)
541 FUNC_END(_restgpr_29_x)
542 FUNC_END(_restgpr_28_x)
543 FUNC_END(_restgpr_27_x)
544 FUNC_END(_restgpr_26_x)
545 FUNC_END(_restgpr_25_x)
546 FUNC_END(_restgpr_24_x)
547 FUNC_END(_restgpr_23_x)
548 FUNC_END(_restgpr_22_x)
549 FUNC_END(_restgpr_21_x)
550 FUNC_END(_restgpr_20_x)
551 FUNC_END(_restgpr_19_x)
552 FUNC_END(_restgpr_18_x)
553 FUNC_END(_restgpr_17_x)
554 FUNC_END(_restgpr_16_x)
555 FUNC_END(_restgpr_15_x)
556 FUNC_END(_restgpr_14_x)