about summary refs log tree commit diff
path: root/sysdeps/arc/dl-trampoline.S
blob: 9717be94829506b896e3082342dc2ef1fc84a5ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* PLT trampolines.  ARC version.
   Copyright (C) 2020-2024 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
   <https://www.gnu.org/licenses/>.  */

#include <sysdep.h>
#include <libc-symbols.h>

#include <sysdep.h>
#include <sys/syscall.h>

/* resolver has atypical calling ABI (r11 and r12)
        PLTn which lands us here, sets up
	r11 = Module info (tpnt pointer as expected by resolver)
	r12 = PC of the PLTn itself - needed by resolver to find
	      corresponding .rela.plt entry.  */

ENTRY (_dl_runtime_resolve)

	/* save args to func being resolved before entering resolver.  */
	push_s	r0
	push_s	r1
	push_s	r2
	push_s	r3
	st.a	r4, [sp, -4]
	st.a	r5, [sp, -4]
	st.a	r6, [sp, -4]
	st.a	r7, [sp, -4]
	st.a	r8, [sp, -4]
	st.a	r9, [sp, -4]
	cfi_adjust_cfa_offset (40)
	push_s	blink
	cfi_adjust_cfa_offset (4)
	cfi_rel_offset (blink, 0)

	mov_s 	r1, r12
	bl.d  	_dl_fixup
	mov   	r0, r11

	/* restore regs back.  */
	ld.ab	blink,[sp, 4]
	cfi_adjust_cfa_offset (-4)
	cfi_restore (blink)
	ld.ab	r9, [sp, 4]
	ld.ab	r8, [sp, 4]
	ld.ab	r7, [sp, 4]
	ld.ab	r6, [sp, 4]
	ld.ab	r5, [sp, 4]
	ld.ab	r4, [sp, 4]
	pop_s   r3
	pop_s   r2
	pop_s   r1
	cfi_adjust_cfa_offset (-36)

	j_s.d   [r0]    /* r0 has resolved function addr.  */
	pop_s   r0      /* restore first arg to resolved call.  */
	cfi_adjust_cfa_offset (-4)
	cfi_restore (r0)
END (_dl_runtime_resolve)