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