[PATCH] D57549: [llvm-objdump] - llvm-objdump can miss printing bytes at the end of a section.

Sid Manning via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 31 14:49:17 PST 2019


sidneym created this revision.
sidneym added reviewers: grimar, jhenderson, courbet, kparzysz, bcain.
Herald added a subscriber: rupprecht.

llvm-objdump can miss printing bytes at the end of a section.

This file:

.globl foo
.type foo, @object
foo:
.byte 't','h','i', 's',' ','i','s',' '
.byte 'a',' ','t','e','s','t'
.size foo, . - foo

Produces this output:
f.o:	file format ELF64-x86-64

Disassembly of section .text:
0000000000000000 foo:

  0:	 74 68 69 73 20 69 73 20         this is 
  8:	 61 20 74 65 73 74               a 

It should be:
f.o:	file format ELF64-x86-64

Disassembly of section .text:
0000000000000000 foo:

  0:	 74 68 69 73 20 69 73 20         this is 
  8:	 61 20 74 65 73 74               a test


Repository:
  rL LLVM

https://reviews.llvm.org/D57549

Files:
  test/tools/llvm-objdump/X86/bytes.test
  tools/llvm-objdump/llvm-objdump.cpp


Index: tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- tools/llvm-objdump/llvm-objdump.cpp
+++ tools/llvm-objdump/llvm-objdump.cpp
@@ -1265,7 +1265,7 @@
               // Indent the space for less than 8 bytes data.
               // 2 spaces for byte and one for space between bytes
               IndentOffset = 3 * (8 - NumBytes);
-              for (int Excess = 8 - NumBytes; Excess < 8; Excess++)
+              for (int Excess = NumBytes; Excess < 8; Excess++)
                 AsciiData[Excess] = '\0';
               NumBytes = 8;
             }
Index: test/tools/llvm-objdump/X86/bytes.test
===================================================================
--- /dev/null
+++ test/tools/llvm-objdump/X86/bytes.test
@@ -0,0 +1,18 @@
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o -| \
+# RUN: llvm-objdump -d - | FileCheck %s
+
+.globl foo
+.type foo, @object
+
+foo:
+.byte 't','h','i', 's',' ','i','s',' '
+.byte 'a',' ','t','e','s','t'
+# .byte 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20
+# .byte 0x61, 0x20, 0x74, 0x65, 0x73, 0x74
+
+.size foo, . - foo
+
+# CHECK: foo:
+# CHECK:       0:       74 68 69 73 20 69 73 20         this is
+# CHECK:       8:       61 20 74 65 73 74               a test
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57549.184620.patch
Type: text/x-patch
Size: 1297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190131/fdd2d7e6/attachment.bin>


More information about the llvm-commits mailing list