From ea8050283f7ef5fb4265dea5e07a8f515f41fce5 Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Thu, 23 Jul 2015 20:58:49 +0000 Subject: [PATCH] [llvm-objdump] Add -D and --disassemble-all flags that attempt disassembly on all sections instead of just text sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243041 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/tools/llvm-objdump/disassemble-data.test | 6 ++++++ tools/llvm-objdump/llvm-objdump.cpp | 13 +++++++++++-- tools/llvm-objdump/llvm-objdump.h | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 test/tools/llvm-objdump/disassemble-data.test diff --git a/test/tools/llvm-objdump/disassemble-data.test b/test/tools/llvm-objdump/disassemble-data.test new file mode 100644 index 00000000000..97f11c12f53 --- /dev/null +++ b/test/tools/llvm-objdump/disassemble-data.test @@ -0,0 +1,6 @@ +// This test checks that -D disassembles from a data section +// RUN: llvm-mc -filetype=obj -o - %s | llvm-objdump -D - | FileCheck %s + +// CHECK: Disassembly of section .data: +.data +.word 0x0 \ No newline at end of file diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index 275eb9c6a45..91626c15d87 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -70,7 +70,14 @@ llvm::Disassemble("disassemble", cl::desc("Display assembler mnemonics for the machine instructions")); static cl::alias Disassembled("d", cl::desc("Alias for --disassemble"), - cl::aliasopt(Disassemble)); + cl::aliasopt(Disassemble)); + +cl::opt +llvm::DisassembleAll("disassemble-all", + cl::desc("Display assembler mnemonics for the machine instructions")); +static cl::alias +DisassembleAlld("D", cl::desc("Alias for --disassemble-all"), + cl::aliasopt(DisassembleAll)); cl::opt llvm::Relocations("r", cl::desc("Display the relocation entries in the file")); @@ -837,7 +844,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) { } for (const SectionRef &Section : Obj->sections()) { - if (!Section.isText() || Section.isVirtual()) + if (!DisassembleAll && (!Section.isText() || Section.isVirtual())) continue; uint64_t SectionAddr = Section.getAddress(); @@ -1514,6 +1521,8 @@ int main(int argc, char **argv) { if (InputFilenames.size() == 0) InputFilenames.push_back("a.out"); + if (DisassembleAll) + Disassemble = true; if (!Disassemble && !Relocations && !SectionHeaders diff --git a/tools/llvm-objdump/llvm-objdump.h b/tools/llvm-objdump/llvm-objdump.h index eb10d8344f7..0fa2d29f547 100644 --- a/tools/llvm-objdump/llvm-objdump.h +++ b/tools/llvm-objdump/llvm-objdump.h @@ -26,7 +26,8 @@ extern cl::opt ArchName; extern cl::opt MCPU; extern cl::list MAttrs; extern cl::list DumpSections; -extern cl::opt Disassemble; +extern cl::opt Disassemble; +extern cl::opt DisassembleAll; extern cl::opt NoShowRawInsn; extern cl::opt PrivateHeaders; extern cl::opt ExportsTrie;