Home | History | Annotate | Download | only in llvm-readobj
      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.
     40   virtual void printDynamicRelocations() { }
     41   virtual void printDynamicTable() { }
     42   virtual void printNeededLibraries() { }
     43   virtual void printProgramHeaders() { }
     44   virtual void printHashTable() { }
     45   virtual void printGnuHashTable() { }
     46   virtual void printLoadName() {}
     47   virtual void printVersionInfo() {}
     48   virtual void printGroupSections() {}
     49   virtual void printHashHistogram() {}
     50 
     51   // Only implemented for ARM ELF at this time.
     52   virtual void printAttributes() { }
     53 
     54   // Only implemented for MIPS ELF at this time.
     55   virtual void printMipsPLTGOT() { }
     56   virtual void printMipsABIFlags() { }
     57   virtual void printMipsReginfo() { }
     58   virtual void printMipsOptions() { }
     59 
     60   // Only implemented for PE/COFF.
     61   virtual void printCOFFImports() { }
     62   virtual void printCOFFExports() { }
     63   virtual void printCOFFDirectives() { }
     64   virtual void printCOFFBaseReloc() { }
     65   virtual void printCOFFDebugDirectory() { }
     66   virtual void printCodeViewDebugInfo() { }
     67   virtual void
     68   mergeCodeViewTypes(llvm::codeview::MemoryTypeTableBuilder &CVTypes) {}
     69 
     70   // Only implemented for MachO.
     71   virtual void printMachODataInCode() { }
     72   virtual void printMachOVersionMin() { }
     73   virtual void printMachODysymtab() { }
     74   virtual void printMachOSegment() { }
     75   virtual void printMachOIndirectSymbols() { }
     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