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