[llvm-objdump] Reorganize cl::opt variables and move Mach-O specifics to MachODump.cpp
authorFangrui Song <maskray@google.com>
Mon, 15 Apr 2019 15:00:10 +0000 (15:00 +0000)
committerFangrui Song <maskray@google.com>
Mon, 15 Apr 2019 15:00:10 +0000 (15:00 +0000)
llvm-svn: 358415

llvm/tools/llvm-objdump/MachODump.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/tools/llvm-objdump/llvm-objdump.h

index bbee17b..6577b3a 100644 (file)
@@ -58,6 +58,44 @@ extern "C" {
 using namespace llvm;
 using namespace object;
 
+namespace llvm {
+
+extern cl::opt<bool> ArchiveHeaders;
+extern cl::opt<bool> Disassemble;
+extern cl::opt<bool> DisassembleAll;
+extern cl::opt<DIDumpType> DwarfDumpType;
+extern cl::list<std::string> FilterSections;
+extern cl::list<std::string> MAttrs;
+extern cl::opt<std::string> MCPU;
+extern cl::opt<bool> NoShowRawInsn;
+extern cl::opt<bool> NoLeadingAddr;
+extern cl::opt<bool> PrintImmHex;
+extern cl::opt<bool> PrivateHeaders;
+extern cl::opt<bool> Relocations;
+extern cl::opt<bool> SectionHeaders;
+extern cl::opt<bool> SectionContents;
+extern cl::opt<bool> SymbolTable;
+extern cl::opt<std::string> TripleName;
+extern cl::opt<bool> UnwindInfo;
+
+cl::opt<bool>
+    FirstPrivateHeader("private-header",
+                       cl::desc("Display only the first format specific file "
+                                "header"));
+
+cl::opt<bool> ExportsTrie("exports-trie",
+                                 cl::desc("Display mach-o exported symbols"));
+
+cl::opt<bool> Rebase("rebase", cl::desc("Display mach-o rebasing info"));
+
+cl::opt<bool> Bind("bind", cl::desc("Display mach-o binding info"));
+
+cl::opt<bool> LazyBind("lazy-bind",
+                              cl::desc("Display mach-o lazy binding info"));
+
+cl::opt<bool> WeakBind("weak-bind",
+                              cl::desc("Display mach-o weak binding info"));
+
 static cl::opt<bool>
     UseDbg("g", cl::Grouping,
            cl::desc("Print line information from debug info if available"));
@@ -71,9 +109,9 @@ static cl::opt<bool> FullLeadingAddr("full-leading-addr",
 static cl::opt<bool> NoLeadingHeaders("no-leading-headers",
                                       cl::desc("Print no leading headers"));
 
-cl::opt<bool> llvm::UniversalHeaders("universal-headers",
-                                     cl::desc("Print Mach-O universal headers "
-                                              "(requires -macho)"));
+cl::opt<bool> UniversalHeaders("universal-headers",
+                               cl::desc("Print Mach-O universal headers "
+                                        "(requires -macho)"));
 
 cl::opt<bool>
     ArchiveMemberOffsets("archive-member-offsets",
@@ -81,47 +119,43 @@ cl::opt<bool>
                                   "Mach-O archives (requires -macho and "
                                   "-archive-headers)"));
 
-cl::opt<bool>
-    llvm::IndirectSymbols("indirect-symbols",
-                          cl::desc("Print indirect symbol table for Mach-O "
-                                   "objects (requires -macho)"));
+cl::opt<bool> IndirectSymbols("indirect-symbols",
+                              cl::desc("Print indirect symbol table for Mach-O "
+                                       "objects (requires -macho)"));
 
 cl::opt<bool>
-    llvm::DataInCode("data-in-code",
-                     cl::desc("Print the data in code table for Mach-O objects "
-                              "(requires -macho)"));
+    DataInCode("data-in-code",
+               cl::desc("Print the data in code table for Mach-O objects "
+                        "(requires -macho)"));
 
-cl::opt<bool>
-    llvm::LinkOptHints("link-opt-hints",
-                       cl::desc("Print the linker optimization hints for "
-                                "Mach-O objects (requires -macho)"));
+cl::opt<bool> LinkOptHints("link-opt-hints",
+                           cl::desc("Print the linker optimization hints for "
+                                    "Mach-O objects (requires -macho)"));
 
-cl::opt<bool>
-    llvm::InfoPlist("info-plist",
-                    cl::desc("Print the info plist section as strings for "
-                             "Mach-O objects (requires -macho)"));
+cl::opt<bool> InfoPlist("info-plist",
+                        cl::desc("Print the info plist section as strings for "
+                                 "Mach-O objects (requires -macho)"));
 
-cl::opt<bool>
-    llvm::DylibsUsed("dylibs-used",
-                     cl::desc("Print the shared libraries used for linked "
-                              "Mach-O files (requires -macho)"));
+cl::opt<bool> DylibsUsed("dylibs-used",
+                         cl::desc("Print the shared libraries used for linked "
+                                  "Mach-O files (requires -macho)"));
 
 cl::opt<bool>
-    llvm::DylibId("dylib-id",
-                  cl::desc("Print the shared library's id for the dylib Mach-O "
-                           "file (requires -macho)"));
+    DylibId("dylib-id",
+            cl::desc("Print the shared library's id for the dylib Mach-O "
+                     "file (requires -macho)"));
 
 cl::opt<bool>
-    llvm::NonVerbose("non-verbose",
-                     cl::desc("Print the info for Mach-O objects in "
-                              "non-verbose or numeric form (requires -macho)"));
+    NonVerbose("non-verbose",
+               cl::desc("Print the info for Mach-O objects in "
+                        "non-verbose or numeric form (requires -macho)"));
 
 cl::opt<bool>
-    llvm::ObjcMetaData("objc-meta-data",
-                       cl::desc("Print the Objective-C runtime meta data for "
-                                "Mach-O files (requires -macho)"));
+    ObjcMetaData("objc-meta-data",
+                 cl::desc("Print the Objective-C runtime meta data for "
+                          "Mach-O files (requires -macho)"));
 
-cl::opt<std::string> llvm::DisSymName(
+cl::opt<std::string> DisSymName(
     "dis-symname",
     cl::desc("disassemble just this symbol's instructions (requires -macho)"));
 
@@ -132,6 +166,7 @@ static cl::opt<bool> NoSymbolicOperands(
 static cl::list<std::string>
     ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
               cl::ZeroOrMore);
+} // namespace llvm
 
 bool ArchAll = false;
 
@@ -10216,3 +10251,52 @@ static const char *get_dyld_bind_info_symbolname(uint64_t ReferenceValue,
   return !name.empty() ? name.data() : nullptr;
 }
 
+void llvm::printLazyBindTable(ObjectFile *o) {
+  outs() << "Lazy bind table:\n";
+  if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
+    printMachOLazyBindTable(MachO);
+  else
+    WithColor::error()
+        << "This operation is only currently supported "
+           "for Mach-O executable files.\n";
+}
+
+void llvm::printWeakBindTable(ObjectFile *o) {
+  outs() << "Weak bind table:\n";
+  if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
+    printMachOWeakBindTable(MachO);
+  else
+    WithColor::error()
+        << "This operation is only currently supported "
+           "for Mach-O executable files.\n";
+}
+
+void llvm::printExportsTrie(const ObjectFile *o) {
+  outs() << "Exports trie:\n";
+  if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
+    printMachOExportsTrie(MachO);
+  else
+    WithColor::error()
+        << "This operation is only currently supported "
+           "for Mach-O executable files.\n";
+}
+
+void llvm::printRebaseTable(ObjectFile *o) {
+  outs() << "Rebase table:\n";
+  if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
+    printMachORebaseTable(MachO);
+  else
+    WithColor::error()
+        << "This operation is only currently supported "
+           "for Mach-O executable files.\n";
+}
+
+void llvm::printBindTable(ObjectFile *o) {
+  outs() << "Bind table:\n";
+  if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
+    printMachOBindTable(MachO);
+  else
+    WithColor::error()
+        << "This operation is only currently supported "
+           "for Mach-O executable files.\n";
+}
index 0722db0..f81238e 100644 (file)
 using namespace llvm;
 using namespace object;
 
-cl::opt<unsigned long long> AdjustVMA(
+namespace llvm {
+
+// MachO specific
+extern cl::opt<bool> Bind;
+extern cl::opt<bool> DataInCode;
+extern cl::opt<bool> DylibsUsed;
+extern cl::opt<bool> DylibId;
+extern cl::opt<bool> ExportsTrie;
+extern cl::opt<bool> FirstPrivateHeader;
+extern cl::opt<bool> IndirectSymbols;
+extern cl::opt<bool> InfoPlist;
+extern cl::opt<bool> LazyBind;
+extern cl::opt<bool> LinkOptHints;
+extern cl::opt<bool> ObjcMetaData;
+extern cl::opt<bool> Rebase;
+extern cl::opt<bool> UniversalHeaders;
+extern cl::opt<bool> WeakBind;
+
+static cl::opt<unsigned long long> AdjustVMA(
     "adjust-vma",
     cl::desc("Increase the displayed address by the specified offset"),
     cl::value_desc("offset"), cl::init(0));
 
-cl::opt<bool>
-    llvm::AllHeaders("all-headers",
-                     cl::desc("Display all available header information"));
+static cl::opt<bool>
+    AllHeaders("all-headers",
+               cl::desc("Display all available header information"));
 static cl::alias AllHeadersShort("x", cl::desc("Alias for --all-headers"),
                                  cl::NotHidden, cl::Grouping,
                                  cl::aliasopt(AllHeaders));
 
-static cl::list<std::string>
-InputFilenames(cl::Positional, cl::desc("<input object files>"),cl::ZeroOrMore);
-
-cl::opt<bool>
-llvm::Disassemble("disassemble",
-  cl::desc("Display assembler mnemonics for the machine instructions"));
-static cl::alias Disassembled("d", cl::desc("Alias for --disassemble"),
-                              cl::NotHidden, cl::Grouping,
-                              cl::aliasopt(Disassemble));
+static cl::opt<std::string>
+    ArchName("arch-name", cl::desc("Target arch to disassemble for, "
+                                   "see -version for available targets"));
 
-cl::opt<bool>
-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::NotHidden, cl::Grouping,
-                                 cl::aliasopt(DisassembleAll));
-
-cl::opt<bool> llvm::Demangle("demangle", cl::desc("Demangle symbols names"),
-                             cl::init(false));
+cl::opt<bool> ArchiveHeaders("archive-headers",
+                             cl::desc("Display archive header information"));
+static cl::alias ArchiveHeadersShort("a",
+                                     cl::desc("Alias for --archive-headers"),
+                                     cl::NotHidden, cl::Grouping,
+                                     cl::aliasopt(ArchiveHeaders));
 
+cl::opt<bool> Demangle("demangle", cl::desc("Demangle symbols names"),
+                       cl::init(false));
 static cl::alias DemangleShort("C", cl::desc("Alias for --demangle"),
                                cl::NotHidden, cl::Grouping,
-                               cl::aliasopt(llvm::Demangle));
+                               cl::aliasopt(Demangle));
+
+cl::opt<bool> Disassemble(
+    "disassemble",
+    cl::desc("Display assembler mnemonics for the machine instructions"));
+static cl::alias DisassembleShort("d", cl::desc("Alias for --disassemble"),
+                                  cl::NotHidden, cl::Grouping,
+                                  cl::aliasopt(Disassemble));
+
+cl::opt<bool> DisassembleAll(
+    "disassemble-all",
+    cl::desc("Display assembler mnemonics for the machine instructions"));
+static cl::alias DisassembleAllShort("D",
+                                     cl::desc("Alias for --disassemble-all"),
+                                     cl::NotHidden, cl::Grouping,
+                                     cl::aliasopt(DisassembleAll));
 
 static cl::list<std::string>
 DisassembleFunctions("disassemble-functions",
                      cl::CommaSeparated,
                      cl::desc("List of functions to disassemble"));
-static StringSet<> DisasmFuncsSet;
 
-cl::opt<bool>
-llvm::Relocations("reloc",
-                  cl::desc("Display the relocation entries in the file"));
-static cl::alias RelocationsShort("r", cl::desc("Alias for --reloc"),
-                                  cl::NotHidden, cl::Grouping,
-                                  cl::aliasopt(llvm::Relocations));
+static cl::opt<bool> DisassembleZeroes(
+    "disassemble-zeroes",
+    cl::desc("Do not skip blocks of zeroes when disassembling"));
+static cl::alias
+    DisassembleZeroesShort("z", cl::desc("Alias for --disassemble-zeroes"),
+                           cl::NotHidden, cl::Grouping,
+                           cl::aliasopt(DisassembleZeroes));
 
-cl::opt<bool>
-llvm::DynamicRelocations("dynamic-reloc",
-  cl::desc("Display the dynamic relocation entries in the file"));
-static cl::alias DynamicRelocationsd("R", cl::desc("Alias for --dynamic-reloc"),
-                                     cl::NotHidden, cl::Grouping,
-                                     cl::aliasopt(DynamicRelocations));
+static cl::list<std::string>
+    DisassemblerOptions("disassembler-options",
+                        cl::desc("Pass target specific disassembler options"),
+                        cl::value_desc("options"), cl::CommaSeparated);
+static cl::alias
+    DisassemblerOptionsShort("M", cl::desc("Alias for --disassembler-options"),
+                             cl::NotHidden, cl::Grouping, cl::Prefix,
+                             cl::CommaSeparated,
+                             cl::aliasopt(DisassemblerOptions));
 
-cl::opt<bool>
-    llvm::SectionContents("full-contents",
-                          cl::desc("Display the content of each section"));
-static cl::alias SectionContentsShort("s",
-                                      cl::desc("Alias for --full-contents"),
-                                      cl::NotHidden, cl::Grouping,
-                                      cl::aliasopt(SectionContents));
+cl::opt<DIDumpType> DwarfDumpType(
+    "dwarf", cl::init(DIDT_Null), cl::desc("Dump of dwarf debug sections:"),
+    cl::values(clEnumValN(DIDT_DebugFrame, "frames", ".debug_frame")));
 
-cl::opt<bool> llvm::SymbolTable("syms", cl::desc("Display the symbol table"));
-static cl::alias SymbolTableShort("t", cl::desc("Alias for --syms"),
-                                  cl::NotHidden, cl::Grouping,
-                                  cl::aliasopt(llvm::SymbolTable));
+static cl::opt<bool> DynamicRelocations(
+    "dynamic-reloc",
+    cl::desc("Display the dynamic relocation entries in the file"));
+static cl::alias DynamicRelocationShort("R",
+                                        cl::desc("Alias for --dynamic-reloc"),
+                                        cl::NotHidden, cl::Grouping,
+                                        cl::aliasopt(DynamicRelocations));
 
-cl::opt<bool>
-llvm::ExportsTrie("exports-trie", cl::desc("Display mach-o exported symbols"));
-
-cl::opt<bool>
-llvm::Rebase("rebase", cl::desc("Display mach-o rebasing info"));
+static cl::opt<bool>
+    FaultMapSection("fault-map-section",
+                   cl::desc("Display contents of faultmap section"));
 
-cl::opt<bool>
-llvm::Bind("bind", cl::desc("Display mach-o binding info"));
+static cl::opt<bool>
+    FileHeaders("file-headers",
+                cl::desc("Display the contents of the overall file header"));
+static cl::alias FileHeadersShort("f", cl::desc("Alias for --file-headers"),
+                                  cl::NotHidden, cl::Grouping,
+                                  cl::aliasopt(FileHeaders));
 
-cl::opt<bool>
-llvm::LazyBind("lazy-bind", cl::desc("Display mach-o lazy binding info"));
+cl::opt<bool> SectionContents("full-contents",
+                              cl::desc("Display the content of each section"));
+static cl::alias SectionContentsShort("s",
+                                      cl::desc("Alias for --full-contents"),
+                                      cl::NotHidden, cl::Grouping,
+                                      cl::aliasopt(SectionContents));
 
-cl::opt<bool>
-llvm::WeakBind("weak-bind", cl::desc("Display mach-o weak binding info"));
+static cl::list<std::string>
+InputFilenames(cl::Positional, cl::desc("<input object files>"),cl::ZeroOrMore);
 
-cl::opt<bool>
-llvm::RawClangAST("raw-clang-ast",
-    cl::desc("Dump the raw binary contents of the clang AST section"));
+static cl::opt<bool>
+    PrintLines("line-numbers",
+               cl::desc("Display source line numbers with "
+                        "disassembly. Implies disassemble object"));
+static cl::alias PrintLinesShort("l", cl::desc("Alias for --line-numbers"),
+                                 cl::NotHidden, cl::Grouping,
+                                 cl::aliasopt(PrintLines));
 
 static cl::opt<bool>
 MachOOpt("macho", cl::desc("Use MachO specific object file parser"));
@@ -164,22 +202,55 @@ static cl::alias MachOm("m", cl::desc("Alias for --macho"), cl::NotHidden,
                         cl::Grouping, cl::aliasopt(MachOOpt));
 
 cl::opt<std::string>
-llvm::TripleName("triple", cl::desc("Target triple to disassemble for, "
-                                    "see -version for available targets"));
+    MCPU("mcpu",
+         cl::desc("Target a specific cpu type (-mcpu=help for details)"),
+         cl::value_desc("cpu-name"), cl::init(""));
+
+cl::list<std::string> MAttrs("mattr", cl::CommaSeparated,
+                             cl::desc("Target specific attributes"),
+                             cl::value_desc("a1,+a2,-a3,..."));
+
+cl::opt<bool> NoShowRawInsn("no-show-raw-insn",
+                            cl::desc("When disassembling "
+                                     "instructions, do not print "
+                                     "the instruction bytes."));
+cl::opt<bool> NoLeadingAddr("no-leading-addr",
+                                   cl::desc("Print no leading address"));
+
+static cl::opt<bool> RawClangAST(
+    "raw-clang-ast",
+    cl::desc("Dump the raw binary contents of the clang AST section"));
 
-cl::opt<std::string>
-llvm::MCPU("mcpu",
-     cl::desc("Target a specific cpu type (-mcpu=help for details)"),
-     cl::value_desc("cpu-name"),
-     cl::init(""));
+cl::opt<bool>
+    Relocations("reloc",
+                cl::desc("Display the relocation entries in the file"));
+static cl::alias RelocationsShort("r", cl::desc("Alias for --reloc"),
+                                  cl::NotHidden, cl::Grouping,
+                                  cl::aliasopt(Relocations));
 
-cl::opt<std::string>
-llvm::ArchName("arch-name", cl::desc("Target arch to disassemble for, "
-                                "see -version for available targets"));
+cl::opt<bool>
+    PrintImmHex("print-imm-hex",
+                cl::desc("Use hex format for immediate values"));
 
 cl::opt<bool>
-llvm::SectionHeaders("section-headers", cl::desc("Display summaries of the "
-                                                 "headers for each section."));
+    PrivateHeaders("private-headers",
+                   cl::desc("Display format specific file headers"));
+static cl::alias PrivateHeadersShort("p",
+                                     cl::desc("Alias for --private-headers"),
+                                     cl::NotHidden, cl::Grouping,
+                                     cl::aliasopt(PrivateHeaders));
+
+cl::list<std::string>
+    FilterSections("section",
+                   cl::desc("Operate on the specified sections only. "
+                            "With -macho dump segment,section"));
+static cl::alias FilterSectionsj("j", cl::desc("Alias for --section"),
+                                 cl::NotHidden, cl::Grouping, cl::Prefix,
+                                 cl::aliasopt(FilterSections));
+
+cl::opt<bool> SectionHeaders("section-headers",
+                             cl::desc("Display summaries of the "
+                                      "headers for each section."));
 static cl::alias SectionHeadersShort("headers",
                                      cl::desc("Alias for --section-headers"),
                                      cl::NotHidden,
@@ -193,120 +264,43 @@ static cl::opt<bool>
     ShowLMA("show-lma",
             cl::desc("Display LMA column when dumping ELF section headers"));
 
-cl::list<std::string>
-llvm::FilterSections("section", cl::desc("Operate on the specified sections only. "
-                                         "With -macho dump segment,section"));
-cl::alias static FilterSectionsj("j", cl::desc("Alias for --section"),
-                                 cl::NotHidden, cl::Grouping, cl::Prefix,
-                                 cl::aliasopt(llvm::FilterSections));
-
-cl::list<std::string>
-llvm::MAttrs("mattr",
-  cl::CommaSeparated,
-  cl::desc("Target specific attributes"),
-  cl::value_desc("a1,+a2,-a3,..."));
-
-cl::opt<bool>
-llvm::NoShowRawInsn("no-show-raw-insn", cl::desc("When disassembling "
-                                                 "instructions, do not print "
-                                                 "the instruction bytes."));
-cl::opt<bool>
-llvm::NoLeadingAddr("no-leading-addr", cl::desc("Print no leading address"));
-
-cl::opt<bool>
-llvm::UnwindInfo("unwind-info", cl::desc("Display unwind information"));
-
-static cl::alias UnwindInfoShort("u", cl::desc("Alias for --unwind-info"),
-                                 cl::NotHidden, cl::Grouping,
-                                 cl::aliasopt(UnwindInfo));
-
-cl::opt<bool>
-llvm::PrivateHeaders("private-headers",
-                     cl::desc("Display format specific file headers"));
-
-cl::opt<bool>
-llvm::FirstPrivateHeader("private-header",
-                         cl::desc("Display only the first format specific file "
-                                  "header"));
-
-static cl::alias PrivateHeadersShort("p",
-                                     cl::desc("Alias for --private-headers"),
-                                     cl::NotHidden, cl::Grouping,
-                                     cl::aliasopt(PrivateHeaders));
-
-cl::opt<bool> llvm::FileHeaders(
-    "file-headers",
-    cl::desc("Display the contents of the overall file header"));
-
-static cl::alias FileHeadersShort("f", cl::desc("Alias for --file-headers"),
-                                  cl::NotHidden, cl::Grouping,
-                                  cl::aliasopt(FileHeaders));
-
-cl::opt<bool>
-    llvm::ArchiveHeaders("archive-headers",
-                         cl::desc("Display archive header information"));
-
-cl::alias ArchiveHeadersShort("a", cl::desc("Alias for --archive-headers"),
-                              cl::NotHidden, cl::Grouping,
-                              cl::aliasopt(ArchiveHeaders));
-
-cl::opt<bool>
-    llvm::PrintImmHex("print-imm-hex",
-                      cl::desc("Use hex format for immediate values"));
-
-cl::opt<bool> PrintFaultMaps("fault-map-section",
-                             cl::desc("Display contents of faultmap section"));
-
-cl::opt<DIDumpType> llvm::DwarfDumpType(
-    "dwarf", cl::init(DIDT_Null), cl::desc("Dump of dwarf debug sections:"),
-    cl::values(clEnumValN(DIDT_DebugFrame, "frames", ".debug_frame")));
-
-cl::opt<bool> PrintSource(
+static cl::opt<bool> PrintSource(
     "source",
     cl::desc(
         "Display source inlined with disassembly. Implies disassemble object"));
+static cl::alias PrintSourceShort("S", cl::desc("Alias for -source"),
+                                  cl::NotHidden, cl::Grouping,
+                                  cl::aliasopt(PrintSource));
 
-cl::alias PrintSourceShort("S", cl::desc("Alias for -source"), cl::NotHidden,
-                           cl::Grouping, cl::aliasopt(PrintSource));
-
-cl::opt<bool> PrintLines("line-numbers",
-                         cl::desc("Display source line numbers with "
-                                  "disassembly. Implies disassemble object"));
-
-cl::alias PrintLinesShort("l", cl::desc("Alias for -line-numbers"),
-                          cl::NotHidden, cl::Grouping,
-                          cl::aliasopt(PrintLines));
-
-cl::opt<unsigned long long>
+static cl::opt<unsigned long long>
     StartAddress("start-address", cl::desc("Disassemble beginning at address"),
                  cl::value_desc("address"), cl::init(0));
-cl::opt<unsigned long long>
-    StopAddress("stop-address",
-                cl::desc("Stop disassembly at address"),
+static cl::opt<unsigned long long>
+    StopAddress("stop-address", cl::desc("Stop disassembly at address"),
                 cl::value_desc("address"), cl::init(UINT64_MAX));
 
-cl::opt<bool> DisassembleZeroes(
-                "disassemble-zeroes",
-                cl::desc("Do not skip blocks of zeroes when disassembling"));
-cl::alias DisassembleZeroesShort("z",
-                                 cl::desc("Alias for --disassemble-zeroes"),
+cl::opt<bool> SymbolTable("syms", cl::desc("Display the symbol table"));
+static cl::alias SymbolTableShort("t", cl::desc("Alias for --syms"),
+                                  cl::NotHidden, cl::Grouping,
+                                  cl::aliasopt(SymbolTable));
+
+cl::opt<std::string> TripleName("triple",
+                                cl::desc("Target triple to disassemble for, "
+                                         "see -version for available targets"));
+
+cl::opt<bool> UnwindInfo("unwind-info",
+                                cl::desc("Display unwind information"));
+static cl::alias UnwindInfoShort("u", cl::desc("Alias for --unwind-info"),
                                  cl::NotHidden, cl::Grouping,
-                                 cl::aliasopt(DisassembleZeroes));
+                                 cl::aliasopt(UnwindInfo));
 
-static cl::list<std::string>
-    DisassemblerOptions("disassembler-options",
-                        cl::desc("Pass target specific disassembler options"),
-                        cl::value_desc("options"), cl::CommaSeparated);
-static cl::alias
-    DisassemblerOptionsShort("M", cl::desc("Alias for --disassembler-options"),
-                             cl::NotHidden, cl::Grouping, cl::Prefix,
-                             cl::CommaSeparated,
-                             cl::aliasopt(DisassemblerOptions));
 
 static cl::opt<bool>
     Wide("wide", cl::desc("Ignored for compatibility with GNU objdump"));
 static cl::alias WideShort("w", cl::Grouping, cl::aliasopt(Wide));
+} // namespace llvm
 
+static StringSet<> DisasmFuncsSet;
 static StringRef ToolName;
 
 typedef std::vector<std::tuple<uint64_t, StringRef, uint8_t>> SectionSymbolsTy;
@@ -1728,56 +1722,6 @@ static void printUnwindInfo(const ObjectFile *O) {
            "for COFF and MachO object files.\n";
 }
 
-void llvm::printExportsTrie(const ObjectFile *o) {
-  outs() << "Exports trie:\n";
-  if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
-    printMachOExportsTrie(MachO);
-  else
-    WithColor::error(errs(), ToolName)
-        << "This operation is only currently supported "
-           "for Mach-O executable files.\n";
-}
-
-void llvm::printRebaseTable(ObjectFile *o) {
-  outs() << "Rebase table:\n";
-  if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
-    printMachORebaseTable(MachO);
-  else
-    WithColor::error(errs(), ToolName)
-        << "This operation is only currently supported "
-           "for Mach-O executable files.\n";
-}
-
-void llvm::printBindTable(ObjectFile *o) {
-  outs() << "Bind table:\n";
-  if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
-    printMachOBindTable(MachO);
-  else
-    WithColor::error(errs(), ToolName)
-        << "This operation is only currently supported "
-           "for Mach-O executable files.\n";
-}
-
-void llvm::printLazyBindTable(ObjectFile *o) {
-  outs() << "Lazy bind table:\n";
-  if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
-    printMachOLazyBindTable(MachO);
-  else
-    WithColor::error(errs(), ToolName)
-        << "This operation is only currently supported "
-           "for Mach-O executable files.\n";
-}
-
-void llvm::printWeakBindTable(ObjectFile *o) {
-  outs() << "Weak bind table:\n";
-  if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
-    printMachOWeakBindTable(MachO);
-  else
-    WithColor::error(errs(), ToolName)
-        << "This operation is only currently supported "
-           "for Mach-O executable files.\n";
-}
-
 /// Dump the raw contents of the __clangast section so the output can be piped
 /// into llvm-bcanalyzer.
 void llvm::printRawClangAST(const ObjectFile *Obj) {
@@ -1979,7 +1923,7 @@ static void dumpObject(ObjectFile *O, const Archive *A = nullptr,
     printWeakBindTable(O);
   if (RawClangAST)
     printRawClangAST(O);
-  if (PrintFaultMaps)
+  if (FaultMapSection)
     printFaultMaps(O);
   if (DwarfDumpType != DIDT_Null) {
     std::unique_ptr<DIContext> DICtx = DWARFContext::create(*O);
@@ -2105,7 +2049,7 @@ int main(int argc, char **argv) {
       && !(DylibId && MachOOpt)
       && !(ObjcMetaData && MachOOpt)
       && !(!FilterSections.empty() && MachOOpt)
-      && !PrintFaultMaps
+      && !FaultMapSection
       && DwarfDumpType == DIDT_Null) {
     cl::PrintHelpMessage();
     return 2;
index ea4b36b..2211b50 100644 (file)
@@ -29,45 +29,7 @@ class Archive;
 class RelocationRef;
 }
 
-extern cl::opt<std::string> TripleName;
-extern cl::opt<std::string> ArchName;
-extern cl::opt<std::string> MCPU;
-extern cl::list<std::string> MAttrs;
-extern cl::list<std::string> FilterSections;
-extern cl::opt<bool> AllHeaders;
 extern cl::opt<bool> Demangle;
-extern cl::opt<bool> Disassemble;
-extern cl::opt<bool> DisassembleAll;
-extern cl::opt<bool> NoShowRawInsn;
-extern cl::opt<bool> NoLeadingAddr;
-extern cl::opt<bool> PrivateHeaders;
-extern cl::opt<bool> FileHeaders;
-extern cl::opt<bool> FirstPrivateHeader;
-extern cl::opt<bool> ExportsTrie;
-extern cl::opt<bool> Rebase;
-extern cl::opt<bool> Bind;
-extern cl::opt<bool> LazyBind;
-extern cl::opt<bool> WeakBind;
-extern cl::opt<bool> RawClangAST;
-extern cl::opt<bool> UniversalHeaders;
-extern cl::opt<bool> ArchiveHeaders;
-extern cl::opt<bool> IndirectSymbols;
-extern cl::opt<bool> DataInCode;
-extern cl::opt<bool> LinkOptHints;
-extern cl::opt<bool> InfoPlist;
-extern cl::opt<bool> DylibsUsed;
-extern cl::opt<bool> DylibId;
-extern cl::opt<bool> ObjcMetaData;
-extern cl::opt<std::string> DisSymName;
-extern cl::opt<bool> NonVerbose;
-extern cl::opt<bool> Relocations;
-extern cl::opt<bool> DynamicRelocations;
-extern cl::opt<bool> SectionHeaders;
-extern cl::opt<bool> SectionContents;
-extern cl::opt<bool> SymbolTable;
-extern cl::opt<bool> UnwindInfo;
-extern cl::opt<bool> PrintImmHex;
-extern cl::opt<DIDumpType> DwarfDumpType;
 
 typedef std::function<bool(llvm::object::SectionRef const &)> FilterPredicate;