[llvm] r239039 - Disassemble the start of sections even if there is no symbol there.

Rafael Espindola rafael.espindola at gmail.com
Thu Jun 4 08:01:05 PDT 2015


Author: rafael
Date: Thu Jun  4 10:01:05 2015
New Revision: 239039

URL: http://llvm.org/viewvc/llvm-project?rev=239039&view=rev
Log:
Disassemble the start of sections even if there is no symbol there.

We already handled a section with no symbols, extend that to also handle a
section with symbols that don't include the section start.

Added:
    llvm/trunk/test/Object/Inputs/no-start-symbol.elf-x86_64
    llvm/trunk/test/Object/no-start-symbol.test
Modified:
    llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp

Added: llvm/trunk/test/Object/Inputs/no-start-symbol.elf-x86_64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/no-start-symbol.elf-x86_64?rev=239039&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/no-start-symbol.elf-x86_64 (added) and llvm/trunk/test/Object/Inputs/no-start-symbol.elf-x86_64 Thu Jun  4 10:01:05 2015 differ

Added: llvm/trunk/test/Object/no-start-symbol.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/no-start-symbol.test?rev=239039&view=auto
==============================================================================
--- llvm/trunk/test/Object/no-start-symbol.test (added)
+++ llvm/trunk/test/Object/no-start-symbol.test Thu Jun  4 10:01:05 2015
@@ -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

Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=239039&r1=239038&r2=239039&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Thu Jun  4 10:01:05 2015
@@ -809,11 +809,9 @@ static void DisassembleObject(const Obje
       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);





More information about the llvm-commits mailing list