]>
Commit | Line | Data |
---|---|---|
849e84dd | 1 | /* PLT trampolines. ARM version. |
568035b7 | 2 | Copyright (C) 2005-2013 Free Software Foundation, Inc. |
849e84dd PB |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
ab84e3ff PE |
16 | License along with the GNU C Library. If not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
849e84dd PB |
18 | |
19 | #include <sysdep.h> | |
20 | #include <libc-symbols.h> | |
21 | ||
22 | #if defined(__USE_BX__) | |
23 | #define BX(x) bx x | |
24 | #else | |
25 | #define BX(x) mov pc, x | |
26 | #endif | |
27 | ||
28 | .text | |
29 | .globl _dl_runtime_resolve | |
30 | .type _dl_runtime_resolve, #function | |
01b32e73 | 31 | .cfi_sections .debug_frame |
849e84dd PB |
32 | cfi_startproc |
33 | .align 2 | |
34 | _dl_runtime_resolve: | |
35 | cfi_adjust_cfa_offset (4) | |
36 | cfi_rel_offset (lr, 0) | |
37 | ||
38 | @ we get called with | |
39 | @ stack[0] contains the return address from this call | |
40 | @ ip contains &GOT[n+3] (pointer to function) | |
41 | @ lr points to &GOT[2] | |
42 | ||
43 | @ Save arguments. We save r4 to realign the stack. | |
44 | stmdb sp!,{r0-r4} | |
45 | cfi_adjust_cfa_offset (20) | |
46 | cfi_rel_offset (r0, 0) | |
47 | cfi_rel_offset (r1, 4) | |
48 | cfi_rel_offset (r2, 8) | |
49 | cfi_rel_offset (r3, 12) | |
50 | ||
51 | @ get pointer to linker struct | |
52 | ldr r0, [lr, #-4] | |
53 | ||
54 | @ prepare to call _dl_fixup() | |
55 | @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each | |
56 | sub r1, ip, lr | |
57 | sub r1, r1, #4 | |
58 | add r1, r1, r1 | |
59 | ||
60 | @ call fixup routine | |
61 | bl _dl_fixup | |
62 | ||
63 | @ save the return | |
64 | mov ip, r0 | |
65 | ||
66 | @ get arguments and return address back. We restore r4 | |
67 | @ only to realign the stack. | |
68 | ldmia sp!, {r0-r4,lr} | |
69 | cfi_adjust_cfa_offset (-24) | |
70 | ||
71 | @ jump to the newly found address | |
72 | BX(ip) | |
73 | ||
74 | cfi_endproc | |
75 | .size _dl_runtime_resolve, .-_dl_runtime_resolve | |
76 | ||
609908d7 | 77 | #ifndef PROF |
849e84dd PB |
78 | .globl _dl_runtime_profile |
79 | .type _dl_runtime_profile, #function | |
01b32e73 | 80 | .cfi_sections .debug_frame |
849e84dd PB |
81 | cfi_startproc |
82 | .align 2 | |
83 | _dl_runtime_profile: | |
84 | cfi_adjust_cfa_offset (4) | |
85 | cfi_rel_offset (lr, 0) | |
86 | ||
87 | @ we get called with | |
88 | @ stack[0] contains the return address from this call | |
89 | @ ip contains &GOT[n+3] (pointer to function) | |
90 | @ lr points to &GOT[2] | |
91 | ||
92 | @ Stack layout: | |
93 | @ 212 - saved lr | |
94 | @ 208 - framesize returned from pltenter | |
95 | @ 16 - La_arm_regs | |
96 | @ 8 - Saved two arguments to _dl_profile_fixup | |
97 | @ 4 - Saved result of _dl_profile_fixup | |
98 | @ 0 - outgoing argument to _dl_profile_fixup | |
99 | @ For now, we only save the general purpose registers. | |
100 | ||
101 | sub sp, sp, #196 | |
102 | cfi_adjust_cfa_offset (196) | |
103 | stmia sp, {r0-r3} | |
104 | cfi_rel_offset (r0, 0) | |
105 | cfi_rel_offset (r1, 4) | |
106 | cfi_rel_offset (r2, 8) | |
107 | cfi_rel_offset (r3, 12) | |
108 | ||
109 | sub sp, sp, #16 | |
110 | cfi_adjust_cfa_offset (16) | |
111 | ||
112 | @ Save sp and lr. | |
113 | add r0, sp, #216 | |
114 | str r0, [sp, #32] | |
115 | ldr r2, [sp, #212] | |
116 | str r2, [sp, #36] | |
117 | ||
118 | @ get pointer to linker struct | |
119 | ldr r0, [lr, #-4] | |
120 | ||
121 | @ prepare to call _dl_profile_fixup() | |
122 | @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each | |
123 | sub r1, ip, lr | |
124 | sub r1, r1, #4 | |
125 | add r1, r1, r1 | |
126 | ||
127 | @ Save these two arguments for pltexit. | |
128 | add r3, sp, #8 | |
129 | stmia r3!, {r0,r1} | |
130 | ||
131 | @ Set up extra args for _dl_profile_fixup. | |
132 | @ r2 and r3 are already loaded. | |
133 | add ip, sp, #208 | |
134 | str ip, [sp, #0] | |
135 | ||
136 | @ call profiling fixup routine | |
137 | bl _dl_profile_fixup | |
138 | ||
139 | @ The address to call is now in r0. | |
140 | ||
141 | @ Check whether we're wrapping this function. | |
142 | ldr ip, [sp, #208] | |
143 | cmp ip, #0 | |
144 | bge 1f | |
145 | cfi_remember_state | |
146 | ||
147 | @ save the return | |
148 | mov ip, r0 | |
149 | ||
150 | @ get arguments and return address back | |
151 | add sp, sp, #16 | |
152 | cfi_adjust_cfa_offset (-16) | |
153 | ldmia sp, {r0-r3,sp,lr} | |
154 | cfi_adjust_cfa_offset (-200) | |
155 | ||
156 | @ jump to the newly found address | |
157 | BX(ip) | |
158 | ||
159 | cfi_restore_state | |
160 | 1: | |
161 | @ The new frame size is in ip. | |
162 | ||
163 | @ New stack layout: | |
164 | @ 268 - saved r7 | |
165 | @ 264 - saved result of _dl_profile_fixup | |
166 | @ 72 - La_arm_regs | |
167 | @ 64 - Saved two arguments to _dl_profile_fixup | |
168 | @ 0 - La_arm_retval | |
169 | @ For now, we only save the general purpose registers. | |
170 | ||
171 | @ Build the new frame. | |
172 | str r7, [sp, #212] | |
173 | cfi_rel_offset (r7, 212) | |
174 | sub r7, sp, #56 | |
175 | cfi_def_cfa_register (r7) | |
176 | cfi_adjust_cfa_offset (56) | |
177 | sub sp, sp, ip | |
178 | bic sp, sp, #7 | |
179 | ||
180 | @ Save the _dl_profile_fixup result around the call to memcpy. | |
181 | str r0, [r7, #264] | |
182 | ||
183 | @ Copy the stack arguments. | |
184 | mov r0, sp | |
185 | add r1, r7, #272 | |
186 | mov r2, ip | |
187 | bl memcpy | |
188 | ||
189 | @ Call the function. | |
190 | add ip, r7, #72 | |
191 | ldmia ip, {r0-r3} | |
192 | ldr ip, [r7, #264] | |
193 | mov lr, pc | |
194 | BX(ip) | |
195 | stmia r7, {r0-r3} | |
196 | ||
197 | @ Call pltexit. | |
198 | add ip, r7, #64 | |
199 | ldmia ip, {r0,r1} | |
200 | add r2, r7, #72 | |
201 | add r3, r7, #0 | |
202 | bl _dl_call_pltexit | |
203 | ||
204 | @ Return to caller. | |
205 | ldmia r7, {r0-r3} | |
206 | mov sp, r7 | |
207 | cfi_def_cfa_register (sp) | |
208 | ldr r7, [sp, #268] | |
209 | ldr lr, [sp, #92] | |
210 | add sp, sp, #272 | |
211 | cfi_adjust_cfa_offset (-272) | |
212 | BX(lr) | |
213 | ||
214 | cfi_endproc | |
609908d7 PB |
215 | .size _dl_runtime_profile, .-_dl_runtime_profile |
216 | #endif | |
849e84dd | 217 | .previous |