• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- ObjDumper.h ---------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_TOOLS_LLVM_READOBJ_OBJDUMPER_H
11 #define LLVM_TOOLS_LLVM_READOBJ_OBJDUMPER_H
12 
13 #include <memory>
14 #include <system_error>
15 
16 namespace llvm {
17 namespace object {
18 class COFFImportFile;
19 class ObjectFile;
20 }
21 namespace codeview {
22 class MemoryTypeTableBuilder;
23 }
24 
25 class ScopedPrinter;
26 
27 class ObjDumper {
28 public:
29   ObjDumper(ScopedPrinter &Writer);
30   virtual ~ObjDumper();
31 
32   virtual void printFileHeaders() = 0;
33   virtual void printSections() = 0;
34   virtual void printRelocations() = 0;
35   virtual void printSymbols() = 0;
36   virtual void printDynamicSymbols() = 0;
37   virtual void printUnwindInfo() = 0;
38 
39   // Only implemented for ELF at this time.
printDynamicRelocations()40   virtual void printDynamicRelocations() { }
printDynamicTable()41   virtual void printDynamicTable() { }
printNeededLibraries()42   virtual void printNeededLibraries() { }
printProgramHeaders()43   virtual void printProgramHeaders() { }
printHashTable()44   virtual void printHashTable() { }
printGnuHashTable()45   virtual void printGnuHashTable() { }
printLoadName()46   virtual void printLoadName() {}
printVersionInfo()47   virtual void printVersionInfo() {}
printGroupSections()48   virtual void printGroupSections() {}
printHashHistogram()49   virtual void printHashHistogram() {}
50 
51   // Only implemented for ARM ELF at this time.
printAttributes()52   virtual void printAttributes() { }
53 
54   // Only implemented for MIPS ELF at this time.
printMipsPLTGOT()55   virtual void printMipsPLTGOT() { }
printMipsABIFlags()56   virtual void printMipsABIFlags() { }
printMipsReginfo()57   virtual void printMipsReginfo() { }
printMipsOptions()58   virtual void printMipsOptions() { }
59 
60   // Only implemented for PE/COFF.
printCOFFImports()61   virtual void printCOFFImports() { }
printCOFFExports()62   virtual void printCOFFExports() { }
printCOFFDirectives()63   virtual void printCOFFDirectives() { }
printCOFFBaseReloc()64   virtual void printCOFFBaseReloc() { }
printCOFFDebugDirectory()65   virtual void printCOFFDebugDirectory() { }
printCodeViewDebugInfo()66   virtual void printCodeViewDebugInfo() { }
67   virtual void
mergeCodeViewTypes(llvm::codeview::MemoryTypeTableBuilder & CVTypes)68   mergeCodeViewTypes(llvm::codeview::MemoryTypeTableBuilder &CVTypes) {}
69 
70   // Only implemented for MachO.
printMachODataInCode()71   virtual void printMachODataInCode() { }
printMachOVersionMin()72   virtual void printMachOVersionMin() { }
printMachODysymtab()73   virtual void printMachODysymtab() { }
printMachOSegment()74   virtual void printMachOSegment() { }
printMachOIndirectSymbols()75   virtual void printMachOIndirectSymbols() { }
printMachOLinkerOptions()76   virtual void printMachOLinkerOptions() { }
77 
78   virtual void printStackMap() const = 0;
79 
80 protected:
81   ScopedPrinter &W;
82 };
83 
84 std::error_code createCOFFDumper(const object::ObjectFile *Obj,
85                                  ScopedPrinter &Writer,
86                                  std::unique_ptr<ObjDumper> &Result);
87 
88 std::error_code createELFDumper(const object::ObjectFile *Obj,
89                                 ScopedPrinter &Writer,
90                                 std::unique_ptr<ObjDumper> &Result);
91 
92 std::error_code createMachODumper(const object::ObjectFile *Obj,
93                                   ScopedPrinter &Writer,
94                                   std::unique_ptr<ObjDumper> &Result);
95 
96 void dumpCOFFImportFile(const object::COFFImportFile *File);
97 
98 void dumpCodeViewMergedTypes(ScopedPrinter &Writer,
99                              llvm::codeview::MemoryTypeTableBuilder &CVTypes);
100 
101 } // namespace llvm
102 
103 #endif
104