jump_ppc64_sysv_elf_gas.S 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*
  2. Copyright Oliver Kowalke 2009.
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*******************************************************
  8. * *
  9. * ------------------------------------------------- *
  10. * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
  11. * ------------------------------------------------- *
  12. * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
  13. * ------------------------------------------------- *
  14. * | TOC | R14 | R15 | R16 | *
  15. * ------------------------------------------------- *
  16. * ------------------------------------------------- *
  17. * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
  18. * ------------------------------------------------- *
  19. * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
  20. * ------------------------------------------------- *
  21. * | R17 | R18 | R19 | R20 | *
  22. * ------------------------------------------------- *
  23. * ------------------------------------------------- *
  24. * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
  25. * ------------------------------------------------- *
  26. * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
  27. * ------------------------------------------------- *
  28. * | R21 | R22 | R23 | R24 | *
  29. * ------------------------------------------------- *
  30. * ------------------------------------------------- *
  31. * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
  32. * ------------------------------------------------- *
  33. * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
  34. * ------------------------------------------------- *
  35. * | R25 | R26 | R27 | R28 | *
  36. * ------------------------------------------------- *
  37. * ------------------------------------------------- *
  38. * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
  39. * ------------------------------------------------- *
  40. * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
  41. * ------------------------------------------------- *
  42. * | R29 | R30 | R31 | hidden | *
  43. * ------------------------------------------------- *
  44. * ------------------------------------------------- *
  45. * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
  46. * ------------------------------------------------- *
  47. * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
  48. * ------------------------------------------------- *
  49. * | CR | LR | PC | back-chain| *
  50. * ------------------------------------------------- *
  51. * ------------------------------------------------- *
  52. * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | *
  53. * ------------------------------------------------- *
  54. * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
  55. * ------------------------------------------------- *
  56. * | cr saved | lr saved | compiler | linker | *
  57. * ------------------------------------------------- *
  58. * ------------------------------------------------- *
  59. * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | *
  60. * ------------------------------------------------- *
  61. * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | *
  62. * ------------------------------------------------- *
  63. * | TOC saved | FCTX | DATA | | *
  64. * ------------------------------------------------- *
  65. * *
  66. *******************************************************/
  67. .globl jump_fcontext
  68. #if _CALL_ELF == 2
  69. .text
  70. .align 2
  71. jump_fcontext:
  72. addis %r2, %r12, .TOC.-jump_fcontext@ha
  73. addi %r2, %r2, .TOC.-jump_fcontext@l
  74. .localentry jump_fcontext, . - jump_fcontext
  75. #else
  76. .section ".opd","aw"
  77. .align 3
  78. jump_fcontext:
  79. # ifdef _CALL_LINUX
  80. .quad .L.jump_fcontext,.TOC.@tocbase,0
  81. .type jump_fcontext,@function
  82. .text
  83. .align 2
  84. .L.jump_fcontext:
  85. # else
  86. .hidden .jump_fcontext
  87. .globl .jump_fcontext
  88. .quad .jump_fcontext,.TOC.@tocbase,0
  89. .size jump_fcontext,24
  90. .type .jump_fcontext,@function
  91. .text
  92. .align 2
  93. .jump_fcontext:
  94. # endif
  95. #endif
  96. # reserve space on stack
  97. subi %r1, %r1, 184
  98. #if _CALL_ELF != 2
  99. std %r2, 0(%r1) # save TOC
  100. #endif
  101. std %r14, 8(%r1) # save R14
  102. std %r15, 16(%r1) # save R15
  103. std %r16, 24(%r1) # save R16
  104. std %r17, 32(%r1) # save R17
  105. std %r18, 40(%r1) # save R18
  106. std %r19, 48(%r1) # save R19
  107. std %r20, 56(%r1) # save R20
  108. std %r21, 64(%r1) # save R21
  109. std %r22, 72(%r1) # save R22
  110. std %r23, 80(%r1) # save R23
  111. std %r24, 88(%r1) # save R24
  112. std %r25, 96(%r1) # save R25
  113. std %r26, 104(%r1) # save R26
  114. std %r27, 112(%r1) # save R27
  115. std %r28, 120(%r1) # save R28
  116. std %r29, 128(%r1) # save R29
  117. std %r30, 136(%r1) # save R30
  118. std %r31, 144(%r1) # save R31
  119. #if _CALL_ELF != 2
  120. std %r3, 152(%r1) # save hidden
  121. #endif
  122. # save CR
  123. mfcr %r0
  124. std %r0, 160(%r1)
  125. # save LR
  126. mflr %r0
  127. std %r0, 168(%r1)
  128. # save LR as PC
  129. std %r0, 176(%r1)
  130. # store RSP (pointing to context-data) in R6
  131. mr %r6, %r1
  132. #if _CALL_ELF == 2
  133. # restore RSP (pointing to context-data) from R3
  134. mr %r1, %r3
  135. #else
  136. # restore RSP (pointing to context-data) from R4
  137. mr %r1, %r4
  138. ld %r2, 0(%r1) # restore TOC
  139. #endif
  140. ld %r14, 8(%r1) # restore R14
  141. ld %r15, 16(%r1) # restore R15
  142. ld %r16, 24(%r1) # restore R16
  143. ld %r17, 32(%r1) # restore R17
  144. ld %r18, 40(%r1) # restore R18
  145. ld %r19, 48(%r1) # restore R19
  146. ld %r20, 56(%r1) # restore R20
  147. ld %r21, 64(%r1) # restore R21
  148. ld %r22, 72(%r1) # restore R22
  149. ld %r23, 80(%r1) # restore R23
  150. ld %r24, 88(%r1) # restore R24
  151. ld %r25, 96(%r1) # restore R25
  152. ld %r26, 104(%r1) # restore R26
  153. ld %r27, 112(%r1) # restore R27
  154. ld %r28, 120(%r1) # restore R28
  155. ld %r29, 128(%r1) # restore R29
  156. ld %r30, 136(%r1) # restore R30
  157. ld %r31, 144(%r1) # restore R31
  158. #if _CALL_ELF != 2
  159. ld %r3, 152(%r1) # restore hidden
  160. #endif
  161. # restore CR
  162. ld %r0, 160(%r1)
  163. mtcr %r0
  164. # restore LR
  165. ld %r0, 168(%r1)
  166. mtlr %r0
  167. # load PC
  168. ld %r12, 176(%r1)
  169. # restore CTR
  170. mtctr %r12
  171. # adjust stack
  172. addi %r1, %r1, 184
  173. #if _CALL_ELF == 2
  174. # copy transfer_t into transfer_fn arg registers
  175. mr %r3, %r6
  176. # arg pointer already in %r4
  177. # jump to context
  178. bctr
  179. .size jump_fcontext, .-jump_fcontext
  180. #else
  181. # zero in r3 indicates first jump to context-function
  182. cmpdi %r3, 0
  183. beq use_entry_arg
  184. # return transfer_t
  185. std %r6, 0(%r3)
  186. std %r5, 8(%r3)
  187. # jump to context
  188. bctr
  189. use_entry_arg:
  190. # copy transfer_t into transfer_fn arg registers
  191. mr %r3, %r6
  192. mr %r4, %r5
  193. # jump to context
  194. bctr
  195. # ifdef _CALL_LINUX
  196. .size .jump_fcontext, .-.L.jump_fcontext
  197. # else
  198. .size .jump_fcontext, .-.jump_fcontext
  199. # endif
  200. #endif
  201. /* Mark that we don't need executable stack. */
  202. .section .note.GNU-stack,"",%progbits