resolve.S 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2017 Hangzhou C-SKY Microsystems co.,ltd.
  3. *
  4. * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB
  5. * in this tarball.
  6. */
  7. /*
  8. * This function is not called directly. It is jumped when attempting to use a
  9. * symbol that has not yet been resolved.
  10. *
  11. *.plt*:
  12. * subi r0, 32
  13. * stw r2, (r0, 0)
  14. * stw r3, (r0, 4)
  15. * lrw r3, #offset
  16. * ldw r2, (gb, 8)
  17. * jmp r2
  18. */
  19. .import _dl_linux_resolver
  20. .text
  21. .globl _dl_linux_resolve
  22. .type _dl_linux_resolve,@function
  23. _dl_linux_resolve:
  24. #ifdef __CSKYABIV1__
  25. stw r4, (r0, 8)
  26. stw r5, (r0, 12)
  27. stw r6, (r0, 16)
  28. stw r7, (r0, 20)
  29. stw r15,(r0, 24)
  30. # load the ID of this module
  31. ldw r2, (gb, 4)
  32. # r2 = id, r3 = offset(do it in plt*)
  33. #ifdef __PIC__
  34. # get global offset table address_
  35. bsr .L2
  36. .L2:
  37. lrw r7, .L2@GOTPC
  38. add r7, r15
  39. # get the address of function (_dl_linux_resolver) in got table
  40. lrw r6, _dl_linux_resolver@GOT
  41. add r6, r7
  42. ldw r5, (r6, 0)
  43. jsr r5
  44. #else /* no __PIC__ */
  45. jsri _dl_linux_resolver /* need modify */
  46. #endif
  47. # Return from _dl_linux_resolver, the address of function is in r2
  48. mov r1, r2
  49. # Restore the registers
  50. ldw r2, (r0, 0)
  51. ldw r3, (r0, 4)
  52. ldw r4, (r0, 8)
  53. ldw r5, (r0, 12)
  54. ldw r6, (r0, 16)
  55. ldw r7, (r0, 20)
  56. ldw r15,(r0, 24)
  57. # Restore the r0, because r0 is subtracted in PLT table
  58. addi r0, 32
  59. # The address of function is in r1, call the function without saving pc
  60. jmp r1
  61. #else /* __CSKYABIV1__ */
  62. subi sp, 20
  63. stm a0-a3, (sp)
  64. stw lr, (sp, 16)
  65. # a0 = id, a1 = offset(do it in plt*)
  66. ldw a0, (gb, 4)
  67. mov a1, t1
  68. bsr _dl_linux_resolver
  69. mov t0, a0
  70. ldw lr, (sp, 16)
  71. ldm a0-a3, (sp)
  72. addi sp, 20
  73. jmp t0
  74. #endif