Rafael Espindola | ed3c543 | 2015-07-21 13:42:38 +0000 | [diff] [blame] | 1 | //===-- ObjDumper.h ---------------------------------------------*- C++ -*-===// |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 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 Kramer | 00e08fc | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_TOOLS_LLVM_READOBJ_OBJDUMPER_H |
| 11 | #define LLVM_TOOLS_LLVM_READOBJ_OBJDUMPER_H |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 12 | |
Ahmed Charles | f4ccd11 | 2014-03-06 05:51:42 +0000 | [diff] [blame] | 13 | #include <memory> |
Rafael Espindola | d5132f9 | 2014-06-12 17:38:55 +0000 | [diff] [blame] | 14 | #include <system_error> |
Ahmed Charles | f4ccd11 | 2014-03-06 05:51:42 +0000 | [diff] [blame] | 15 | |
Paul Semel | 064db43 | 2018-06-15 14:15:02 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/StringRef.h" |
Paul Semel | 9f006d3 | 2018-07-18 18:00:41 +0000 | [diff] [blame] | 17 | #include "llvm/Object/ObjectFile.h" |
Paul Semel | 064db43 | 2018-06-15 14:15:02 +0000 | [diff] [blame] | 18 | |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 19 | namespace llvm { |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 20 | namespace object { |
Rui Ueyama | c2aa179 | 2015-08-28 10:27:50 +0000 | [diff] [blame] | 21 | class COFFImportFile; |
| 22 | class ObjectFile; |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 23 | } |
Reid Kleckner | fed38e2 | 2016-05-14 00:02:53 +0000 | [diff] [blame] | 24 | namespace codeview { |
Zachary Turner | 47856b2 | 2017-11-30 18:39:50 +0000 | [diff] [blame] | 25 | class MergingTypeTableBuilder; |
Michael Kuperstein | e7eda98 | 2016-05-16 23:09:32 +0000 | [diff] [blame] | 26 | } |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 27 | |
Zachary Turner | 2448e9f | 2016-05-03 00:28:04 +0000 | [diff] [blame] | 28 | class ScopedPrinter; |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 29 | |
| 30 | class ObjDumper { |
| 31 | public: |
Zachary Turner | 2448e9f | 2016-05-03 00:28:04 +0000 | [diff] [blame] | 32 | ObjDumper(ScopedPrinter &Writer); |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 33 | virtual ~ObjDumper(); |
| 34 | |
| 35 | virtual void printFileHeaders() = 0; |
Jordan Rupprecht | 6856bcc | 2018-11-12 18:02:38 +0000 | [diff] [blame] | 36 | virtual void printSectionHeaders() = 0; |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 37 | virtual void printRelocations() = 0; |
| 38 | virtual void printSymbols() = 0; |
| 39 | virtual void printDynamicSymbols() = 0; |
| 40 | virtual void printUnwindInfo() = 0; |
| 41 | |
| 42 | // Only implemented for ELF at this time. |
Michael J. Spencer | 4cbb2db | 2015-06-25 21:47:32 +0000 | [diff] [blame] | 43 | virtual void printDynamicRelocations() { } |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 44 | virtual void printDynamicTable() { } |
| 45 | virtual void printNeededLibraries() { } |
Nico Rieck | cf3b55a | 2013-04-12 04:07:39 +0000 | [diff] [blame] | 46 | virtual void printProgramHeaders() { } |
Paul Semel | 94b0940 | 2018-07-11 10:00:29 +0000 | [diff] [blame] | 47 | virtual void printSectionAsHex(StringRef SectionName) {} |
Michael J. Spencer | 8109763 | 2015-07-09 22:32:24 +0000 | [diff] [blame] | 48 | virtual void printHashTable() { } |
Igor Kudrin | 4598154 | 2015-10-14 12:11:50 +0000 | [diff] [blame] | 49 | virtual void printGnuHashTable() { } |
Rafael Espindola | 71e3525 | 2015-07-21 13:48:41 +0000 | [diff] [blame] | 50 | virtual void printLoadName() {} |
Davide Italiano | c813f4c | 2015-10-16 23:19:01 +0000 | [diff] [blame] | 51 | virtual void printVersionInfo() {} |
Hemant Kulkarni | 8822b47 | 2016-01-26 19:46:39 +0000 | [diff] [blame] | 52 | virtual void printGroupSections() {} |
Hemant Kulkarni | 14dddbf | 2016-04-11 17:15:30 +0000 | [diff] [blame] | 53 | virtual void printHashHistogram() {} |
Michael J. Spencer | 56500c7 | 2018-06-02 16:33:01 +0000 | [diff] [blame] | 54 | virtual void printCGProfile() {} |
Peter Collingbourne | a29ff2e | 2018-07-17 22:17:18 +0000 | [diff] [blame] | 55 | virtual void printAddrsig() {} |
Saleem Abdulrasool | b899d19 | 2016-08-30 18:52:02 +0000 | [diff] [blame] | 56 | virtual void printNotes() {} |
Saleem Abdulrasool | e7676fe | 2018-01-30 16:29:29 +0000 | [diff] [blame] | 57 | virtual void printELFLinkerOptions() {} |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 58 | |
Saleem Abdulrasool | 459c949 | 2014-01-30 04:46:33 +0000 | [diff] [blame] | 59 | // Only implemented for ARM ELF at this time. |
| 60 | virtual void printAttributes() { } |
| 61 | |
Simon Atanasyan | 42469f6 | 2014-06-18 08:47:09 +0000 | [diff] [blame] | 62 | // Only implemented for MIPS ELF at this time. |
| 63 | virtual void printMipsPLTGOT() { } |
Simon Atanasyan | ef7c256 | 2015-05-07 15:40:35 +0000 | [diff] [blame] | 64 | virtual void printMipsABIFlags() { } |
Simon Atanasyan | 3bcfd46 | 2015-06-16 21:47:43 +0000 | [diff] [blame] | 65 | virtual void printMipsReginfo() { } |
Simon Atanasyan | 125d646 | 2016-05-04 05:58:57 +0000 | [diff] [blame] | 66 | virtual void printMipsOptions() { } |
Simon Atanasyan | 42469f6 | 2014-06-18 08:47:09 +0000 | [diff] [blame] | 67 | |
Rui Ueyama | f3cd10b | 2014-10-02 17:02:18 +0000 | [diff] [blame] | 68 | // Only implemented for PE/COFF. |
| 69 | virtual void printCOFFImports() { } |
Saleem Abdulrasool | b19a485 | 2015-01-03 21:35:09 +0000 | [diff] [blame] | 70 | virtual void printCOFFExports() { } |
Saleem Abdulrasool | db02fa5 | 2014-10-07 19:37:52 +0000 | [diff] [blame] | 71 | virtual void printCOFFDirectives() { } |
Rui Ueyama | 6272b8c | 2014-11-19 00:18:07 +0000 | [diff] [blame] | 72 | virtual void printCOFFBaseReloc() { } |
Reid Kleckner | fb1a911 | 2016-06-02 17:10:43 +0000 | [diff] [blame] | 73 | virtual void printCOFFDebugDirectory() { } |
Zachary Turner | 224acd2 | 2017-04-27 19:38:38 +0000 | [diff] [blame] | 74 | virtual void printCOFFResources() {} |
Reid Kleckner | 367f21d | 2017-06-22 01:10:29 +0000 | [diff] [blame] | 75 | virtual void printCOFFLoadConfig() { } |
Reid Kleckner | c81f000 | 2015-12-16 18:28:12 +0000 | [diff] [blame] | 76 | virtual void printCodeViewDebugInfo() { } |
Zachary Turner | 47856b2 | 2017-11-30 18:39:50 +0000 | [diff] [blame] | 77 | virtual void |
| 78 | mergeCodeViewTypes(llvm::codeview::MergingTypeTableBuilder &CVIDs, |
| 79 | llvm::codeview::MergingTypeTableBuilder &CVTypes) {} |
Rui Ueyama | f3cd10b | 2014-10-02 17:02:18 +0000 | [diff] [blame] | 80 | |
Davide Italiano | 241f716 | 2015-08-21 20:28:30 +0000 | [diff] [blame] | 81 | // Only implemented for MachO. |
| 82 | virtual void printMachODataInCode() { } |
Davide Italiano | 7dbe74f | 2015-08-27 15:11:32 +0000 | [diff] [blame] | 83 | virtual void printMachOVersionMin() { } |
Davide Italiano | 19c43a6 | 2015-08-31 19:32:31 +0000 | [diff] [blame] | 84 | virtual void printMachODysymtab() { } |
Davide Italiano | 885eb98 | 2015-09-02 16:24:24 +0000 | [diff] [blame] | 85 | virtual void printMachOSegment() { } |
Davide Italiano | 7ab2009 | 2015-09-03 18:10:28 +0000 | [diff] [blame] | 86 | virtual void printMachOIndirectSymbols() { } |
Davide Italiano | 793616c | 2015-09-09 00:21:18 +0000 | [diff] [blame] | 87 | virtual void printMachOLinkerOptions() { } |
Davide Italiano | 241f716 | 2015-08-21 20:28:30 +0000 | [diff] [blame] | 88 | |
Lang Hames | 63f4054 | 2015-06-26 23:56:53 +0000 | [diff] [blame] | 89 | virtual void printStackMap() const = 0; |
| 90 | |
Paul Semel | 9f006d3 | 2018-07-18 18:00:41 +0000 | [diff] [blame] | 91 | void printSectionAsString(const object::ObjectFile *Obj, StringRef SecName); |
Paul Semel | cac968e | 2018-07-25 10:04:37 +0000 | [diff] [blame] | 92 | void printSectionAsHex(const object::ObjectFile *Obj, StringRef SecName); |
Paul Semel | 9f006d3 | 2018-07-18 18:00:41 +0000 | [diff] [blame] | 93 | |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 94 | protected: |
Zachary Turner | 2448e9f | 2016-05-03 00:28:04 +0000 | [diff] [blame] | 95 | ScopedPrinter &W; |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 96 | }; |
| 97 | |
Rafael Espindola | a20bcb9 | 2014-06-13 01:25:41 +0000 | [diff] [blame] | 98 | std::error_code createCOFFDumper(const object::ObjectFile *Obj, |
Zachary Turner | 2448e9f | 2016-05-03 00:28:04 +0000 | [diff] [blame] | 99 | ScopedPrinter &Writer, |
Rafael Espindola | a20bcb9 | 2014-06-13 01:25:41 +0000 | [diff] [blame] | 100 | std::unique_ptr<ObjDumper> &Result); |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 101 | |
Rafael Espindola | a20bcb9 | 2014-06-13 01:25:41 +0000 | [diff] [blame] | 102 | std::error_code createELFDumper(const object::ObjectFile *Obj, |
Zachary Turner | 2448e9f | 2016-05-03 00:28:04 +0000 | [diff] [blame] | 103 | ScopedPrinter &Writer, |
Rafael Espindola | a20bcb9 | 2014-06-13 01:25:41 +0000 | [diff] [blame] | 104 | std::unique_ptr<ObjDumper> &Result); |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 105 | |
Rafael Espindola | a20bcb9 | 2014-06-13 01:25:41 +0000 | [diff] [blame] | 106 | std::error_code createMachODumper(const object::ObjectFile *Obj, |
Zachary Turner | 2448e9f | 2016-05-03 00:28:04 +0000 | [diff] [blame] | 107 | ScopedPrinter &Writer, |
Rafael Espindola | a20bcb9 | 2014-06-13 01:25:41 +0000 | [diff] [blame] | 108 | std::unique_ptr<ObjDumper> &Result); |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 109 | |
Derek Schuff | c20099f | 2017-01-30 23:30:52 +0000 | [diff] [blame] | 110 | std::error_code createWasmDumper(const object::ObjectFile *Obj, |
| 111 | ScopedPrinter &Writer, |
| 112 | std::unique_ptr<ObjDumper> &Result); |
| 113 | |
Sam Clegg | 5248326 | 2018-01-10 00:14:19 +0000 | [diff] [blame] | 114 | void dumpCOFFImportFile(const object::COFFImportFile *File, |
| 115 | ScopedPrinter &Writer); |
Rui Ueyama | c2aa179 | 2015-08-28 10:27:50 +0000 | [diff] [blame] | 116 | |
Zachary Turner | 47856b2 | 2017-11-30 18:39:50 +0000 | [diff] [blame] | 117 | void dumpCodeViewMergedTypes( |
| 118 | ScopedPrinter &Writer, llvm::codeview::MergingTypeTableBuilder &IDTable, |
| 119 | llvm::codeview::MergingTypeTableBuilder &TypeTable); |
Reid Kleckner | fed38e2 | 2016-05-14 00:02:53 +0000 | [diff] [blame] | 120 | |
Eric Christopher | 76e70f3 | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 121 | } // namespace llvm |
| 122 | |
| 123 | #endif |