1 /* PLT trampolines. Nios II version.
2 Copyright (C) 2005-2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
20 #include <libc-symbols.h>
23 .globl _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. */
33 cfi_adjust_cfa_offset (28)
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)
39 cfi_rel_offset (r7, 16)
41 cfi_rel_offset (r6, 12)
43 cfi_rel_offset (r5, 8)
45 cfi_rel_offset (r4, 4)
47 cfi_rel_offset (ra, 0)
49 /* Get pointer to linker struct. */
52 /* Get the relocation offset. We're given a multiple of 4 and
53 need a multiple of 12, so multiply by 3. */
57 /* Call the fixup routine. */
59 1: movhi r2, %hiadj(_gp_got - 1b)
60 addi r2, r2, %lo(_gp_got - 1b)
62 ldw r2, %call(_dl_fixup)(r22)
65 /* Restore the arguments and return address. */
74 cfi_adjust_cfa_offset (-28)
76 /* Jump to the newly found address. */