]>
Commit | Line | Data |
---|---|---|
1ba6212c | 1 | /* PLT trampolines. Alpha version. |
dff8da6b | 2 | Copyright (C) 2005-2024 Free Software Foundation, Inc. |
1ba6212c RH |
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 | 16 | License along with the GNU C Library. If not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
1ba6212c RH |
18 | |
19 | #include <sysdep.h> | |
20 | ||
21 | .set noat | |
22 | ||
685896ef RH |
23 | .macro savei regno, offset |
24 | stq $\regno, \offset($30) | |
25 | cfi_rel_offset(\regno, \offset) | |
26 | .endm | |
27 | ||
28 | .macro savef regno, offset | |
29 | stt $f\regno, \offset($30) | |
30 | cfi_rel_offset(\regno+32, \offset) | |
31 | .endm | |
32 | ||
33 | .align 4 | |
34 | .globl _dl_runtime_resolve_new | |
35 | .ent _dl_runtime_resolve_new | |
36 | ||
37 | #undef FRAMESIZE | |
38 | #define FRAMESIZE 14*8 | |
39 | ||
40 | _dl_runtime_resolve_new: | |
41 | .frame $30, FRAMESIZE, $26, 0 | |
42 | .mask 0x4000000, 0 | |
43 | ||
44 | ldah $29, 0($27) !gpdisp!1 | |
45 | lda $30, -FRAMESIZE($30) | |
46 | stq $26, 0*8($30) | |
47 | stq $16, 2*8($30) | |
48 | ||
49 | stq $17, 3*8($30) | |
50 | lda $29, 0($29) !gpdisp!1 | |
51 | stq $18, 4*8($30) | |
52 | mov $28, $16 /* link_map from .got.plt */ | |
53 | ||
54 | stq $19, 5*8($30) | |
55 | mov $25, $17 /* offset of reloc entry */ | |
56 | stq $20, 6*8($30) | |
57 | mov $26, $18 /* return address */ | |
58 | ||
59 | stq $21, 7*8($30) | |
60 | stt $f16, 8*8($30) | |
61 | stt $f17, 9*8($30) | |
62 | stt $f18, 10*8($30) | |
63 | ||
64 | stt $f19, 11*8($30) | |
65 | stt $f20, 12*8($30) | |
66 | stt $f21, 13*8($30) | |
67 | .prologue 2 | |
68 | ||
69 | bsr $26, _dl_fixup !samegp | |
70 | mov $0, $27 | |
71 | ||
72 | ldq $26, 0*8($30) | |
73 | ldq $16, 2*8($30) | |
74 | ldq $17, 3*8($30) | |
75 | ldq $18, 4*8($30) | |
76 | ldq $19, 5*8($30) | |
77 | ldq $20, 6*8($30) | |
78 | ldq $21, 7*8($30) | |
79 | ldt $f16, 8*8($30) | |
80 | ldt $f17, 9*8($30) | |
81 | ldt $f18, 10*8($30) | |
82 | ldt $f19, 11*8($30) | |
83 | ldt $f20, 12*8($30) | |
84 | ldt $f21, 13*8($30) | |
85 | lda $30, FRAMESIZE($30) | |
86 | jmp $31, ($27), 0 | |
87 | .end _dl_runtime_resolve_new | |
88 | ||
89 | .globl _dl_runtime_profile_new | |
90 | .type _dl_runtime_profile_new, @function | |
91 | ||
55f41ef8 | 92 | #ifdef SHARED |
685896ef RH |
93 | #undef FRAMESIZE |
94 | #define FRAMESIZE 20*8 | |
95 | ||
96 | /* We save the registers in a different order than desired by | |
97 | .mask/.fmask, so we have to use explicit cfi directives. */ | |
98 | cfi_startproc | |
99 | ||
100 | _dl_runtime_profile_new: | |
101 | ldah $29, 0($27) !gpdisp!2 | |
102 | lda $30, -FRAMESIZE($30) | |
103 | savei 26, 0*8 | |
104 | stq $16, 2*8($30) | |
105 | ||
106 | stq $17, 3*8($30) | |
107 | lda $29, 0($29) !gpdisp!2 | |
108 | stq $18, 4*8($30) | |
109 | lda $1, FRAMESIZE($30) /* incoming sp value */ | |
110 | ||
111 | stq $1, 1*8($30) | |
112 | stq $19, 5*8($30) | |
113 | stq $20, 6*8($30) | |
114 | mov $28, $16 /* link_map from .got.plt */ | |
115 | ||
116 | stq $21, 7*8($30) | |
117 | mov $25, $17 /* offset of reloc entry */ | |
118 | stt $f16, 8*8($30) | |
119 | mov $26, $18 /* return address */ | |
120 | ||
121 | stt $f17, 9*8($30) | |
122 | mov $30, $19 /* La_alpha_regs address */ | |
123 | stt $f18, 10*8($30) | |
124 | lda $20, 14*8($30) /* framesize address */ | |
125 | ||
126 | stt $f19, 11*8($30) | |
127 | stt $f20, 12*8($30) | |
128 | stt $f21, 13*8($30) | |
129 | stq $28, 16*8($30) | |
130 | stq $25, 17*8($30) | |
131 | ||
132 | bsr $26, _dl_profile_fixup !samegp | |
133 | mov $0, $27 | |
134 | ||
135 | /* Discover if we're wrapping this call. */ | |
136 | ldq $18, 14*8($30) | |
137 | bge $18, 1f | |
138 | ||
139 | ldq $26, 0*8($30) | |
140 | ldq $16, 2*8($30) | |
141 | ldq $17, 3*8($30) | |
142 | ldq $18, 4*8($30) | |
143 | ldq $19, 5*8($30) | |
144 | ldq $20, 6*8($30) | |
145 | ldq $21, 7*8($30) | |
146 | ldt $f16, 8*8($30) | |
147 | ldt $f17, 9*8($30) | |
148 | ldt $f18, 10*8($30) | |
149 | ldt $f19, 11*8($30) | |
150 | ldt $f20, 12*8($30) | |
151 | ldt $f21, 13*8($30) | |
152 | lda $30, FRAMESIZE($30) | |
153 | jmp $31, ($27), 0 | |
154 | ||
155 | 1: | |
156 | /* Create a frame pointer and allocate a new argument frame. */ | |
157 | savei 15, 15*8 | |
158 | mov $30, $15 | |
159 | cfi_def_cfa_register (15) | |
160 | addq $18, 15, $18 | |
161 | bic $18, 15, $18 | |
162 | subq $30, $18, $30 | |
163 | ||
164 | /* Save the call destination around memcpy. */ | |
165 | stq $0, 14*8($30) | |
166 | ||
167 | /* Copy the stack arguments into place. */ | |
168 | lda $16, 0($30) | |
169 | lda $17, FRAMESIZE($15) | |
170 | jsr $26, memcpy | |
171 | ldgp $29, 0($26) | |
172 | ||
173 | /* Reload the argument registers. */ | |
174 | ldq $27, 14*8($30) | |
175 | ldq $16, 2*8($15) | |
176 | ldq $17, 3*8($15) | |
177 | ldq $18, 4*8($15) | |
178 | ldq $19, 5*8($15) | |
179 | ldq $20, 6*8($15) | |
180 | ldq $21, 7*8($15) | |
181 | ldt $f16, 8*8($15) | |
182 | ldt $f17, 9*8($15) | |
183 | ldt $f18, 10*8($15) | |
184 | ldt $f19, 11*8($15) | |
185 | ldt $f20, 12*8($15) | |
186 | ldt $f21, 13*8($15) | |
187 | ||
188 | jsr $26, ($27), 0 | |
189 | ldgp $29, 0($26) | |
190 | ||
8c0664e2 | 191 | /* Set up for call to _dl_audit_pltexit. */ |
685896ef RH |
192 | ldq $16, 16*8($15) |
193 | ldq $17, 17*8($15) | |
194 | stq $0, 16*8($15) | |
195 | lda $18, 0($15) | |
196 | stq $1, 17*8($15) | |
197 | lda $19, 16*8($15) | |
198 | stt $f0, 18*8($15) | |
199 | stt $f1, 19*8($15) | |
8c0664e2 | 200 | bsr $26, _dl_audit_pltexit !samegp |
685896ef RH |
201 | |
202 | mov $15, $30 | |
203 | cfi_def_cfa_register (30) | |
204 | ldq $26, 0($30) | |
205 | ldq $15, 15*8($30) | |
206 | lda $30, FRAMESIZE($30) | |
207 | ret | |
208 | ||
209 | cfi_endproc | |
210 | .size _dl_runtime_profile_new, .-_dl_runtime_profile_new | |
55f41ef8 | 211 | #endif /* SHARED */ |
685896ef RH |
212 | |
213 | .align 4 | |
214 | .globl _dl_runtime_resolve_old | |
215 | .ent _dl_runtime_resolve_old | |
1ba6212c RH |
216 | |
217 | #undef FRAMESIZE | |
218 | #define FRAMESIZE 44*8 | |
219 | ||
685896ef | 220 | _dl_runtime_resolve_old: |
1ba6212c RH |
221 | lda $30, -FRAMESIZE($30) |
222 | .frame $30, FRAMESIZE, $26 | |
223 | /* Preserve all registers that C normally doesn't. */ | |
224 | stq $26, 0*8($30) | |
225 | stq $0, 1*8($30) | |
226 | stq $1, 2*8($30) | |
227 | stq $2, 3*8($30) | |
228 | stq $3, 4*8($30) | |
229 | stq $4, 5*8($30) | |
230 | stq $5, 6*8($30) | |
231 | stq $6, 7*8($30) | |
232 | stq $7, 8*8($30) | |
233 | stq $8, 9*8($30) | |
234 | stq $16, 10*8($30) | |
235 | stq $17, 11*8($30) | |
236 | stq $18, 12*8($30) | |
237 | stq $19, 13*8($30) | |
238 | stq $20, 14*8($30) | |
239 | stq $21, 15*8($30) | |
240 | stq $22, 16*8($30) | |
241 | stq $23, 17*8($30) | |
242 | stq $24, 18*8($30) | |
243 | stq $25, 19*8($30) | |
244 | stq $29, 20*8($30) | |
245 | stt $f0, 21*8($30) | |
246 | stt $f1, 22*8($30) | |
247 | stt $f10, 23*8($30) | |
248 | stt $f11, 24*8($30) | |
249 | stt $f12, 25*8($30) | |
250 | stt $f13, 26*8($30) | |
251 | stt $f14, 27*8($30) | |
252 | stt $f15, 28*8($30) | |
253 | stt $f16, 29*8($30) | |
254 | stt $f17, 30*8($30) | |
255 | stt $f18, 31*8($30) | |
256 | stt $f19, 32*8($30) | |
257 | stt $f20, 33*8($30) | |
258 | stt $f21, 34*8($30) | |
259 | stt $f22, 35*8($30) | |
260 | stt $f23, 36*8($30) | |
261 | stt $f24, 37*8($30) | |
262 | stt $f25, 38*8($30) | |
263 | stt $f26, 39*8($30) | |
264 | stt $f27, 40*8($30) | |
265 | stt $f28, 41*8($30) | |
266 | stt $f29, 42*8($30) | |
267 | stt $f30, 43*8($30) | |
268 | .mask 0x27ff01ff, -FRAMESIZE | |
269 | .fmask 0xfffffc03, -FRAMESIZE+21*8 | |
270 | /* Set up our GP. */ | |
271 | br $29, .+4 | |
272 | ldgp $29, 0($29) | |
273 | .prologue 0 | |
274 | /* Set up the arguments for _dl_fixup: | |
275 | $16 = link_map out of plt0 | |
276 | $17 = offset of reloc entry = ($28 - $27 - 20) /12 * 24 | |
277 | $18 = return address | |
278 | */ | |
279 | subq $28, $27, $17 | |
280 | ldq $16, 8($27) | |
281 | subq $17, 20, $17 | |
282 | mov $26, $18 | |
283 | addq $17, $17, $17 | |
284 | bsr $26, _dl_fixup !samegp | |
285 | ||
286 | /* Move the destination address into position. */ | |
287 | mov $0, $27 | |
288 | /* Restore program registers. */ | |
289 | ldq $26, 0*8($30) | |
290 | ldq $0, 1*8($30) | |
291 | ldq $1, 2*8($30) | |
292 | ldq $2, 3*8($30) | |
293 | ldq $3, 4*8($30) | |
294 | ldq $4, 5*8($30) | |
295 | ldq $5, 6*8($30) | |
296 | ldq $6, 7*8($30) | |
297 | ldq $7, 8*8($30) | |
298 | ldq $8, 9*8($30) | |
299 | ldq $16, 10*8($30) | |
300 | ldq $17, 11*8($30) | |
301 | ldq $18, 12*8($30) | |
302 | ldq $19, 13*8($30) | |
303 | ldq $20, 14*8($30) | |
304 | ldq $21, 15*8($30) | |
305 | ldq $22, 16*8($30) | |
306 | ldq $23, 17*8($30) | |
307 | ldq $24, 18*8($30) | |
308 | ldq $25, 19*8($30) | |
309 | ldq $29, 20*8($30) | |
310 | ldt $f0, 21*8($30) | |
311 | ldt $f1, 22*8($30) | |
312 | ldt $f10, 23*8($30) | |
313 | ldt $f11, 24*8($30) | |
314 | ldt $f12, 25*8($30) | |
315 | ldt $f13, 26*8($30) | |
316 | ldt $f14, 27*8($30) | |
317 | ldt $f15, 28*8($30) | |
318 | ldt $f16, 29*8($30) | |
319 | ldt $f17, 30*8($30) | |
320 | ldt $f18, 31*8($30) | |
321 | ldt $f19, 32*8($30) | |
322 | ldt $f20, 33*8($30) | |
323 | ldt $f21, 34*8($30) | |
324 | ldt $f22, 35*8($30) | |
325 | ldt $f23, 36*8($30) | |
326 | ldt $f24, 37*8($30) | |
327 | ldt $f25, 38*8($30) | |
328 | ldt $f26, 39*8($30) | |
329 | ldt $f27, 40*8($30) | |
330 | ldt $f28, 41*8($30) | |
331 | ldt $f29, 42*8($30) | |
332 | ldt $f30, 43*8($30) | |
333 | /* Flush the Icache after having modified the .plt code. */ | |
334 | imb | |
335 | /* Clean up and turn control to the destination */ | |
336 | lda $30, FRAMESIZE($30) | |
337 | jmp $31, ($27) | |
338 | ||
685896ef | 339 | .end _dl_runtime_resolve_old |
1ba6212c | 340 | |
685896ef RH |
341 | .globl _dl_runtime_profile_old |
342 | .usepv _dl_runtime_profile_old, no | |
343 | .type _dl_runtime_profile_old, @function | |
1ba6212c | 344 | |
55f41ef8 | 345 | #ifdef SHARED |
1ba6212c RH |
346 | /* We save the registers in a different order than desired by |
347 | .mask/.fmask, so we have to use explicit cfi directives. */ | |
348 | cfi_startproc | |
349 | ||
1ba6212c RH |
350 | #undef FRAMESIZE |
351 | #define FRAMESIZE 50*8 | |
352 | ||
685896ef RH |
353 | .align 4 |
354 | _dl_runtime_profile_old: | |
1ba6212c RH |
355 | lda $30, -FRAMESIZE($30) |
356 | cfi_adjust_cfa_offset (FRAMESIZE) | |
357 | ||
358 | /* Preserve all argument registers. This also constructs the | |
359 | La_alpha_regs structure. */ | |
360 | savei 26, 0*8 | |
361 | savei 16, 2*8 | |
362 | savei 17, 3*8 | |
363 | savei 18, 4*8 | |
364 | savei 19, 5*8 | |
365 | savei 20, 6*8 | |
366 | savei 21, 7*8 | |
367 | lda $16, FRAMESIZE($30) | |
368 | savef 16, 8*8 | |
369 | savef 17, 9*8 | |
370 | savef 18, 10*8 | |
371 | savef 19, 11*8 | |
372 | savef 20, 12*8 | |
373 | savef 21, 13*8 | |
374 | stq $16, 1*8($30) | |
375 | ||
376 | /* Preserve all registers that C normally doesn't. */ | |
377 | savei 0, 14*8 | |
378 | savei 1, 15*8 | |
379 | savei 2, 16*8 | |
380 | savei 3, 17*8 | |
381 | savei 4, 18*8 | |
382 | savei 5, 19*8 | |
383 | savei 6, 20*8 | |
384 | savei 7, 21*8 | |
385 | savei 8, 22*8 | |
386 | savei 22, 23*8 | |
387 | savei 23, 24*8 | |
388 | savei 24, 25*8 | |
389 | savei 25, 26*8 | |
390 | savei 29, 27*8 | |
391 | savef 0, 28*8 | |
392 | savef 1, 29*8 | |
393 | savef 10, 30*8 | |
394 | savef 11, 31*8 | |
395 | savef 12, 32*8 | |
396 | savef 13, 33*8 | |
397 | savef 14, 34*8 | |
398 | savef 15, 35*8 | |
399 | savef 22, 36*8 | |
400 | savef 23, 37*8 | |
401 | savef 24, 38*8 | |
402 | savef 25, 39*8 | |
403 | savef 26, 40*8 | |
404 | savef 27, 41*8 | |
405 | savef 28, 42*8 | |
406 | savef 29, 43*8 | |
407 | savef 30, 44*8 | |
408 | ||
409 | /* Set up our GP. */ | |
410 | br $29, .+4 | |
411 | ldgp $29, 0($29) | |
412 | ||
413 | /* Set up the arguments for _dl_profile_fixup: | |
414 | $16 = link_map out of plt0 | |
415 | $17 = offset of reloc entry = ($28 - $27 - 20) /12 * 24 | |
416 | $18 = return address | |
417 | $19 = La_alpha_regs address | |
418 | $20 = framesize address | |
419 | */ | |
420 | subq $28, $27, $17 | |
421 | ldq $16, 8($27) | |
422 | subq $17, 20, $17 | |
423 | mov $26, $18 | |
424 | addq $17, $17, $17 | |
425 | lda $19, 0($30) | |
426 | lda $20, 45*8($30) | |
427 | stq $16, 48*8($30) | |
428 | stq $17, 49*8($30) | |
429 | ||
430 | bsr $26, _dl_profile_fixup !samegp | |
431 | ||
432 | /* Discover if we're wrapping this call. */ | |
433 | ldq $18, 45*8($30) | |
434 | bge $18, 1f | |
435 | ||
436 | /* Move the destination address into position. */ | |
437 | mov $0, $27 | |
438 | /* Restore program registers. */ | |
439 | ldq $26, 0*8($30) | |
440 | ldq $16, 2*8($30) | |
441 | ldq $17, 3*8($30) | |
442 | ldq $18, 4*8($30) | |
443 | ldq $19, 5*8($30) | |
444 | ldq $20, 6*8($30) | |
445 | ldq $21, 7*8($30) | |
446 | ldt $f16, 8*8($30) | |
447 | ldt $f17, 9*8($30) | |
448 | ldt $f18, 10*8($30) | |
449 | ldt $f19, 11*8($30) | |
450 | ldt $f20, 12*8($30) | |
451 | ldt $f21, 13*8($30) | |
452 | ldq $0, 14*8($30) | |
453 | ldq $1, 15*8($30) | |
454 | ldq $2, 16*8($30) | |
455 | ldq $3, 17*8($30) | |
456 | ldq $4, 18*8($30) | |
457 | ldq $5, 19*8($30) | |
458 | ldq $6, 20*8($30) | |
459 | ldq $7, 21*8($30) | |
460 | ldq $8, 22*8($30) | |
461 | ldq $22, 23*8($30) | |
462 | ldq $23, 24*8($30) | |
463 | ldq $24, 25*8($30) | |
464 | ldq $25, 26*8($30) | |
465 | ldq $29, 27*8($30) | |
466 | ldt $f0, 28*8($30) | |
467 | ldt $f1, 29*8($30) | |
468 | ldt $f10, 30*8($30) | |
469 | ldt $f11, 31*8($30) | |
470 | ldt $f12, 32*8($30) | |
471 | ldt $f13, 33*8($30) | |
472 | ldt $f14, 34*8($30) | |
473 | ldt $f15, 35*8($30) | |
474 | ldt $f22, 36*8($30) | |
475 | ldt $f23, 37*8($30) | |
476 | ldt $f24, 38*8($30) | |
477 | ldt $f25, 39*8($30) | |
478 | ldt $f26, 40*8($30) | |
479 | ldt $f27, 41*8($30) | |
480 | ldt $f28, 42*8($30) | |
481 | ldt $f29, 43*8($30) | |
482 | ldt $f30, 44*8($30) | |
483 | ||
484 | /* Clean up and turn control to the destination. */ | |
485 | lda $30, FRAMESIZE($30) | |
486 | jmp $31, ($27) | |
487 | ||
488 | 1: | |
489 | /* Create a frame pointer and allocate a new argument frame. */ | |
490 | savei 15, 45*8 | |
491 | mov $30, $15 | |
492 | cfi_def_cfa_register (15) | |
493 | addq $18, 15, $18 | |
494 | bic $18, 15, $18 | |
495 | subq $30, $18, $30 | |
496 | ||
497 | /* Save the call destination around memcpy. */ | |
498 | stq $0, 46*8($30) | |
499 | ||
500 | /* Copy the stack arguments into place. */ | |
501 | lda $16, 0($30) | |
502 | lda $17, FRAMESIZE($15) | |
503 | jsr $26, memcpy | |
504 | ldgp $29, 0($26) | |
505 | ||
506 | /* Reload the argument registers. */ | |
507 | ldq $27, 46*8($30) | |
508 | ldq $16, 2*8($15) | |
509 | ldq $17, 3*8($15) | |
510 | ldq $18, 4*8($15) | |
511 | ldq $19, 5*8($15) | |
512 | ldq $20, 6*8($15) | |
513 | ldq $21, 7*8($15) | |
514 | ldt $f16, 8*8($15) | |
515 | ldt $f17, 9*8($15) | |
516 | ldt $f18, 10*8($15) | |
517 | ldt $f19, 11*8($15) | |
518 | ldt $f20, 12*8($15) | |
519 | ldt $f21, 13*8($15) | |
520 | ||
521 | jsr $26, ($27), 0 | |
522 | ldgp $29, 0($26) | |
523 | ||
8c0664e2 | 524 | /* Set up for call to _dl_audit_pltexit. */ |
685896ef RH |
525 | ldq $16, 48*8($15) |
526 | ldq $17, 49*8($15) | |
1ba6212c RH |
527 | stq $0, 46*8($15) |
528 | lda $18, 0($15) | |
529 | stq $1, 47*8($15) | |
530 | lda $19, 46*8($15) | |
531 | stt $f0, 48*8($15) | |
532 | stt $f1, 49*8($15) | |
8c0664e2 | 533 | bsr $26, _dl_audit_pltexit !samegp |
1ba6212c RH |
534 | |
535 | mov $15, $30 | |
536 | cfi_def_cfa_register (30) | |
537 | ldq $26, 0($30) | |
538 | ldq $15, 45*8($30) | |
539 | lda $30, FRAMESIZE($30) | |
540 | ret | |
541 | ||
542 | cfi_endproc | |
685896ef | 543 | .size _dl_runtime_profile_old, .-_dl_runtime_profile_old |
55f41ef8 | 544 | #endif /* SHARED */ |