summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid CARLIER <devnexen@gmail.com>2021-11-08 22:26:32 +0000
committerDavid CARLIER <devnexen@gmail.com>2021-11-08 22:26:32 +0000
commit443820179a849eac6ddb5cbf0ba5cc7bbc42e2d2 (patch)
tree1f643aa9d867b9791e463c6147752095516e7492
parent2caf85ad7ab83c441cb8e3550916d7028dfb8525 (diff)
downloadllvm-443820179a849eac6ddb5cbf0ba5cc7bbc42e2d2.tar.gz
[compiler-rt] TlsBaseAddr value for darwin arm64
getting the tls base address. unlike linux arm64, the tpidr_el0 returns always 0 (aka unused) thus using tpidrro_el0 instead clearing up the cpu id encoded in the lower bits. Reviewed-By: yln Differential Revision: https://reviews.llvm.org/D112866
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index 36a9d5098042..b67203d4c10e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -543,6 +543,9 @@ uptr TlsBaseAddr() {
asm("movq %%gs:0,%0" : "=r"(segbase));
#elif defined(__i386__)
asm("movl %%gs:0,%0" : "=r"(segbase));
+#elif defined(__aarch64__)
+ asm("mrs %x0, tpidrro_el0" : "=r"(segbase));
+ segbase &= 0x07ul; // clearing lower bits, cpu id stored there
#endif
return segbase;
}