[compiler-rt] b226894 - [sanitizer] Correct GetTls for x32
H.J. Lu via llvm-commits
llvm-commits at lists.llvm.org
Thu May 5 13:55:59 PDT 2022
Author: H.J. Lu
Date: 2022-05-05T13:55:19-07:00
New Revision: b226894d475b4758ed1da0c23e664b027c89634b
URL: https://github.com/llvm/llvm-project/commit/b226894d475b4758ed1da0c23e664b027c89634b
DIFF: https://github.com/llvm/llvm-project/commit/b226894d475b4758ed1da0c23e664b027c89634b.diff
LOG: [sanitizer] Correct GetTls for x32
Since x32 pointer size is 4 bytes, the self pointer offset in TCB:
struct
{
void *tcb;
dtv_t *dtv;
void *self;
...
should be 8, not 16.
Fixes https://github.com/llvm/llvm-project/issues/55288
Differential Revision: https://reviews.llvm.org/D125025
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 25ad825f568bd..9bf14ef647315 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -462,7 +462,11 @@ static void GetTls(uptr *addr, uptr *size) {
#elif SANITIZER_GLIBC && defined(__x86_64__)
// For aarch64 and x86-64, use an O(1) approach which requires relatively
// precise ThreadDescriptorSize. g_tls_size was initialized in InitTlsSize.
+# if SANITIZER_X32
+ asm("mov %%fs:8,%0" : "=r"(*addr));
+# else
asm("mov %%fs:16,%0" : "=r"(*addr));
+# endif
*size = g_tls_size;
*addr -= *size;
*addr += ThreadDescriptorSize();
More information about the llvm-commits
mailing list