[PATCH] D63944: [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.3
Julian Lettner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 16:25:26 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL364874: [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.3 (authored by yln, committed by ).
Herald added a subscriber: delcypher.
Changed prior to commit:
https://reviews.llvm.org/D63944?vs=207106&id=207437#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63944/new/
https://reviews.llvm.org/D63944
Files:
compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_amd64.S
Index: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
===================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
@@ -553,7 +553,7 @@
}
// FIXME: put everything below into a common extern "C" block?
-extern "C" void __tsan_setjmp(uptr sp, uptr mangled_sp) {
+extern "C" void __tsan_setjmp(uptr sp) {
cur_thread_init();
SetJmp(cur_thread(), sp);
}
Index: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_amd64.S
===================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_amd64.S
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_amd64.S
@@ -189,19 +189,11 @@
push %rdi
CFI_ADJUST_CFA_OFFSET(8)
CFI_REL_OFFSET(%rdi, 0)
- // obtain %rsp
+ // obtain SP, store in %rdi, first argument to `void __tsan_setjmp(uptr sp)`
#if defined(__FreeBSD__) || defined(__NetBSD__)
lea 8(%rsp), %rdi
- mov %rdi, %rsi
-#elif defined(__APPLE__)
+#elif defined(__linux__) || defined(__APPLE__)
lea 16(%rsp), %rdi
- mov %rdi, %rsi
- xorq ___tsan_darwin_setjmp_xor_key(%rip), %rsi
-#elif defined(__linux__)
- lea 16(%rsp), %rdi
- mov %rdi, %rsi
- xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp)
- rol $0x11, %rsi
#else
# error "Unknown platform"
#endif
@@ -238,19 +230,11 @@
push %rdi
CFI_ADJUST_CFA_OFFSET(8)
CFI_REL_OFFSET(%rdi, 0)
- // obtain %rsp
+ // obtain SP, store in %rdi, first argument to `void __tsan_setjmp(uptr sp)`
#if defined(__FreeBSD__) || defined(__NetBSD__)
lea 8(%rsp), %rdi
- mov %rdi, %rsi
-#elif defined(__APPLE__)
- lea 16(%rsp), %rdi
- mov %rdi, %rsi
- xorq ___tsan_darwin_setjmp_xor_key(%rip), %rsi
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__APPLE__)
lea 16(%rsp), %rdi
- mov %rdi, %rsi
- xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp)
- rol $0x11, %rsi
#else
# error "Unknown platform"
#endif
@@ -294,19 +278,11 @@
// align stack frame
sub $8, %rsp
CFI_ADJUST_CFA_OFFSET(8)
- // obtain %rsp
+ // obtain SP, store in %rdi, first argument to `void __tsan_setjmp(uptr sp)`
#if defined(__FreeBSD__) || defined(__NetBSD__)
lea 24(%rsp), %rdi
- mov %rdi, %rsi
-#elif defined(__APPLE__)
- lea 32(%rsp), %rdi
- mov %rdi, %rsi
- xorq ___tsan_darwin_setjmp_xor_key(%rip), %rsi
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__APPLE__)
lea 32(%rsp), %rdi
- mov %rdi, %rsi
- xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp)
- rol $0x11, %rsi
#else
# error "Unknown platform"
#endif
@@ -358,15 +334,11 @@
// align stack frame
sub $8, %rsp
CFI_ADJUST_CFA_OFFSET(8)
- // obtain %rsp
+ // obtain SP, store in %rdi, first argument to `void __tsan_setjmp(uptr sp)`
#if defined(__FreeBSD__)
lea 24(%rsp), %rdi
- mov %rdi, %rsi
#else
lea 32(%rsp), %rdi
- mov %rdi, %rsi
- xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp)
- rol $0x11, %rsi
#endif
// call tsan interceptor
call ASM_SYMBOL(__tsan_setjmp)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63944.207437.patch
Type: text/x-patch
Size: 3069 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190701/159da006/attachment.bin>
More information about the llvm-commits
mailing list