[compiler-rt] 08843a0 - [sanitizer] GetTls: work around ppc64 with glibc<2.25(?) or GNU ld 2.30
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 16 14:03:32 PDT 2021
Author: Fangrui Song
Date: 2021-04-16T14:03:28-07:00
New Revision: 08843a0c3f3ee572633b8ed8dda9dbacae9dd520
URL: https://github.com/llvm/llvm-project/commit/08843a0c3f3ee572633b8ed8dda9dbacae9dd520
DIFF: https://github.com/llvm/llvm-project/commit/08843a0c3f3ee572633b8ed8dda9dbacae9dd520.diff
LOG: [sanitizer] GetTls: work around ppc64 with glibc<2.25(?) or GNU ld 2.30
GNU ld 2.26 and GNU ld 2.31 seem fine but GNU ld 2.30 has mysterious
segfaults linking msan tests.
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 42c38add033d..d5f61e10d753 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -203,7 +203,7 @@ void InitTlsSize() {
g_use_dlpi_tls_data =
GetLibcVersion(&major, &minor, &patch) && major == 2 && minor >= 25;
-#ifdef __x86_64__
+#if defined(__x86_64__) || defined(__powerpc64__)
void *get_tls_static_info = dlsym(RTLD_NEXT, "_dl_get_tls_static_info");
size_t tls_align;
((void (*)(size_t *, size_t *))get_tls_static_info)(&g_tls_size, &tls_align);
@@ -429,6 +429,13 @@ static void GetTls(uptr *addr, uptr *size) {
*size = g_tls_size;
*addr -= *size;
*addr += ThreadDescriptorSize();
+#elif SANITIZER_GLIBC && defined(__powerpc64__)
+ // Workaround for glibc<2.25(?). 2.27 is known to not need this.
+ uptr tp;
+ asm("addi %0,13,-0x7000" : "=r"(tp));
+ const uptr pre_tcb_size = TlsPreTcbSize();
+ *addr = tp - pre_tcb_size;
+ *size = g_tls_size + pre_tcb_size;
#elif SANITIZER_FREEBSD || SANITIZER_LINUX
uptr align;
GetStaticTlsBoundary(addr, size, &align);
More information about the llvm-commits
mailing list