blob: 03a71b82ba68f945a94ad4dfb8efbfcfb97b48a2 [file] [log] [blame]
Rafael Espindolafbb86b22015-07-21 13:42:38 +00001//===-- ObjDumper.h ---------------------------------------------*- C++ -*-===//
Eric Christopher9cad53c2013-04-03 18:31:38 +00002//
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 {
Rui Ueyama93210892015-08-28 10:27:50 +000018class COFFImportFile;
19class ObjectFile;
Eric Christopher9cad53c2013-04-03 18:31:38 +000020}
21
Eric Christopher9cad53c2013-04-03 18:31:38 +000022class StreamWriter;
23
24class ObjDumper {
25public:
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.
Michael J. Spencer594c0282015-06-25 21:47:32 +000037 virtual void printDynamicRelocations() { }
Eric Christopher9cad53c2013-04-03 18:31:38 +000038 virtual void printDynamicTable() { }
39 virtual void printNeededLibraries() { }
Nico Rieckd6df0542013-04-12 04:07:39 +000040 virtual void printProgramHeaders() { }
Michael J. Spencer20546ff2015-07-09 22:32:24 +000041 virtual void printHashTable() { }
Rafael Espindola33e746f22015-07-21 13:48:41 +000042 virtual void printLoadName() {}
Eric Christopher9cad53c2013-04-03 18:31:38 +000043
Saleem Abdulrasool15d16d82014-01-30 04:46:33 +000044 // Only implemented for ARM ELF at this time.
45 virtual void printAttributes() { }
46
Simon Atanasyan80433902014-06-18 08:47:09 +000047 // Only implemented for MIPS ELF at this time.
48 virtual void printMipsPLTGOT() { }
Simon Atanasyanc914de22015-05-07 15:40:35 +000049 virtual void printMipsABIFlags() { }
Simon Atanasyan6e07e932015-06-16 21:47:43 +000050 virtual void printMipsReginfo() { }
Simon Atanasyan80433902014-06-18 08:47:09 +000051
Rui Ueyama1e152d52014-10-02 17:02:18 +000052 // Only implemented for PE/COFF.
53 virtual void printCOFFImports() { }
Saleem Abdulrasoolddd92642015-01-03 21:35:09 +000054 virtual void printCOFFExports() { }
Saleem Abdulrasoolf9578632014-10-07 19:37:52 +000055 virtual void printCOFFDirectives() { }
Rui Ueyama74e85132014-11-19 00:18:07 +000056 virtual void printCOFFBaseReloc() { }
Rui Ueyama1e152d52014-10-02 17:02:18 +000057
Davide Italiano07e7acb2015-08-21 20:28:30 +000058 // Only implemented for MachO.
59 virtual void printMachODataInCode() { }
Davide Italiano976f4da2015-08-27 15:11:32 +000060 virtual void printMachOVersionMin() { }
Davide Italiano07e7acb2015-08-21 20:28:30 +000061
Lang Hames0000afd2015-06-26 23:56:53 +000062 virtual void printStackMap() const = 0;
63
Eric Christopher9cad53c2013-04-03 18:31:38 +000064protected:
65 StreamWriter& W;
66};
67
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000068std::error_code createCOFFDumper(const object::ObjectFile *Obj,
69 StreamWriter &Writer,
70 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000071
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000072std::error_code createELFDumper(const object::ObjectFile *Obj,
73 StreamWriter &Writer,
74 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000075
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000076std::error_code createMachODumper(const object::ObjectFile *Obj,
77 StreamWriter &Writer,
78 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000079
Rui Ueyama93210892015-08-28 10:27:50 +000080void dumpCOFFImportFile(const object::COFFImportFile *File);
81
Eric Christopher9cad53c2013-04-03 18:31:38 +000082} // namespace llvm
83
84#endif