blob: 2bf4dfe5a40beb42703d1c182c15da988006694b [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}
Reid Kleckner0b269742016-05-14 00:02:53 +000021namespace codeview {
Zachary Turnerca6dbf12017-11-30 18:39:50 +000022class MergingTypeTableBuilder;
Michael Kupersteina5560502016-05-16 23:09:32 +000023}
Eric Christopher9cad53c2013-04-03 18:31:38 +000024
Zachary Turner88bb1632016-05-03 00:28:04 +000025class ScopedPrinter;
Eric Christopher9cad53c2013-04-03 18:31:38 +000026
27class ObjDumper {
28public:
Zachary Turner88bb1632016-05-03 00:28:04 +000029 ObjDumper(ScopedPrinter &Writer);
Eric Christopher9cad53c2013-04-03 18:31:38 +000030 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.
Michael J. Spencer594c0282015-06-25 21:47:32 +000040 virtual void printDynamicRelocations() { }
Eric Christopher9cad53c2013-04-03 18:31:38 +000041 virtual void printDynamicTable() { }
42 virtual void printNeededLibraries() { }
Nico Rieckd6df0542013-04-12 04:07:39 +000043 virtual void printProgramHeaders() { }
Michael J. Spencer20546ff2015-07-09 22:32:24 +000044 virtual void printHashTable() { }
Igor Kudrin496fb2f2015-10-14 12:11:50 +000045 virtual void printGnuHashTable() { }
Rafael Espindola33e746f22015-07-21 13:48:41 +000046 virtual void printLoadName() {}
Davide Italiano4f05f322015-10-16 23:19:01 +000047 virtual void printVersionInfo() {}
Hemant Kulkarniab4a46f2016-01-26 19:46:39 +000048 virtual void printGroupSections() {}
Hemant Kulkarni9b1b7f02016-04-11 17:15:30 +000049 virtual void printHashHistogram() {}
Saleem Abdulrasool6a405442016-08-30 18:52:02 +000050 virtual void printNotes() {}
Saleem Abdulrasoolb36fbbc2018-01-30 16:29:29 +000051 virtual void printELFLinkerOptions() {}
Eric Christopher9cad53c2013-04-03 18:31:38 +000052
Saleem Abdulrasool15d16d82014-01-30 04:46:33 +000053 // Only implemented for ARM ELF at this time.
54 virtual void printAttributes() { }
55
Simon Atanasyan80433902014-06-18 08:47:09 +000056 // Only implemented for MIPS ELF at this time.
57 virtual void printMipsPLTGOT() { }
Simon Atanasyanc914de22015-05-07 15:40:35 +000058 virtual void printMipsABIFlags() { }
Simon Atanasyan6e07e932015-06-16 21:47:43 +000059 virtual void printMipsReginfo() { }
Simon Atanasyan8a71b532016-05-04 05:58:57 +000060 virtual void printMipsOptions() { }
Simon Atanasyan80433902014-06-18 08:47:09 +000061
Rui Ueyama1e152d52014-10-02 17:02:18 +000062 // Only implemented for PE/COFF.
63 virtual void printCOFFImports() { }
Saleem Abdulrasoolddd92642015-01-03 21:35:09 +000064 virtual void printCOFFExports() { }
Saleem Abdulrasoolf9578632014-10-07 19:37:52 +000065 virtual void printCOFFDirectives() { }
Rui Ueyama74e85132014-11-19 00:18:07 +000066 virtual void printCOFFBaseReloc() { }
Reid Kleckner2da433e2016-06-02 17:10:43 +000067 virtual void printCOFFDebugDirectory() { }
Zachary Turner8d6396d2017-04-27 19:38:38 +000068 virtual void printCOFFResources() {}
Reid Klecknerb7d716c2017-06-22 01:10:29 +000069 virtual void printCOFFLoadConfig() { }
Reid Kleckner83ebad32015-12-16 18:28:12 +000070 virtual void printCodeViewDebugInfo() { }
Zachary Turnerca6dbf12017-11-30 18:39:50 +000071 virtual void
72 mergeCodeViewTypes(llvm::codeview::MergingTypeTableBuilder &CVIDs,
73 llvm::codeview::MergingTypeTableBuilder &CVTypes) {}
Rui Ueyama1e152d52014-10-02 17:02:18 +000074
Davide Italiano07e7acb2015-08-21 20:28:30 +000075 // Only implemented for MachO.
76 virtual void printMachODataInCode() { }
Davide Italiano976f4da2015-08-27 15:11:32 +000077 virtual void printMachOVersionMin() { }
Davide Italiano35eebe12015-08-31 19:32:31 +000078 virtual void printMachODysymtab() { }
Davide Italianod1f09962015-09-02 16:24:24 +000079 virtual void printMachOSegment() { }
Davide Italiano4410b222015-09-03 18:10:28 +000080 virtual void printMachOIndirectSymbols() { }
Davide Italiano9a429b72015-09-09 00:21:18 +000081 virtual void printMachOLinkerOptions() { }
Davide Italiano07e7acb2015-08-21 20:28:30 +000082
Lang Hames0000afd2015-06-26 23:56:53 +000083 virtual void printStackMap() const = 0;
84
Eric Christopher9cad53c2013-04-03 18:31:38 +000085protected:
Zachary Turner88bb1632016-05-03 00:28:04 +000086 ScopedPrinter &W;
Eric Christopher9cad53c2013-04-03 18:31:38 +000087};
88
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000089std::error_code createCOFFDumper(const object::ObjectFile *Obj,
Zachary Turner88bb1632016-05-03 00:28:04 +000090 ScopedPrinter &Writer,
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000091 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000092
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000093std::error_code createELFDumper(const object::ObjectFile *Obj,
Zachary Turner88bb1632016-05-03 00:28:04 +000094 ScopedPrinter &Writer,
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000095 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +000096
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000097std::error_code createMachODumper(const object::ObjectFile *Obj,
Zachary Turner88bb1632016-05-03 00:28:04 +000098 ScopedPrinter &Writer,
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000099 std::unique_ptr<ObjDumper> &Result);
Eric Christopher9cad53c2013-04-03 18:31:38 +0000100
Derek Schuff6d76b7b2017-01-30 23:30:52 +0000101std::error_code createWasmDumper(const object::ObjectFile *Obj,
102 ScopedPrinter &Writer,
103 std::unique_ptr<ObjDumper> &Result);
104
Sam Clegg88e9a152018-01-10 00:14:19 +0000105void dumpCOFFImportFile(const object::COFFImportFile *File,
106 ScopedPrinter &Writer);
Rui Ueyama93210892015-08-28 10:27:50 +0000107
Zachary Turnerca6dbf12017-11-30 18:39:50 +0000108void dumpCodeViewMergedTypes(
109 ScopedPrinter &Writer, llvm::codeview::MergingTypeTableBuilder &IDTable,
110 llvm::codeview::MergingTypeTableBuilder &TypeTable);
Reid Kleckner0b269742016-05-14 00:02:53 +0000111
Eric Christopher9cad53c2013-04-03 18:31:38 +0000112} // namespace llvm
113
114#endif