1 //===-- llvm-objdump.cpp - Object file dumping utility for llvm -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This program is a utility that works like binutils "objdump", that is, it
11 // dumps out a plethora of information about an object file depending on the
14 // The flags and output of this program should be near identical to those of
17 //===----------------------------------------------------------------------===//
19 #include "llvm-objdump.h"
20 #include "llvm/ADT/Optional.h"
21 #include "llvm/ADT/STLExtras.h"
22 #include "llvm/ADT/StringExtras.h"
23 #include "llvm/ADT/Triple.h"
24 #include "llvm/CodeGen/FaultMaps.h"
25 #include "llvm/MC/MCAsmInfo.h"
26 #include "llvm/MC/MCContext.h"
27 #include "llvm/MC/MCDisassembler.h"
28 #include "llvm/MC/MCInst.h"
29 #include "llvm/MC/MCInstPrinter.h"
30 #include "llvm/MC/MCInstrAnalysis.h"
31 #include "llvm/MC/MCInstrInfo.h"
32 #include "llvm/MC/MCObjectFileInfo.h"
33 #include "llvm/MC/MCRegisterInfo.h"
34 #include "llvm/MC/MCRelocationInfo.h"
35 #include "llvm/MC/MCSubtargetInfo.h"
36 #include "llvm/Object/Archive.h"
37 #include "llvm/Object/ELFObjectFile.h"
38 #include "llvm/Object/COFF.h"
39 #include "llvm/Object/MachO.h"
40 #include "llvm/Object/ObjectFile.h"
41 #include "llvm/Support/Casting.h"
42 #include "llvm/Support/CommandLine.h"
43 #include "llvm/Support/Debug.h"
44 #include "llvm/Support/Errc.h"
45 #include "llvm/Support/FileSystem.h"
46 #include "llvm/Support/Format.h"
47 #include "llvm/Support/GraphWriter.h"
48 #include "llvm/Support/Host.h"
49 #include "llvm/Support/ManagedStatic.h"
50 #include "llvm/Support/MemoryBuffer.h"
51 #include "llvm/Support/PrettyStackTrace.h"
52 #include "llvm/Support/Signals.h"
53 #include "llvm/Support/SourceMgr.h"
54 #include "llvm/Support/TargetRegistry.h"
55 #include "llvm/Support/TargetSelect.h"
56 #include "llvm/Support/raw_ostream.h"
60 #include <system_error>
63 using namespace object;
65 static cl::list<std::string>
66 InputFilenames(cl::Positional, cl::desc("<input object files>"),cl::ZeroOrMore);
69 llvm::Disassemble("disassemble",
70 cl::desc("Display assembler mnemonics for the machine instructions"));
72 Disassembled("d", cl::desc("Alias for --disassemble"),
73 cl::aliasopt(Disassemble));
76 llvm::Relocations("r", cl::desc("Display the relocation entries in the file"));
79 llvm::SectionContents("s", cl::desc("Display the content of each section"));
82 llvm::SymbolTable("t", cl::desc("Display the symbol table"));
85 llvm::ExportsTrie("exports-trie", cl::desc("Display mach-o exported symbols"));
88 llvm::Rebase("rebase", cl::desc("Display mach-o rebasing info"));
91 llvm::Bind("bind", cl::desc("Display mach-o binding info"));
94 llvm::LazyBind("lazy-bind", cl::desc("Display mach-o lazy binding info"));
97 llvm::WeakBind("weak-bind", cl::desc("Display mach-o weak binding info"));
100 llvm::RawClangAST("raw-clang-ast",
101 cl::desc("Dump the raw binary contents of the clang AST section"));
104 MachOOpt("macho", cl::desc("Use MachO specific object file parser"));
106 MachOm("m", cl::desc("Alias for --macho"), cl::aliasopt(MachOOpt));
109 llvm::TripleName("triple", cl::desc("Target triple to disassemble for, "
110 "see -version for available targets"));
114 cl::desc("Target a specific cpu type (-mcpu=help for details)"),
115 cl::value_desc("cpu-name"),
119 llvm::ArchName("arch-name", cl::desc("Target arch to disassemble for, "
120 "see -version for available targets"));
123 llvm::SectionHeaders("section-headers", cl::desc("Display summaries of the "
124 "headers for each section."));
126 SectionHeadersShort("headers", cl::desc("Alias for --section-headers"),
127 cl::aliasopt(SectionHeaders));
129 SectionHeadersShorter("h", cl::desc("Alias for --section-headers"),
130 cl::aliasopt(SectionHeaders));
132 cl::list<std::string>
133 llvm::MAttrs("mattr",
135 cl::desc("Target specific attributes"),
136 cl::value_desc("a1,+a2,-a3,..."));
139 llvm::NoShowRawInsn("no-show-raw-insn", cl::desc("When disassembling "
140 "instructions, do not print "
141 "the instruction bytes."));
144 llvm::UnwindInfo("unwind-info", cl::desc("Display unwind information"));
147 UnwindInfoShort("u", cl::desc("Alias for --unwind-info"),
148 cl::aliasopt(UnwindInfo));
151 llvm::PrivateHeaders("private-headers",
152 cl::desc("Display format specific file headers"));
155 PrivateHeadersShort("p", cl::desc("Alias for --private-headers"),
156 cl::aliasopt(PrivateHeaders));
159 llvm::PrintImmHex("print-imm-hex",
160 cl::desc("Use hex format for immediate values"));
162 cl::opt<bool> PrintFaultMaps("fault-map-section",
163 cl::desc("Display contents of faultmap section"));
165 static StringRef ToolName;
166 static int ReturnValue = EXIT_SUCCESS;
168 bool llvm::error(std::error_code EC) {
172 outs() << ToolName << ": error reading file: " << EC.message() << ".\n";
174 ReturnValue = EXIT_FAILURE;
178 static void report_error(StringRef File, std::error_code EC) {
180 errs() << ToolName << ": '" << File << "': " << EC.message() << ".\n";
181 ReturnValue = EXIT_FAILURE;
184 static const Target *getTarget(const ObjectFile *Obj = nullptr) {
185 // Figure out the target triple.
186 llvm::Triple TheTriple("unknown-unknown-unknown");
187 if (TripleName.empty()) {
189 TheTriple.setArch(Triple::ArchType(Obj->getArch()));
190 // TheTriple defaults to ELF, and COFF doesn't have an environment:
191 // the best we can do here is indicate that it is mach-o.
193 TheTriple.setObjectFormat(Triple::MachO);
196 const auto COFFObj = dyn_cast<COFFObjectFile>(Obj);
197 if (COFFObj->getArch() == Triple::thumb)
198 TheTriple.setTriple("thumbv7-windows");
202 TheTriple.setTriple(Triple::normalize(TripleName));
204 // Get the target specific parser.
206 const Target *TheTarget = TargetRegistry::lookupTarget(ArchName, TheTriple,
209 errs() << ToolName << ": " << Error;
213 // Update the triple name and return the found target.
214 TripleName = TheTriple.getTriple();
218 bool llvm::RelocAddressLess(RelocationRef a, RelocationRef b) {
219 return a.getOffset() < b.getOffset();
223 class PrettyPrinter {
225 virtual ~PrettyPrinter(){}
226 virtual void printInst(MCInstPrinter &IP, const MCInst *MI,
227 ArrayRef<uint8_t> Bytes, uint64_t Address,
228 raw_ostream &OS, StringRef Annot,
229 MCSubtargetInfo const &STI) {
230 outs() << format("%8" PRIx64 ":", Address);
231 if (!NoShowRawInsn) {
233 dumpBytes(Bytes, outs());
235 IP.printInst(MI, outs(), "", STI);
238 PrettyPrinter PrettyPrinterInst;
239 class HexagonPrettyPrinter : public PrettyPrinter {
241 void printLead(ArrayRef<uint8_t> Bytes, uint64_t Address,
244 (Bytes[3] << 24) | (Bytes[2] << 16) | (Bytes[1] << 8) | Bytes[0];
245 OS << format("%8" PRIx64 ":", Address);
246 if (!NoShowRawInsn) {
248 dumpBytes(Bytes.slice(0, 4), OS);
249 OS << format("%08" PRIx32, opcode);
252 void printInst(MCInstPrinter &IP, const MCInst *MI,
253 ArrayRef<uint8_t> Bytes, uint64_t Address,
254 raw_ostream &OS, StringRef Annot,
255 MCSubtargetInfo const &STI) override {
258 raw_string_ostream TempStream(Buffer);
259 IP.printInst(MI, TempStream, "", STI);
261 StringRef Contents(Buffer);
262 // Split off bundle attributes
263 auto PacketBundle = Contents.rsplit('\n');
264 // Split off first instruction from the rest
265 auto HeadTail = PacketBundle.first.split('\n');
266 auto Preamble = " { ";
268 while(!HeadTail.first.empty()) {
271 printLead(Bytes, Address, OS);
275 auto Duplex = HeadTail.first.split('\v');
276 if(!Duplex.second.empty()){
279 Inst = Duplex.second;
282 Inst = HeadTail.first;
284 Bytes = Bytes.slice(4);
286 HeadTail = HeadTail.second.split('\n');
288 OS << " } " << PacketBundle.second;
291 HexagonPrettyPrinter HexagonPrettyPrinterInst;
292 PrettyPrinter &selectPrettyPrinter(Triple const &Triple) {
293 switch(Triple.getArch()) {
295 return PrettyPrinterInst;
296 case Triple::hexagon:
297 return HexagonPrettyPrinterInst;
302 template <class ELFT>
303 static std::error_code getRelocationValueString(const ELFObjectFile<ELFT> *Obj,
305 SmallVectorImpl<char> &Result) {
306 typedef typename ELFObjectFile<ELFT>::Elf_Sym Elf_Sym;
307 typedef typename ELFObjectFile<ELFT>::Elf_Shdr Elf_Shdr;
308 typedef typename ELFObjectFile<ELFT>::Elf_Rel Elf_Rel;
309 typedef typename ELFObjectFile<ELFT>::Elf_Rela Elf_Rela;
311 const ELFFile<ELFT> &EF = *Obj->getELFFile();
313 ErrorOr<const Elf_Shdr *> SecOrErr = EF.getSection(Rel.d.a);
314 if (std::error_code EC = SecOrErr.getError())
316 const Elf_Shdr *Sec = *SecOrErr;
317 ErrorOr<const Elf_Shdr *> SymTabOrErr = EF.getSection(Sec->sh_link);
318 if (std::error_code EC = SymTabOrErr.getError())
320 const Elf_Shdr *SymTab = *SymTabOrErr;
321 assert(SymTab->sh_type == ELF::SHT_SYMTAB ||
322 SymTab->sh_type == ELF::SHT_DYNSYM);
323 ErrorOr<const Elf_Shdr *> StrTabSec = EF.getSection(SymTab->sh_link);
324 if (std::error_code EC = StrTabSec.getError())
326 ErrorOr<StringRef> StrTabOrErr = EF.getStringTable(*StrTabSec);
327 if (std::error_code EC = StrTabOrErr.getError())
329 StringRef StrTab = *StrTabOrErr;
333 uint16_t symbol_index = 0;
334 switch (Sec->sh_type) {
336 return object_error::parse_failed;
338 const Elf_Rel *ERel = Obj->getRel(Rel);
339 type = ERel->getType(EF.isMips64EL());
340 symbol_index = ERel->getSymbol(EF.isMips64EL());
341 // TODO: Read implicit addend from section data.
344 case ELF::SHT_RELA: {
345 const Elf_Rela *ERela = Obj->getRela(Rel);
346 type = ERela->getType(EF.isMips64EL());
347 symbol_index = ERela->getSymbol(EF.isMips64EL());
348 addend = ERela->r_addend;
352 const Elf_Sym *symb =
353 EF.template getEntry<Elf_Sym>(Sec->sh_link, symbol_index);
355 ErrorOr<const Elf_Shdr *> SymSec = EF.getSection(symb);
356 if (std::error_code EC = SymSec.getError())
358 if (symb->getType() == ELF::STT_SECTION) {
359 ErrorOr<StringRef> SecName = EF.getSectionName(*SymSec);
360 if (std::error_code EC = SecName.getError())
364 ErrorOr<StringRef> SymName = symb->getName(StrTab);
366 return SymName.getError();
369 switch (EF.getHeader()->e_machine) {
372 case ELF::R_X86_64_PC8:
373 case ELF::R_X86_64_PC16:
374 case ELF::R_X86_64_PC32: {
376 raw_string_ostream fmt(fmtbuf);
377 fmt << Target << (addend < 0 ? "" : "+") << addend << "-P";
379 Result.append(fmtbuf.begin(), fmtbuf.end());
381 case ELF::R_X86_64_8:
382 case ELF::R_X86_64_16:
383 case ELF::R_X86_64_32:
384 case ELF::R_X86_64_32S:
385 case ELF::R_X86_64_64: {
387 raw_string_ostream fmt(fmtbuf);
388 fmt << Target << (addend < 0 ? "" : "+") << addend;
390 Result.append(fmtbuf.begin(), fmtbuf.end());
396 case ELF::EM_AARCH64: {
398 raw_string_ostream fmt(fmtbuf);
401 fmt << (addend < 0 ? "" : "+") << addend;
403 Result.append(fmtbuf.begin(), fmtbuf.end());
408 case ELF::EM_HEXAGON:
416 Result.append(res.begin(), res.end());
417 return std::error_code();
420 static std::error_code getRelocationValueString(const ELFObjectFileBase *Obj,
421 const RelocationRef &RelRef,
422 SmallVectorImpl<char> &Result) {
423 DataRefImpl Rel = RelRef.getRawDataRefImpl();
424 if (auto *ELF32LE = dyn_cast<ELF32LEObjectFile>(Obj))
425 return getRelocationValueString(ELF32LE, Rel, Result);
426 if (auto *ELF64LE = dyn_cast<ELF64LEObjectFile>(Obj))
427 return getRelocationValueString(ELF64LE, Rel, Result);
428 if (auto *ELF32BE = dyn_cast<ELF32BEObjectFile>(Obj))
429 return getRelocationValueString(ELF32BE, Rel, Result);
430 auto *ELF64BE = cast<ELF64BEObjectFile>(Obj);
431 return getRelocationValueString(ELF64BE, Rel, Result);
434 static std::error_code getRelocationValueString(const COFFObjectFile *Obj,
435 const RelocationRef &Rel,
436 SmallVectorImpl<char> &Result) {
437 symbol_iterator SymI = Rel.getSymbol();
438 ErrorOr<StringRef> SymNameOrErr = SymI->getName();
439 if (std::error_code EC = SymNameOrErr.getError())
441 StringRef SymName = *SymNameOrErr;
442 Result.append(SymName.begin(), SymName.end());
443 return std::error_code();
446 static void printRelocationTargetName(const MachOObjectFile *O,
447 const MachO::any_relocation_info &RE,
448 raw_string_ostream &fmt) {
449 bool IsScattered = O->isRelocationScattered(RE);
451 // Target of a scattered relocation is an address. In the interest of
452 // generating pretty output, scan through the symbol table looking for a
453 // symbol that aligns with that address. If we find one, print it.
454 // Otherwise, we just print the hex address of the target.
456 uint32_t Val = O->getPlainRelocationSymbolNum(RE);
458 for (const SymbolRef &Symbol : O->symbols()) {
460 ErrorOr<uint64_t> Addr = Symbol.getAddress();
461 if ((ec = Addr.getError()))
462 report_fatal_error(ec.message());
465 ErrorOr<StringRef> Name = Symbol.getName();
466 if (std::error_code EC = Name.getError())
467 report_fatal_error(EC.message());
472 // If we couldn't find a symbol that this relocation refers to, try
473 // to find a section beginning instead.
474 for (const SectionRef &Section : O->sections()) {
478 uint64_t Addr = Section.getAddress();
481 if ((ec = Section.getName(Name)))
482 report_fatal_error(ec.message());
487 fmt << format("0x%x", Val);
492 bool isExtern = O->getPlainRelocationExternal(RE);
493 uint64_t Val = O->getPlainRelocationSymbolNum(RE);
496 symbol_iterator SI = O->symbol_begin();
498 ErrorOr<StringRef> SOrErr = SI->getName();
499 if (!error(SOrErr.getError()))
502 section_iterator SI = O->section_begin();
503 // Adjust for the fact that sections are 1-indexed.
504 advance(SI, Val - 1);
511 static std::error_code getRelocationValueString(const MachOObjectFile *Obj,
512 const RelocationRef &RelRef,
513 SmallVectorImpl<char> &Result) {
514 DataRefImpl Rel = RelRef.getRawDataRefImpl();
515 MachO::any_relocation_info RE = Obj->getRelocation(Rel);
517 unsigned Arch = Obj->getArch();
520 raw_string_ostream fmt(fmtbuf);
521 unsigned Type = Obj->getAnyRelocationType(RE);
522 bool IsPCRel = Obj->getAnyRelocationPCRel(RE);
524 // Determine any addends that should be displayed with the relocation.
525 // These require decoding the relocation type, which is triple-specific.
527 // X86_64 has entirely custom relocation types.
528 if (Arch == Triple::x86_64) {
529 bool isPCRel = Obj->getAnyRelocationPCRel(RE);
532 case MachO::X86_64_RELOC_GOT_LOAD:
533 case MachO::X86_64_RELOC_GOT: {
534 printRelocationTargetName(Obj, RE, fmt);
540 case MachO::X86_64_RELOC_SUBTRACTOR: {
541 DataRefImpl RelNext = Rel;
542 Obj->moveRelocationNext(RelNext);
543 MachO::any_relocation_info RENext = Obj->getRelocation(RelNext);
545 // X86_64_RELOC_SUBTRACTOR must be followed by a relocation of type
546 // X86_64_RELOC_UNSIGNED.
547 // NOTE: Scattered relocations don't exist on x86_64.
548 unsigned RType = Obj->getAnyRelocationType(RENext);
549 if (RType != MachO::X86_64_RELOC_UNSIGNED)
550 report_fatal_error("Expected X86_64_RELOC_UNSIGNED after "
551 "X86_64_RELOC_SUBTRACTOR.");
553 // The X86_64_RELOC_UNSIGNED contains the minuend symbol;
554 // X86_64_RELOC_SUBTRACTOR contains the subtrahend.
555 printRelocationTargetName(Obj, RENext, fmt);
557 printRelocationTargetName(Obj, RE, fmt);
560 case MachO::X86_64_RELOC_TLV:
561 printRelocationTargetName(Obj, RE, fmt);
566 case MachO::X86_64_RELOC_SIGNED_1:
567 printRelocationTargetName(Obj, RE, fmt);
570 case MachO::X86_64_RELOC_SIGNED_2:
571 printRelocationTargetName(Obj, RE, fmt);
574 case MachO::X86_64_RELOC_SIGNED_4:
575 printRelocationTargetName(Obj, RE, fmt);
579 printRelocationTargetName(Obj, RE, fmt);
582 // X86 and ARM share some relocation types in common.
583 } else if (Arch == Triple::x86 || Arch == Triple::arm ||
584 Arch == Triple::ppc) {
585 // Generic relocation types...
587 case MachO::GENERIC_RELOC_PAIR: // prints no info
588 return std::error_code();
589 case MachO::GENERIC_RELOC_SECTDIFF: {
590 DataRefImpl RelNext = Rel;
591 Obj->moveRelocationNext(RelNext);
592 MachO::any_relocation_info RENext = Obj->getRelocation(RelNext);
594 // X86 sect diff's must be followed by a relocation of type
595 // GENERIC_RELOC_PAIR.
596 unsigned RType = Obj->getAnyRelocationType(RENext);
598 if (RType != MachO::GENERIC_RELOC_PAIR)
599 report_fatal_error("Expected GENERIC_RELOC_PAIR after "
600 "GENERIC_RELOC_SECTDIFF.");
602 printRelocationTargetName(Obj, RE, fmt);
604 printRelocationTargetName(Obj, RENext, fmt);
609 if (Arch == Triple::x86 || Arch == Triple::ppc) {
611 case MachO::GENERIC_RELOC_LOCAL_SECTDIFF: {
612 DataRefImpl RelNext = Rel;
613 Obj->moveRelocationNext(RelNext);
614 MachO::any_relocation_info RENext = Obj->getRelocation(RelNext);
616 // X86 sect diff's must be followed by a relocation of type
617 // GENERIC_RELOC_PAIR.
618 unsigned RType = Obj->getAnyRelocationType(RENext);
619 if (RType != MachO::GENERIC_RELOC_PAIR)
620 report_fatal_error("Expected GENERIC_RELOC_PAIR after "
621 "GENERIC_RELOC_LOCAL_SECTDIFF.");
623 printRelocationTargetName(Obj, RE, fmt);
625 printRelocationTargetName(Obj, RENext, fmt);
628 case MachO::GENERIC_RELOC_TLV: {
629 printRelocationTargetName(Obj, RE, fmt);
636 printRelocationTargetName(Obj, RE, fmt);
638 } else { // ARM-specific relocations
640 case MachO::ARM_RELOC_HALF:
641 case MachO::ARM_RELOC_HALF_SECTDIFF: {
642 // Half relocations steal a bit from the length field to encode
643 // whether this is an upper16 or a lower16 relocation.
644 bool isUpper = Obj->getAnyRelocationLength(RE) >> 1;
650 printRelocationTargetName(Obj, RE, fmt);
652 DataRefImpl RelNext = Rel;
653 Obj->moveRelocationNext(RelNext);
654 MachO::any_relocation_info RENext = Obj->getRelocation(RelNext);
656 // ARM half relocs must be followed by a relocation of type
658 unsigned RType = Obj->getAnyRelocationType(RENext);
659 if (RType != MachO::ARM_RELOC_PAIR)
660 report_fatal_error("Expected ARM_RELOC_PAIR after "
663 // NOTE: The half of the target virtual address is stashed in the
664 // address field of the secondary relocation, but we can't reverse
665 // engineer the constant offset from it without decoding the movw/movt
666 // instruction to find the other half in its immediate field.
668 // ARM_RELOC_HALF_SECTDIFF encodes the second section in the
669 // symbol/section pointer of the follow-on relocation.
670 if (Type == MachO::ARM_RELOC_HALF_SECTDIFF) {
672 printRelocationTargetName(Obj, RENext, fmt);
678 default: { printRelocationTargetName(Obj, RE, fmt); }
682 printRelocationTargetName(Obj, RE, fmt);
685 Result.append(fmtbuf.begin(), fmtbuf.end());
686 return std::error_code();
689 static std::error_code getRelocationValueString(const RelocationRef &Rel,
690 SmallVectorImpl<char> &Result) {
691 const ObjectFile *Obj = Rel.getObject();
692 if (auto *ELF = dyn_cast<ELFObjectFileBase>(Obj))
693 return getRelocationValueString(ELF, Rel, Result);
694 if (auto *COFF = dyn_cast<COFFObjectFile>(Obj))
695 return getRelocationValueString(COFF, Rel, Result);
696 auto *MachO = cast<MachOObjectFile>(Obj);
697 return getRelocationValueString(MachO, Rel, Result);
700 /// @brief Indicates whether this relocation should hidden when listing
701 /// relocations, usually because it is the trailing part of a multipart
702 /// relocation that will be printed as part of the leading relocation.
703 static bool getHidden(RelocationRef RelRef) {
704 const ObjectFile *Obj = RelRef.getObject();
705 auto *MachO = dyn_cast<MachOObjectFile>(Obj);
709 unsigned Arch = MachO->getArch();
710 DataRefImpl Rel = RelRef.getRawDataRefImpl();
711 uint64_t Type = MachO->getRelocationType(Rel);
713 // On arches that use the generic relocations, GENERIC_RELOC_PAIR
715 if (Arch == Triple::x86 || Arch == Triple::arm || Arch == Triple::ppc) {
716 if (Type == MachO::GENERIC_RELOC_PAIR)
718 } else if (Arch == Triple::x86_64) {
719 // On x86_64, X86_64_RELOC_UNSIGNED is hidden only when it follows
720 // an X86_64_RELOC_SUBTRACTOR.
721 if (Type == MachO::X86_64_RELOC_UNSIGNED && Rel.d.a > 0) {
722 DataRefImpl RelPrev = Rel;
724 uint64_t PrevType = MachO->getRelocationType(RelPrev);
725 if (PrevType == MachO::X86_64_RELOC_SUBTRACTOR)
733 static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
734 const Target *TheTarget = getTarget(Obj);
735 // getTarget() will have already issued a diagnostic if necessary, so
736 // just bail here if it failed.
740 // Package up features to be passed to target/subtarget
741 std::string FeaturesStr;
743 SubtargetFeatures Features;
744 for (unsigned i = 0; i != MAttrs.size(); ++i)
745 Features.AddFeature(MAttrs[i]);
746 FeaturesStr = Features.getString();
749 std::unique_ptr<const MCRegisterInfo> MRI(
750 TheTarget->createMCRegInfo(TripleName));
752 errs() << "error: no register info for target " << TripleName << "\n";
756 // Set up disassembler.
757 std::unique_ptr<const MCAsmInfo> AsmInfo(
758 TheTarget->createMCAsmInfo(*MRI, TripleName));
760 errs() << "error: no assembly info for target " << TripleName << "\n";
764 std::unique_ptr<const MCSubtargetInfo> STI(
765 TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr));
767 errs() << "error: no subtarget info for target " << TripleName << "\n";
771 std::unique_ptr<const MCInstrInfo> MII(TheTarget->createMCInstrInfo());
773 errs() << "error: no instruction info for target " << TripleName << "\n";
777 std::unique_ptr<const MCObjectFileInfo> MOFI(new MCObjectFileInfo);
778 MCContext Ctx(AsmInfo.get(), MRI.get(), MOFI.get());
780 std::unique_ptr<MCDisassembler> DisAsm(
781 TheTarget->createMCDisassembler(*STI, Ctx));
784 errs() << "error: no disassembler for target " << TripleName << "\n";
788 std::unique_ptr<const MCInstrAnalysis> MIA(
789 TheTarget->createMCInstrAnalysis(MII.get()));
791 int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
792 std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter(
793 Triple(TripleName), AsmPrinterVariant, *AsmInfo, *MII, *MRI));
795 errs() << "error: no instruction printer for target " << TripleName
799 IP->setPrintImmHex(PrintImmHex);
800 PrettyPrinter &PIP = selectPrettyPrinter(Triple(TripleName));
802 StringRef Fmt = Obj->getBytesInAddress() > 4 ? "\t\t%016" PRIx64 ": " :
803 "\t\t\t%08" PRIx64 ": ";
805 // Create a mapping, RelocSecs = SectionRelocMap[S], where sections
806 // in RelocSecs contain the relocations for section S.
808 std::map<SectionRef, SmallVector<SectionRef, 1>> SectionRelocMap;
809 for (const SectionRef &Section : Obj->sections()) {
810 section_iterator Sec2 = Section.getRelocatedSection();
811 if (Sec2 != Obj->section_end())
812 SectionRelocMap[*Sec2].push_back(Section);
815 // Create a mapping from virtual address to symbol name. This is used to
816 // pretty print the target of a call.
817 std::vector<std::pair<uint64_t, StringRef>> AllSymbols;
819 for (const SymbolRef &Symbol : Obj->symbols()) {
820 if (Symbol.getType() != SymbolRef::ST_Function)
823 ErrorOr<uint64_t> AddressOrErr = Symbol.getAddress();
824 if (error(AddressOrErr.getError()))
826 uint64_t Address = *AddressOrErr;
828 ErrorOr<StringRef> Name = Symbol.getName();
829 if (error(Name.getError()))
833 AllSymbols.push_back(std::make_pair(Address, *Name));
836 array_pod_sort(AllSymbols.begin(), AllSymbols.end());
839 for (const SectionRef &Section : Obj->sections()) {
840 if (!Section.isText() || Section.isVirtual())
843 uint64_t SectionAddr = Section.getAddress();
844 uint64_t SectSize = Section.getSize();
848 // Make a list of all the symbols in this section.
849 std::vector<std::pair<uint64_t, StringRef>> Symbols;
850 for (const SymbolRef &Symbol : Obj->symbols()) {
851 if (Section.containsSymbol(Symbol)) {
852 ErrorOr<uint64_t> AddressOrErr = Symbol.getAddress();
853 if (error(AddressOrErr.getError()))
855 uint64_t Address = *AddressOrErr;
856 Address -= SectionAddr;
857 if (Address >= SectSize)
860 ErrorOr<StringRef> Name = Symbol.getName();
861 if (error(Name.getError()))
863 Symbols.push_back(std::make_pair(Address, *Name));
867 // Sort the symbols by address, just in case they didn't come in that way.
868 array_pod_sort(Symbols.begin(), Symbols.end());
870 // Make a list of all the relocations for this section.
871 std::vector<RelocationRef> Rels;
873 for (const SectionRef &RelocSec : SectionRelocMap[Section]) {
874 for (const RelocationRef &Reloc : RelocSec.relocations()) {
875 Rels.push_back(Reloc);
880 // Sort relocations by address.
881 std::sort(Rels.begin(), Rels.end(), RelocAddressLess);
883 StringRef SegmentName = "";
884 if (const MachOObjectFile *MachO = dyn_cast<const MachOObjectFile>(Obj)) {
885 DataRefImpl DR = Section.getRawDataRefImpl();
886 SegmentName = MachO->getSectionFinalSegmentName(DR);
889 if (error(Section.getName(name)))
891 outs() << "Disassembly of section ";
892 if (!SegmentName.empty())
893 outs() << SegmentName << ",";
894 outs() << name << ':';
896 // If the section has no symbol at the start, just insert a dummy one.
897 if (Symbols.empty() || Symbols[0].first != 0)
898 Symbols.insert(Symbols.begin(), std::make_pair(0, name));
900 SmallString<40> Comments;
901 raw_svector_ostream CommentStream(Comments);
904 if (error(Section.getContents(BytesStr)))
906 ArrayRef<uint8_t> Bytes(reinterpret_cast<const uint8_t *>(BytesStr.data()),
912 std::vector<RelocationRef>::const_iterator rel_cur = Rels.begin();
913 std::vector<RelocationRef>::const_iterator rel_end = Rels.end();
914 // Disassemble symbol by symbol.
915 for (unsigned si = 0, se = Symbols.size(); si != se; ++si) {
917 uint64_t Start = Symbols[si].first;
918 // The end is either the section end or the beginning of the next symbol.
919 uint64_t End = (si == se - 1) ? SectSize : Symbols[si + 1].first;
920 // If this symbol has the same address as the next symbol, then skip it.
924 outs() << '\n' << Symbols[si].second << ":\n";
927 raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls();
929 raw_ostream &DebugOut = nulls();
932 for (Index = Start; Index < End; Index += Size) {
935 if (DisAsm->getInstruction(Inst, Size, Bytes.slice(Index),
936 SectionAddr + Index, DebugOut,
938 PIP.printInst(*IP, &Inst,
939 Bytes.slice(Index, Size),
940 SectionAddr + Index, outs(), "", *STI);
941 outs() << CommentStream.str();
943 if (MIA && (MIA->isCall(Inst) || MIA->isUnconditionalBranch(Inst) ||
944 MIA->isConditionalBranch(Inst))) {
946 if (MIA->evaluateBranch(Inst, SectionAddr + Index, Size, Target)) {
947 auto TargetSym = std::upper_bound(
948 AllSymbols.begin(), AllSymbols.end(), Target,
949 [](uint64_t LHS, const std::pair<uint64_t, StringRef> &RHS) {
950 return LHS < RHS.first;
952 if (TargetSym != AllSymbols.begin())
955 TargetSym = AllSymbols.end();
957 if (TargetSym != AllSymbols.end()) {
958 outs() << " <" << TargetSym->second;
959 uint64_t Disp = Target - TargetSym->first;
961 outs() << '+' << utohexstr(Disp);
968 errs() << ToolName << ": warning: invalid instruction encoding\n";
970 Size = 1; // skip illegible bytes
973 // Print relocation for instruction.
974 while (rel_cur != rel_end) {
975 bool hidden = getHidden(*rel_cur);
976 uint64_t addr = rel_cur->getOffset();
977 SmallString<16> name;
980 // If this relocation is hidden, skip it.
981 if (hidden) goto skip_print_rel;
983 // Stop when rel_cur's address is past the current instruction.
984 if (addr >= Index + Size) break;
985 rel_cur->getTypeName(name);
986 if (error(getRelocationValueString(*rel_cur, val)))
988 outs() << format(Fmt.data(), SectionAddr + addr) << name
989 << "\t" << val << "\n";
999 void llvm::PrintRelocations(const ObjectFile *Obj) {
1000 StringRef Fmt = Obj->getBytesInAddress() > 4 ? "%016" PRIx64 :
1002 // Regular objdump doesn't print relocations in non-relocatable object
1004 if (!Obj->isRelocatableObject())
1007 for (const SectionRef &Section : Obj->sections()) {
1008 if (Section.relocation_begin() == Section.relocation_end())
1011 if (error(Section.getName(secname)))
1013 outs() << "RELOCATION RECORDS FOR [" << secname << "]:\n";
1014 for (const RelocationRef &Reloc : Section.relocations()) {
1015 bool hidden = getHidden(Reloc);
1016 uint64_t address = Reloc.getOffset();
1017 SmallString<32> relocname;
1018 SmallString<32> valuestr;
1021 Reloc.getTypeName(relocname);
1022 if (error(getRelocationValueString(Reloc, valuestr)))
1024 outs() << format(Fmt.data(), address) << " " << relocname << " "
1025 << valuestr << "\n";
1031 void llvm::PrintSectionHeaders(const ObjectFile *Obj) {
1032 outs() << "Sections:\n"
1033 "Idx Name Size Address Type\n";
1035 for (const SectionRef &Section : Obj->sections()) {
1037 if (error(Section.getName(Name)))
1039 uint64_t Address = Section.getAddress();
1040 uint64_t Size = Section.getSize();
1041 bool Text = Section.isText();
1042 bool Data = Section.isData();
1043 bool BSS = Section.isBSS();
1044 std::string Type = (std::string(Text ? "TEXT " : "") +
1045 (Data ? "DATA " : "") + (BSS ? "BSS" : ""));
1046 outs() << format("%3d %-13s %08" PRIx64 " %016" PRIx64 " %s\n", i,
1047 Name.str().c_str(), Size, Address, Type.c_str());
1052 void llvm::PrintSectionContents(const ObjectFile *Obj) {
1054 for (const SectionRef &Section : Obj->sections()) {
1057 if (error(Section.getName(Name)))
1059 uint64_t BaseAddr = Section.getAddress();
1060 uint64_t Size = Section.getSize();
1064 outs() << "Contents of section " << Name << ":\n";
1065 if (Section.isBSS()) {
1066 outs() << format("<skipping contents of bss section at [%04" PRIx64
1067 ", %04" PRIx64 ")>\n",
1068 BaseAddr, BaseAddr + Size);
1072 if (error(Section.getContents(Contents)))
1075 // Dump out the content as hex and printable ascii characters.
1076 for (std::size_t addr = 0, end = Contents.size(); addr < end; addr += 16) {
1077 outs() << format(" %04" PRIx64 " ", BaseAddr + addr);
1078 // Dump line of hex.
1079 for (std::size_t i = 0; i < 16; ++i) {
1080 if (i != 0 && i % 4 == 0)
1083 outs() << hexdigit((Contents[addr + i] >> 4) & 0xF, true)
1084 << hexdigit(Contents[addr + i] & 0xF, true);
1090 for (std::size_t i = 0; i < 16 && addr + i < end; ++i) {
1091 if (std::isprint(static_cast<unsigned char>(Contents[addr + i]) & 0xFF))
1092 outs() << Contents[addr + i];
1101 static void PrintCOFFSymbolTable(const COFFObjectFile *coff) {
1102 for (unsigned SI = 0, SE = coff->getNumberOfSymbols(); SI != SE; ++SI) {
1103 ErrorOr<COFFSymbolRef> Symbol = coff->getSymbol(SI);
1105 if (error(Symbol.getError()))
1108 if (error(coff->getSymbolName(*Symbol, Name)))
1111 outs() << "[" << format("%2d", SI) << "]"
1112 << "(sec " << format("%2d", int(Symbol->getSectionNumber())) << ")"
1113 << "(fl 0x00)" // Flag bits, which COFF doesn't have.
1114 << "(ty " << format("%3x", unsigned(Symbol->getType())) << ")"
1115 << "(scl " << format("%3x", unsigned(Symbol->getStorageClass())) << ") "
1116 << "(nx " << unsigned(Symbol->getNumberOfAuxSymbols()) << ") "
1117 << "0x" << format("%08x", unsigned(Symbol->getValue())) << " "
1120 for (unsigned AI = 0, AE = Symbol->getNumberOfAuxSymbols(); AI < AE; ++AI, ++SI) {
1121 if (Symbol->isSectionDefinition()) {
1122 const coff_aux_section_definition *asd;
1123 if (error(coff->getAuxSymbol<coff_aux_section_definition>(SI + 1, asd)))
1126 int32_t AuxNumber = asd->getNumber(Symbol->isBigObj());
1129 << format("scnlen 0x%x nreloc %d nlnno %d checksum 0x%x "
1130 , unsigned(asd->Length)
1131 , unsigned(asd->NumberOfRelocations)
1132 , unsigned(asd->NumberOfLinenumbers)
1133 , unsigned(asd->CheckSum))
1134 << format("assoc %d comdat %d\n"
1135 , unsigned(AuxNumber)
1136 , unsigned(asd->Selection));
1137 } else if (Symbol->isFileRecord()) {
1138 const char *FileName;
1139 if (error(coff->getAuxSymbol<char>(SI + 1, FileName)))
1142 StringRef Name(FileName, Symbol->getNumberOfAuxSymbols() *
1143 coff->getSymbolTableEntrySize());
1144 outs() << "AUX " << Name.rtrim(StringRef("\0", 1)) << '\n';
1146 SI = SI + Symbol->getNumberOfAuxSymbols();
1149 outs() << "AUX Unknown\n";
1155 void llvm::PrintSymbolTable(const ObjectFile *o) {
1156 outs() << "SYMBOL TABLE:\n";
1158 if (const COFFObjectFile *coff = dyn_cast<const COFFObjectFile>(o)) {
1159 PrintCOFFSymbolTable(coff);
1162 for (const SymbolRef &Symbol : o->symbols()) {
1163 ErrorOr<uint64_t> AddressOrError = Symbol.getAddress();
1164 if (error(AddressOrError.getError()))
1166 uint64_t Address = *AddressOrError;
1167 SymbolRef::Type Type = Symbol.getType();
1168 uint32_t Flags = Symbol.getFlags();
1169 section_iterator Section = o->section_end();
1170 if (error(Symbol.getSection(Section)))
1173 if (Type == SymbolRef::ST_Debug && Section != o->section_end()) {
1174 Section->getName(Name);
1176 ErrorOr<StringRef> NameOrErr = Symbol.getName();
1177 if (error(NameOrErr.getError()))
1182 bool Global = Flags & SymbolRef::SF_Global;
1183 bool Weak = Flags & SymbolRef::SF_Weak;
1184 bool Absolute = Flags & SymbolRef::SF_Absolute;
1185 bool Common = Flags & SymbolRef::SF_Common;
1186 bool Hidden = Flags & SymbolRef::SF_Hidden;
1189 if (Type != SymbolRef::ST_Unknown)
1190 GlobLoc = Global ? 'g' : 'l';
1191 char Debug = (Type == SymbolRef::ST_Debug || Type == SymbolRef::ST_File)
1193 char FileFunc = ' ';
1194 if (Type == SymbolRef::ST_File)
1196 else if (Type == SymbolRef::ST_Function)
1199 const char *Fmt = o->getBytesInAddress() > 4 ? "%016" PRIx64 :
1202 outs() << format(Fmt, Address) << " "
1203 << GlobLoc // Local -> 'l', Global -> 'g', Neither -> ' '
1204 << (Weak ? 'w' : ' ') // Weak?
1205 << ' ' // Constructor. Not supported yet.
1206 << ' ' // Warning. Not supported yet.
1207 << ' ' // Indirect reference to another symbol.
1208 << Debug // Debugging (d) or dynamic (D) symbol.
1209 << FileFunc // Name of function (F), file (f) or object (O).
1213 } else if (Common) {
1215 } else if (Section == o->section_end()) {
1218 if (const MachOObjectFile *MachO =
1219 dyn_cast<const MachOObjectFile>(o)) {
1220 DataRefImpl DR = Section->getRawDataRefImpl();
1221 StringRef SegmentName = MachO->getSectionFinalSegmentName(DR);
1222 outs() << SegmentName << ",";
1224 StringRef SectionName;
1225 if (error(Section->getName(SectionName)))
1227 outs() << SectionName;
1231 if (Common || isa<ELFObjectFileBase>(o)) {
1233 Common ? Symbol.getAlignment() : ELFSymbolRef(Symbol).getSize();
1234 outs() << format("\t %08" PRIx64 " ", Val);
1238 outs() << ".hidden ";
1245 static void PrintUnwindInfo(const ObjectFile *o) {
1246 outs() << "Unwind info:\n\n";
1248 if (const COFFObjectFile *coff = dyn_cast<COFFObjectFile>(o)) {
1249 printCOFFUnwindInfo(coff);
1250 } else if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
1251 printMachOUnwindInfo(MachO);
1253 // TODO: Extract DWARF dump tool to objdump.
1254 errs() << "This operation is only currently supported "
1255 "for COFF and MachO object files.\n";
1260 void llvm::printExportsTrie(const ObjectFile *o) {
1261 outs() << "Exports trie:\n";
1262 if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
1263 printMachOExportsTrie(MachO);
1265 errs() << "This operation is only currently supported "
1266 "for Mach-O executable files.\n";
1271 void llvm::printRebaseTable(const ObjectFile *o) {
1272 outs() << "Rebase table:\n";
1273 if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
1274 printMachORebaseTable(MachO);
1276 errs() << "This operation is only currently supported "
1277 "for Mach-O executable files.\n";
1282 void llvm::printBindTable(const ObjectFile *o) {
1283 outs() << "Bind table:\n";
1284 if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
1285 printMachOBindTable(MachO);
1287 errs() << "This operation is only currently supported "
1288 "for Mach-O executable files.\n";
1293 void llvm::printLazyBindTable(const ObjectFile *o) {
1294 outs() << "Lazy bind table:\n";
1295 if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
1296 printMachOLazyBindTable(MachO);
1298 errs() << "This operation is only currently supported "
1299 "for Mach-O executable files.\n";
1304 void llvm::printWeakBindTable(const ObjectFile *o) {
1305 outs() << "Weak bind table:\n";
1306 if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
1307 printMachOWeakBindTable(MachO);
1309 errs() << "This operation is only currently supported "
1310 "for Mach-O executable files.\n";
1315 /// Dump the raw contents of the __clangast section so the output can be piped
1316 /// into llvm-bcanalyzer.
1317 void llvm::printRawClangAST(const ObjectFile *Obj) {
1318 if (outs().is_displayed()) {
1319 errs() << "The -raw-clang-ast option will dump the raw binary contents of "
1320 "the clang ast section.\n"
1321 "Please redirect the output to a file or another program such as "
1322 "llvm-bcanalyzer.\n";
1326 StringRef ClangASTSectionName("__clangast");
1327 if (isa<COFFObjectFile>(Obj)) {
1328 ClangASTSectionName = "clangast";
1331 Optional<object::SectionRef> ClangASTSection;
1332 for (auto Sec : Obj->sections()) {
1335 if (Name == ClangASTSectionName) {
1336 ClangASTSection = Sec;
1340 if (!ClangASTSection)
1343 StringRef ClangASTContents;
1344 if (error(ClangASTSection.getValue().getContents(ClangASTContents))) {
1345 errs() << "Could not read the " << ClangASTSectionName << " section!\n";
1349 outs().write(ClangASTContents.data(), ClangASTContents.size());
1352 static void printFaultMaps(const ObjectFile *Obj) {
1353 const char *FaultMapSectionName = nullptr;
1355 if (isa<ELFObjectFileBase>(Obj)) {
1356 FaultMapSectionName = ".llvm_faultmaps";
1357 } else if (isa<MachOObjectFile>(Obj)) {
1358 FaultMapSectionName = "__llvm_faultmaps";
1360 errs() << "This operation is only currently supported "
1361 "for ELF and Mach-O executable files.\n";
1365 Optional<object::SectionRef> FaultMapSection;
1367 for (auto Sec : Obj->sections()) {
1370 if (Name == FaultMapSectionName) {
1371 FaultMapSection = Sec;
1376 outs() << "FaultMap table:\n";
1378 if (!FaultMapSection.hasValue()) {
1379 outs() << "<not found>\n";
1383 StringRef FaultMapContents;
1384 if (error(FaultMapSection.getValue().getContents(FaultMapContents))) {
1385 errs() << "Could not read the " << FaultMapContents << " section!\n";
1389 FaultMapParser FMP(FaultMapContents.bytes_begin(),
1390 FaultMapContents.bytes_end());
1395 static void printPrivateFileHeader(const ObjectFile *o) {
1397 printELFFileHeader(o);
1398 } else if (o->isCOFF()) {
1399 printCOFFFileHeader(o);
1400 } else if (o->isMachO()) {
1401 printMachOFileHeader(o);
1405 static void DumpObject(const ObjectFile *o) {
1406 // Avoid other output when using a raw option.
1409 outs() << o->getFileName()
1410 << ":\tfile format " << o->getFileFormatName() << "\n\n";
1414 DisassembleObject(o, Relocations);
1415 if (Relocations && !Disassemble)
1416 PrintRelocations(o);
1418 PrintSectionHeaders(o);
1419 if (SectionContents)
1420 PrintSectionContents(o);
1422 PrintSymbolTable(o);
1426 printPrivateFileHeader(o);
1428 printExportsTrie(o);
1430 printRebaseTable(o);
1434 printLazyBindTable(o);
1436 printWeakBindTable(o);
1438 printRawClangAST(o);
1443 /// @brief Dump each object file in \a a;
1444 static void DumpArchive(const Archive *a) {
1445 for (Archive::child_iterator i = a->child_begin(), e = a->child_end(); i != e;
1447 ErrorOr<std::unique_ptr<Binary>> ChildOrErr = i->getAsBinary();
1448 if (std::error_code EC = ChildOrErr.getError()) {
1449 // Ignore non-object files.
1450 if (EC != object_error::invalid_file_type)
1451 report_error(a->getFileName(), EC);
1454 if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get()))
1457 report_error(a->getFileName(), object_error::invalid_file_type);
1461 /// @brief Open file and figure out how to dump it.
1462 static void DumpInput(StringRef file) {
1463 // If file isn't stdin, check that it exists.
1464 if (file != "-" && !sys::fs::exists(file)) {
1465 report_error(file, errc::no_such_file_or_directory);
1469 // If we are using the Mach-O specific object file parser, then let it parse
1470 // the file and process the command line options. So the -arch flags can
1471 // be used to select specific slices, etc.
1473 ParseInputMachO(file);
1477 // Attempt to open the binary.
1478 ErrorOr<OwningBinary<Binary>> BinaryOrErr = createBinary(file);
1479 if (std::error_code EC = BinaryOrErr.getError()) {
1480 report_error(file, EC);
1483 Binary &Binary = *BinaryOrErr.get().getBinary();
1485 if (Archive *a = dyn_cast<Archive>(&Binary))
1487 else if (ObjectFile *o = dyn_cast<ObjectFile>(&Binary))
1490 report_error(file, object_error::invalid_file_type);
1493 int main(int argc, char **argv) {
1494 // Print a stack trace if we signal out.
1495 sys::PrintStackTraceOnErrorSignal();
1496 PrettyStackTraceProgram X(argc, argv);
1497 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
1499 // Initialize targets and assembly printers/parsers.
1500 llvm::InitializeAllTargetInfos();
1501 llvm::InitializeAllTargetMCs();
1502 llvm::InitializeAllAsmParsers();
1503 llvm::InitializeAllDisassemblers();
1505 // Register the target printer for --version.
1506 cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
1508 cl::ParseCommandLineOptions(argc, argv, "llvm object file dumper\n");
1509 TripleName = Triple::normalize(TripleName);
1513 // Defaults to a.out if no filenames specified.
1514 if (InputFilenames.size() == 0)
1515 InputFilenames.push_back("a.out");
1530 && !(UniversalHeaders && MachOOpt)
1531 && !(ArchiveHeaders && MachOOpt)
1532 && !(IndirectSymbols && MachOOpt)
1533 && !(DataInCode && MachOOpt)
1534 && !(LinkOptHints && MachOOpt)
1535 && !(InfoPlist && MachOOpt)
1536 && !(DylibsUsed && MachOOpt)
1537 && !(DylibId && MachOOpt)
1538 && !(ObjcMetaData && MachOOpt)
1539 && !(DumpSections.size() != 0 && MachOOpt)
1540 && !PrintFaultMaps) {
1541 cl::PrintHelpMessage();
1545 std::for_each(InputFilenames.begin(), InputFilenames.end(),