1 //===-- ObjDumper.h ---------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_TOOLS_LLVM_READOBJ_OBJDUMPER_H
10 #define LLVM_TOOLS_LLVM_READOBJ_OBJDUMPER_H
13 #include <system_error>
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/Object/ObjectFile.h"
17 #include "llvm/Support/CommandLine.h"
25 class GlobalTypeTableBuilder
;
26 class MergingTypeTableBuilder
;
27 } // namespace codeview
33 ObjDumper(ScopedPrinter
&Writer
);
36 virtual void printFileHeaders() = 0;
37 virtual void printSectionHeaders() = 0;
38 virtual void printRelocations() = 0;
39 virtual void printSymbols(bool PrintSymbols
, bool PrintDynamicSymbols
) {
42 if (PrintDynamicSymbols
)
43 printDynamicSymbols();
45 virtual void printProgramHeaders(bool PrintProgramHeaders
,
46 cl::boolOrDefault PrintSectionMapping
) {
47 if (PrintProgramHeaders
)
48 printProgramHeaders();
49 if (PrintSectionMapping
== cl::BOU_TRUE
)
50 printSectionMapping();
53 virtual void printUnwindInfo() = 0;
55 // Only implemented for ELF at this time.
56 virtual void printDynamicRelocations() { }
57 virtual void printDynamicTable() { }
58 virtual void printNeededLibraries() { }
59 virtual void printSectionAsHex(StringRef SectionName
) {}
60 virtual void printHashTable() { }
61 virtual void printGnuHashTable() { }
62 virtual void printHashSymbols() {}
63 virtual void printLoadName() {}
64 virtual void printVersionInfo() {}
65 virtual void printGroupSections() {}
66 virtual void printHashHistogram() {}
67 virtual void printCGProfile() {}
68 virtual void printAddrsig() {}
69 virtual void printNotes() {}
70 virtual void printELFLinkerOptions() {}
71 virtual void printStackSizes() {}
73 // Only implemented for ARM ELF at this time.
74 virtual void printAttributes() { }
76 // Only implemented for MIPS ELF at this time.
77 virtual void printMipsPLTGOT() { }
78 virtual void printMipsABIFlags() { }
79 virtual void printMipsReginfo() { }
80 virtual void printMipsOptions() { }
82 // Only implemented for PE/COFF.
83 virtual void printCOFFImports() { }
84 virtual void printCOFFExports() { }
85 virtual void printCOFFDirectives() { }
86 virtual void printCOFFBaseReloc() { }
87 virtual void printCOFFDebugDirectory() { }
88 virtual void printCOFFResources() {}
89 virtual void printCOFFLoadConfig() { }
90 virtual void printCodeViewDebugInfo() { }
92 mergeCodeViewTypes(llvm::codeview::MergingTypeTableBuilder
&CVIDs
,
93 llvm::codeview::MergingTypeTableBuilder
&CVTypes
,
94 llvm::codeview::GlobalTypeTableBuilder
&GlobalCVIDs
,
95 llvm::codeview::GlobalTypeTableBuilder
&GlobalCVTypes
,
98 // Only implemented for MachO.
99 virtual void printMachODataInCode() { }
100 virtual void printMachOVersionMin() { }
101 virtual void printMachODysymtab() { }
102 virtual void printMachOSegment() { }
103 virtual void printMachOIndirectSymbols() { }
104 virtual void printMachOLinkerOptions() { }
106 virtual void printStackMap() const = 0;
108 void printSectionsAsString(const object::ObjectFile
*Obj
,
109 ArrayRef
<std::string
> Sections
);
110 void printSectionsAsHex(const object::ObjectFile
*Obj
,
111 ArrayRef
<std::string
> Sections
);
117 virtual void printSymbols() {}
118 virtual void printDynamicSymbols() {}
119 virtual void printProgramHeaders() {}
120 virtual void printSectionMapping() {}
123 std::error_code
createCOFFDumper(const object::ObjectFile
*Obj
,
124 ScopedPrinter
&Writer
,
125 std::unique_ptr
<ObjDumper
> &Result
);
127 std::error_code
createELFDumper(const object::ObjectFile
*Obj
,
128 ScopedPrinter
&Writer
,
129 std::unique_ptr
<ObjDumper
> &Result
);
131 std::error_code
createMachODumper(const object::ObjectFile
*Obj
,
132 ScopedPrinter
&Writer
,
133 std::unique_ptr
<ObjDumper
> &Result
);
135 std::error_code
createWasmDumper(const object::ObjectFile
*Obj
,
136 ScopedPrinter
&Writer
,
137 std::unique_ptr
<ObjDumper
> &Result
);
139 std::error_code
createXCOFFDumper(const object::ObjectFile
*Obj
,
140 ScopedPrinter
&Writer
,
141 std::unique_ptr
<ObjDumper
> &Result
);
143 void dumpCOFFImportFile(const object::COFFImportFile
*File
,
144 ScopedPrinter
&Writer
);
146 void dumpCodeViewMergedTypes(ScopedPrinter
&Writer
,
147 ArrayRef
<ArrayRef
<uint8_t>> IpiRecords
,
148 ArrayRef
<ArrayRef
<uint8_t>> TpiRecords
);