diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -59,6 +59,8 @@ namespace llvm { +cl::OptionCategory MachOCat("llvm-objdump MachO Specific Options"); + extern cl::opt ArchiveHeaders; extern cl::opt Disassemble; extern cl::opt DisassembleAll; @@ -80,91 +82,113 @@ cl::opt FirstPrivateHeader("private-header", cl::desc("Display only the first format specific file " - "header")); + "header"), + cl::cat(MachOCat)); cl::opt ExportsTrie("exports-trie", - cl::desc("Display mach-o exported symbols")); + cl::desc("Display mach-o exported symbols"), + cl::cat(MachOCat)); -cl::opt Rebase("rebase", cl::desc("Display mach-o rebasing info")); +cl::opt Rebase("rebase", cl::desc("Display mach-o rebasing info"), + cl::cat(MachOCat)); -cl::opt Bind("bind", cl::desc("Display mach-o binding info")); +cl::opt Bind("bind", cl::desc("Display mach-o binding info"), + cl::cat(MachOCat)); cl::opt LazyBind("lazy-bind", - cl::desc("Display mach-o lazy binding info")); + cl::desc("Display mach-o lazy binding info"), + cl::cat(MachOCat)); cl::opt WeakBind("weak-bind", - cl::desc("Display mach-o weak binding info")); + cl::desc("Display mach-o weak binding info"), + cl::cat(MachOCat)); static cl::opt UseDbg("g", cl::Grouping, - cl::desc("Print line information from debug info if available")); + cl::desc("Print line information from debug info if available"), + cl::cat(MachOCat)); static cl::opt DSYMFile("dsym", - cl::desc("Use .dSYM file for debug info")); + cl::desc("Use .dSYM file for debug info"), + cl::cat(MachOCat)); static cl::opt FullLeadingAddr("full-leading-addr", - cl::desc("Print full leading address")); + cl::desc("Print full leading address"), + cl::cat(MachOCat)); static cl::opt NoLeadingHeaders("no-leading-headers", - cl::desc("Print no leading headers")); + cl::desc("Print no leading headers"), + cl::cat(MachOCat)); cl::opt UniversalHeaders("universal-headers", cl::desc("Print Mach-O universal headers " - "(requires -macho)")); + "(requires -macho)"), + cl::cat(MachOCat)); cl::opt ArchiveMemberOffsets("archive-member-offsets", cl::desc("Print the offset to each archive member for " "Mach-O archives (requires -macho and " - "-archive-headers)")); + "-archive-headers)"), + cl::cat(MachOCat)); cl::opt IndirectSymbols("indirect-symbols", cl::desc("Print indirect symbol table for Mach-O " - "objects (requires -macho)")); + "objects (requires -macho)"), + cl::cat(MachOCat)); cl::opt DataInCode("data-in-code", cl::desc("Print the data in code table for Mach-O objects " - "(requires -macho)")); + "(requires -macho)"), + cl::cat(MachOCat)); cl::opt LinkOptHints("link-opt-hints", cl::desc("Print the linker optimization hints for " - "Mach-O objects (requires -macho)")); + "Mach-O objects (requires -macho)"), + cl::cat(MachOCat)); cl::opt InfoPlist("info-plist", cl::desc("Print the info plist section as strings for " - "Mach-O objects (requires -macho)")); + "Mach-O objects (requires -macho)"), + cl::cat(MachOCat)); cl::opt DylibsUsed("dylibs-used", cl::desc("Print the shared libraries used for linked " - "Mach-O files (requires -macho)")); + "Mach-O files (requires -macho)"), + cl::cat(MachOCat)); cl::opt DylibId("dylib-id", cl::desc("Print the shared library's id for the dylib Mach-O " - "file (requires -macho)")); + "file (requires -macho)"), + cl::cat(MachOCat)); cl::opt NonVerbose("non-verbose", cl::desc("Print the info for Mach-O objects in " - "non-verbose or numeric form (requires -macho)")); + "non-verbose or numeric form (requires -macho)"), + cl::cat(MachOCat)); cl::opt ObjcMetaData("objc-meta-data", cl::desc("Print the Objective-C runtime meta data for " - "Mach-O files (requires -macho)")); + "Mach-O files (requires -macho)"), + cl::cat(MachOCat)); cl::opt DisSymName( "dis-symname", - cl::desc("disassemble just this symbol's instructions (requires -macho)")); + cl::desc("disassemble just this symbol's instructions (requires -macho)"), + cl::cat(MachOCat)); static cl::opt NoSymbolicOperands( "no-symbolic-operands", - cl::desc("do not symbolic operands when disassembling (requires -macho)")); + cl::desc("do not symbolic operands when disassembling (requires -macho)"), + cl::cat(MachOCat)); static cl::list ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"), - cl::ZeroOrMore); + cl::ZeroOrMore, cl::cat(MachOCat)); bool ArchAll = false; diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -71,7 +71,10 @@ namespace llvm { +cl::OptionCategory ObjdumpCat("llvm-objdump Options"); + // MachO specific +extern cl::OptionCategory MachOCat; extern cl::opt Bind; extern cl::opt DataInCode; extern cl::opt DylibsUsed; @@ -90,55 +93,62 @@ static cl::opt AdjustVMA( "adjust-vma", cl::desc("Increase the displayed address by the specified offset"), - cl::value_desc("offset"), cl::init(0)); + cl::value_desc("offset"), cl::init(0), cl::cat(ObjdumpCat)); static cl::opt AllHeaders("all-headers", - cl::desc("Display all available header information")); + cl::desc("Display all available header information"), + cl::cat(ObjdumpCat)); static cl::alias AllHeadersShort("x", cl::desc("Alias for --all-headers"), cl::NotHidden, cl::Grouping, cl::aliasopt(AllHeaders)); static cl::opt - ArchName("arch-name", cl::desc("Target arch to disassemble for, " - "see -version for available targets")); + ArchName("arch-name", + cl::desc("Target arch to disassemble for, " + "see -version for available targets"), + cl::cat(ObjdumpCat)); cl::opt ArchiveHeaders("archive-headers", - cl::desc("Display archive header information")); + cl::desc("Display archive header information"), + cl::cat(ObjdumpCat)); static cl::alias ArchiveHeadersShort("a", cl::desc("Alias for --archive-headers"), cl::NotHidden, cl::Grouping, cl::aliasopt(ArchiveHeaders)); cl::opt Demangle("demangle", cl::desc("Demangle symbols names"), - cl::init(false)); + cl::init(false), cl::cat(ObjdumpCat)); static cl::alias DemangleShort("C", cl::desc("Alias for --demangle"), cl::NotHidden, cl::Grouping, cl::aliasopt(Demangle)); cl::opt Disassemble( "disassemble", - cl::desc("Display assembler mnemonics for the machine instructions")); + cl::desc("Display assembler mnemonics for the machine instructions"), + cl::cat(ObjdumpCat)); static cl::alias DisassembleShort("d", cl::desc("Alias for --disassemble"), cl::NotHidden, cl::Grouping, cl::aliasopt(Disassemble)); cl::opt DisassembleAll( "disassemble-all", - cl::desc("Display assembler mnemonics for the machine instructions")); + cl::desc("Display assembler mnemonics for the machine instructions"), + cl::cat(ObjdumpCat)); static cl::alias DisassembleAllShort("D", cl::desc("Alias for --disassemble-all"), cl::NotHidden, cl::Grouping, cl::aliasopt(DisassembleAll)); static cl::list -DisassembleFunctions("disassemble-functions", - cl::CommaSeparated, - cl::desc("List of functions to disassemble")); + DisassembleFunctions("disassemble-functions", cl::CommaSeparated, + cl::desc("List of functions to disassemble"), + cl::cat(ObjdumpCat)); static cl::opt DisassembleZeroes( "disassemble-zeroes", - cl::desc("Do not skip blocks of zeroes when disassembling")); + cl::desc("Do not skip blocks of zeroes when disassembling"), + cl::cat(ObjdumpCat)); static cl::alias DisassembleZeroesShort("z", cl::desc("Alias for --disassemble-zeroes"), cl::NotHidden, cl::Grouping, @@ -147,7 +157,8 @@ static cl::list DisassemblerOptions("disassembler-options", cl::desc("Pass target specific disassembler options"), - cl::value_desc("options"), cl::CommaSeparated); + cl::value_desc("options"), cl::CommaSeparated, + cl::cat(ObjdumpCat)); static cl::alias DisassemblerOptionsShort("M", cl::desc("Alias for --disassembler-options"), cl::NotHidden, cl::Grouping, cl::Prefix, @@ -156,11 +167,13 @@ cl::opt DwarfDumpType( "dwarf", cl::init(DIDT_Null), cl::desc("Dump of dwarf debug sections:"), - cl::values(clEnumValN(DIDT_DebugFrame, "frames", ".debug_frame"))); + cl::values(clEnumValN(DIDT_DebugFrame, "frames", ".debug_frame")), + cl::cat(ObjdumpCat)); static cl::opt DynamicRelocations( "dynamic-reloc", - cl::desc("Display the dynamic relocation entries in the file")); + cl::desc("Display the dynamic relocation entries in the file"), + cl::cat(ObjdumpCat)); static cl::alias DynamicRelocationShort("R", cl::desc("Alias for --dynamic-reloc"), cl::NotHidden, cl::Grouping, @@ -168,72 +181,83 @@ static cl::opt FaultMapSection("fault-map-section", - cl::desc("Display contents of faultmap section")); + cl::desc("Display contents of faultmap section"), + cl::cat(ObjdumpCat)); static cl::opt FileHeaders("file-headers", - cl::desc("Display the contents of the overall file header")); + cl::desc("Display the contents of the overall file header"), + cl::cat(ObjdumpCat)); static cl::alias FileHeadersShort("f", cl::desc("Alias for --file-headers"), cl::NotHidden, cl::Grouping, cl::aliasopt(FileHeaders)); cl::opt SectionContents("full-contents", - cl::desc("Display the content of each section")); + cl::desc("Display the content of each section"), + cl::cat(ObjdumpCat)); static cl::alias SectionContentsShort("s", cl::desc("Alias for --full-contents"), cl::NotHidden, cl::Grouping, cl::aliasopt(SectionContents)); -static cl::list -InputFilenames(cl::Positional, cl::desc(""),cl::ZeroOrMore); +static cl::list InputFilenames(cl::Positional, + cl::desc(""), + cl::ZeroOrMore, + cl::cat(ObjdumpCat)); static cl::opt PrintLines("line-numbers", cl::desc("Display source line numbers with " - "disassembly. Implies disassemble object")); + "disassembly. Implies disassemble object"), + cl::cat(ObjdumpCat)); static cl::alias PrintLinesShort("l", cl::desc("Alias for --line-numbers"), cl::NotHidden, cl::Grouping, cl::aliasopt(PrintLines)); -static cl::opt -MachOOpt("macho", cl::desc("Use MachO specific object file parser")); +static cl::opt MachOOpt("macho", + cl::desc("Use MachO specific object file parser"), + cl::cat(ObjdumpCat)); static cl::alias MachOm("m", cl::desc("Alias for --macho"), cl::NotHidden, cl::Grouping, cl::aliasopt(MachOOpt)); cl::opt MCPU("mcpu", cl::desc("Target a specific cpu type (-mcpu=help for details)"), - cl::value_desc("cpu-name"), cl::init("")); + cl::value_desc("cpu-name"), cl::init(""), cl::cat(ObjdumpCat)); cl::list MAttrs("mattr", cl::CommaSeparated, cl::desc("Target specific attributes"), - cl::value_desc("a1,+a2,-a3,...")); + cl::value_desc("a1,+a2,-a3,..."), + cl::cat(ObjdumpCat)); cl::opt NoShowRawInsn("no-show-raw-insn", cl::desc("When disassembling " "instructions, do not print " - "the instruction bytes.")); + "the instruction bytes."), + cl::cat(ObjdumpCat)); cl::opt NoLeadingAddr("no-leading-addr", - cl::desc("Print no leading address")); + cl::desc("Print no leading address"), + cl::cat(ObjdumpCat)); static cl::opt RawClangAST( "raw-clang-ast", - cl::desc("Dump the raw binary contents of the clang AST section")); + cl::desc("Dump the raw binary contents of the clang AST section"), + cl::cat(ObjdumpCat)); cl::opt - Relocations("reloc", - cl::desc("Display the relocation entries in the file")); + Relocations("reloc", cl::desc("Display the relocation entries in the file"), + cl::cat(ObjdumpCat)); static cl::alias RelocationsShort("r", cl::desc("Alias for --reloc"), cl::NotHidden, cl::Grouping, cl::aliasopt(Relocations)); -cl::opt - PrintImmHex("print-imm-hex", - cl::desc("Use hex format for immediate values")); +cl::opt PrintImmHex("print-imm-hex", + cl::desc("Use hex format for immediate values"), + cl::cat(ObjdumpCat)); -cl::opt - PrivateHeaders("private-headers", - cl::desc("Display format specific file headers")); +cl::opt PrivateHeaders("private-headers", + cl::desc("Display format specific file headers"), + cl::cat(ObjdumpCat)); static cl::alias PrivateHeadersShort("p", cl::desc("Alias for --private-headers"), cl::NotHidden, cl::Grouping, @@ -242,14 +266,16 @@ cl::list FilterSections("section", cl::desc("Operate on the specified sections only. " - "With -macho dump segment,section")); + "With -macho dump segment,section"), + cl::cat(ObjdumpCat)); static cl::alias FilterSectionsj("j", cl::desc("Alias for --section"), cl::NotHidden, cl::Grouping, cl::Prefix, cl::aliasopt(FilterSections)); cl::opt SectionHeaders("section-headers", cl::desc("Display summaries of the " - "headers for each section.")); + "headers for each section."), + cl::cat(ObjdumpCat)); static cl::alias SectionHeadersShort("headers", cl::desc("Alias for --section-headers"), cl::NotHidden, @@ -261,42 +287,46 @@ static cl::opt ShowLMA("show-lma", - cl::desc("Display LMA column when dumping ELF section headers")); + cl::desc("Display LMA column when dumping ELF section headers"), + cl::cat(ObjdumpCat)); static cl::opt PrintSource( "source", cl::desc( - "Display source inlined with disassembly. Implies disassemble object")); + "Display source inlined with disassembly. Implies disassemble object"), + cl::cat(ObjdumpCat)); static cl::alias PrintSourceShort("S", cl::desc("Alias for -source"), cl::NotHidden, cl::Grouping, cl::aliasopt(PrintSource)); static cl::opt StartAddress("start-address", cl::desc("Disassemble beginning at address"), - cl::value_desc("address"), cl::init(0)); + cl::value_desc("address"), cl::init(0), cl::cat(ObjdumpCat)); static cl::opt StopAddress("stop-address", cl::desc("Stop disassembly at address"), cl::value_desc("address"), - cl::init(UINT64_MAX)); + cl::init(UINT64_MAX), cl::cat(ObjdumpCat)); -cl::opt SymbolTable("syms", cl::desc("Display the symbol table")); +cl::opt SymbolTable("syms", cl::desc("Display the symbol table"), + cl::cat(ObjdumpCat)); static cl::alias SymbolTableShort("t", cl::desc("Alias for --syms"), cl::NotHidden, cl::Grouping, cl::aliasopt(SymbolTable)); cl::opt TripleName("triple", cl::desc("Target triple to disassemble for, " - "see -version for available targets")); + "see -version for available targets"), + cl::cat(ObjdumpCat)); -cl::opt UnwindInfo("unwind-info", - cl::desc("Display unwind information")); +cl::opt UnwindInfo("unwind-info", cl::desc("Display unwind information"), + cl::cat(ObjdumpCat)); static cl::alias UnwindInfoShort("u", cl::desc("Alias for --unwind-info"), cl::NotHidden, cl::Grouping, cl::aliasopt(UnwindInfo)); - static cl::opt - Wide("wide", cl::desc("Ignored for compatibility with GNU objdump")); + Wide("wide", cl::desc("Ignored for compatibility with GNU objdump"), + cl::cat(ObjdumpCat)); static cl::alias WideShort("w", cl::Grouping, cl::aliasopt(Wide)); static StringSet<> DisasmFuncsSet; @@ -2011,6 +2041,8 @@ int main(int argc, char **argv) { using namespace llvm; InitLLVM X(argc, argv); + cl::OptionCategory const *OptionFilters[] = {&ObjdumpCat, &MachOCat}; + cl::HideUnrelatedOptions(OptionFilters); // Initialize targets and assembly printers/parsers. InitializeAllTargetInfos();