resolve.S 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Stolen from glibc-2.2.2 by Eddie C. Dost <ecd@atecom.com>
  3. */
  4. .text
  5. .globl _dl_linux_resolver
  6. .globl _dl_linux_resolve
  7. .type _dl_linux_resolve, @function
  8. .balign 16
  9. _dl_linux_resolve:
  10. mov.l r3, @-r15
  11. mov.l r4, @-r15
  12. mov.l r5, @-r15
  13. mov.l r6, @-r15
  14. mov.l r7, @-r15
  15. mov.l r12, @-r15
  16. movt r3 ! Save T flag
  17. mov.l r3, @-r15
  18. #ifdef HAVE_FPU
  19. sts.l fpscr, @-r15
  20. mov #8,r3
  21. swap.w r3, r3
  22. lds r3, fpscr
  23. fmov.s fr11, @-r15
  24. fmov.s fr10, @-r15
  25. fmov.s fr9, @-r15
  26. fmov.s fr8, @-r15
  27. fmov.s fr7, @-r15
  28. fmov.s fr6, @-r15
  29. fmov.s fr5, @-r15
  30. fmov.s fr4, @-r15
  31. #endif
  32. sts.l pr, @-r15
  33. /* Note - The PLT entries have been "optimised" not to use r2. r2 is used by
  34. GCC to return the address of large structures, so it should not be
  35. corrupted here. This does mean however, that those PLTs does not conform
  36. to the SH PIC ABI. That spec says that r0 contains the type of the PLT
  37. and r2 contains the GOT id. The GNU Plt version stores the GOT id in r0 and
  38. ignores the type. We can easily detect this difference however,
  39. since the type will always be 0 or 8, and the GOT ids will always be
  40. greater than or equal to 12.
  41. Found in binutils/bfd/elf32-sh.c by Stefan Allius <allius@atecom.com>
  42. */
  43. mov #8 ,r5
  44. cmp/gt r5, r0
  45. bt 1f
  46. mov r2, r0 ! link map address in r2 (SH PIC ABI)
  47. 1:
  48. mov r0, r4 ! link map address in r0 (GNUs PLT)
  49. mova .LG, r0
  50. mov.l .LG, r5
  51. add r5, r0
  52. mov.l 3f, r5
  53. mov.l @(r0, r5),r5
  54. jsr @r5
  55. mov r1, r5 ! Reloc offset
  56. lds.l @r15+, pr ! Get register content back
  57. #ifdef HAVE_FPU
  58. fmov.s @r15+, fr4
  59. fmov.s @r15+, fr5
  60. fmov.s @r15+, fr6
  61. fmov.s @r15+, fr7
  62. fmov.s @r15+, fr8
  63. fmov.s @r15+, fr9
  64. fmov.s @r15+, fr10
  65. fmov.s @r15+, fr11
  66. lds.l @r15+, fpscr
  67. #endif
  68. mov.l @r15+, r3
  69. shal r3 ! Load T flag
  70. mov.l @r15+, r12
  71. mov.l @r15+, r7
  72. mov.l @r15+, r6
  73. mov.l @r15+, r5
  74. mov.l @r15+, r4
  75. jmp @r0 ! Jump to function address
  76. mov.l @r15+, r3
  77. .balign 4
  78. 3:
  79. .long _dl_linux_resolver@GOT
  80. .LG:
  81. .long _GLOBAL_OFFSET_TABLE_
  82. .size _dl_linux_resolve, . - _dl_linux_resolve