2015-01-18 06:29:12 +00:00
|
|
|
/* PLT trampolines. Nios II version.
|
2020-01-01 00:14:33 +00:00
|
|
|
Copyright (C) 2005-2020 Free Software Foundation, Inc.
|
2015-01-18 06:29:12 +00:00
|
|
|
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
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2015-01-18 06:29:12 +00:00
|
|
|
|
|
|
|
#include <sysdep.h>
|
|
|
|
#include <libc-symbols.h>
|
|
|
|
|
|
|
|
.text
|
|
|
|
.globl _dl_runtime_resolve
|
|
|
|
cfi_startproc
|
|
|
|
_dl_runtime_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
|
|
|
|
cfi_adjust_cfa_offset (28)
|
|
|
|
stw r22, 24(sp)
|
|
|
|
cfi_rel_offset (r22, 24)
|
|
|
|
stw r8, 20(sp) /* save r8, because this might be a call to mcount */
|
|
|
|
cfi_rel_offset (r8, 20)
|
|
|
|
stw r7, 16(sp)
|
|
|
|
cfi_rel_offset (r7, 16)
|
|
|
|
stw r6, 12(sp)
|
|
|
|
cfi_rel_offset (r6, 12)
|
|
|
|
stw r5, 8(sp)
|
|
|
|
cfi_rel_offset (r5, 8)
|
|
|
|
stw r4, 4(sp)
|
|
|
|
cfi_rel_offset (r4, 4)
|
|
|
|
stw ra, 0(sp)
|
|
|
|
cfi_rel_offset (ra, 0)
|
|
|
|
|
|
|
|
/* 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_fixup)(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
|
|
|
|
cfi_adjust_cfa_offset (-28)
|
|
|
|
|
|
|
|
/* Jump to the newly found address. */
|
|
|
|
jmp r2
|
|
|
|
|
|
|
|
cfi_endproc
|