OSDN Git Service

Correctly reload r30 if -mrelocatable
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / eabi.asm
1 # File to either setup register 2 to point to the GOT, or to adjust the
2 # pointers in the .got2 section to point to their new addresses.
3
4         .file   "eabi.asm"
5         .section ".text"
6         .globl   __eabi
7
8         .long   0x4000                          # traceback table
9 __eabi: mflr    0
10         bl      .Laddr                          # get current address
11
12 # Table of addresses
13 .Ltable:
14         .long   .Ltable                         # address we are really at
15         .long   _GLOBAL_OFFSET_TABLE_           # normal GOT address
16         .long   _GOT2_START_                    # -mrelocatable GOT pointers start
17         .long   _GOT2_END_                      # -mrelocatable GOT pointers end
18
19 .Laddr: mflr    11                              # real address of .Ltable
20         lwz     12,0(11)                        # linker generated address of .Ltable
21         subf.   12,12,11                        # calculate difference
22         bc      4,2,.Lreloc                     # skip if we need to relocate
23
24 # Normal program, load up register 2
25
26         mtlr    0                               # restore link register
27         lwz     2,4(11)                         # normal GOT address
28         blr
29
30 # We need to relocate the .got2 pointers.  Don't load register 2
31
32 .Lreloc:
33         stwu    30,-4(1)
34         stwu    31,-4(1)
35         lwz     30,8(11)                        # GOT pointers start
36         lwz     31,12(11)                       # GOT pointers end
37         add     30,12,30                        # adjust pointers
38         add     31,12,31
39
40         cmpw    1,30,31                         # any pointers to adjust
41         bc      12,6,.Ldone
42
43 .Lloop: lwz     11,0(30)                        # next pointer
44         add     11,11,12                        # adjust
45         stw     11,0(30)
46         addi    30,30,4                         # bump to next word
47         cmpw    1,30,31                         # more pointers to adjust?
48         bc      4,6,.Lloop
49
50 # Done adjusting pointers, return
51
52 .Ldone:
53         mtlr    0                               # restore link register
54         lwz     31,0(1)
55         lwz     30,4(1)                         # restore regs
56         addic   1,1,8                           # pop stack
57         blr