Blame sysdeps/nios2/dl-trampoline.S

Packit Service 82fcde
/* PLT trampolines.  Nios II version.
Packit Service 82fcde
   Copyright (C) 2005-2018 Free Software Foundation, Inc.
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 <libc-symbols.h>
Packit Service 82fcde
Packit Service 82fcde
	.text
Packit Service 82fcde
	.globl _dl_runtime_resolve
Packit Service 82fcde
	cfi_startproc
Packit Service 82fcde
_dl_runtime_resolve:
Packit Service 82fcde
/* The runtime resolver receives the original function arguments in r4
Packit Service 82fcde
   through r7, the shared library identifier from GOT[1]? in r14, and the
Packit Service 82fcde
   relocation index times four in r15. It updates the corresponding PLT GOT
Packit Service 82fcde
   entry so that the PLT entry will transfer control directly to the target
Packit Service 82fcde
   in the future, and then transfers control to the target. */
Packit Service 82fcde
	/* Save arguments and return address.  */
Packit Service 82fcde
	subi sp, sp, 28
Packit Service 82fcde
	cfi_adjust_cfa_offset (28)
Packit Service 82fcde
	stw r22, 24(sp)
Packit Service 82fcde
	cfi_rel_offset (r22, 24)
Packit Service 82fcde
	stw r8, 20(sp)  /* save r8, because this might be a call to mcount */
Packit Service 82fcde
	cfi_rel_offset (r8, 20)
Packit Service 82fcde
	stw r7, 16(sp)
Packit Service 82fcde
	cfi_rel_offset (r7, 16)
Packit Service 82fcde
	stw r6, 12(sp)
Packit Service 82fcde
	cfi_rel_offset (r6, 12)
Packit Service 82fcde
	stw r5, 8(sp)
Packit Service 82fcde
	cfi_rel_offset (r5, 8)
Packit Service 82fcde
	stw r4, 4(sp)
Packit Service 82fcde
	cfi_rel_offset (r4, 4)
Packit Service 82fcde
	stw ra, 0(sp)
Packit Service 82fcde
	cfi_rel_offset (ra, 0)
Packit Service 82fcde
Packit Service 82fcde
	/* Get pointer to linker struct.  */
Packit Service 82fcde
	mov r4, r14
Packit Service 82fcde
Packit Service 82fcde
	/* Get the relocation offset.  We're given a multiple of 4 and
Packit Service 82fcde
	   need a multiple of 12, so multiply by 3. */
Packit Service 82fcde
	slli r5, r15, 1
Packit Service 82fcde
	add r5, r5, r15
Packit Service 82fcde
Packit Service 82fcde
	/* Call the fixup routine.  */
Packit Service 82fcde
	nextpc r22
Packit Service 82fcde
1:	movhi r2, %hiadj(_gp_got - 1b)
Packit Service 82fcde
	addi r2, r2, %lo(_gp_got - 1b)
Packit Service 82fcde
	add r22, r22, r2
Packit Service 82fcde
	ldw r2, %call(_dl_fixup)(r22)
Packit Service 82fcde
	callr r2
Packit Service 82fcde
Packit Service 82fcde
	/* Restore the arguments and return address.  */
Packit Service 82fcde
	ldw ra, 0(sp)
Packit Service 82fcde
	ldw r4, 4(sp)
Packit Service 82fcde
	ldw r5, 8(sp)
Packit Service 82fcde
	ldw r6, 12(sp)
Packit Service 82fcde
	ldw r7, 16(sp)
Packit Service 82fcde
	ldw r8, 20(sp)
Packit Service 82fcde
	ldw r22, 24(sp)
Packit Service 82fcde
	addi sp, sp, 28
Packit Service 82fcde
	cfi_adjust_cfa_offset (-28)
Packit Service 82fcde
Packit Service 82fcde
	/* Jump to the newly found address.  */
Packit Service 82fcde
	jmp r2
Packit Service 82fcde
Packit Service 82fcde
	cfi_endproc