about summary refs log tree commit diff
path: root/sysdeps/or1k/dl-trampoline.S
diff options
context:
space:
mode:
authorStafford Horne <shorne@gmail.com>2021-10-20 06:47:26 +0900
committerStafford Horne <shorne@gmail.com>2022-01-05 06:40:05 +0900
commit6e5964311d57c017ed0af3d87095e54805f2541e (patch)
tree4051701820df33ddd05c3451f88b475b8f5dbdfc /sysdeps/or1k/dl-trampoline.S
parent9dde3a24f132090fa8f88d6eaa2bc4c48f2e942f (diff)
downloadglibc-6e5964311d57c017ed0af3d87095e54805f2541e.tar.gz
glibc-6e5964311d57c017ed0af3d87095e54805f2541e.tar.xz
glibc-6e5964311d57c017ed0af3d87095e54805f2541e.zip
or1k: ABI Implementation
This code deals with the OpenRISC ABI.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/or1k/dl-trampoline.S')
-rw-r--r--sysdeps/or1k/dl-trampoline.S73
1 files changed, 73 insertions, 0 deletions
diff --git a/sysdeps/or1k/dl-trampoline.S b/sysdeps/or1k/dl-trampoline.S
new file mode 100644
index 0000000000..d2936cbd10
--- /dev/null
+++ b/sysdeps/or1k/dl-trampoline.S
@@ -0,0 +1,73 @@
+/* Machine-dependent ELF runtime symbol resolution, OpenRISC version.
+   Copyright (C) 2022 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sysdep.h>
+
+/* This code is plugged into the PLT and used by the dynamic linker to
+   call _dl_fixup (dl-runtime.c).
+
+   We assume that R11 contains the relocation offset and R12 contains
+   link_map (_DYNAMIC).  This must be consistent with the JUMP_SLOT
+   layout generated by binutils.  */
+
+ENTRY (_dl_runtime_resolve)
+	l.sw	-4(r1), r9
+	l.sw	-8(r1), r1
+
+	/* save function arguments.  */
+	l.sw	-12(r1), r3
+	l.sw	-16(r1), r4
+	l.sw	-20(r1), r5
+	l.sw	-24(r1), r6
+	l.sw	-28(r1), r7
+	l.sw	-32(r1), r8
+
+	.cfi_offset 9, -4
+	.cfi_offset 1, -8
+	.cfi_offset 3, -12
+	.cfi_offset 4, -16
+	.cfi_offset 5, -20
+	.cfi_offset 6, -24
+	.cfi_offset 7, -28
+	.cfi_offset 8, -32
+
+	l.addi	r1,r1, -32
+	.cfi_def_cfa_offset 32
+
+	l.ori	r3, r12, 0
+	l.ori	r4, r11, 0
+
+	l.jal	_dl_fixup
+	 l.nop
+
+	/* Restore function arguments.  */
+	l.addi	r1,r1, 32
+	l.lwz	r8, -32(r1)
+	l.lwz	r7, -28(r1)
+	l.lwz	r6, -24(r1)
+	l.lwz	r5, -20(r1)
+	l.lwz	r4, -16(r1)
+	l.lwz	r3, -12(r1)
+
+	/* restore return address.  */
+	l.lwz	r9, -4(r1)
+
+	l.jr	r11
+	 l.nop
+END (_dl_runtime_resolve)