[compiler-rt] [NFC][sanitizer] Make `GetLibcVersion` `void` (PR #108915)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 17 13:12:12 PDT 2024
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/108915
>From 51ec360811c547480fbc9a3da93fd4005aacc010 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Mon, 16 Sep 2024 19:49:06 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20change?=
=?UTF-8?q?s=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
[skip ci]
---
.../sanitizer_linux_libcdep.cpp | 50 ++++++++++++-------
1 file changed, 33 insertions(+), 17 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index a5101291904430..5829692531e8d0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -244,11 +244,11 @@ void InitTlsSize() {}
// On glibc x86_64, ThreadDescriptorSize() needs to be precise due to the usage
// of g_tls_size. On other targets, ThreadDescriptorSize() is only used by lsan
// to get the pointer to thread-specific data keys in the thread control block.
-# if (SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_SOLARIS) && \
- !SANITIZER_ANDROID && !SANITIZER_GO
+# if (SANITIZER_FREEBSD || SANITIZER_GLIBC) && !SANITIZER_GO
// sizeof(struct pthread) from glibc.
static atomic_uintptr_t thread_descriptor_size;
+// FIXME: Implementation is very GLIBC specific, but it's used by FREEBSD.
static uptr ThreadDescriptorSizeFallback() {
# if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
int major;
@@ -281,19 +281,9 @@ static uptr ThreadDescriptorSizeFallback() {
return FIRST_32_SECOND_64(1344, 2496);
}
return 0;
-# elif defined(__s390__) || defined(__sparc__)
- // The size of a prefix of TCB including pthread::{specific_1stblock,specific}
- // suffices. Just return offsetof(struct pthread, specific_used), which hasn't
- // changed since 2007-05. Technically this applies to i386/x86_64 as well but
- // we call _dl_get_tls_static_info and need the precise size of struct
- // pthread.
- return FIRST_32_SECOND_64(524, 1552);
-# elif defined(__mips__)
- // TODO(sagarthakur): add more values as per different glibc versions.
- return FIRST_32_SECOND_64(1152, 1776);
-# elif SANITIZER_LOONGARCH64
- return 1856; // from glibc 2.36
-# elif SANITIZER_RISCV64
+# endif
+
+# if SANITIZER_RISCV64
int major;
int minor;
int patch;
@@ -307,10 +297,32 @@ static uptr ThreadDescriptorSizeFallback() {
return 1936; // tested against glibc 2.32
}
return 0;
-# elif defined(__aarch64__)
+# endif
+
+# if defined(__s390__) || defined(__sparc__)
+ // The size of a prefix of TCB including pthread::{specific_1stblock,specific}
+ // suffices. Just return offsetof(struct pthread, specific_used), which hasn't
+ // changed since 2007-05. Technically this applies to i386/x86_64 as well but
+ // we call _dl_get_tls_static_info and need the precise size of struct
+ // pthread.
+ return FIRST_32_SECOND_64(524, 1552);
+# endif
+
+# if defined(__mips__)
+ // TODO(sagarthakur): add more values as per different glibc versions.
+ return FIRST_32_SECOND_64(1152, 1776);
+# endif
+
+# if SANITIZER_LOONGARCH64
+ return 1856; // from glibc 2.36
+# endif
+
+# if defined(__aarch64__)
// The sizeof (struct pthread) is the same from GLIBC 2.17 to 2.22.
return 1776;
-# elif defined(__powerpc64__)
+# endif
+
+# if defined(__powerpc64__)
return 1776; // from glibc.ppc64le 2.20-8.fc21
# endif
}
@@ -351,6 +363,10 @@ static uptr TlsPreTcbSize() {
}
# endif
+# endif
+
+# if (SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_SOLARIS) && \
+ !SANITIZER_ANDROID && !SANITIZER_GO
namespace {
struct TlsBlock {
uptr begin, end, align;
More information about the llvm-commits
mailing list