|
Packit Service |
82fcde |
/* RISC-V PLT trampoline
|
|
Packit Service |
82fcde |
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library. If not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <sysdep.h>
|
|
Packit Service |
82fcde |
#include <sys/asm.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Assembler veneer called from the PLT header code for lazy loading.
|
|
Packit Service |
82fcde |
The PLT header passes its own args in t0-t2. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifdef __riscv_float_abi_soft
|
|
Packit Service |
82fcde |
# define FRAME_SIZE (-((-10 * SZREG) & ALMASK))
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
# define FRAME_SIZE (-((-10 * SZREG - 8 * SZFREG) & ALMASK))
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
ENTRY (_dl_runtime_resolve)
|
|
Packit Service |
82fcde |
# Save arguments to stack.
|
|
Packit Service |
82fcde |
addi sp, sp, -FRAME_SIZE
|
|
Packit Service |
82fcde |
REG_S ra, 9*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_S a0, 1*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_S a1, 2*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_S a2, 3*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_S a3, 4*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_S a4, 5*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_S a5, 6*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_S a6, 7*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_S a7, 8*SZREG(sp)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifndef __riscv_float_abi_soft
|
|
Packit Service |
82fcde |
FREG_S fa0, (10*SZREG + 0*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_S fa1, (10*SZREG + 1*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_S fa2, (10*SZREG + 2*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_S fa3, (10*SZREG + 3*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_S fa4, (10*SZREG + 4*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_S fa5, (10*SZREG + 5*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_S fa6, (10*SZREG + 6*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_S fa7, (10*SZREG + 7*SZFREG)(sp)
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# Update .got.plt and obtain runtime address of callee.
|
|
Packit Service |
82fcde |
slli a1, t1, 1
|
|
Packit Service |
82fcde |
mv a0, t0 # link map
|
|
Packit Service |
82fcde |
add a1, a1, t1 # reloc offset (== thrice the .got.plt offset)
|
|
Packit Service |
82fcde |
la a2, _dl_fixup
|
|
Packit Service |
82fcde |
jalr a2
|
|
Packit Service |
82fcde |
mv t1, a0
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# Restore arguments from stack.
|
|
Packit Service |
82fcde |
REG_L ra, 9*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_L a0, 1*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_L a1, 2*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_L a2, 3*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_L a3, 4*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_L a4, 5*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_L a5, 6*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_L a6, 7*SZREG(sp)
|
|
Packit Service |
82fcde |
REG_L a7, 8*SZREG(sp)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifndef __riscv_float_abi_soft
|
|
Packit Service |
82fcde |
FREG_L fa0, (10*SZREG + 0*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_L fa1, (10*SZREG + 1*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_L fa2, (10*SZREG + 2*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_L fa3, (10*SZREG + 3*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_L fa4, (10*SZREG + 4*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_L fa5, (10*SZREG + 5*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_L fa6, (10*SZREG + 6*SZFREG)(sp)
|
|
Packit Service |
82fcde |
FREG_L fa7, (10*SZREG + 7*SZFREG)(sp)
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
addi sp, sp, FRAME_SIZE
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# Invoke the callee.
|
|
Packit Service |
82fcde |
jr t1
|
|
Packit Service |
82fcde |
END (_dl_runtime_resolve)
|