]>
Commit | Line | Data |
---|---|---|
522e6ee3 | 1 | /* PLT trampolines. Nios II version. |
2b778ceb | 2 | Copyright (C) 2005-2021 Free Software Foundation, Inc. |
522e6ee3 CLT |
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, see | |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
522e6ee3 CLT |
18 | |
19 | #include <sysdep.h> | |
20 | #include <libc-symbols.h> | |
21 | ||
22 | .text | |
23 | .globl _dl_runtime_resolve | |
24 | cfi_startproc | |
25 | _dl_runtime_resolve: | |
26 | /* The runtime resolver receives the original function arguments in r4 | |
27 | through r7, the shared library identifier from GOT[1]? in r14, and the | |
28 | relocation index times four in r15. It updates the corresponding PLT GOT | |
29 | entry so that the PLT entry will transfer control directly to the target | |
30 | in the future, and then transfers control to the target. */ | |
31 | /* Save arguments and return address. */ | |
32 | subi sp, sp, 28 | |
33 | cfi_adjust_cfa_offset (28) | |
34 | stw r22, 24(sp) | |
35 | cfi_rel_offset (r22, 24) | |
36 | stw r8, 20(sp) /* save r8, because this might be a call to mcount */ | |
37 | cfi_rel_offset (r8, 20) | |
38 | stw r7, 16(sp) | |
39 | cfi_rel_offset (r7, 16) | |
40 | stw r6, 12(sp) | |
41 | cfi_rel_offset (r6, 12) | |
42 | stw r5, 8(sp) | |
43 | cfi_rel_offset (r5, 8) | |
44 | stw r4, 4(sp) | |
45 | cfi_rel_offset (r4, 4) | |
46 | stw ra, 0(sp) | |
47 | cfi_rel_offset (ra, 0) | |
48 | ||
49 | /* Get pointer to linker struct. */ | |
50 | mov r4, r14 | |
51 | ||
52 | /* Get the relocation offset. We're given a multiple of 4 and | |
53 | need a multiple of 12, so multiply by 3. */ | |
54 | slli r5, r15, 1 | |
55 | add r5, r5, r15 | |
56 | ||
57 | /* Call the fixup routine. */ | |
58 | nextpc r22 | |
59 | 1: movhi r2, %hiadj(_gp_got - 1b) | |
60 | addi r2, r2, %lo(_gp_got - 1b) | |
61 | add r22, r22, r2 | |
62 | ldw r2, %call(_dl_fixup)(r22) | |
63 | callr r2 | |
64 | ||
65 | /* Restore the arguments and return address. */ | |
66 | ldw ra, 0(sp) | |
67 | ldw r4, 4(sp) | |
68 | ldw r5, 8(sp) | |
69 | ldw r6, 12(sp) | |
70 | ldw r7, 16(sp) | |
71 | ldw r8, 20(sp) | |
72 | ldw r22, 24(sp) | |
73 | addi sp, sp, 28 | |
74 | cfi_adjust_cfa_offset (-28) | |
75 | ||
76 | /* Jump to the newly found address. */ | |
77 | jmp r2 | |
78 | ||
79 | cfi_endproc |