blob: cfca850150f7ceced85c62c5109251406c7483df [file] [log] [blame]
Eric Christopher9cad53c2013-04-03 18:31:38 +00001//===-- 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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_TOOLS_LLVM_READOBJ_OBJDUMPER_H
11#define LLVM_TOOLS_LLVM_READOBJ_OBJDUMPER_H
Eric Christopher9cad53c2013-04-03 18:31:38 +000012
Ahmed Charles56440fd2014-03-06 05:51:42 +000013#include <memory>
Rafael Espindolaa6e9c3e2014-06-12 17:38:55 +000014#include <system_error>
Ahmed Charles56440fd2014-03-06 05:51:42 +000015
Eric Christopher9cad53c2013-04-03 18:31:38 +000016namespace llvm {
Eric Christopher9cad53c2013-04-03 18:31:38 +000017namespace object {
18 class ObjectFile;
19}
20
Eric Christopher9cad53c2013-04-03 18:31:38 +000021class StreamWriter;
22
23class ObjDumper {
24public:
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.
Michael J. Spencer594c0282015-06-25 21:47:32 +000036 virtual void printDynamicRelocations() { }
Eric Christopher9cad53c2013-04-03 18:31:38 +000037 virtual void printDynamicTable() { }
38 virtual void printNeededLibraries() { }
Nico Rieckd6df0542013-04-12 04:07:39 +000039 virtual void printProgramHeaders() { }
Eric Christopher9cad53c2013-04-03 18:31:38 +000040
Saleem Abdulrasool15d16d82014-01-30 04:46:33 +000041 // Only implemented for ARM ELF at this time.
42 virtual void printAttributes() { }
43
Simon Atanasyan80433902014-06-18 08:47:09 +000044 // Only implemented for MIPS ELF at this time.
45 virtual void printMipsPLTGOT() { }
Simon Atanasyanc914de22015-05-07 15:40:35 +000046 virtual void printMipsABIFlags() { }
Simon Atanasyan6e07e932015-06-16 21:47:43 +000047 virtual void printMipsReginfo() { }
Simon Atanasyan80433902014-06-18 08:47:09 +000048
Rui Ueyama1e152d52014-10-02 17:02:18 +000049 // Only implemented for PE/COFF.
50 virtual void printCOFFImports() { }
Saleem Abdulrasoolddd92642015-01-03 21:35:09 +000051 virtual void printCOFFExports() { }
Saleem Abdulrasoolf9578632014-10-07 19:37:52 +000052 virtual void printCOFFDirectives() { }
Rui Ueyama74e85132014-11-19 00:18:07 +000053 virtual void printCOFFBaseReloc() { }
Rui Ueyama1e152d52014-10-02 17:02:18 +000054
Eric Christopher9cad53c2013-04-03 18:31:38 +000055protected:
56 StreamWriter& W;
57};
58
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000059std::error_code createCOFFDumper(const object::ObjectFile *Obj,
60 StreamWriter &Writer,
61 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000062
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000063std::error_code createELFDumper(const object::ObjectFile *Obj,
64 StreamWriter &Writer,
65 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000066
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000067std::error_code createMachODumper(const object::ObjectFile *Obj,
68 StreamWriter &Writer,
69 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000070
71} // namespace llvm
72
73#endif