Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 1 | #include "sanitizer_common/sanitizer_asm.h" |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 2 | #if !defined(__APPLE__) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 3 | .section .text |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 4 | #else |
| 5 | .section __TEXT,__text |
| 6 | #endif |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 7 | |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 8 | ASM_HIDDEN(__tsan_trace_switch) |
| 9 | .globl ASM_TSAN_SYMBOL(__tsan_trace_switch_thunk) |
| 10 | ASM_TSAN_SYMBOL(__tsan_trace_switch_thunk): |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 11 | CFI_STARTPROC |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 12 | # Save scratch registers. |
| 13 | push %rax |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 14 | CFI_ADJUST_CFA_OFFSET(8) |
| 15 | CFI_REL_OFFSET(%rax, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 16 | push %rcx |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 17 | CFI_ADJUST_CFA_OFFSET(8) |
| 18 | CFI_REL_OFFSET(%rcx, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 19 | push %rdx |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 20 | CFI_ADJUST_CFA_OFFSET(8) |
| 21 | CFI_REL_OFFSET(%rdx, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 22 | push %rsi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 23 | CFI_ADJUST_CFA_OFFSET(8) |
| 24 | CFI_REL_OFFSET(%rsi, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 25 | push %rdi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 26 | CFI_ADJUST_CFA_OFFSET(8) |
| 27 | CFI_REL_OFFSET(%rdi, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 28 | push %r8 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 29 | CFI_ADJUST_CFA_OFFSET(8) |
| 30 | CFI_REL_OFFSET(%r8, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 31 | push %r9 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 32 | CFI_ADJUST_CFA_OFFSET(8) |
| 33 | CFI_REL_OFFSET(%r9, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 34 | push %r10 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 35 | CFI_ADJUST_CFA_OFFSET(8) |
| 36 | CFI_REL_OFFSET(%r10, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 37 | push %r11 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 38 | CFI_ADJUST_CFA_OFFSET(8) |
| 39 | CFI_REL_OFFSET(%r11, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 40 | # Align stack frame. |
| 41 | push %rbx # non-scratch |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 42 | CFI_ADJUST_CFA_OFFSET(8) |
| 43 | CFI_REL_OFFSET(%rbx, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 44 | mov %rsp, %rbx # save current rsp |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 45 | CFI_DEF_CFA_REGISTER(%rbx) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 46 | shr $4, %rsp # clear 4 lsb, align to 16 |
| 47 | shl $4, %rsp |
| 48 | |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 49 | call ASM_TSAN_SYMBOL(__tsan_trace_switch) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 50 | |
| 51 | # Unalign stack frame back. |
| 52 | mov %rbx, %rsp # restore the original rsp |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 53 | CFI_DEF_CFA_REGISTER(%rsp) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 54 | pop %rbx |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 55 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 56 | # Restore scratch registers. |
| 57 | pop %r11 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 58 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 59 | pop %r10 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 60 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 61 | pop %r9 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 62 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 63 | pop %r8 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 64 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 65 | pop %rdi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 66 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 67 | pop %rsi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 68 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 69 | pop %rdx |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 70 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 71 | pop %rcx |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 72 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 73 | pop %rax |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 74 | CFI_ADJUST_CFA_OFFSET(-8) |
| 75 | CFI_RESTORE(%rax) |
| 76 | CFI_RESTORE(%rbx) |
| 77 | CFI_RESTORE(%rcx) |
| 78 | CFI_RESTORE(%rdx) |
| 79 | CFI_RESTORE(%rsi) |
| 80 | CFI_RESTORE(%rdi) |
| 81 | CFI_RESTORE(%r8) |
| 82 | CFI_RESTORE(%r9) |
| 83 | CFI_RESTORE(%r10) |
| 84 | CFI_RESTORE(%r11) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 85 | ret |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 86 | CFI_ENDPROC |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 87 | |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 88 | ASM_HIDDEN(__tsan_report_race) |
| 89 | .globl ASM_TSAN_SYMBOL(__tsan_report_race_thunk) |
| 90 | ASM_TSAN_SYMBOL(__tsan_report_race_thunk): |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 91 | CFI_STARTPROC |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 92 | # Save scratch registers. |
| 93 | push %rax |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 94 | CFI_ADJUST_CFA_OFFSET(8) |
| 95 | CFI_REL_OFFSET(%rax, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 96 | push %rcx |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 97 | CFI_ADJUST_CFA_OFFSET(8) |
| 98 | CFI_REL_OFFSET(%rcx, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 99 | push %rdx |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 100 | CFI_ADJUST_CFA_OFFSET(8) |
| 101 | CFI_REL_OFFSET(%rdx, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 102 | push %rsi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 103 | CFI_ADJUST_CFA_OFFSET(8) |
| 104 | CFI_REL_OFFSET(%rsi, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 105 | push %rdi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 106 | CFI_ADJUST_CFA_OFFSET(8) |
| 107 | CFI_REL_OFFSET(%rdi, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 108 | push %r8 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 109 | CFI_ADJUST_CFA_OFFSET(8) |
| 110 | CFI_REL_OFFSET(%r8, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 111 | push %r9 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 112 | CFI_ADJUST_CFA_OFFSET(8) |
| 113 | CFI_REL_OFFSET(%r9, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 114 | push %r10 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 115 | CFI_ADJUST_CFA_OFFSET(8) |
| 116 | CFI_REL_OFFSET(%r10, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 117 | push %r11 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 118 | CFI_ADJUST_CFA_OFFSET(8) |
| 119 | CFI_REL_OFFSET(%r11, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 120 | # Align stack frame. |
| 121 | push %rbx # non-scratch |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 122 | CFI_ADJUST_CFA_OFFSET(8) |
| 123 | CFI_REL_OFFSET(%rbx, 0) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 124 | mov %rsp, %rbx # save current rsp |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 125 | CFI_DEF_CFA_REGISTER(%rbx) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 126 | shr $4, %rsp # clear 4 lsb, align to 16 |
| 127 | shl $4, %rsp |
| 128 | |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 129 | call ASM_TSAN_SYMBOL(__tsan_report_race) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 130 | |
| 131 | # Unalign stack frame back. |
| 132 | mov %rbx, %rsp # restore the original rsp |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 133 | CFI_DEF_CFA_REGISTER(%rsp) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 134 | pop %rbx |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 135 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 136 | # Restore scratch registers. |
| 137 | pop %r11 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 138 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 139 | pop %r10 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 140 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 141 | pop %r9 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 142 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 143 | pop %r8 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 144 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 145 | pop %rdi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 146 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 147 | pop %rsi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 148 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 149 | pop %rdx |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 150 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 151 | pop %rcx |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 152 | CFI_ADJUST_CFA_OFFSET(-8) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 153 | pop %rax |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 154 | CFI_ADJUST_CFA_OFFSET(-8) |
| 155 | CFI_RESTORE(%rax) |
| 156 | CFI_RESTORE(%rbx) |
| 157 | CFI_RESTORE(%rcx) |
| 158 | CFI_RESTORE(%rdx) |
| 159 | CFI_RESTORE(%rsi) |
| 160 | CFI_RESTORE(%rdi) |
| 161 | CFI_RESTORE(%r8) |
| 162 | CFI_RESTORE(%r9) |
| 163 | CFI_RESTORE(%r10) |
| 164 | CFI_RESTORE(%r11) |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 165 | ret |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 166 | CFI_ENDPROC |
Dmitry Vyukov | a911c6f | 2012-08-17 18:05:28 +0000 | [diff] [blame] | 167 | |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 168 | ASM_HIDDEN(__tsan_setjmp) |
| 169 | #if !defined(__APPLE__) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 170 | .comm _ZN14__interception11real_setjmpE,8,8 |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 171 | #endif |
| 172 | .globl ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp) |
| 173 | ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp)) |
| 174 | ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp): |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 175 | CFI_STARTPROC |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 176 | // save env parameter |
| 177 | push %rdi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 178 | CFI_ADJUST_CFA_OFFSET(8) |
| 179 | CFI_REL_OFFSET(%rdi, 0) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 180 | // obtain %rsp |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 181 | #if defined(__FreeBSD__) |
| 182 | lea 8(%rsp), %rdi |
| 183 | mov %rdi, %rsi |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 184 | #elif defined(__APPLE__) |
| 185 | lea 16(%rsp), %rdi |
| 186 | mov %rdi, %rsi |
| 187 | #elif defined(__linux__) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 188 | lea 16(%rsp), %rdi |
| 189 | mov %rdi, %rsi |
| 190 | xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp) |
| 191 | rol $0x11, %rsi |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 192 | #else |
| 193 | # error "Unknown platform" |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 194 | #endif |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 195 | // call tsan interceptor |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 196 | call ASM_TSAN_SYMBOL(__tsan_setjmp) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 197 | // restore env parameter |
| 198 | pop %rdi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 199 | CFI_ADJUST_CFA_OFFSET(-8) |
| 200 | CFI_RESTORE(%rdi) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 201 | // tail jump to libc setjmp |
| 202 | movl $0, %eax |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 203 | #if !defined(__APPLE__) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 204 | movq _ZN14__interception11real_setjmpE@GOTPCREL(%rip), %rdx |
| 205 | jmp *(%rdx) |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 206 | #else |
| 207 | jmp ASM_TSAN_SYMBOL(setjmp) |
| 208 | #endif |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 209 | CFI_ENDPROC |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 210 | ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp)) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 211 | |
| 212 | .comm _ZN14__interception12real__setjmpE,8,8 |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 213 | .globl ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp) |
| 214 | ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp)) |
| 215 | ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp): |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 216 | CFI_STARTPROC |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 217 | // save env parameter |
| 218 | push %rdi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 219 | CFI_ADJUST_CFA_OFFSET(8) |
| 220 | CFI_REL_OFFSET(%rdi, 0) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 221 | // obtain %rsp |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 222 | #if defined(__FreeBSD__) |
| 223 | lea 8(%rsp), %rdi |
| 224 | mov %rdi, %rsi |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 225 | #elif defined(__APPLE__) |
| 226 | lea 16(%rsp), %rdi |
| 227 | mov %rdi, %rsi |
| 228 | #elif defined(__linux__) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 229 | lea 16(%rsp), %rdi |
| 230 | mov %rdi, %rsi |
| 231 | xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp) |
| 232 | rol $0x11, %rsi |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 233 | #else |
| 234 | # error "Unknown platform" |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 235 | #endif |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 236 | // call tsan interceptor |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 237 | call ASM_TSAN_SYMBOL(__tsan_setjmp) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 238 | // restore env parameter |
| 239 | pop %rdi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 240 | CFI_ADJUST_CFA_OFFSET(-8) |
| 241 | CFI_RESTORE(%rdi) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 242 | // tail jump to libc setjmp |
| 243 | movl $0, %eax |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 244 | #if !defined(__APPLE__) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 245 | movq _ZN14__interception12real__setjmpE@GOTPCREL(%rip), %rdx |
| 246 | jmp *(%rdx) |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 247 | #else |
| 248 | jmp ASM_TSAN_SYMBOL(_setjmp) |
| 249 | #endif |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 250 | CFI_ENDPROC |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 251 | ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp)) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 252 | |
| 253 | .comm _ZN14__interception14real_sigsetjmpE,8,8 |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 254 | .globl ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp) |
| 255 | ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp)) |
| 256 | ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp): |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 257 | CFI_STARTPROC |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 258 | // save env parameter |
| 259 | push %rdi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 260 | CFI_ADJUST_CFA_OFFSET(8) |
| 261 | CFI_REL_OFFSET(%rdi, 0) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 262 | // save savesigs parameter |
| 263 | push %rsi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 264 | CFI_ADJUST_CFA_OFFSET(8) |
| 265 | CFI_REL_OFFSET(%rsi, 0) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 266 | // align stack frame |
| 267 | sub $8, %rsp |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 268 | CFI_ADJUST_CFA_OFFSET(8) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 269 | // obtain %rsp |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 270 | #if defined(__FreeBSD__) |
| 271 | lea 24(%rsp), %rdi |
| 272 | mov %rdi, %rsi |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 273 | #elif defined(__APPLE__) |
| 274 | lea 32(%rsp), %rdi |
| 275 | mov %rdi, %rsi |
| 276 | #elif defined(__linux__) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 277 | lea 32(%rsp), %rdi |
| 278 | mov %rdi, %rsi |
| 279 | xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp) |
| 280 | rol $0x11, %rsi |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 281 | #else |
| 282 | # error "Unknown platform" |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 283 | #endif |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 284 | // call tsan interceptor |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 285 | call ASM_TSAN_SYMBOL(__tsan_setjmp) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 286 | // unalign stack frame |
| 287 | add $8, %rsp |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 288 | CFI_ADJUST_CFA_OFFSET(-8) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 289 | // restore savesigs parameter |
| 290 | pop %rsi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 291 | CFI_ADJUST_CFA_OFFSET(-8) |
| 292 | CFI_RESTORE(%rsi) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 293 | // restore env parameter |
| 294 | pop %rdi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 295 | CFI_ADJUST_CFA_OFFSET(-8) |
| 296 | CFI_RESTORE(%rdi) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 297 | // tail jump to libc sigsetjmp |
| 298 | movl $0, %eax |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 299 | #if !defined(__APPLE__) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 300 | movq _ZN14__interception14real_sigsetjmpE@GOTPCREL(%rip), %rdx |
| 301 | jmp *(%rdx) |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 302 | #else |
| 303 | jmp ASM_TSAN_SYMBOL(sigsetjmp) |
| 304 | #endif |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 305 | CFI_ENDPROC |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 306 | ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp)) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 307 | |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 308 | #if !defined(__APPLE__) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 309 | .comm _ZN14__interception16real___sigsetjmpE,8,8 |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 310 | .globl ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp) |
| 311 | ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp)) |
| 312 | ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp): |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 313 | CFI_STARTPROC |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 314 | // save env parameter |
| 315 | push %rdi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 316 | CFI_ADJUST_CFA_OFFSET(8) |
| 317 | CFI_REL_OFFSET(%rdi, 0) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 318 | // save savesigs parameter |
| 319 | push %rsi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 320 | CFI_ADJUST_CFA_OFFSET(8) |
| 321 | CFI_REL_OFFSET(%rsi, 0) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 322 | // align stack frame |
| 323 | sub $8, %rsp |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 324 | CFI_ADJUST_CFA_OFFSET(8) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 325 | // obtain %rsp |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 326 | #if defined(__FreeBSD__) |
| 327 | lea 24(%rsp), %rdi |
| 328 | mov %rdi, %rsi |
| 329 | #else |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 330 | lea 32(%rsp), %rdi |
| 331 | mov %rdi, %rsi |
| 332 | xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp) |
| 333 | rol $0x11, %rsi |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 334 | #endif |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 335 | // call tsan interceptor |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 336 | call ASM_TSAN_SYMBOL(__tsan_setjmp) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 337 | // unalign stack frame |
| 338 | add $8, %rsp |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 339 | CFI_ADJUST_CFA_OFFSET(-8) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 340 | // restore savesigs parameter |
| 341 | pop %rsi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 342 | CFI_ADJUST_CFA_OFFSET(-8) |
| 343 | CFI_RESTORE(%rsi) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 344 | // restore env parameter |
| 345 | pop %rdi |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 346 | CFI_ADJUST_CFA_OFFSET(-8) |
| 347 | CFI_RESTORE(%rdi) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 348 | // tail jump to libc sigsetjmp |
| 349 | movl $0, %eax |
| 350 | movq _ZN14__interception16real___sigsetjmpE@GOTPCREL(%rip), %rdx |
| 351 | jmp *(%rdx) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 352 | CFI_ENDPROC |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 353 | ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp)) |
| 354 | #endif // !defined(__APPLE__) |
Dmitry Vyukov | 8b30c25 | 2013-03-25 10:10:44 +0000 | [diff] [blame] | 355 | |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 356 | #if defined(__FreeBSD__) || defined(__linux__) |
Dmitry Vyukov | a911c6f | 2012-08-17 18:05:28 +0000 | [diff] [blame] | 357 | /* We do not need executable stack. */ |
| 358 | .section .note.GNU-stack,"",@progbits |
| 359 | #endif |