[PATCH] llvm-objdump bug may hide a single-byte instruction near a label.

Steve King kingshizzle at gmail.com
Tue Aug 12 08:50:17 PDT 2014


An off-by-one bug in the target indepedent llvm-objdump code prevents display of a single byte instruction before a label.

http://reviews.llvm.org/D4868

Files:
  test/Object/Inputs/trivial-label-test.elf-x86-64
  test/Object/objdump-label.test
  tools/llvm-objdump/llvm-objdump.cpp

Index: test/Object/objdump-label.test
===================================================================
--- /dev/null
+++ test/Object/objdump-label.test
@@ -0,0 +1,10 @@
+RUN: llvm-objdump -d %p/Inputs/trivial-label-test.elf-x86-64 \
+RUN:              | FileCheck %s -check-prefix ELF-x86-64
+
+ELF-x86-64: file format ELF64-x86-64
+ELF-x86-64: Disassembly of section .text:
+ELF-x86-64: foo:
+ELF-x86-64:        0:	90                                           	nop
+ELF-x86-64: bum:
+ELF-x86-64:        1:	90                                           	nop
+
Index: tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- tools/llvm-objdump/llvm-objdump.cpp
+++ tools/llvm-objdump/llvm-objdump.cpp
@@ -494,17 +494,12 @@
     std::vector<RelocationRef>::const_iterator rel_end = Rels.end();
     // Disassemble symbol by symbol.
     for (unsigned si = 0, se = Symbols.size(); si != se; ++si) {
+
+      // The end is either the section end or the beginning of the next symbol.
+      // If this symbol has the same address as the next symbol, then skip it.
       uint64_t Start = Symbols[si].first;
-      uint64_t End;
-      // The end is either the size of the section or the beginning of the next
-      // symbol.
-      if (si == se - 1)
-        End = SectSize;
-      // Make sure this symbol takes up space.
-      else if (Symbols[si + 1].first != Start)
-        End = Symbols[si + 1].first - 1;
-      else
-        // This symbol has the same address as the next symbol. Skip it.
+      uint64_t End = (si == se - 1) ? SectSize : Symbols[si + 1].first;
+      if (Start == End)
         continue;
 
       outs() << '\n' << Symbols[si].second << ":\n";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4868.12401.patch
Type: text/x-patch
Size: 1722 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140812/d5dd693f/attachment.bin>


More information about the llvm-commits mailing list