diff options
| author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2014-06-06 14:06:14 +0000 |
|---|---|---|
| committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2014-06-06 14:06:14 +0000 |
| commit | ee98fb197be6c60e3bcf25aad3a9fcac0f47915c (patch) | |
| tree | 80ba5968ccff049ff7cf6da97a907e2001ba62df /compiler-rt | |
| parent | 58cb2edd69a863f7d284b5db493403e8945ca652 (diff) | |
| download | bcm5719-llvm-ee98fb197be6c60e3bcf25aad3a9fcac0f47915c.tar.gz bcm5719-llvm-ee98fb197be6c60e3bcf25aad3a9fcac0f47915c.zip | |
[msan] Fix wrong endianness when printing shadow.
llvm-svn: 210335
Diffstat (limited to 'compiler-rt')
| -rw-r--r-- | compiler-rt/lib/msan/msan.cc | 4 | ||||
| -rw-r--r-- | compiler-rt/lib/msan/msan_report.cc | 6 | ||||
| -rw-r--r-- | compiler-rt/test/msan/msan_print_shadow3.cc | 16 |
3 files changed, 25 insertions, 1 deletions
diff --git a/compiler-rt/lib/msan/msan.cc b/compiler-rt/lib/msan/msan.cc index 15714e7d574..4c58200f1e7 100644 --- a/compiler-rt/lib/msan/msan.cc +++ b/compiler-rt/lib/msan/msan.cc @@ -440,7 +440,11 @@ void __msan_dump_shadow(const void *x, uptr size) { unsigned char *s = (unsigned char*)MEM_TO_SHADOW(x); for (uptr i = 0; i < size; i++) { +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + Printf("%x%x ", s[i] & 0xf, s[i] >> 4); +#else Printf("%x%x ", s[i] >> 4, s[i] & 0xf); +#endif } Printf("\n"); } diff --git a/compiler-rt/lib/msan/msan_report.cc b/compiler-rt/lib/msan/msan_report.cc index 8a3fd04cb3b..566034c6631 100644 --- a/compiler-rt/lib/msan/msan_report.cc +++ b/compiler-rt/lib/msan/msan_report.cc @@ -221,7 +221,11 @@ void DescribeMemoryRange(const void *x, uptr size) { } else { unsigned char v = *(unsigned char *)s; if (v) last_quad_poisoned = true; - Printf("%02x", v); +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + Printf("%x%x", v & 0xf, v >> 4); +#else + Printf("%x%x", v >> 4, v & 0xf); +#endif } // Group end. if (pos % 4 == 3 && with_origins) { diff --git a/compiler-rt/test/msan/msan_print_shadow3.cc b/compiler-rt/test/msan/msan_print_shadow3.cc new file mode 100644 index 00000000000..c605ef18886 --- /dev/null +++ b/compiler-rt/test/msan/msan_print_shadow3.cc @@ -0,0 +1,16 @@ +// RUN: %clangxx_msan -m64 -O0 -g %s -o %t && %run %t >%t.out 2>&1 +// RUN: FileCheck %s < %t.out + +#include <stdint.h> +#include <sanitizer/msan_interface.h> + +int main(void) { + unsigned long long x = 0; // For 8-byte alignment. + uint32_t x_s = 0x12345678U; + __msan_partial_poison(&x, &x_s, sizeof(x_s)); + __msan_print_shadow(&x, sizeof(x_s)); + return 0; +} + +// CHECK: Shadow map of [{{.*}}), 4 bytes: +// CHECK: 0x{{.*}}: 87654321 ........ ........ ........ |

