summaryrefslogtreecommitdiff
path: root/ldso/ldso/nds32/resolve.S
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2016-04-21 01:25:29 +0200
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2016-06-30 03:24:42 +0200
commitee92c0fe5c1b9d59508273916e2c9a75b68dbc13 (patch)
tree65a22258b12f84325910fc2ad47e2b02696ef593 /ldso/ldso/nds32/resolve.S
parentdd46699e46decb7273f44dc2cbf307f096dc39e8 (diff)
nds32: add support for new architecture
Add support for Andes Technology NDS32 architecture. See here http://www.andestech.com/en/index/index.htm for more informaton. Verification of the port from an older uClibc port was done on a sponsored AG101p board. The testsuite only has 5 errors, three are related to an existing bug in dlclose() with LT.old, also happening on cris32 and m68k. Failures to fallocate/posix_fallocate are unresolved. Thanks to Andes Technology sponsoring the hardware and being very helpful while doing the uClibc-ng porting. Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
Diffstat (limited to 'ldso/ldso/nds32/resolve.S')
-rw-r--r--ldso/ldso/nds32/resolve.S76
1 files changed, 76 insertions, 0 deletions
diff --git a/ldso/ldso/nds32/resolve.S b/ldso/ldso/nds32/resolve.S
new file mode 100644
index 000000000..8c53850d7
--- /dev/null
+++ b/ldso/ldso/nds32/resolve.S
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2016 Andes Technology, Inc.
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#if defined(NDS32_ABI_2) || defined(NDS32_ABI_2FP)
+# define STACK_PUSH
+# define STACK_POP
+#else
+# define STACK_PUSH addi $sp, $sp, -24
+# define STACK_POP addi $sp, $sp, 24
+#endif
+
+ .text
+ .align 4 ! 16 byte boundary
+ .globl _dl_linux_resolve
+ .type _dl_linux_resolve,#function
+ .pic
+
+_dl_linux_resolve:
+ ! we get called with
+ ! lp contains the return address from this call
+ ! r16 contains offset to target reloc entry
+ ! r17 contains GOT[1] (identity of taget lib)
+ ! ta is GOT[2] (starting address of this function)
+
+ ! save arguments r0 - r5 and gp, lp
+ smw.adm $r0, [$sp], $r5, 6
+
+ ! init gp
+#ifdef __NDS32_N1213_43U1H__
+ sethi $gp, HI20(_GLOBAL_OFFSET_TABLE_+4)
+ ori $gp, $gp, LO12(_GLOBAL_OFFSET_TABLE_+8)
+ add $gp, $ta, $gp
+#else
+ mfusr $ta, $PC
+ sethi $gp, HI20(_GLOBAL_OFFSET_TABLE_+4)
+ ori $gp, $gp, LO12(_GLOBAL_OFFSET_TABLE_+8)
+ add $gp, $ta, $gp
+#endif
+
+ ! #ifdef __NDS32_ABI_1__
+ ! adjust stack
+ !addi $sp, $sp, -24
+ STACK_PUSH
+ ! #endif
+
+ ! set arguments
+ addi $r0, $r17, 0
+ !addi $r1, $r16, 0
+ slli $r1, $r16, 2
+ slli $r16, $r16, 3
+ add $r1, $r1, $r16
+
+ ! comment out profiling argument
+ !addi $r2, $lp, 0
+
+ ! call fixup routine
+ bal _dl_linux_resolver@PLT
+
+ ! save the return
+ addi $ta, $r0, 0
+
+ ! #ifdef __NDS32_ABI_1__
+ ! adjust sp
+ !addi $sp, $sp, 24
+ STACK_POP
+ ! #endif
+
+ ! reload registers
+ lmw.bim $r0, [$sp], $r5, 6
+
+ ! jump to the newly found address
+ jr $ta
+
+.size _dl_linux_resolve, .-_dl_linux_resolve