[compiler-rt] [sanitizer][Darwin] Define TlsSize on arm64 (PR #133989)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 23 21:17:57 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Leonard Grey (speednoisemovement)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/133989.diff
1 Files Affected:
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp (+6-10)
``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index 0b8a75391136d..70d8cddc6e573 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -558,16 +558,12 @@ uptr TlsBaseAddr() {
return segbase;
}
-// The size of the tls on darwin does not appear to be well documented,
-// however the vm memory map suggests that it is 1024 uptrs in size,
-// with a size of 0x2000 bytes on x86_64 and 0x1000 bytes on i386.
-uptr TlsSize() {
-#if defined(__x86_64__) || defined(__i386__)
- return 1024 * sizeof(uptr);
-#else
- return 0;
-#endif
-}
+// The size of the tls on darwin does not appear to be well documented.
+// but `pthread_s`'s `tsd` member (see libpthread/src/types_internal.h) is
+// defined as `_INTERNAL_POSIX_THREAD_KEYS_MAX +
+// `_INTERNAL_POSIX_THREAD_KEYS_END` (512 pointers on iPhone and 768 elsewhere).
+// Keep at 1024 for backwards compatibility.
+uptr TlsSize() { return 1024 * sizeof(uptr); }
void GetThreadStackAndTls(bool main, uptr *stk_begin, uptr *stk_end,
uptr *tls_begin, uptr *tls_end) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/133989
More information about the llvm-commits
mailing list