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 
22 class StreamWriter;
23 
24 class ObjDumper {
25 public:
26   ObjDumper(StreamWriter& Writer);
27   virtual ~ObjDumper();
28 
29   virtual void printFileHeaders() = 0;
30   virtual void printSections() = 0;
31   virtual void printRelocations() = 0;
32   virtual void printSymbols() = 0;
33   virtual void printDynamicSymbols() = 0;
34   virtual void printUnwindInfo() = 0;
35 
36   // Only implemented for ELF at this time.
printDynamicRelocations()37   virtual void printDynamicRelocations() { }
printDynamicTable()38   virtual void printDynamicTable() { }
printNeededLibraries()39   virtual void printNeededLibraries() { }
printProgramHeaders()40   virtual void printProgramHeaders() { }
printHashTable()41   virtual void printHashTable() { }
printGnuHashTable()42   virtual void printGnuHashTable() { }
printLoadName()43   virtual void printLoadName() {}
printVersionInfo()44   virtual void printVersionInfo() {}
45 
46   // Only implemented for ARM ELF at this time.
printAttributes()47   virtual void printAttributes() { }
48 
49   // Only implemented for MIPS ELF at this time.
printMipsPLTGOT()50   virtual void printMipsPLTGOT() { }
printMipsABIFlags()51   virtual void printMipsABIFlags() { }
printMipsReginfo()52   virtual void printMipsReginfo() { }
53 
54   // Only implemented for PE/COFF.
printCOFFImports()55   virtual void printCOFFImports() { }
printCOFFExports()56   virtual void printCOFFExports() { }
printCOFFDirectives()57   virtual void printCOFFDirectives() { }
printCOFFBaseReloc()58   virtual void printCOFFBaseReloc() { }
printCodeViewDebugInfo()59   virtual void printCodeViewDebugInfo() { }
60 
61   // Only implemented for MachO.
printMachODataInCode()62   virtual void printMachODataInCode() { }
printMachOVersionMin()63   virtual void printMachOVersionMin() { }
printMachODysymtab()64   virtual void printMachODysymtab() { }
printMachOSegment()65   virtual void printMachOSegment() { }
printMachOIndirectSymbols()66   virtual void printMachOIndirectSymbols() { }
printMachOLinkerOptions()67   virtual void printMachOLinkerOptions() { }
68 
69   virtual void printStackMap() const = 0;
70 
71 protected:
72   StreamWriter& W;
73 };
74 
75 std::error_code createCOFFDumper(const object::ObjectFile *Obj,
76                                  StreamWriter &Writer,
77                                  std::unique_ptr<ObjDumper> &Result);
78 
79 std::error_code createELFDumper(const object::ObjectFile *Obj,
80                                 StreamWriter &Writer,
81                                 std::unique_ptr<ObjDumper> &Result);
82 
83 std::error_code createMachODumper(const object::ObjectFile *Obj,
84                                   StreamWriter &Writer,
85                                   std::unique_ptr<ObjDumper> &Result);
86 
87 void dumpCOFFImportFile(const object::COFFImportFile *File);
88 
89 } // namespace llvm
90 
91 #endif
92