Disassemble the start of sections even if there is no symbol there.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 4 Jun 2015 15:01:05 +0000 (15:01 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 4 Jun 2015 15:01:05 +0000 (15:01 +0000)
We already handled a section with no symbols, extend that to also handle a
section with symbols that don't include the section start.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239039 91177308-0d34-0410-b5e6-96231b3b80d8

test/Object/Inputs/no-start-symbol.elf-x86_64 [new file with mode: 0644]
test/Object/no-start-symbol.test [new file with mode: 0644]
tools/llvm-objdump/llvm-objdump.cpp

diff --git a/test/Object/Inputs/no-start-symbol.elf-x86_64 b/test/Object/Inputs/no-start-symbol.elf-x86_64
new file mode 100644 (file)
index 0000000..b2c9edc
Binary files /dev/null and b/test/Object/Inputs/no-start-symbol.elf-x86_64 differ
diff --git a/test/Object/no-start-symbol.test b/test/Object/no-start-symbol.test
new file mode 100644 (file)
index 0000000..ea8e6db
--- /dev/null
@@ -0,0 +1,9 @@
+RUN: llvm-objdump -d %p/Inputs/no-start-symbol.elf-x86_64 | FileCheck %s
+
+Test that we disassemble the start of the section.
+
+CHECK: Disassembly of section .text:
+CHECK-NEXT:  .text:
+CHECK-NEXT:       0:   90      nop
+CHECK: foo:
+CHECK-NEXT:       1:   90      nop
index d03556c461599e2aee1372f4443fd8696e586856..58600f62f4d35982c2da286de653ed646f6ffb7e 100644 (file)
@@ -809,11 +809,9 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
       outs() << SegmentName << ",";
     outs() << name << ':';
 
-    // If the section has no symbols just insert a dummy one and disassemble
-    // the whole section.
-    if (Symbols.empty())
-      Symbols.push_back(std::make_pair(0, name));
-
+    // If the section has no symbol at the start, just insert a dummy one.
+    if (Symbols.empty() || Symbols[0].first != 0)
+      Symbols.insert(Symbols.begin(), std::make_pair(0, name));
 
     SmallString<40> Comments;
     raw_svector_ostream CommentStream(Comments);