Skip to content

Commit

Permalink
Fix bugs in llvm-objdump printing the last word for -section in non i…
Browse files Browse the repository at this point in the history
…386 and x86 files.

Two problems, 1) for the last 4 bytes it would print them as separate bytes not a word
and 2) it would print the same last byte for those bytes less than a word.

rdar://25938224


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267819 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
enderby committed Apr 27, 2016
1 parent 4a4743c commit 05e0103
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Binary file modified test/tools/llvm-objdump/Inputs/section.macho-armv7
Binary file not shown.
6 changes: 5 additions & 1 deletion test/tools/llvm-objdump/macho-sections.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@

# RUN: llvm-objdump -macho -section=__data %p/Inputs/section.macho-armv7 | FileCheck -check-prefix CHECK-ADDR %s

# CHECK-ADDR: 00000004 00000001
# CHECK-ADDR: 00000004 00000001 00000002

# RUN: llvm-objdump -macho -section=__const %p/Inputs/section.macho-armv7 | FileCheck -check-prefix CHECK-BYTES %s

# CHECK-BYTES: 0000000c 00000003 04 05 06
4 changes: 2 additions & 2 deletions tools/llvm-objdump/MachODump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1004,15 +1004,15 @@ static void DumpRawSectionContents(MachOObjectFile *O, const char *sect,
outs() << format("%08" PRIx64, addr) << "\t";
for (j = 0; j < 4 * sizeof(int32_t) && i + j < size;
j += sizeof(int32_t)) {
if (i + j + sizeof(int32_t) < size) {
if (i + j + sizeof(int32_t) <= size) {
uint32_t long_word;
memcpy(&long_word, sect + i + j, sizeof(int32_t));
if (O->isLittleEndian() != sys::IsLittleEndianHost)
sys::swapByteOrder(long_word);
outs() << format("%08" PRIx32, long_word) << " ";
} else {
for (uint32_t k = 0; i + j + k < size; k++) {
uint8_t byte_word = *(sect + i + j);
uint8_t byte_word = *(sect + i + j + k);
outs() << format("%02" PRIx32, (uint32_t)byte_word) << " ";
}
}
Expand Down

0 comments on commit 05e0103

Please sign in to comment.