Skip to content

Commit

Permalink
[MSan] Endianness should not matter while printing a byte
Browse files Browse the repository at this point in the history
Reviewers: eugenis

Subscribers: jaydeep, sagar, llvm-commits

Differential Revision: http://reviews.llvm.org/D17264
Differential Revision: http://reviews.llvm.org/D17563

llvm-svn: 261982
  • Loading branch information
Mohit7 committed Feb 26, 2016
1 parent 5539f85 commit fac2e24
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
7 changes: 1 addition & 6 deletions compiler-rt/lib/msan/msan.cc
Expand Up @@ -462,13 +462,8 @@ 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
for (uptr i = 0; i < size; i++)
Printf("%x%x ", s[i] >> 4, s[i] & 0xf);
#endif
}
Printf("\n");
}

Expand Down
4 changes: 0 additions & 4 deletions compiler-rt/lib/msan/msan_report.cc
Expand Up @@ -221,11 +221,7 @@ void DescribeMemoryRange(const void *x, uptr size) {
} else {
unsigned char v = *(unsigned char *)s;
if (v) last_quad_poisoned = true;
#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) {
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/msan_print_shadow3.cc
Expand Up @@ -6,7 +6,7 @@

int main(void) {
unsigned long long x = 0; // For 8-byte alignment.
uint32_t x_s = 0x12345678U;
char x_s[4] = {0x87, 0x65, 0x43, 0x21};
__msan_partial_poison(&x, &x_s, sizeof(x_s));
__msan_print_shadow(&x, sizeof(x_s));
return 0;
Expand Down

0 comments on commit fac2e24

Please sign in to comment.