OSDN Git Service

V.4 support.
[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   .LCTOC1                         # address we are really at
14
15 .Lgot = .-.LCTOC1
16         .long   _GLOBAL_OFFSET_TABLE_           # normal GOT address
17
18 .Lgots = .-.LCTOC1
19         .long   _GOT_START_                     # start of .got section
20
21 .Lgote = .-.LCTOC1
22         .long   _GOT_END_                       # end of .got section
23
24 .Lgot2s = .-.LCTOC1
25         .long   _GOT2_START_                    # -mrelocatable GOT pointers start
26
27 .Lgot2e = .-.LCTOC1
28         .long   _GOT2_END_                      # -mrelocatable GOT pointers end
29
30 .Lfixups = .-.LCTOC1
31         .long   _FIXUP_START_                   # start of .fixup section
32
33 .Lfixupe = .-.LCTOC1
34         .long   _FIXUP_END_                     # end of .fixup section
35
36         .text
37 .Lptr:
38         .long   .LCTOC1-.Laddr                  # PC relative pointer to .got2
39         .long   0x4000                          # traceback table
40
41 __eabi: mflr    0
42         bl      .Laddr                          # get current address
43 .Laddr:
44         mflr    12                              # real address of .Laddr
45         lwz     11,(.Lptr-.Laddr)(12)           # linker generated address of .LCTOC1
46         add     11,11,12                        # correct to real pointer
47         lwz     12,.Ltable(11)                  # get linker's idea of where .Laddr is
48         subf.   12,12,11                        # calculate difference
49         mtlr    0                               # restore link register
50         bc      4,2,.Lreloc                     # skip if we need to relocate
51
52 # Only load up register 2 if there is a .got section
53
54         lwz     3,.Lgots(11)                    # start of .got section
55         lwz     4,.Lgote(11)                    # end of .got section
56         cmpw    1,3,4                           # .got section non-empty?
57         bc      12,6,.Ldone
58
59 # Normal program, load up register 2
60
61         lwz     2,.Lgot(11)                     # normal GOT address
62         b       __do_global_ctors               # do any C++ global constructors (which returns to caller)
63
64 # We need to relocate the .got2 pointers.  Don't load register 2
65
66 .Lreloc:
67         lwz     3,.Lgot2s(11)                   # GOT pointers start
68         lwz     4,.Lgot2e(11)                   # GOT pointers end
69         add     3,12,3                          # adjust pointers
70         add     4,12,4
71
72         cmpw    1,3,4                           # any pointers to adjust
73         bc      12,6,.Lfix
74
75 .Lloop:
76         lwz     5,0(3)                          # next pointer
77         add     5,5,12                          # adjust
78         stw     5,0(3)
79         addi    3,3,4                           # bump to next word
80         cmpw    1,3,4                           # more pointers to adjust?
81         bc      4,6,.Lloop
82
83 # Fixup any user initialized pointers now (the compiler drops pointers to
84 # each of the relocs that it does in the .fixup section).  Note, the pointers
85 # themselves have already been fixed up by the previous loop.
86
87 .Lfix:
88         lwz     3,.Lfixups(11)                  # fixup pointers start
89         lwz     4,.Lfixupe(11)                  # fixup pointers end
90
91         cmpw    1,3,4                           # any user pointers to adjust
92         bc      12,6,.Ldone
93
94 .Lfloop:
95         lwz     5,0(3)                          # next pointer
96         lwz     6,0(5)                          # get the pointer it points to
97         add     6,6,12                          # adjust
98         stw     6,0(5)
99         addi    3,3,4                           # bump to next word
100         cmpw    1,3,4                           # more pointers to adjust?
101         bc      4,6,.Lfloop
102
103 # Done adjusting pointers, return
104
105 .Ldone:
106         b       __do_global_ctors               # do any C++ global constructors (which returns to caller)
107
108 # Routines for saving floating point registers, called by the compiler.
109 # Called with r11 pointing to the stack header word of the caller of the
110 # function, just beyond the end of the floating point save area.
111
112         .globl  _savefpr_14_l
113         .globl  _savefpr_15_l
114         .globl  _savefpr_16_l
115         .globl  _savefpr_17_l
116         .globl  _savefpr_18_l
117         .globl  _savefpr_19_l
118         .globl  _savefpr_20_l
119         .globl  _savefpr_21_l
120         .globl  _savefpr_22_l
121         .globl  _savefpr_23_l
122         .globl  _savefpr_24_l
123         .globl  _savefpr_25_l
124         .globl  _savefpr_26_l
125         .globl  _savefpr_27_l
126         .globl  _savefpr_28_l
127         .globl  _savefpr_29_l
128         .globl  _savefpr_30_l
129         .globl  _savefpr_31_l
130
131                 .long   0x00400000      # traceback tag
132 _savefpr_14_l:  stfd    14,-144(11)     # save fp registers
133 _savefpr_15_l:  stfd    15,-136(11)
134 _savefpr_16_l:  stfd    16,-128(11)
135 _savefpr_17_l:  stfd    17,-120(11)
136 _savefpr_18_l:  stfd    18,-112(11)
137 _savefpr_19_l:  stfd    19,-104(11)
138 _savefpr_20_l:  stfd    20,-96(11)
139 _savefpr_21_l:  stfd    21,-88(11)
140 _savefpr_22_l:  stfd    22,-80(11)
141 _savefpr_23_l:  stfd    23,-72(11)
142 _savefpr_24_l:  stfd    24,-64(11)
143 _savefpr_25_l:  stfd    25,-56(11)
144 _savefpr_26_l:  stfd    26,-48(11)
145 _savefpr_27_l:  stfd    27,-40(11)
146 _savefpr_28_l:  stfd    28,-32(11)
147 _savefpr_29_l:  stfd    29,-24(11)
148 _savefpr_30_l:  stfd    30,-16(11)
149 _savefpr_31_l:  stfd    31,-8(11)
150                 stw     0,4(11)         # save return address also
151                 blr
152
153
154 # Routines for restoring floating point registers, called by the compiler.
155 # Called with r11 pointing to the stack header word of the caller of the
156 # function, just beyond the end of the floating point save area.
157
158         .globl  _restfpr_14_l
159         .globl  _restfpr_15_l
160         .globl  _restfpr_16_l
161         .globl  _restfpr_17_l
162         .globl  _restfpr_18_l
163         .globl  _restfpr_19_l
164         .globl  _restfpr_20_l
165         .globl  _restfpr_21_l
166         .globl  _restfpr_22_l
167         .globl  _restfpr_23_l
168         .globl  _restfpr_24_l
169         .globl  _restfpr_25_l
170         .globl  _restfpr_26_l
171         .globl  _restfpr_27_l
172         .globl  _restfpr_28_l
173         .globl  _restfpr_29_l
174         .globl  _restfpr_30_l
175         .globl  _restfpr_31_l
176
177                 .long   0x00600000      # traceback tag
178 _restfpr_14_l:  lfd     14,-144(11)     # restore fp registers
179 _restfpr_15_l:  lfd     15,-136(11)
180 _restfpr_16_l:  lfd     16,-128(11)
181 _restfpr_17_l:  lfd     17,-120(11)
182 _restfpr_18_l:  lfd     18,-112(11)
183 _restfpr_19_l:  lfd     19,-104(11)
184 _restfpr_20_l:  lfd     20,-96(11)
185 _restfpr_21_l:  lfd     21,-88(11)
186 _restfpr_22_l:  lfd     22,-80(11)
187 _restfpr_23_l:  lfd     23,-72(11)
188 _restfpr_24_l:  lfd     24,-64(11)
189 _restfpr_25_l:  lfd     25,-56(11)
190 _restfpr_26_l:  lfd     26,-48(11)
191 _restfpr_27_l:  lfd     27,-40(11)
192 _restfpr_28_l:  lfd     28,-32(11)
193 _restfpr_29_l:  lfd     29,-24(11)
194 _restfpr_30_l:  lfd     30,-16(11)
195 _restfpr_31_l:  lwz     0,4(11)         # caller's caller address
196                 lfd     31,-8(11)
197                 mtlr    0
198                 mr      1,11
199                 blr