summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/asan_thread.cc
diff options
context:
space:
mode:
authorKamil Rytarowski <n54@gmx.com>2018-05-19 01:20:00 +0000
committerKamil Rytarowski <n54@gmx.com>2018-05-19 01:20:00 +0000
commit434606c8e477c9ee786a0d0699e7ec23c79589e7 (patch)
tree41975130c46538610de76f7534fcb1c1a919f3da /compiler-rt/lib/asan/asan_thread.cc
parent51daee08cd5ecfcdebfcb5411f16fe12f102e681 (diff)
downloadbcm5719-llvm-434606c8e477c9ee786a0d0699e7ec23c79589e7.tar.gz
bcm5719-llvm-434606c8e477c9ee786a0d0699e7ec23c79589e7.zip
Align ClearShadowForThreadStackAndTLS for NetBSD/i386
Summary: The static TLS vector for the main thread on NetBSD/i386 can be unaligned in terms of the shadow granularity. Align the start of it with Round Down and end of it with Round Up operations for the shadow granularity shift. Example static TLS vector ranges on NetBSD/i386: tls_begin_=0xfbee7244 tls_end_=0xfbee726c. ClearShadowForThreadStackAndTLS() is called from the Main Thread bootstrap functions. This change restores the NetBSD x86 32-bit (i386) support. Sponsored by <The NetBSD Foundation> Reviewers: vitalybuka, joerg Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D46585 llvm-svn: 332792
Diffstat (limited to 'compiler-rt/lib/asan/asan_thread.cc')
-rw-r--r--compiler-rt/lib/asan/asan_thread.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler-rt/lib/asan/asan_thread.cc b/compiler-rt/lib/asan/asan_thread.cc
index c5a6db6e409..44aa018d894 100644
--- a/compiler-rt/lib/asan/asan_thread.cc
+++ b/compiler-rt/lib/asan/asan_thread.cc
@@ -303,8 +303,13 @@ void AsanThread::SetThreadStackAndTls(const InitOptions *options) {
void AsanThread::ClearShadowForThreadStackAndTLS() {
PoisonShadow(stack_bottom_, stack_top_ - stack_bottom_, 0);
- if (tls_begin_ != tls_end_)
- PoisonShadow(tls_begin_, tls_end_ - tls_begin_, 0);
+ if (tls_begin_ != tls_end_) {
+ uptr tls_begin_aligned = RoundDownTo(tls_begin_, SHADOW_GRANULARITY);
+ uptr tls_end_aligned = RoundUpTo(tls_end_, SHADOW_GRANULARITY);
+ FastPoisonShadowPartialRightRedzone(tls_begin_aligned,
+ tls_end_ - tls_begin_aligned,
+ tls_end_aligned - tls_end_, 0);
+ }
}
bool AsanThread::GetStackFrameAccessByAddr(uptr addr,
OpenPOWER on IntegriCloud