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/STLExtras.h"
21 #include "llvm/ADT/StringExtras.h"
22 #include "llvm/ADT/Triple.h"
23 #include "llvm/MC/MCAsmInfo.h"
24 #include "llvm/MC/MCContext.h"
25 #include "llvm/MC/MCDisassembler.h"
26 #include "llvm/MC/MCInst.h"
27 #include "llvm/MC/MCInstPrinter.h"
28 #include "llvm/MC/MCInstrAnalysis.h"
29 #include "llvm/MC/MCInstrInfo.h"
30 #include "llvm/MC/MCObjectFileInfo.h"
31 #include "llvm/MC/MCRegisterInfo.h"
32 #include "llvm/MC/MCRelocationInfo.h"
33 #include "llvm/MC/MCSubtargetInfo.h"
34 #include "llvm/Object/Archive.h"
35 #include "llvm/Object/COFF.h"
36 #include "llvm/Object/MachO.h"
37 #include "llvm/Object/ObjectFile.h"
38 #include "llvm/Support/Casting.h"
39 #include "llvm/Support/CommandLine.h"
40 #include "llvm/Support/Debug.h"
41 #include "llvm/Support/FileSystem.h"
42 #include "llvm/Support/Format.h"
43 #include "llvm/Support/GraphWriter.h"
44 #include "llvm/Support/Host.h"
45 #include "llvm/Support/ManagedStatic.h"
46 #include "llvm/Support/MemoryBuffer.h"
47 #include "llvm/Support/MemoryObject.h"
48 #include "llvm/Support/PrettyStackTrace.h"
49 #include "llvm/Support/Signals.h"
50 #include "llvm/Support/SourceMgr.h"
51 #include "llvm/Support/TargetRegistry.h"
52 #include "llvm/Support/TargetSelect.h"
53 #include "llvm/Support/raw_ostream.h"
57 #include <system_error>
60 using namespace object;
62 static cl::list<std::string>
63 InputFilenames(cl::Positional, cl::desc("<input object files>"),cl::ZeroOrMore);
66 Disassemble("disassemble",
67 cl::desc("Display assembler mnemonics for the machine instructions"));
69 Disassembled("d", cl::desc("Alias for --disassemble"),
70 cl::aliasopt(Disassemble));
73 Relocations("r", cl::desc("Display the relocation entries in the file"));
76 SectionContents("s", cl::desc("Display the content of each section"));
79 SymbolTable("t", cl::desc("Display the symbol table"));
82 ExportsTrie("exports-trie", cl::desc("Display mach-o exported symbols"));
85 MachOOpt("macho", cl::desc("Use MachO specific object file parser"));
87 MachOm("m", cl::desc("Alias for --macho"), cl::aliasopt(MachOOpt));
90 llvm::TripleName("triple", cl::desc("Target triple to disassemble for, "
91 "see -version for available targets"));
95 cl::desc("Target a specific cpu type (-mcpu=help for details)"),
96 cl::value_desc("cpu-name"),
100 llvm::ArchName("arch", cl::desc("Target arch to disassemble for, "
101 "see -version for available targets"));
104 SectionHeaders("section-headers", cl::desc("Display summaries of the headers "
105 "for each section."));
107 SectionHeadersShort("headers", cl::desc("Alias for --section-headers"),
108 cl::aliasopt(SectionHeaders));
110 SectionHeadersShorter("h", cl::desc("Alias for --section-headers"),
111 cl::aliasopt(SectionHeaders));
113 cl::list<std::string>
114 llvm::MAttrs("mattr",
116 cl::desc("Target specific attributes"),
117 cl::value_desc("a1,+a2,-a3,..."));
120 NoShowRawInsn("no-show-raw-insn", cl::desc("When disassembling instructions, "
121 "do not print the instruction bytes."));
124 UnwindInfo("unwind-info", cl::desc("Display unwind information"));
127 UnwindInfoShort("u", cl::desc("Alias for --unwind-info"),
128 cl::aliasopt(UnwindInfo));
131 PrivateHeaders("private-headers",
132 cl::desc("Display format specific file headers"));
135 PrivateHeadersShort("p", cl::desc("Alias for --private-headers"),
136 cl::aliasopt(PrivateHeaders));
138 static StringRef ToolName;
140 bool llvm::error(std::error_code EC) {
144 outs() << ToolName << ": error reading file: " << EC.message() << ".\n";
149 static const Target *getTarget(const ObjectFile *Obj = nullptr) {
150 // Figure out the target triple.
151 llvm::Triple TheTriple("unknown-unknown-unknown");
152 if (TripleName.empty()) {
154 TheTriple.setArch(Triple::ArchType(Obj->getArch()));
155 // TheTriple defaults to ELF, and COFF doesn't have an environment:
156 // the best we can do here is indicate that it is mach-o.
158 TheTriple.setObjectFormat(Triple::MachO);
161 const auto COFFObj = dyn_cast<COFFObjectFile>(Obj);
162 if (COFFObj->getArch() == Triple::thumb)
163 TheTriple.setTriple("thumbv7-windows");
167 TheTriple.setTriple(Triple::normalize(TripleName));
169 // Get the target specific parser.
171 const Target *TheTarget = TargetRegistry::lookupTarget(ArchName, TheTriple,
174 errs() << ToolName << ": " << Error;
178 // Update the triple name and return the found target.
179 TripleName = TheTriple.getTriple();
183 void llvm::DumpBytes(StringRef bytes) {
184 static const char hex_rep[] = "0123456789abcdef";
185 // FIXME: The real way to do this is to figure out the longest instruction
186 // and align to that size before printing. I'll fix this when I get
187 // around to outputting relocations.
188 // 15 is the longest x86 instruction
189 // 3 is for the hex rep of a byte + a space.
190 // 1 is for the null terminator.
191 enum { OutputSize = (15 * 3) + 1 };
192 char output[OutputSize];
194 assert(bytes.size() <= 15
195 && "DumpBytes only supports instructions of up to 15 bytes");
196 memset(output, ' ', sizeof(output));
198 for (StringRef::iterator i = bytes.begin(),
199 e = bytes.end(); i != e; ++i) {
200 output[index] = hex_rep[(*i & 0xF0) >> 4];
201 output[index + 1] = hex_rep[*i & 0xF];
205 output[sizeof(output) - 1] = 0;
209 bool llvm::RelocAddressLess(RelocationRef a, RelocationRef b) {
210 uint64_t a_addr, b_addr;
211 if (error(a.getOffset(a_addr))) return false;
212 if (error(b.getOffset(b_addr))) return false;
213 return a_addr < b_addr;
216 static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
217 const Target *TheTarget = getTarget(Obj);
218 // getTarget() will have already issued a diagnostic if necessary, so
219 // just bail here if it failed.
223 // Package up features to be passed to target/subtarget
224 std::string FeaturesStr;
226 SubtargetFeatures Features;
227 for (unsigned i = 0; i != MAttrs.size(); ++i)
228 Features.AddFeature(MAttrs[i]);
229 FeaturesStr = Features.getString();
232 std::unique_ptr<const MCRegisterInfo> MRI(
233 TheTarget->createMCRegInfo(TripleName));
235 errs() << "error: no register info for target " << TripleName << "\n";
239 // Set up disassembler.
240 std::unique_ptr<const MCAsmInfo> AsmInfo(
241 TheTarget->createMCAsmInfo(*MRI, TripleName));
243 errs() << "error: no assembly info for target " << TripleName << "\n";
247 std::unique_ptr<const MCSubtargetInfo> STI(
248 TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr));
250 errs() << "error: no subtarget info for target " << TripleName << "\n";
254 std::unique_ptr<const MCInstrInfo> MII(TheTarget->createMCInstrInfo());
256 errs() << "error: no instruction info for target " << TripleName << "\n";
260 std::unique_ptr<const MCObjectFileInfo> MOFI(new MCObjectFileInfo);
261 MCContext Ctx(AsmInfo.get(), MRI.get(), MOFI.get());
263 std::unique_ptr<MCDisassembler> DisAsm(
264 TheTarget->createMCDisassembler(*STI, Ctx));
267 errs() << "error: no disassembler for target " << TripleName << "\n";
271 std::unique_ptr<const MCInstrAnalysis> MIA(
272 TheTarget->createMCInstrAnalysis(MII.get()));
274 int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
275 std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter(
276 AsmPrinterVariant, *AsmInfo, *MII, *MRI, *STI));
278 errs() << "error: no instruction printer for target " << TripleName
283 StringRef Fmt = Obj->getBytesInAddress() > 4 ? "\t\t%016" PRIx64 ": " :
284 "\t\t\t%08" PRIx64 ": ";
286 // Create a mapping, RelocSecs = SectionRelocMap[S], where sections
287 // in RelocSecs contain the relocations for section S.
289 std::map<SectionRef, SmallVector<SectionRef, 1>> SectionRelocMap;
290 for (const SectionRef &Section : Obj->sections()) {
291 section_iterator Sec2 = Section.getRelocatedSection();
292 if (Sec2 != Obj->section_end())
293 SectionRelocMap[*Sec2].push_back(Section);
296 for (const SectionRef &Section : Obj->sections()) {
298 if (error(Section.isText(Text)))
303 uint64_t SectionAddr;
304 if (error(Section.getAddress(SectionAddr)))
308 if (error(Section.getSize(SectSize)))
311 // Make a list of all the symbols in this section.
312 std::vector<std::pair<uint64_t, StringRef>> Symbols;
313 for (const SymbolRef &Symbol : Obj->symbols()) {
315 if (!error(Section.containsSymbol(Symbol, contains)) && contains) {
317 if (error(Symbol.getAddress(Address)))
319 if (Address == UnknownAddressOrSize)
321 Address -= SectionAddr;
322 if (Address >= SectSize)
326 if (error(Symbol.getName(Name)))
328 Symbols.push_back(std::make_pair(Address, Name));
332 // Sort the symbols by address, just in case they didn't come in that way.
333 array_pod_sort(Symbols.begin(), Symbols.end());
335 // Make a list of all the relocations for this section.
336 std::vector<RelocationRef> Rels;
338 for (const SectionRef &RelocSec : SectionRelocMap[Section]) {
339 for (const RelocationRef &Reloc : RelocSec.relocations()) {
340 Rels.push_back(Reloc);
345 // Sort relocations by address.
346 std::sort(Rels.begin(), Rels.end(), RelocAddressLess);
348 StringRef SegmentName = "";
349 if (const MachOObjectFile *MachO = dyn_cast<const MachOObjectFile>(Obj)) {
350 DataRefImpl DR = Section.getRawDataRefImpl();
351 SegmentName = MachO->getSectionFinalSegmentName(DR);
354 if (error(Section.getName(name)))
356 outs() << "Disassembly of section ";
357 if (!SegmentName.empty())
358 outs() << SegmentName << ",";
359 outs() << name << ':';
361 // If the section has no symbols just insert a dummy one and disassemble
362 // the whole section.
364 Symbols.push_back(std::make_pair(0, name));
367 SmallString<40> Comments;
368 raw_svector_ostream CommentStream(Comments);
371 if (error(Section.getContents(Bytes)))
373 StringRefMemoryObject memoryObject(Bytes, SectionAddr);
377 std::vector<RelocationRef>::const_iterator rel_cur = Rels.begin();
378 std::vector<RelocationRef>::const_iterator rel_end = Rels.end();
379 // Disassemble symbol by symbol.
380 for (unsigned si = 0, se = Symbols.size(); si != se; ++si) {
382 uint64_t Start = Symbols[si].first;
383 // The end is either the section end or the beginning of the next symbol.
384 uint64_t End = (si == se - 1) ? SectSize : Symbols[si + 1].first;
385 // If this symbol has the same address as the next symbol, then skip it.
389 outs() << '\n' << Symbols[si].second << ":\n";
392 raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls();
394 raw_ostream &DebugOut = nulls();
397 for (Index = Start; Index < End; Index += Size) {
400 if (DisAsm->getInstruction(Inst, Size, memoryObject,
402 DebugOut, CommentStream)) {
403 outs() << format("%8" PRIx64 ":", SectionAddr + Index);
404 if (!NoShowRawInsn) {
406 DumpBytes(StringRef(Bytes.data() + Index, Size));
408 IP->printInst(&Inst, outs(), "");
409 outs() << CommentStream.str();
413 errs() << ToolName << ": warning: invalid instruction encoding\n";
415 Size = 1; // skip illegible bytes
418 // Print relocation for instruction.
419 while (rel_cur != rel_end) {
422 SmallString<16> name;
425 // If this relocation is hidden, skip it.
426 if (error(rel_cur->getHidden(hidden))) goto skip_print_rel;
427 if (hidden) goto skip_print_rel;
429 if (error(rel_cur->getOffset(addr))) goto skip_print_rel;
430 // Stop when rel_cur's address is past the current instruction.
431 if (addr >= Index + Size) break;
432 if (error(rel_cur->getTypeName(name))) goto skip_print_rel;
433 if (error(rel_cur->getValueString(val))) goto skip_print_rel;
435 outs() << format(Fmt.data(), SectionAddr + addr) << name
436 << "\t" << val << "\n";
446 static void PrintRelocations(const ObjectFile *Obj) {
447 StringRef Fmt = Obj->getBytesInAddress() > 4 ? "%016" PRIx64 :
449 // Regular objdump doesn't print relocations in non-relocatable object
451 if (!Obj->isRelocatableObject())
454 for (const SectionRef &Section : Obj->sections()) {
455 if (Section.relocation_begin() == Section.relocation_end())
458 if (error(Section.getName(secname)))
460 outs() << "RELOCATION RECORDS FOR [" << secname << "]:\n";
461 for (const RelocationRef &Reloc : Section.relocations()) {
464 SmallString<32> relocname;
465 SmallString<32> valuestr;
466 if (error(Reloc.getHidden(hidden)))
470 if (error(Reloc.getTypeName(relocname)))
472 if (error(Reloc.getOffset(address)))
474 if (error(Reloc.getValueString(valuestr)))
476 outs() << format(Fmt.data(), address) << " " << relocname << " "
483 static void PrintSectionHeaders(const ObjectFile *Obj) {
484 outs() << "Sections:\n"
485 "Idx Name Size Address Type\n";
487 for (const SectionRef &Section : Obj->sections()) {
489 if (error(Section.getName(Name)))
492 if (error(Section.getAddress(Address)))
495 if (error(Section.getSize(Size)))
497 bool Text, Data, BSS;
498 if (error(Section.isText(Text)))
500 if (error(Section.isData(Data)))
502 if (error(Section.isBSS(BSS)))
504 std::string Type = (std::string(Text ? "TEXT " : "") +
505 (Data ? "DATA " : "") + (BSS ? "BSS" : ""));
506 outs() << format("%3d %-13s %08" PRIx64 " %016" PRIx64 " %s\n", i,
507 Name.str().c_str(), Size, Address, Type.c_str());
512 static void PrintSectionContents(const ObjectFile *Obj) {
514 for (const SectionRef &Section : Obj->sections()) {
519 if (error(Section.getName(Name)))
521 if (error(Section.getAddress(BaseAddr)))
523 if (error(Section.isBSS(BSS)))
526 outs() << "Contents of section " << Name << ":\n";
529 if (error(Section.getSize(Size)))
531 outs() << format("<skipping contents of bss section at [%04" PRIx64
532 ", %04" PRIx64 ")>\n",
533 BaseAddr, BaseAddr + Size);
537 if (error(Section.getContents(Contents)))
540 // Dump out the content as hex and printable ascii characters.
541 for (std::size_t addr = 0, end = Contents.size(); addr < end; addr += 16) {
542 outs() << format(" %04" PRIx64 " ", BaseAddr + addr);
544 for (std::size_t i = 0; i < 16; ++i) {
545 if (i != 0 && i % 4 == 0)
548 outs() << hexdigit((Contents[addr + i] >> 4) & 0xF, true)
549 << hexdigit(Contents[addr + i] & 0xF, true);
555 for (std::size_t i = 0; i < 16 && addr + i < end; ++i) {
556 if (std::isprint(static_cast<unsigned char>(Contents[addr + i]) & 0xFF))
557 outs() << Contents[addr + i];
566 static void PrintCOFFSymbolTable(const COFFObjectFile *coff) {
567 for (unsigned SI = 0, SE = coff->getNumberOfSymbols(); SI != SE; ++SI) {
568 ErrorOr<COFFSymbolRef> Symbol = coff->getSymbol(SI);
570 if (error(Symbol.getError()))
573 if (error(coff->getSymbolName(*Symbol, Name)))
576 outs() << "[" << format("%2d", SI) << "]"
577 << "(sec " << format("%2d", int(Symbol->getSectionNumber())) << ")"
578 << "(fl 0x00)" // Flag bits, which COFF doesn't have.
579 << "(ty " << format("%3x", unsigned(Symbol->getType())) << ")"
580 << "(scl " << format("%3x", unsigned(Symbol->getStorageClass())) << ") "
581 << "(nx " << unsigned(Symbol->getNumberOfAuxSymbols()) << ") "
582 << "0x" << format("%08x", unsigned(Symbol->getValue())) << " "
585 for (unsigned AI = 0, AE = Symbol->getNumberOfAuxSymbols(); AI < AE; ++AI, ++SI) {
586 if (Symbol->isSectionDefinition()) {
587 const coff_aux_section_definition *asd;
588 if (error(coff->getAuxSymbol<coff_aux_section_definition>(SI + 1, asd)))
592 << format("scnlen 0x%x nreloc %d nlnno %d checksum 0x%x "
593 , unsigned(asd->Length)
594 , unsigned(asd->NumberOfRelocations)
595 , unsigned(asd->NumberOfLinenumbers)
596 , unsigned(asd->CheckSum))
597 << format("assoc %d comdat %d\n"
598 , unsigned(asd->Number)
599 , unsigned(asd->Selection));
600 } else if (Symbol->isFileRecord()) {
601 const char *FileName;
602 if (error(coff->getAuxSymbol<char>(SI + 1, FileName)))
605 StringRef Name(FileName, Symbol->getNumberOfAuxSymbols() *
606 coff->getSymbolTableEntrySize());
607 outs() << "AUX " << Name.rtrim(StringRef("\0", 1)) << '\n';
609 SI = SI + Symbol->getNumberOfAuxSymbols();
612 outs() << "AUX Unknown\n";
618 static void PrintSymbolTable(const ObjectFile *o) {
619 outs() << "SYMBOL TABLE:\n";
621 if (const COFFObjectFile *coff = dyn_cast<const COFFObjectFile>(o)) {
622 PrintCOFFSymbolTable(coff);
625 for (const SymbolRef &Symbol : o->symbols()) {
628 SymbolRef::Type Type;
630 uint32_t Flags = Symbol.getFlags();
631 section_iterator Section = o->section_end();
632 if (error(Symbol.getName(Name)))
634 if (error(Symbol.getAddress(Address)))
636 if (error(Symbol.getType(Type)))
638 if (error(Symbol.getSize(Size)))
640 if (error(Symbol.getSection(Section)))
643 bool Global = Flags & SymbolRef::SF_Global;
644 bool Weak = Flags & SymbolRef::SF_Weak;
645 bool Absolute = Flags & SymbolRef::SF_Absolute;
647 if (Address == UnknownAddressOrSize)
649 if (Size == UnknownAddressOrSize)
652 if (Type != SymbolRef::ST_Unknown)
653 GlobLoc = Global ? 'g' : 'l';
654 char Debug = (Type == SymbolRef::ST_Debug || Type == SymbolRef::ST_File)
657 if (Type == SymbolRef::ST_File)
659 else if (Type == SymbolRef::ST_Function)
662 const char *Fmt = o->getBytesInAddress() > 4 ? "%016" PRIx64 :
665 outs() << format(Fmt, Address) << " "
666 << GlobLoc // Local -> 'l', Global -> 'g', Neither -> ' '
667 << (Weak ? 'w' : ' ') // Weak?
668 << ' ' // Constructor. Not supported yet.
669 << ' ' // Warning. Not supported yet.
670 << ' ' // Indirect reference to another symbol.
671 << Debug // Debugging (d) or dynamic (D) symbol.
672 << FileFunc // Name of function (F), file (f) or object (O).
676 } else if (Section == o->section_end()) {
679 if (const MachOObjectFile *MachO =
680 dyn_cast<const MachOObjectFile>(o)) {
681 DataRefImpl DR = Section->getRawDataRefImpl();
682 StringRef SegmentName = MachO->getSectionFinalSegmentName(DR);
683 outs() << SegmentName << ",";
685 StringRef SectionName;
686 if (error(Section->getName(SectionName)))
688 outs() << SectionName;
691 << format("%08" PRIx64 " ", Size)
697 static void PrintUnwindInfo(const ObjectFile *o) {
698 outs() << "Unwind info:\n\n";
700 if (const COFFObjectFile *coff = dyn_cast<COFFObjectFile>(o)) {
701 printCOFFUnwindInfo(coff);
702 } else if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
703 printMachOUnwindInfo(MachO);
705 // TODO: Extract DWARF dump tool to objdump.
706 errs() << "This operation is only currently supported "
707 "for COFF and MachO object files.\n";
712 static void printExportsTrie(const ObjectFile *o) {
713 outs() << "Exports trie:\n";
714 if (const MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o))
715 printMachOExportsTrie(MachO);
717 errs() << "This operation is only currently supported "
718 "for Mach-O executable files.\n";
723 static void printPrivateFileHeader(const ObjectFile *o) {
725 printELFFileHeader(o);
726 } else if (o->isCOFF()) {
727 printCOFFFileHeader(o);
728 } else if (o->isMachO()) {
729 printMachOFileHeader(o);
733 static void DumpObject(const ObjectFile *o) {
735 outs() << o->getFileName()
736 << ":\tfile format " << o->getFileFormatName() << "\n\n";
739 DisassembleObject(o, Relocations);
740 if (Relocations && !Disassemble)
743 PrintSectionHeaders(o);
745 PrintSectionContents(o);
751 printPrivateFileHeader(o);
756 /// @brief Dump each object file in \a a;
757 static void DumpArchive(const Archive *a) {
758 for (Archive::child_iterator i = a->child_begin(), e = a->child_end(); i != e;
760 ErrorOr<std::unique_ptr<Binary>> ChildOrErr = i->getAsBinary();
761 if (std::error_code EC = ChildOrErr.getError()) {
762 // Ignore non-object files.
763 if (EC != object_error::invalid_file_type)
764 errs() << ToolName << ": '" << a->getFileName() << "': " << EC.message()
768 if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get()))
771 errs() << ToolName << ": '" << a->getFileName() << "': "
772 << "Unrecognized file type.\n";
776 /// @brief Open file and figure out how to dump it.
777 static void DumpInput(StringRef file) {
778 // If file isn't stdin, check that it exists.
779 if (file != "-" && !sys::fs::exists(file)) {
780 errs() << ToolName << ": '" << file << "': " << "No such file\n";
784 if (MachOOpt && Disassemble) {
785 DisassembleInputMachO(file);
789 // Attempt to open the binary.
790 ErrorOr<OwningBinary<Binary>> BinaryOrErr = createBinary(file);
791 if (std::error_code EC = BinaryOrErr.getError()) {
792 errs() << ToolName << ": '" << file << "': " << EC.message() << ".\n";
795 Binary &Binary = *BinaryOrErr.get().getBinary();
797 if (Archive *a = dyn_cast<Archive>(&Binary))
799 else if (ObjectFile *o = dyn_cast<ObjectFile>(&Binary))
802 errs() << ToolName << ": '" << file << "': " << "Unrecognized file type.\n";
805 int main(int argc, char **argv) {
806 // Print a stack trace if we signal out.
807 sys::PrintStackTraceOnErrorSignal();
808 PrettyStackTraceProgram X(argc, argv);
809 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
811 // Initialize targets and assembly printers/parsers.
812 llvm::InitializeAllTargetInfos();
813 llvm::InitializeAllTargetMCs();
814 llvm::InitializeAllAsmParsers();
815 llvm::InitializeAllDisassemblers();
817 // Register the target printer for --version.
818 cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
820 cl::ParseCommandLineOptions(argc, argv, "llvm object file dumper\n");
821 TripleName = Triple::normalize(TripleName);
825 // Defaults to a.out if no filenames specified.
826 if (InputFilenames.size() == 0)
827 InputFilenames.push_back("a.out");
837 cl::PrintHelpMessage();
841 std::for_each(InputFilenames.begin(), InputFilenames.end(),