diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2016-05-28 18:12:58 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-11-04 00:03:07 +0100 |
commit | b8fcdddcbb192fc367ff04bbd753b9deb69b09f3 (patch) | |
tree | 8febdb9d4e3d090e9273c29df9ff06116196c8e4 /ldso/ldso/nios2/resolve.S | |
parent | 191739597c6d380692885cfdd8dd8aa4f31f029d (diff) |
nios2: sync support with glibc
Only static linking is supported for now.
More debugging and analyzing for ld.so, TLS and NPTL
is required. But at least you can bootup a static
root fileystem in Qemu.
Diffstat (limited to 'ldso/ldso/nios2/resolve.S')
-rw-r--r-- | ldso/ldso/nios2/resolve.S | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/ldso/ldso/nios2/resolve.S b/ldso/ldso/nios2/resolve.S new file mode 100644 index 000000000..a71839e17 --- /dev/null +++ b/ldso/ldso/nios2/resolve.S @@ -0,0 +1,73 @@ +/* PLT trampolines. Nios II version. + Copyright (C) 2005-2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +/* This code is used in dl-runtime.c to call the `fixup' function + and then redirect to the address it returns. */ + + .text + .align 4 + .globl _dl_linux_resolver + .globl _dl_linux_resolve + .type _dl_linux_resolve,@function + +_dl_linux_resolve: +/* The runtime resolver receives the original function arguments in r4 + through r7, the shared library identifier from GOT[1]? in r14, and the + relocation index times four in r15. It updates the corresponding PLT GOT + entry so that the PLT entry will transfer control directly to the target + in the future, and then transfers control to the target. */ + /* Save arguments and return address. */ + subi sp, sp, 28 + stw r22, 24(sp) + stw r8, 20(sp) /* save r8, because this might be a call to mcount */ + stw r7, 16(sp) + stw r6, 12(sp) + stw r5, 8(sp) + stw r4, 4(sp) + stw ra, 0(sp) + + /* Get pointer to linker struct. */ + mov r4, r14 + + /* Get the relocation offset. We're given a multiple of 4 and + need a multiple of 12, so multiply by 3. */ + slli r5, r15, 1 + add r5, r5, r15 + + /* Call the fixup routine. */ + nextpc r22 +1: movhi r2, %hiadj(_gp_got - 1b) + addi r2, r2, %lo(_gp_got - 1b) + add r22, r22, r2 + ldw r2, %call(_dl_linux_resolver)(r22) + callr r2 + + /* Restore the arguments and return address. */ + ldw ra, 0(sp) + ldw r4, 4(sp) + ldw r5, 8(sp) + ldw r6, 12(sp) + ldw r7, 16(sp) + ldw r8, 20(sp) + ldw r22, 24(sp) + addi sp, sp, 28 + + /* Jump to the newly found address. */ + jmp r2 + + .size _dl_linux_resolve, . - _dl_linux_resolve |