diff options
author | Alexey Samsonov <vonosmas@gmail.com> | 2016-03-09 23:39:40 +0000 |
---|---|---|
committer | Alexey Samsonov <vonosmas@gmail.com> | 2016-03-09 23:39:40 +0000 |
commit | 9501121033a49dc54862d0f13c900532729b5002 (patch) | |
tree | 461c1254cc7dca639a9a5f80c716001717802070 /lib | |
parent | 9556c37f11feeeee3a43e4467b88d1b2e40f4ba9 (diff) |
sanitizer: Fix endianness checks for gcc
Summary:
__BIG_ENDIAN__ and __LITTLE_ENDIAN__ are not supported by gcc, which
eg. for ubsan Value::getFloatValue will silently fall through to
the little endian branch, breaking display of float values by ubsan.
Use __BYTE_ORDER__ == __ORDER_BIG/LITTLE_ENDIAN__ as the condition
instead, which is supported by both clang and gcc.
Noticed while porting ubsan to s390x.
Patch by Marcin KoĆcielnicki!
Differential Revision: http://reviews.llvm.org/D17660
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/asan/asan_report.cc | 2 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc | 4 | ||||
-rw-r--r-- | lib/tsan/rtl/tsan_interceptors.cc | 4 | ||||
-rw-r--r-- | lib/ubsan/ubsan_value.cc | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/lib/asan/asan_report.cc b/lib/asan/asan_report.cc index 94fe04e26..9a67f2d19 100644 --- a/lib/asan/asan_report.cc +++ b/lib/asan/asan_report.cc @@ -471,7 +471,7 @@ bool DescribeAddressIfStack(uptr addr, uptr access_size) { // previously. That's unfortunate, but I have no better solution, // especially given that the alloca may be from entirely different place // (e.g. use-after-scope, or different thread's stack). -#if defined(__powerpc64__) && defined(__BIG_ENDIAN__) +#if defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ // On PowerPC64 ELFv1, the address of a function actually points to a // three-doubleword data structure with the first field containing // the address of the function's code. diff --git a/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc b/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc index 7b0d9c406..e82581fe6 100644 --- a/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc +++ b/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc @@ -209,9 +209,9 @@ class LLVMSymbolizerProcess : public SymbolizerProcess { const char* const kSymbolizerArch = "--default-arch=arm64"; #elif defined(__arm__) const char* const kSymbolizerArch = "--default-arch=arm"; -#elif defined(__powerpc64__) && defined(__BIG_ENDIAN__) +#elif defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ const char* const kSymbolizerArch = "--default-arch=powerpc64"; -#elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) +#elif defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ const char* const kSymbolizerArch = "--default-arch=powerpc64le"; #else const char* const kSymbolizerArch = "--default-arch=unknown"; diff --git a/lib/tsan/rtl/tsan_interceptors.cc b/lib/tsan/rtl/tsan_interceptors.cc index 76cd740ed..5e541f264 100644 --- a/lib/tsan/rtl/tsan_interceptors.cc +++ b/lib/tsan/rtl/tsan_interceptors.cc @@ -87,10 +87,10 @@ struct ucontext_t { #endif #if defined(__x86_64__) || defined(__mips__) \ - || (defined(__powerpc64__) && defined(__BIG_ENDIAN__)) + || (defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) #define PTHREAD_ABI_BASE "GLIBC_2.3.2" #elif defined(__aarch64__) || (defined(__powerpc64__) \ - && defined(__LITTLE_ENDIAN__)) + && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) #define PTHREAD_ABI_BASE "GLIBC_2.17" #endif diff --git a/lib/ubsan/ubsan_value.cc b/lib/ubsan/ubsan_value.cc index 79dc4c8e8..72faf2ee1 100644 --- a/lib/ubsan/ubsan_value.cc +++ b/lib/ubsan/ubsan_value.cc @@ -83,7 +83,7 @@ FloatMax Value::getFloatValue() const { #endif case 32: { float Value; -#if defined(__BIG_ENDIAN__) +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ // For big endian the float value is in the last 4 bytes. // On some targets we may only have 4 bytes so we count backwards from // the end of Val to account for both the 32-bit and 64-bit cases. |