summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_internal_defs.h
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2017-02-10 22:26:19 +0000
committerKostya Serebryany <kcc@google.com>2017-02-10 22:26:19 +0000
commitf54319c55a5b91d30c4fd5b58ffbb56840f4e565 (patch)
tree193e81a1ca403d13154064a7abbfa6655d2d1e9a /lib/sanitizer_common/sanitizer_internal_defs.h
parent44809bf00a1a6fec7a9480fb2d02e4aeb78d7ae0 (diff)
downloadcompiler-rt-f54319c55a5b91d30c4fd5b58ffbb56840f4e565.tar.gz
Fix AddressSanitizer on s390 (31-bit)
Summary: GET_CALLER_PC doesn't work properly on 31-bit s390, as pointers are 31-bit, the MSB bit can be set when the return address is copied into integer. This causes e.g. errors like: #0 0xfdadb129 (<unknown module>) #1 0x7da5e1d1 in __asan::GetStackTraceWithPcBpAndContext(__sanitizer::BufferedStackTrace*, unsigned long, unsigned long, unsigned long, void*, bool) ../../../../../libsanitizer/asan/asan_stack.h:50 #2 0x7da5e1d1 in __asan::ErrorGeneric::Print() ../../../../../libsanitizer/asan/asan_errors.cc:482 #3 0x7db178d5 in __asan::ErrorDescription::Print() ../../../../../libsanitizer/asan/asan_errors.h:360 #4 0x7db178d5 in __asan::ScopedInErrorReport::~ScopedInErrorReport() ../../../../../libsanitizer/asan/asan_report.cc:167 #5 0x7db178d5 in __asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool) ../../../../../libsanitizer/asan/asan_report.cc:397 #6 0x7dadb14f in __interceptor_memcmp ../../../../../libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:626 #7 0x400cf5 in main /home/jakub/gcc/gcc/testsuite/c-c++-common/asan/memcmp-1.c:14 #8 0x7d807215 in __libc_start_main (/lib/libc.so.6+0x1a215) #9 0x4007ed (/home/jakub/gcc/obj/gcc/testsuite/memcmp-1.exe+0x4007ed) The actual return PC inside __interceptor_memcmp was 0x7dadb129 rather than 0xfdadb129. Reviewers: koriakin, kcc Reviewed By: kcc Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D29824 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@294793 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_internal_defs.h')
-rw-r--r--lib/sanitizer_common/sanitizer_internal_defs.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_internal_defs.h b/lib/sanitizer_common/sanitizer_internal_defs.h
index 5085d2015..ea5022e31 100644
--- a/lib/sanitizer_common/sanitizer_internal_defs.h
+++ b/lib/sanitizer_common/sanitizer_internal_defs.h
@@ -327,7 +327,12 @@ void NORETURN CheckFailed(const char *file, int line, const char *cond,
enum LinkerInitialized { LINKER_INITIALIZED = 0 };
#if !defined(_MSC_VER) || defined(__clang__)
+#if SANITIZER_S390_31
+#define GET_CALLER_PC() \
+ (__sanitizer::uptr) __builtin_extract_return_addr(__builtin_return_address(0))
+#else
#define GET_CALLER_PC() (__sanitizer::uptr) __builtin_return_address(0)
+#endif
#define GET_CURRENT_FRAME() (__sanitizer::uptr) __builtin_frame_address(0)
inline void Trap() {
__builtin_trap();