[llvm-objdump] Add -D and --disassemble-all flags that attempt disassembly on all...
authorColin LeMahieu <colinl@codeaurora.org>
Thu, 23 Jul 2015 20:58:49 +0000 (20:58 +0000)
committerColin LeMahieu <colinl@codeaurora.org>
Thu, 23 Jul 2015 20:58:49 +0000 (20:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243041 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-objdump/disassemble-data.test [new file with mode: 0644]
tools/llvm-objdump/llvm-objdump.cpp
tools/llvm-objdump/llvm-objdump.h

diff --git a/test/tools/llvm-objdump/disassemble-data.test b/test/tools/llvm-objdump/disassemble-data.test
new file mode 100644 (file)
index 0000000..97f11c1
--- /dev/null
@@ -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
index 275eb9c6a454e44e90a9bc7ce9a674eb69ee6679..91626c15d87a167066e865b76c953444629631e6 100644 (file)
@@ -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));\r
+\r
+cl::opt<bool>\r
+llvm::DisassembleAll("disassemble-all",\r
+  cl::desc("Display assembler mnemonics for the machine instructions"));\r
+static cl::alias\r
+DisassembleAlld("D", cl::desc("Alias for --disassemble-all"),\r
+             cl::aliasopt(DisassembleAll));
 
 cl::opt<bool>
 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
index eb10d8344f71149a51d1afa60f04afb978bc6fd5..0fa2d29f5471a282e13a04cbe0ff8344be5a596c 100644 (file)
@@ -26,7 +26,8 @@ extern cl::opt<std::string> ArchName;
 extern cl::opt<std::string> MCPU;
 extern cl::list<std::string> MAttrs;
 extern cl::list<std::string> DumpSections;
-extern cl::opt<bool> Disassemble;
+extern cl::opt<bool> Disassemble;\r
+extern cl::opt<bool> DisassembleAll;
 extern cl::opt<bool> NoShowRawInsn;
 extern cl::opt<bool> PrivateHeaders;
 extern cl::opt<bool> ExportsTrie;