blob: b898224a44d080583871b1a5c968c6c487892ecb [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.
36 virtual void printDynamicTable() { }
37 virtual void printNeededLibraries() { }
Nico Rieckd6df0542013-04-12 04:07:39 +000038 virtual void printProgramHeaders() { }
Eric Christopher9cad53c2013-04-03 18:31:38 +000039
Saleem Abdulrasool15d16d82014-01-30 04:46:33 +000040 // Only implemented for ARM ELF at this time.
41 virtual void printAttributes() { }
42
Simon Atanasyan80433902014-06-18 08:47:09 +000043 // Only implemented for MIPS ELF at this time.
44 virtual void printMipsPLTGOT() { }
45
Rui Ueyama1e152d52014-10-02 17:02:18 +000046 // Only implemented for PE/COFF.
47 virtual void printCOFFImports() { }
Saleem Abdulrasoolf9578632014-10-07 19:37:52 +000048 virtual void printCOFFDirectives() { }
Rui Ueyama1e152d52014-10-02 17:02:18 +000049
Eric Christopher9cad53c2013-04-03 18:31:38 +000050protected:
51 StreamWriter& W;
52};
53
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000054std::error_code createCOFFDumper(const object::ObjectFile *Obj,
55 StreamWriter &Writer,
56 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000057
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000058std::error_code createELFDumper(const object::ObjectFile *Obj,
59 StreamWriter &Writer,
60 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000061
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000062std::error_code createMachODumper(const object::ObjectFile *Obj,
63 StreamWriter &Writer,
64 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000065
66} // namespace llvm
67
68#endif