From b4e24fccd1b3597886fe46786596e9811f856bd6 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Wed, 21 May 2014 08:01:44 +0000 Subject: [PATCH] [sanitizer] define SANITIZER_X32 and use it in ThreadDescriptorSize; partially based on patch by H.J. Lu llvm-svn: 209279 --- compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc | 4 +++- compiler-rt/lib/sanitizer_common/sanitizer_platform.h | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc index 40eabfd..6093593 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc @@ -312,7 +312,9 @@ uptr ThreadDescriptorSize() { int minor = internal_simple_strtoll(buf + 8, &end, 10); if (end != buf + 8 && (*end == '\0' || *end == '.')) { /* sizeof(struct thread) values from various glibc versions. */ - if (minor <= 3) + if (SANITIZER_X32) + val = 1728; // Assume only one particular version for x32. + else if (minor <= 3) val = FIRST_32_SECOND_64(1104, 1696); else if (minor == 4) val = FIRST_32_SECOND_64(1120, 1728); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h index a36b05d..d9a7868 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h @@ -69,6 +69,12 @@ # define FIRST_32_SECOND_64(a, b) (a) #endif +#if defined(__x86_64__) && !defined(_LP64) +# define SANITIZER_X32 1 +#else +# define SANITIZER_X32 0 +#endif + // By default we allow to use SizeClassAllocator64 on 64-bit platform. // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64 // does not work well and we need to fallback to SizeClassAllocator32. -- 2.7.4