aboutsummaryrefslogtreecommitdiff
path: root/libsanitizer
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2022-05-05 13:59:16 -0700
committerH.J. Lu <hjl.tools@gmail.com>2022-05-05 13:59:16 -0700
commita48be2e513d9ddb2fa8800a158f18502a0923aec (patch)
tree88bfe3ab36ad7dfbda739e483180ca983c02708c /libsanitizer
parentb6b66006787b0991e94f15c7b5c56403f1eb85fb (diff)
downloadgcc-a48be2e513d9ddb2fa8800a158f18502a0923aec.zip
gcc-a48be2e513d9ddb2fa8800a158f18502a0923aec.tar.gz
gcc-a48be2e513d9ddb2fa8800a158f18502a0923aec.tar.bz2
libsanitizer: cherry-pick commit b226894d475b from upstream
cherry-pick: b226894d475b [sanitizer] [sanitizer] Correct GetTls for x32
Diffstat (limited to 'libsanitizer')
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp b/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp
index d966d85..620267c 100644
--- a/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/libsanitizer/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();