blob: 318a171d49d1b1fc59e0fc2aee07c73979cf2655 [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
Zachary Turner88bb1632016-05-03 00:28:04 +000022class ScopedPrinter;
Eric Christopher9cad53c2013-04-03 18:31:38 +000023
24class ObjDumper {
25public:
Zachary Turner88bb1632016-05-03 00:28:04 +000026 ObjDumper(ScopedPrinter &Writer);
Eric Christopher9cad53c2013-04-03 18:31:38 +000027 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() { }
Igor Kudrin496fb2f2015-10-14 12:11:50 +000042 virtual void printGnuHashTable() { }
Rafael Espindola33e746f22015-07-21 13:48:41 +000043 virtual void printLoadName() {}
Davide Italiano4f05f322015-10-16 23:19:01 +000044 virtual void printVersionInfo() {}
Hemant Kulkarniab4a46f2016-01-26 19:46:39 +000045 virtual void printGroupSections() {}
Hemant Kulkarni9b1b7f02016-04-11 17:15:30 +000046 virtual void printHashHistogram() {}
Eric Christopher9cad53c2013-04-03 18:31:38 +000047
Saleem Abdulrasool15d16d82014-01-30 04:46:33 +000048 // Only implemented for ARM ELF at this time.
49 virtual void printAttributes() { }
50
Simon Atanasyan80433902014-06-18 08:47:09 +000051 // Only implemented for MIPS ELF at this time.
52 virtual void printMipsPLTGOT() { }
Simon Atanasyanc914de22015-05-07 15:40:35 +000053 virtual void printMipsABIFlags() { }
Simon Atanasyan6e07e932015-06-16 21:47:43 +000054 virtual void printMipsReginfo() { }
Simon Atanasyan8a71b532016-05-04 05:58:57 +000055 virtual void printMipsOptions() { }
Simon Atanasyan80433902014-06-18 08:47:09 +000056
Rui Ueyama1e152d52014-10-02 17:02:18 +000057 // Only implemented for PE/COFF.
58 virtual void printCOFFImports() { }
Saleem Abdulrasoolddd92642015-01-03 21:35:09 +000059 virtual void printCOFFExports() { }
Saleem Abdulrasoolf9578632014-10-07 19:37:52 +000060 virtual void printCOFFDirectives() { }
Rui Ueyama74e85132014-11-19 00:18:07 +000061 virtual void printCOFFBaseReloc() { }
Reid Kleckner83ebad32015-12-16 18:28:12 +000062 virtual void printCodeViewDebugInfo() { }
Rui Ueyama1e152d52014-10-02 17:02:18 +000063
Davide Italiano07e7acb2015-08-21 20:28:30 +000064 // Only implemented for MachO.
65 virtual void printMachODataInCode() { }
Davide Italiano976f4da2015-08-27 15:11:32 +000066 virtual void printMachOVersionMin() { }
Davide Italiano35eebe12015-08-31 19:32:31 +000067 virtual void printMachODysymtab() { }
Davide Italianod1f09962015-09-02 16:24:24 +000068 virtual void printMachOSegment() { }
Davide Italiano4410b222015-09-03 18:10:28 +000069 virtual void printMachOIndirectSymbols() { }
Davide Italiano9a429b72015-09-09 00:21:18 +000070 virtual void printMachOLinkerOptions() { }
Davide Italiano07e7acb2015-08-21 20:28:30 +000071
Lang Hames0000afd2015-06-26 23:56:53 +000072 virtual void printStackMap() const = 0;
73
Eric Christopher9cad53c2013-04-03 18:31:38 +000074protected:
Zachary Turner88bb1632016-05-03 00:28:04 +000075 ScopedPrinter &W;
Eric Christopher9cad53c2013-04-03 18:31:38 +000076};
77
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000078std::error_code createCOFFDumper(const object::ObjectFile *Obj,
Zachary Turner88bb1632016-05-03 00:28:04 +000079 ScopedPrinter &Writer,
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000080 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000081
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000082std::error_code createELFDumper(const object::ObjectFile *Obj,
Zachary Turner88bb1632016-05-03 00:28:04 +000083 ScopedPrinter &Writer,
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000084 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000085
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000086std::error_code createMachODumper(const object::ObjectFile *Obj,
Zachary Turner88bb1632016-05-03 00:28:04 +000087 ScopedPrinter &Writer,
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000088 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000089
Rui Ueyama93210892015-08-28 10:27:50 +000090void dumpCOFFImportFile(const object::COFFImportFile *File);
91
Eric Christopher9cad53c2013-04-03 18:31:38 +000092} // namespace llvm
93
94#endif