resolve.S 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* Xtensa dynamic resolver.
  2. Parts copied from glibc/sysdeps/xtensa/dl-trampoline.S
  3. Copyright (C) 2007 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #define MIN_FRAME_SIZE 32
  17. #ifdef __XTENSA_EB__
  18. #define XTENSA_IMM12_FLD_OFFSET 8
  19. #else /* __XTENSA_EL__ */
  20. #define XTENSA_IMM12_FLD_OFFSET 12
  21. #endif /* __XTENSA_EL__ */
  22. .text
  23. .align 4
  24. .literal_position
  25. .global _dl_linux_resolve
  26. .type _dl_linux_resolve, @function
  27. _dl_linux_resolve:
  28. #if defined(__XTENSA_WINDOWED_ABI__)
  29. /* Call the fixup function. */
  30. movi a8, _dl_linux_resolver
  31. callx8 a8
  32. /* Extract the target's frame size from the ENTRY instruction. */
  33. l32i a11, a10, 0
  34. extui a11, a11, XTENSA_IMM12_FLD_OFFSET, 12
  35. slli a11, a11, 3
  36. addi a11, a11, -MIN_FRAME_SIZE
  37. sub a11, sp, a11
  38. movsp sp, a11
  39. /* Jump to the next instruction past the ENTRY. */
  40. addi a10, a10, 3
  41. jx a10
  42. #elif defined(__XTENSA_CALL0_ABI__)
  43. /* Reserve stack space and save incoming arguments. */
  44. addi a1, a1, -32
  45. s32i a0, a1, 0
  46. s32i a2, a1, 8
  47. s32i a3, a1, 12
  48. s32i a4, a1, 16
  49. s32i a5, a1, 20
  50. s32i a6, a1, 24
  51. s32i a7, a1, 28
  52. /* Move arguments for the _dl_linux_resolver to proper registers. */
  53. mov a2, a10
  54. mov a3, a11
  55. /* Call the fixup function. */
  56. movi a0, _dl_linux_resolver
  57. callx0 a0
  58. mov a10, a2
  59. /* Restore incoming arguments from stack and deallocate reservation. */
  60. l32i a0, a1, 0
  61. l32i a2, a1, 8
  62. l32i a3, a1, 12
  63. l32i a4, a1, 16
  64. l32i a5, a1, 20
  65. l32i a6, a1, 24
  66. l32i a7, a1, 28
  67. addi a1, a1, 32
  68. /* Jump to the target function. */
  69. jx a10
  70. #else
  71. #error Unsupported Xtensa ABI
  72. #endif
  73. .size _dl_linux_resolve, . - _dl_linux_resolve