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