tsan_rtl_aarch64.S 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. // The content of this file is AArch64-only:
  2. #if defined(__aarch64__)
  3. #include "sanitizer_common/sanitizer_asm.h"
  4. #if defined(__APPLE__)
  5. .align 2
  6. .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
  7. .long _setjmp$non_lazy_ptr
  8. _setjmp$non_lazy_ptr:
  9. .indirect_symbol _setjmp
  10. .long 0
  11. .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
  12. .long __setjmp$non_lazy_ptr
  13. __setjmp$non_lazy_ptr:
  14. .indirect_symbol __setjmp
  15. .long 0
  16. .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
  17. .long _sigsetjmp$non_lazy_ptr
  18. _sigsetjmp$non_lazy_ptr:
  19. .indirect_symbol _sigsetjmp
  20. .long 0
  21. #endif
  22. #if !defined(__APPLE__)
  23. .section .text
  24. #else
  25. .section __TEXT,__text
  26. .align 3
  27. #endif
  28. ASM_HIDDEN(__tsan_setjmp)
  29. .comm _ZN14__interception11real_setjmpE,8,8
  30. .globl ASM_SYMBOL_INTERCEPTOR(setjmp)
  31. ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(setjmp))
  32. ASM_SYMBOL_INTERCEPTOR(setjmp):
  33. CFI_STARTPROC
  34. // Save frame/link register
  35. stp x29, x30, [sp, -32]!
  36. CFI_DEF_CFA_OFFSET (32)
  37. CFI_OFFSET (29, -32)
  38. CFI_OFFSET (30, -24)
  39. // Adjust the SP for previous frame
  40. add x29, sp, 0
  41. CFI_DEF_CFA_REGISTER (29)
  42. // Save env parameter
  43. str x0, [sp, 16]
  44. CFI_OFFSET (0, -16)
  45. // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
  46. add x0, x29, 32
  47. // call tsan interceptor
  48. bl ASM_SYMBOL(__tsan_setjmp)
  49. // Restore env parameter
  50. ldr x0, [sp, 16]
  51. CFI_RESTORE (0)
  52. // Restore frame/link register
  53. ldp x29, x30, [sp], 32
  54. CFI_RESTORE (29)
  55. CFI_RESTORE (30)
  56. CFI_DEF_CFA (31, 0)
  57. // tail jump to libc setjmp
  58. #if !defined(__APPLE__)
  59. adrp x1, :got:_ZN14__interception11real_setjmpE
  60. ldr x1, [x1, #:got_lo12:_ZN14__interception11real_setjmpE]
  61. ldr x1, [x1]
  62. #else
  63. adrp x1, _setjmp$non_lazy_ptr@page
  64. add x1, x1, _setjmp$non_lazy_ptr@pageoff
  65. ldr x1, [x1]
  66. #endif
  67. br x1
  68. CFI_ENDPROC
  69. ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(setjmp))
  70. .comm _ZN14__interception12real__setjmpE,8,8
  71. .globl ASM_SYMBOL_INTERCEPTOR(_setjmp)
  72. ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(_setjmp))
  73. ASM_SYMBOL_INTERCEPTOR(_setjmp):
  74. CFI_STARTPROC
  75. // Save frame/link register
  76. stp x29, x30, [sp, -32]!
  77. CFI_DEF_CFA_OFFSET (32)
  78. CFI_OFFSET (29, -32)
  79. CFI_OFFSET (30, -24)
  80. // Adjust the SP for previous frame
  81. add x29, sp, 0
  82. CFI_DEF_CFA_REGISTER (29)
  83. // Save env parameter
  84. str x0, [sp, 16]
  85. CFI_OFFSET (0, -16)
  86. // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
  87. add x0, x29, 32
  88. // call tsan interceptor
  89. bl ASM_SYMBOL(__tsan_setjmp)
  90. // Restore env parameter
  91. ldr x0, [sp, 16]
  92. CFI_RESTORE (0)
  93. // Restore frame/link register
  94. ldp x29, x30, [sp], 32
  95. CFI_RESTORE (29)
  96. CFI_RESTORE (30)
  97. CFI_DEF_CFA (31, 0)
  98. // tail jump to libc setjmp
  99. #if !defined(__APPLE__)
  100. adrp x1, :got:_ZN14__interception12real__setjmpE
  101. ldr x1, [x1, #:got_lo12:_ZN14__interception12real__setjmpE]
  102. ldr x1, [x1]
  103. #else
  104. adrp x1, __setjmp$non_lazy_ptr@page
  105. add x1, x1, __setjmp$non_lazy_ptr@pageoff
  106. ldr x1, [x1]
  107. #endif
  108. br x1
  109. CFI_ENDPROC
  110. ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(_setjmp))
  111. .comm _ZN14__interception14real_sigsetjmpE,8,8
  112. .globl ASM_SYMBOL_INTERCEPTOR(sigsetjmp)
  113. ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
  114. ASM_SYMBOL_INTERCEPTOR(sigsetjmp):
  115. CFI_STARTPROC
  116. // Save frame/link register
  117. stp x29, x30, [sp, -32]!
  118. CFI_DEF_CFA_OFFSET (32)
  119. CFI_OFFSET (29, -32)
  120. CFI_OFFSET (30, -24)
  121. // Adjust the SP for previous frame
  122. add x29, sp, 0
  123. CFI_DEF_CFA_REGISTER (29)
  124. // Save env and savesigs parameter
  125. stp x0, x1, [sp, 16]
  126. CFI_OFFSET (0, -16)
  127. CFI_OFFSET (1, -8)
  128. // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
  129. add x0, x29, 32
  130. // call tsan interceptor
  131. bl ASM_SYMBOL(__tsan_setjmp)
  132. // Restore env and savesigs parameter
  133. ldp x0, x1, [sp, 16]
  134. CFI_RESTORE (0)
  135. CFI_RESTORE (1)
  136. // Restore frame/link register
  137. ldp x29, x30, [sp], 32
  138. CFI_RESTORE (29)
  139. CFI_RESTORE (30)
  140. CFI_DEF_CFA (31, 0)
  141. // tail jump to libc sigsetjmp
  142. #if !defined(__APPLE__)
  143. adrp x2, :got:_ZN14__interception14real_sigsetjmpE
  144. ldr x2, [x2, #:got_lo12:_ZN14__interception14real_sigsetjmpE]
  145. ldr x2, [x2]
  146. #else
  147. adrp x2, _sigsetjmp$non_lazy_ptr@page
  148. add x2, x2, _sigsetjmp$non_lazy_ptr@pageoff
  149. ldr x2, [x2]
  150. #endif
  151. br x2
  152. CFI_ENDPROC
  153. ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
  154. #if !defined(__APPLE__)
  155. .comm _ZN14__interception16real___sigsetjmpE,8,8
  156. .globl ASM_SYMBOL_INTERCEPTOR(__sigsetjmp)
  157. ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
  158. ASM_SYMBOL_INTERCEPTOR(__sigsetjmp):
  159. CFI_STARTPROC
  160. // Save frame/link register
  161. stp x29, x30, [sp, -32]!
  162. CFI_DEF_CFA_OFFSET (32)
  163. CFI_OFFSET (29, -32)
  164. CFI_OFFSET (30, -24)
  165. // Adjust the SP for previous frame
  166. add x29, sp, 0
  167. CFI_DEF_CFA_REGISTER (29)
  168. // Save env and savesigs parameter
  169. stp x0, x1, [sp, 16]
  170. CFI_OFFSET (0, -16)
  171. CFI_OFFSET (1, -8)
  172. // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
  173. add x0, x29, 32
  174. // call tsan interceptor
  175. bl ASM_SYMBOL(__tsan_setjmp)
  176. // Restore env and savesigs parameter
  177. ldp x0, x1, [sp, 16]
  178. CFI_RESTORE (0)
  179. CFI_RESTORE (1)
  180. // Restore frame/link register
  181. ldp x29, x30, [sp], 32
  182. CFI_RESTORE (29)
  183. CFI_RESTORE (30)
  184. CFI_DEF_CFA (31, 0)
  185. // tail jump to libc __sigsetjmp
  186. #if !defined(__APPLE__)
  187. adrp x2, :got:_ZN14__interception16real___sigsetjmpE
  188. ldr x2, [x2, #:got_lo12:_ZN14__interception16real___sigsetjmpE]
  189. ldr x2, [x2]
  190. #else
  191. adrp x2, ASM_SYMBOL(__sigsetjmp)@page
  192. add x2, x2, ASM_SYMBOL(__sigsetjmp)@pageoff
  193. #endif
  194. br x2
  195. CFI_ENDPROC
  196. ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
  197. #endif
  198. NO_EXEC_STACK_DIRECTIVE
  199. #endif