From a4ac37168e874878a562ea0fb0c629d488c728e6 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 4 Jun 2015 15:01:05 +0000 Subject: [PATCH] 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. llvm-svn: 239039 --- test/Object/Inputs/no-start-symbol.elf-x86_64 | Bin 0 -> 544 bytes test/Object/no-start-symbol.test | 9 +++++++++ tools/llvm-objdump/llvm-objdump.cpp | 8 +++----- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 test/Object/Inputs/no-start-symbol.elf-x86_64 create mode 100644 test/Object/no-start-symbol.test 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 index 0000000000000000000000000000000000000000..b2c9edc300d03fd8165801d4c9473b66a3b5171e GIT binary patch literal 544 zcmb<-^>JfjWMpQ50!9Wq21XbMiC%!jb^x;-7}$U+Crm(+z{2DKi!ouEsaKL(QNo~? zR9wuEmY>g{S6ot5l9&XfD|5kgN@7VO7V}6I5&&v|dk#r+1(dCZBnD!l`yIpwVK$H? z5^#XBnUKUlOcpf00+0{VkM0H+G<7g8x_)+`1P2BBC4hR--3YSF14ICU0fYj(5u^@e K7YKm#fdBwvX%b)n literal 0 HcmV?d00001 diff --git a/test/Object/no-start-symbol.test b/test/Object/no-start-symbol.test new file mode 100644 index 00000000000..ea8e6db8dbf --- /dev/null +++ b/test/Object/no-start-symbol.test @@ -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 diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index d03556c4615..58600f62f4d 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -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);