dl-trampoline.S 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /* PLT trampolines. m68k version.
  2. Copyright (C) 2005-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <sysdep.h>
  16. #if !defined (__mcoldfire__)
  17. # define FMOVE fmove.x
  18. # define FPSPACE 12
  19. #elif defined (__mcffpu__)
  20. # define FMOVE fmove.d
  21. # define FPSPACE 8
  22. #else
  23. # define FPSPACE 0
  24. #endif
  25. .text
  26. .globl _dl_runtime_resolve
  27. .type _dl_runtime_resolve, @function
  28. _dl_runtime_resolve:
  29. cfi_startproc
  30. cfi_adjust_cfa_offset (8)
  31. | Save %a0 (struct return address) and %a1.
  32. move.l %a0, -(%sp)
  33. cfi_adjust_cfa_offset (4)
  34. move.l %a1, -(%sp)
  35. cfi_adjust_cfa_offset (4)
  36. | Call the real address resolver.
  37. jbsr _dl_fixup
  38. | Restore register %a0 and %a1.
  39. move.l (%sp)+, %a1
  40. cfi_adjust_cfa_offset (-4)
  41. move.l (%sp)+, %a0
  42. cfi_adjust_cfa_offset (-4)
  43. | Pop parameters
  44. addq.l #8, %sp
  45. cfi_adjust_cfa_offset (-8)
  46. | Call real function.
  47. #ifdef __mcoldfire__
  48. move.l %d0,-(%sp)
  49. cfi_adjust_cfa_offset (4)
  50. rts
  51. #else
  52. jmp (%d0)
  53. #endif
  54. cfi_endproc
  55. .size _dl_runtime_resolve, . - _dl_runtime_resolve
  56. .text
  57. .globl _dl_runtime_profile
  58. .type _dl_runtime_profile, @function
  59. _dl_runtime_profile:
  60. cfi_startproc
  61. cfi_adjust_cfa_offset (8)
  62. pea 8(%sp)
  63. cfi_adjust_cfa_offset (4)
  64. move.l %a1, -(%sp)
  65. cfi_adjust_cfa_offset (4)
  66. move.l %a0, -(%sp)
  67. cfi_adjust_cfa_offset (4)
  68. pea -1.w
  69. cfi_adjust_cfa_offset (4)
  70. | Push parameters for _dl_profile_fixup
  71. pea (%sp)
  72. cfi_adjust_cfa_offset (4)
  73. pea 8(%sp)
  74. cfi_adjust_cfa_offset (4)
  75. move.l 32(%sp), -(%sp)
  76. cfi_adjust_cfa_offset (4)
  77. move.l 32(%sp), -(%sp)
  78. cfi_adjust_cfa_offset (4)
  79. move.l 32(%sp), -(%sp)
  80. cfi_adjust_cfa_offset (4)
  81. subq.l #8, %sp
  82. cfi_adjust_cfa_offset (8)
  83. | Call the real address resolver.
  84. jbsr _dl_profile_fixup
  85. | Pop parameters
  86. lea 28(%sp), %sp
  87. cfi_adjust_cfa_offset (-28)
  88. move.l (%sp), %d1
  89. jpl 1f
  90. addq.l #4, %sp
  91. cfi_adjust_cfa_offset (-4)
  92. | Restore register %a0 and %a1.
  93. move.l (%sp)+, %a0
  94. cfi_adjust_cfa_offset (-4)
  95. move.l (%sp)+, %a1
  96. cfi_adjust_cfa_offset (-4)
  97. lea 12(%sp), %sp
  98. cfi_adjust_cfa_offset (-12)
  99. | Call real function.
  100. #ifdef __mcoldfire__
  101. move.l %d0,-(%sp)
  102. cfi_adjust_cfa_offset (4)
  103. rts
  104. #else
  105. jmp (%d0)
  106. #endif
  107. /*
  108. +24 return address
  109. +20 PLT1
  110. +16 PLT2
  111. +12 %sp
  112. +8 %a1
  113. +4 %a0
  114. %sp free
  115. */
  116. #ifdef __mcoldfire__
  117. cfi_adjust_cfa_offset (20)
  118. #else
  119. cfi_adjust_cfa_offset (24)
  120. #endif
  121. 1: move.l %a2, (%sp)
  122. cfi_rel_offset (%a2, 0)
  123. move.l %sp, %a2
  124. move.l %sp, %a0
  125. lea 28(%sp), %a1
  126. | Round framesize up to longword alignment
  127. addq.l #3, %d1
  128. and.l #-3, %d1
  129. sub.l %d1, %a0
  130. move.l %a0, %sp
  131. cfi_def_cfa_register (%a2)
  132. #ifdef __mcoldfire__
  133. tst.l %d1
  134. beq 2f
  135. 1: move.l (%a1)+, (%a0)+
  136. subq.l #4,%d1
  137. bne 1b
  138. 2:
  139. #else
  140. lsr.l #2,%d1
  141. jra 2f
  142. 1: move.l (%a1)+, (%a0)+
  143. 2: dbra %d1,1b
  144. #endif
  145. /*
  146. %a2+24 return address
  147. %a2+20 PLT1
  148. %a2+16 PLT2
  149. %a2+12 %sp
  150. %a2+8 %a1
  151. %a2+4 %a0
  152. %a2 %a2
  153. %sp copied stack frame
  154. */
  155. move.l 4(%a2), %a0
  156. move.l 8(%a2), %a1
  157. #ifdef __mcoldfire__
  158. pea 2f(%pc)
  159. move.l %d0,-(%sp)
  160. rts
  161. 2:
  162. #else
  163. jsr (%d0)
  164. #endif
  165. move.l %a2, %sp
  166. cfi_def_cfa_register (%sp)
  167. move.l (%sp)+, %a2
  168. cfi_adjust_cfa_offset (4)
  169. cfi_restore (%a2)
  170. /*
  171. +20 return address
  172. +16 PLT1
  173. +12 PLT2
  174. +8 %sp
  175. +4 %a1
  176. %sp %a0
  177. */
  178. #ifdef FMOVE
  179. FMOVE %fp0, -(%sp)
  180. cfi_adjust_cfa_offset (FPSPACE)
  181. #endif
  182. move.l %a0, -(%sp)
  183. cfi_adjust_cfa_offset (4)
  184. move.l %d1, -(%sp)
  185. cfi_adjust_cfa_offset (4)
  186. move.l %d0, -(%sp)
  187. cfi_adjust_cfa_offset (4)
  188. pea (%sp)
  189. cfi_adjust_cfa_offset (4)
  190. pea (16+FPSPACE)(%sp)
  191. cfi_adjust_cfa_offset (4)
  192. move.l (32+FPSPACE)(%sp), -(%sp)
  193. cfi_adjust_cfa_offset (4)
  194. move.l (32+FPSPACE)(%sp), -(%sp)
  195. cfi_adjust_cfa_offset (4)
  196. jbsr _dl_call_pltexit
  197. lea 16(%sp), %sp
  198. cfi_adjust_cfa_offset (-16)
  199. move.l (%sp)+, %d0
  200. cfi_adjust_cfa_offset (-4)
  201. move.l (%sp)+, %d1
  202. cfi_adjust_cfa_offset (-4)
  203. move.l (%sp)+, %a0
  204. cfi_adjust_cfa_offset (-4)
  205. #ifdef FMOVE
  206. FMOVE (%sp)+, %fp0
  207. cfi_adjust_cfa_offset (-FPSPACE)
  208. #endif
  209. lea 20(%sp), %sp
  210. cfi_adjust_cfa_offset (-20)
  211. rts
  212. cfi_endproc
  213. .size _dl_runtime_profile, . - _dl_runtime_profile