Blame sysdeps/nios2/dl-trampoline.S

Packit 6c4009
/* PLT trampolines.  Nios II version.
Packit 6c4009
   Copyright (C) 2005-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library.  If not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
#include <libc-symbols.h>
Packit 6c4009
Packit 6c4009
	.text
Packit 6c4009
	.globl _dl_runtime_resolve
Packit 6c4009
	cfi_startproc
Packit 6c4009
_dl_runtime_resolve:
Packit 6c4009
/* The runtime resolver receives the original function arguments in r4
Packit 6c4009
   through r7, the shared library identifier from GOT[1]? in r14, and the
Packit 6c4009
   relocation index times four in r15. It updates the corresponding PLT GOT
Packit 6c4009
   entry so that the PLT entry will transfer control directly to the target
Packit 6c4009
   in the future, and then transfers control to the target. */
Packit 6c4009
	/* Save arguments and return address.  */
Packit 6c4009
	subi sp, sp, 28
Packit 6c4009
	cfi_adjust_cfa_offset (28)
Packit 6c4009
	stw r22, 24(sp)
Packit 6c4009
	cfi_rel_offset (r22, 24)
Packit 6c4009
	stw r8, 20(sp)  /* save r8, because this might be a call to mcount */
Packit 6c4009
	cfi_rel_offset (r8, 20)
Packit 6c4009
	stw r7, 16(sp)
Packit 6c4009
	cfi_rel_offset (r7, 16)
Packit 6c4009
	stw r6, 12(sp)
Packit 6c4009
	cfi_rel_offset (r6, 12)
Packit 6c4009
	stw r5, 8(sp)
Packit 6c4009
	cfi_rel_offset (r5, 8)
Packit 6c4009
	stw r4, 4(sp)
Packit 6c4009
	cfi_rel_offset (r4, 4)
Packit 6c4009
	stw ra, 0(sp)
Packit 6c4009
	cfi_rel_offset (ra, 0)
Packit 6c4009
Packit 6c4009
	/* Get pointer to linker struct.  */
Packit 6c4009
	mov r4, r14
Packit 6c4009
Packit 6c4009
	/* Get the relocation offset.  We're given a multiple of 4 and
Packit 6c4009
	   need a multiple of 12, so multiply by 3. */
Packit 6c4009
	slli r5, r15, 1
Packit 6c4009
	add r5, r5, r15
Packit 6c4009
Packit 6c4009
	/* Call the fixup routine.  */
Packit 6c4009
	nextpc r22
Packit 6c4009
1:	movhi r2, %hiadj(_gp_got - 1b)
Packit 6c4009
	addi r2, r2, %lo(_gp_got - 1b)
Packit 6c4009
	add r22, r22, r2
Packit 6c4009
	ldw r2, %call(_dl_fixup)(r22)
Packit 6c4009
	callr r2
Packit 6c4009
Packit 6c4009
	/* Restore the arguments and return address.  */
Packit 6c4009
	ldw ra, 0(sp)
Packit 6c4009
	ldw r4, 4(sp)
Packit 6c4009
	ldw r5, 8(sp)
Packit 6c4009
	ldw r6, 12(sp)
Packit 6c4009
	ldw r7, 16(sp)
Packit 6c4009
	ldw r8, 20(sp)
Packit 6c4009
	ldw r22, 24(sp)
Packit 6c4009
	addi sp, sp, 28
Packit 6c4009
	cfi_adjust_cfa_offset (-28)
Packit 6c4009
Packit 6c4009
	/* Jump to the newly found address.  */
Packit 6c4009
	jmp r2
Packit 6c4009
Packit 6c4009
	cfi_endproc