1 //===-- ObjDumper.h -------------------------------------------------------===// 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 ObjectFile; 19 } 20 21 class StreamWriter; 22 23 class ObjDumper { 24 public: 25 ObjDumper(StreamWriter& Writer); 26 virtual ~ObjDumper(); 27 28 virtual void printFileHeaders() = 0; 29 virtual void printSections() = 0; 30 virtual void printRelocations() = 0; 31 virtual void printSymbols() = 0; 32 virtual void printDynamicSymbols() = 0; 33 virtual void printUnwindInfo() = 0; 34 35 // Only implemented for ELF at this time. printDynamicRelocations()36 virtual void printDynamicRelocations() { } printDynamicTable()37 virtual void printDynamicTable() { } printNeededLibraries()38 virtual void printNeededLibraries() { } printProgramHeaders()39 virtual void printProgramHeaders() { } printHashTable()40 virtual void printHashTable() { } 41 42 // Only implemented for ARM ELF at this time. printAttributes()43 virtual void printAttributes() { } 44 45 // Only implemented for MIPS ELF at this time. printMipsPLTGOT()46 virtual void printMipsPLTGOT() { } printMipsABIFlags()47 virtual void printMipsABIFlags() { } printMipsReginfo()48 virtual void printMipsReginfo() { } 49 50 // Only implemented for PE/COFF. printCOFFImports()51 virtual void printCOFFImports() { } printCOFFExports()52 virtual void printCOFFExports() { } printCOFFDirectives()53 virtual void printCOFFDirectives() { } printCOFFBaseReloc()54 virtual void printCOFFBaseReloc() { } 55 56 virtual void printStackMap() const = 0; 57 58 protected: 59 StreamWriter& W; 60 }; 61 62 std::error_code createCOFFDumper(const object::ObjectFile *Obj, 63 StreamWriter &Writer, 64 std::unique_ptr<ObjDumper> &Result); 65 66 std::error_code createELFDumper(const object::ObjectFile *Obj, 67 StreamWriter &Writer, 68 std::unique_ptr<ObjDumper> &Result); 69 70 std::error_code createMachODumper(const object::ObjectFile *Obj, 71 StreamWriter &Writer, 72 std::unique_ptr<ObjDumper> &Result); 73 74 } // namespace llvm 75 76 #endif 77