summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cc
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-05-16 00:34:15 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-05-16 00:34:15 +0000
commit7f6290ca9ab4b02eab67262a8a103473c9148acc (patch)
tree59dceb8d91390ca3e7fdb6f141fdb502b7af8ed5 /compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cc
parent1c299d05e6b75d5bdc87239aa7136773df44783e (diff)
downloadbcm5719-llvm-7f6290ca9ab4b02eab67262a8a103473c9148acc.tar.gz
bcm5719-llvm-7f6290ca9ab4b02eab67262a8a103473c9148acc.zip
[sanitizer] Recognize static TLS in __tls_get_addr interceptor.
Current code tries to find the dynamic TLS header to the left of the TLS block without checking that it's not a static TLS allocation. llvm-svn: 237495
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cc')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cc b/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cc
index 6142ce517db..ea037159d00 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cc
@@ -78,7 +78,8 @@ void DTLS_Destroy() {
DTLS_Deallocate(dtls.dtv, s);
}
-DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res) {
+DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
+ uptr static_tls_begin, uptr static_tls_end) {
if (!common_flags()->intercept_tls_get_addr) return 0;
TlsGetAddrParam *arg = reinterpret_cast<TlsGetAddrParam *>(arg_void);
uptr dso_id = arg->dso_id;
@@ -95,6 +96,11 @@ DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res) {
tls_size = dtls.last_memalign_size;
VPrintf(2, "__tls_get_addr: glibc <=2.18 suspected; tls={%p,%p}\n",
tls_beg, tls_size);
+ } else if (tls_beg >= static_tls_begin && tls_beg < static_tls_end) {
+ // This is the static TLS block which was initialized / unpoisoned at thread
+ // creation.
+ VPrintf(2, "__tls_get_addr: static tls: %p\n", tls_beg);
+ tls_size = 0;
} else if ((tls_beg % 4096) == sizeof(Glibc_2_19_tls_header)) {
// We may want to check gnu_get_libc_version().
Glibc_2_19_tls_header *header = (Glibc_2_19_tls_header *)tls_beg - 1;
OpenPOWER on IntegriCloud