[llvm] r267819 - Fix bugs in llvm-objdump printing the last word for -section in non i386 and x86 files.

Kevin Enderby via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 16:43:01 PDT 2016


Author: enderby
Date: Wed Apr 27 18:43:00 2016
New Revision: 267819

URL: http://llvm.org/viewvc/llvm-project?rev=267819&view=rev
Log:
Fix bugs in llvm-objdump printing the last word for -section in non i386 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

Modified:
    llvm/trunk/test/tools/llvm-objdump/Inputs/section.macho-armv7
    llvm/trunk/test/tools/llvm-objdump/macho-sections.test
    llvm/trunk/tools/llvm-objdump/MachODump.cpp

Modified: llvm/trunk/test/tools/llvm-objdump/Inputs/section.macho-armv7
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/Inputs/section.macho-armv7?rev=267819&r1=267818&r2=267819&view=diff
==============================================================================
Binary files - no diff available.

Modified: llvm/trunk/test/tools/llvm-objdump/macho-sections.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/macho-sections.test?rev=267819&r1=267818&r2=267819&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/macho-sections.test (original)
+++ llvm/trunk/test/tools/llvm-objdump/macho-sections.test Wed Apr 27 18:43:00 2016
@@ -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

Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=267819&r1=267818&r2=267819&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Wed Apr 27 18:43:00 2016
@@ -1004,7 +1004,7 @@ static void DumpRawSectionContents(MachO
         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)
@@ -1012,7 +1012,7 @@ static void DumpRawSectionContents(MachO
           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) << " ";
           }
         }




More information about the llvm-commits mailing list