From ee92c0fe5c1b9d59508273916e2c9a75b68dbc13 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Thu, 21 Apr 2016 01:25:29 +0200 Subject: 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 --- ldso/ldso/nds32/resolve.S | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 ldso/ldso/nds32/resolve.S (limited to 'ldso/ldso/nds32/resolve.S') 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 -- cgit v1.2.3