[compiler-rt] [sanitizer] Extract SANITIZER_FREEBSD version of ThreadDescriptorSizeFallback (PR #109743)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 24 13:12:02 PDT 2024
================
@@ -304,6 +293,48 @@ static uptr ThreadDescriptorSizeFallback() {
return 1776; // from glibc.ppc64le 2.20-8.fc21
# endif
}
+# endif // SANITIZER_GLIBC && !SANITIZER_GO
+
+# if SANITIZER_FREEBSD && !SANITIZER_GO
+// FIXME: Implementation is very GLIBC specific, but it's used by FreeBSD.
+static uptr ThreadDescriptorSizeFallback() {
+# 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;
+# endif
+
+# if defined(__powerpc64__)
+ return 1776; // from glibc.ppc64le 2.20-8.fc21
+# endif
+
----------------
vitalybuka wrote:
If you are confident, I can drop them in followup PR, so bisecting could be easiers.
According to https://www.freebsd.org/platforms/
Recent Tier 1 are only x86_64 and aarch64, the former works with 0.
I guess implication of having these values invalid is incorrect DTLS detection which will false positive for msan and lsan.
https://github.com/llvm/llvm-project/pull/109743
More information about the llvm-commits
mailing list