OSDN Git Service

fix typo.
[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          .section ".got2","aw"
9 .LCTOC1 = .+32768
10
11 # Table of addresses
12 .Ltable = .-.LCTOC1
13         .long   .Laddr                          # address we are really at
14         .long   _GLOBAL_OFFSET_TABLE_           # normal GOT address
15         .long   _GOT2_START_                    # -mrelocatable GOT pointers start
16         .long   _GOT2_END_                      # -mrelocatable GOT pointers end
17
18         .text
19 .Lptr:  .long   .LCTOC1-.Laddr                  # PC relative pointer to .got2
20         .long   0x4000                          # traceback table
21
22 __eabi: mflr    0
23         bl      .Laddr                          # get current address
24 .Laddr: mflr    11                              # real address of .Ltable
25         lwz     12,(.Lptr-.Laddr)(11)           # linker generated address of .Ltable
26         add     12,12,11                        # correct to real pointer
27         subf.   12,12,11                        # calculate difference
28         bc      4,2,.Lreloc                     # skip if we need to relocate
29
30 # Normal program, load up register 2
31
32         mtlr    0                               # restore link register
33         lwz     2,4(11)                         # normal GOT address
34         blr
35
36 # We need to relocate the .got2 pointers.  Don't load register 2
37
38 .Lreloc:
39         stwu    30,-4(1)
40         stwu    31,-4(1)
41         lwz     30,8(11)                        # GOT pointers start
42         lwz     31,12(11)                       # GOT pointers end
43         add     30,12,30                        # adjust pointers
44         add     31,12,31
45
46         cmpw    1,30,31                         # any pointers to adjust
47         bc      12,6,.Ldone
48
49 .Lloop: lwz     11,0(30)                        # next pointer
50         add     11,11,12                        # adjust
51         stw     11,0(30)
52         addi    30,30,4                         # bump to next word
53         cmpw    1,30,31                         # more pointers to adjust?
54         bc      4,6,.Lloop
55
56 # Done adjusting pointers, return
57
58 .Ldone:
59         mtlr    0                               # restore link register
60         lwz     31,0(1)
61         lwz     30,4(1)                         # restore regs
62         addic   1,1,8                           # pop stack
63         blr