[compiler-rt] [sanitizer] Change GetDTLSRange (PR #108345)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 12 01:26:23 PDT 2024
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/108345
We only need to change size, tls_beg should be unchanged.
>From cb612f248d232b407a4cde1c1a384b08e4040d2b Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Thu, 12 Sep 2024 01:26:07 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
---
.../sanitizer_tls_get_addr.cpp | 20 ++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
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 e5839f6f497474..17b9ff4aa6c40b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
@@ -110,15 +110,15 @@ SANITIZER_WEAK_ATTRIBUTE
const void *__sanitizer_get_allocated_begin(const void *p);
}
-static bool GetDTLSRange(uptr &tls_beg, uptr &tls_size) {
+static uptr GetDTLSRange(uptr tls_beg) {
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);
+ return 0;
+ CHECK_EQ(start, (void *)tls_beg);
+ uptr tls_size = __sanitizer_get_allocated_size(start);
VReport(2, "__tls_get_addr: glibc DTLS suspected; tls={%p,0x%zx}\n",
(void *)tls_beg, tls_size);
- return true;
+ return tls_size;
}
DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
@@ -142,10 +142,12 @@ 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 (!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;
+ } else {
+ tls_size = GetDTLSRange(tls_beg);
+ if (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.
+ }
}
dtv->beg = tls_beg;
dtv->size = tls_size;
More information about the llvm-commits
mailing list