[compiler-rt] 81ef8e2 - [NFC][sanitizer] Extract GetDTLSRange (#107934)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 17:00:09 PDT 2024
Author: Vitaly Buka
Date: 2024-09-09T17:00:06-07:00
New Revision: 81ef8e2fdbdfac4e186e12a874242b294d05d4e0
URL: https://github.com/llvm/llvm-project/commit/81ef8e2fdbdfac4e186e12a874242b294d05d4e0
DIFF: https://github.com/llvm/llvm-project/commit/81ef8e2fdbdfac4e186e12a874242b294d05d4e0.diff
LOG: [NFC][sanitizer] Extract GetDTLSRange (#107934)
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
index e2a66142e584e6..666e6f3b351067 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
@@ -110,6 +110,17 @@ SANITIZER_WEAK_ATTRIBUTE
const void *__sanitizer_get_allocated_begin(const void *p);
}
+static bool GetDTLSRange(uptr &tls_beg, uptr &tls_size) {
+ const void *start = __sanitizer_get_allocated_begin((void *)tls_beg);
+ if (!start)
+ return false;
+ tls_beg = (uptr)start;
+ tls_size = __sanitizer_get_allocated_size(start);
+ VReport(2, "__tls_get_addr: glibc >=2.25 suspected; tls={%p,0x%zx}\n",
+ (void *)tls_beg, tls_size);
+ return true;
+}
+
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;
@@ -135,13 +146,7 @@ DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
// creation.
VReport(2, "__tls_get_addr: static tls: %p\n", (void *)tls_beg);
tls_size = 0;
- } else if (const void *start =
- __sanitizer_get_allocated_begin((void *)tls_beg)) {
- tls_beg = (uptr)start;
- tls_size = __sanitizer_get_allocated_size(start);
- VReport(2, "__tls_get_addr: glibc >=2.25 suspected; tls={%p,0x%zx}\n",
- (void *)tls_beg, tls_size);
- } else {
+ } else if (!GetDTLSRange(tls_beg, tls_size)) {
VReport(2, "__tls_get_addr: Can't guess glibc version\n");
// This may happen inside the DTOR of main thread, so just ignore it.
tls_size = 0;
More information about the llvm-commits
mailing list