resolve.S 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (C) 2016 Andes Technology, Inc.
  3. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  4. */
  5. #if defined(NDS32_ABI_2) || defined(NDS32_ABI_2FP)
  6. # define STACK_PUSH
  7. # define STACK_POP
  8. #else
  9. # define STACK_PUSH addi $sp, $sp, -24
  10. # define STACK_POP addi $sp, $sp, 24
  11. #endif
  12. .text
  13. .align 4 ! 16 byte boundary
  14. .globl _dl_linux_resolve
  15. .type _dl_linux_resolve,#function
  16. .pic
  17. _dl_linux_resolve:
  18. ! we get called with
  19. ! lp contains the return address from this call
  20. ! r16 contains offset to target reloc entry
  21. ! r17 contains GOT[1] (identity of taget lib)
  22. ! ta is GOT[2] (starting address of this function)
  23. ! save arguments r0 - r5 and gp, lp
  24. smw.adm $r0, [$sp], $r5, 6
  25. ! init gp
  26. #ifdef __NDS32_N1213_43U1H__
  27. sethi $gp, HI20(_GLOBAL_OFFSET_TABLE_+4)
  28. ori $gp, $gp, LO12(_GLOBAL_OFFSET_TABLE_+8)
  29. add $gp, $ta, $gp
  30. #else
  31. mfusr $ta, $PC
  32. sethi $gp, HI20(_GLOBAL_OFFSET_TABLE_+4)
  33. ori $gp, $gp, LO12(_GLOBAL_OFFSET_TABLE_+8)
  34. add $gp, $ta, $gp
  35. #endif
  36. ! #ifdef __NDS32_ABI_1__
  37. ! adjust stack
  38. !addi $sp, $sp, -24
  39. STACK_PUSH
  40. ! #endif
  41. ! set arguments
  42. addi $r0, $r17, 0
  43. !addi $r1, $r16, 0
  44. slli $r1, $r16, 2
  45. slli $r16, $r16, 3
  46. add $r1, $r1, $r16
  47. ! comment out profiling argument
  48. !addi $r2, $lp, 0
  49. ! call fixup routine
  50. bal _dl_linux_resolver@PLT
  51. ! save the return
  52. addi $ta, $r0, 0
  53. ! #ifdef __NDS32_ABI_1__
  54. ! adjust sp
  55. !addi $sp, $sp, 24
  56. STACK_POP
  57. ! #endif
  58. ! reload registers
  59. lmw.bim $r0, [$sp], $r5, 6
  60. ! jump to the newly found address
  61. jr $ta
  62. .size _dl_linux_resolve, .-_dl_linux_resolve