]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/sparc/sparc64/dl-trampoline.S
2.5-18.1
[thirdparty/glibc.git] / sysdeps / sparc / sparc64 / dl-trampoline.S
1 /* PLT trampolines. Sparc 64-bit version.
2 Copyright (C) 2005 Free Software Foundation, Inc.
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
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20 #include <sysdep.h>
21
22 .text
23 .align 32
24
25 /* %g1: PLT offset loaded by PLT entry
26 * %g4: callers PC, which is PLT0 + 24, therefore we
27 * add (32 + 8) to get the address of PLT2 which
28 * is where the magic cookie is stored
29 */
30 .globl _dl_runtime_resolve_0
31 .type _dl_runtime_resolve_0, @function
32 _dl_runtime_resolve_0:
33 cfi_startproc
34
35 save %sp, -192, %sp
36 cfi_def_cfa_register(%fp)
37 cfi_window_save
38 cfi_register(%o7, %i7)
39
40 sethi %hi(1047552), %l2
41 ldx [%g4 + 32 + 8], %o0
42 sub %g1, %g4, %l0
43 xor %l2, -1016, %l2
44 sethi %hi(5120), %l3 /* 160 * 32 */
45 add %l0, %l2, %l0
46 sethi %hi(32768), %l4
47 udivx %l0, %l3, %l3
48 sllx %l3, 2, %l1
49 add %l1, %l3, %l1
50 sllx %l1, 10, %l2
51 sub %l4, 4, %l4
52 sllx %l1, 5, %l1
53 sub %l0, %l2, %l0
54 udivx %l0, 24, %l0
55 add %l0, %l4, %l0
56 add %l1, %l0, %l1
57 add %l1, %l1, %l0
58 add %l0, %l1, %l0
59 call _dl_fixup
60 sllx %l0, 3, %o1
61 jmp %o0
62 restore
63
64 cfi_endproc
65
66 .size _dl_runtime_resolve_0, .-_dl_runtime_resolve_0
67
68 /* %g1: PLT offset loaded by PLT entry
69 * %g4: callers PC, which is PLT1 + 24, therefore we
70 * add 8 to get the address of PLT2 which
71 * is where the magic cookie is stored
72 */
73 .globl _dl_runtime_resolve_1
74 .type _dl_runtime_resolve_1, @function
75 _dl_runtime_resolve_1:
76 cfi_startproc
77
78 save %sp, -192, %sp
79 cfi_def_cfa_register(%fp)
80 cfi_window_save
81 cfi_register(%o7, %i7)
82
83 srlx %g1, 12, %o1
84 ldx [%g4 + 8], %o0
85 add %o1, %o1, %o3
86 sub %o1, 96, %o1
87 call _dl_fixup
88 add %o1, %o3, %o1
89 jmp %o0
90 restore
91
92 cfi_endproc
93
94 .size _dl_runtime_resolve_1, .-_dl_runtime_resolve_1
95
96 /* For the profiling cases we pass in our stack frame
97 * as the base of the La_sparc64_regs, so it looks
98 * like:
99 * %l0 %sp
100 * ...
101 * %l7 %sp + (7 * 8)
102 * %i0 %sp + (8 * 8)
103 * ...
104 * %i7 %sp + (15 * 8)
105 * %f0 %sp + (16 * 8)
106 * %f16 %sp + (31 * 8)
107 * framesize %sp + (32 * 8)
108 */
109
110 .globl _dl_profile_save_regs
111 .type _dl_profile_save_regs, @function
112 _dl_profile_save_regs:
113 cfi_startproc
114
115 stx %l0, [%sp + STACK_BIAS + ( 0 * 8)]
116 stx %l1, [%sp + STACK_BIAS + ( 1 * 8)]
117 stx %l2, [%sp + STACK_BIAS + ( 2 * 8)]
118 stx %l3, [%sp + STACK_BIAS + ( 3 * 8)]
119 stx %l4, [%sp + STACK_BIAS + ( 4 * 8)]
120 stx %l5, [%sp + STACK_BIAS + ( 5 * 8)]
121 stx %l6, [%sp + STACK_BIAS + ( 6 * 8)]
122 stx %l7, [%sp + STACK_BIAS + ( 7 * 8)]
123 stx %i0, [%sp + STACK_BIAS + ( 8 * 8)]
124 stx %i1, [%sp + STACK_BIAS + ( 9 * 8)]
125 stx %i2, [%sp + STACK_BIAS + (10 * 8)]
126 stx %i3, [%sp + STACK_BIAS + (11 * 8)]
127 stx %i4, [%sp + STACK_BIAS + (12 * 8)]
128 stx %i5, [%sp + STACK_BIAS + (13 * 8)]
129 stx %i6, [%sp + STACK_BIAS + (14 * 8)]
130 stx %i7, [%sp + STACK_BIAS + (15 * 8)]
131 std %f0, [%sp + STACK_BIAS + (16 * 8)]
132 std %f2, [%sp + STACK_BIAS + (17 * 8)]
133 std %f4, [%sp + STACK_BIAS + (18 * 8)]
134 std %f6, [%sp + STACK_BIAS + (19 * 8)]
135 std %f8, [%sp + STACK_BIAS + (20 * 8)]
136 std %f10, [%sp + STACK_BIAS + (21 * 8)]
137 std %f12, [%sp + STACK_BIAS + (22 * 8)]
138 std %f14, [%sp + STACK_BIAS + (23 * 8)]
139 std %f16, [%sp + STACK_BIAS + (24 * 8)]
140 std %f18, [%sp + STACK_BIAS + (25 * 8)]
141 std %f20, [%sp + STACK_BIAS + (26 * 8)]
142 std %f22, [%sp + STACK_BIAS + (27 * 8)]
143 std %f24, [%sp + STACK_BIAS + (28 * 8)]
144 std %f26, [%sp + STACK_BIAS + (29 * 8)]
145 std %f28, [%sp + STACK_BIAS + (30 * 8)]
146 retl
147 std %f30, [%sp + STACK_BIAS + (31 * 8)]
148
149 cfi_endproc
150
151 .size _dl_profile_save_regs, .-_dl_profile_save_regs
152
153 /* If we are going to call pltexit, then we must replicate
154 * the caller's stack frame.
155 * %o0: PLT resolved function address
156 */
157 .globl _dl_profile_invoke
158 .type _dl_profile_invoke, @function
159 _dl_profile_invoke:
160 cfi_startproc
161
162 sub %sp, %l0, %sp
163 1:
164 srlx %l0, 3, %l7
165 mov %o0, %l1
166 mov %i0, %o0
167 mov %i1, %o1
168 mov %i2, %o2
169 mov %i3, %o3
170 mov %i4, %o4
171 mov %i5, %o5
172 add %fp, STACK_BIAS, %l2
173 add %sp, STACK_BIAS, %l3
174 1: ldx [%l2], %l4
175 add %l2, 0x8, %l2
176 subcc %l7, 1, %l7
177 stx %l4, [%l3]
178 bne,pt %xcc, 1b
179 add %l3, 0x8, %l3
180
181 jmpl %l1, %o7
182 nop
183
184 stx %o0, [%sp + STACK_BIAS + (16 * 8)]
185 stx %o1, [%sp + STACK_BIAS + (17 * 8)]
186 stx %o2, [%sp + STACK_BIAS + (18 * 8)]
187 stx %o3, [%sp + STACK_BIAS + (19 * 8)]
188 std %f0, [%sp + STACK_BIAS + (20 * 8)]
189 std %f2, [%sp + STACK_BIAS + (21 * 8)]
190 std %f4, [%sp + STACK_BIAS + (22 * 8)]
191 std %f8, [%sp + STACK_BIAS + (23 * 8)]
192
193 mov %l5, %o0
194 mov %l6, %o1
195 add %sp, %l0, %o2
196 add %sp, STACK_BIAS + (16 * 8), %o3
197 call _dl_call_pltexit
198 add %o2, STACK_BIAS, %o2
199
200 ldx [%sp + STACK_BIAS + (16 * 8)], %i0
201 ldx [%sp + STACK_BIAS + (17 * 8)], %i1
202 ldx [%sp + STACK_BIAS + (18 * 8)], %i2
203 ldx [%sp + STACK_BIAS + (19 * 8)], %i3
204
205 jmpl %i7 + 8, %g0
206 restore
207
208 cfi_endproc
209
210 .size _dl_profile_invoke, .-_dl_profile_invoke
211
212 /* %g1: PLT offset loaded by PLT entry
213 * %g4: callers PC, which is PLT0 + 24, therefore we
214 * add (32 + 8) to get the address of PLT2 which
215 * is where the magic cookie is stored
216 */
217 .align 32
218 .globl _dl_runtime_profile_0
219 .type _dl_runtime_profile_0, @function
220 _dl_runtime_profile_0:
221 cfi_startproc
222
223 brz,a,pn %fp, 1f
224 mov 192, %g5
225 sub %fp, %sp, %g5
226 1: save %sp, -336, %sp
227 cfi_def_cfa_register(%fp)
228 cfi_window_save
229 cfi_register(%o7, %i7)
230
231 sethi %hi(1047552), %l2
232 ldx [%g4 + 32 + 8], %o0
233 sub %g1, %g4, %l0
234 xor %l2, -1016, %l2
235 sethi %hi(5120), %l3 /* 160 * 32 */
236 add %l0, %l2, %l0
237 sethi %hi(32768), %l4
238 udivx %l0, %l3, %l3
239 sllx %l3, 2, %l1
240 add %l1, %l3, %l1
241 sllx %l1, 10, %l2
242 sub %l4, 4, %l4
243 sllx %l1, 5, %l1
244 sub %l0, %l2, %l0
245 udivx %l0, 24, %l0
246 add %l0, %l4, %l0
247 add %l1, %l0, %l1
248 add %l1, %l1, %l0
249 add %l0, %l1, %l0
250
251 mov %i7, %o2
252 sllx %l0, 3, %o1
253
254 mov %g5, %l0
255 mov %o0, %l5
256 mov %o1, %l6
257
258 call _dl_profile_save_regs
259 nop
260
261 add %sp, STACK_BIAS, %o3
262 call _dl_profile_fixup
263 add %sp, (STACK_BIAS + (32 * 8)), %o4
264
265 ldx [%sp + STACK_BIAS + (32 * 8)], %o1
266 brgez,pt %o1, 1f
267 nop
268
269 call _dl_profile_invoke
270 nop
271
272 1: jmp %o0
273 restore
274
275 cfi_endproc
276
277 .size _dl_runtime_profile_0, .-_dl_runtime_profile_0
278
279 /* %g1: PLT offset loaded by PLT entry
280 * %g4: callers PC, which is PLT1 + 24, therefore we
281 * add 8 to get the address of PLT2 which
282 * is where the magic cookie is stored
283 */
284 .globl _dl_runtime_profile_1
285 .type _dl_runtime_profile_1, @function
286 _dl_runtime_profile_1:
287 cfi_startproc
288
289 brz,a,pn %fp, 1f
290 mov 192, %g5
291 sub %fp, %sp, %g5
292 1: save %sp, -336, %sp
293 cfi_def_cfa_register(%fp)
294 cfi_window_save
295 cfi_register(%o7, %i7)
296
297 srlx %g1, 12, %o1
298 ldx [%g4 + 8], %o0
299 add %o1, %o1, %o3
300 sub %o1, 96, %o1
301 mov %i7, %o2
302 add %o1, %o3, %o1
303
304 mov %g5, %l0
305 mov %o0, %l5
306 mov %o1, %l6
307
308 call _dl_profile_save_regs
309 nop
310
311 add %sp, STACK_BIAS, %o3
312 call _dl_profile_fixup
313 add %sp, (STACK_BIAS + (32 * 8)), %o4
314
315 ldx [%sp + STACK_BIAS + (32 * 8)], %o1
316 brgez,pt %o1, 1f
317 nop
318
319 call _dl_profile_invoke
320 nop
321
322 1: jmp %o0
323 restore
324
325 cfi_endproc
326
327 .size _dl_runtime_resolve_1, .-_dl_runtime_resolve_1