[DAGCombiner] Eliminate dead stores to stack.
[llvm-complete.git] / tools / llvm-objdump / llvm-objdump.h
blobe559b72aeb7ac23477bf5eac51afa5569614d438
1 //
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 //
6 //===----------------------------------------------------------------------===//
8 #ifndef LLVM_TOOLS_LLVM_OBJDUMP_LLVM_OBJDUMP_H
9 #define LLVM_TOOLS_LLVM_OBJDUMP_LLVM_OBJDUMP_H
11 #include "llvm/DebugInfo/DIContext.h"
12 #include "llvm/Support/CommandLine.h"
13 #include "llvm/Support/Compiler.h"
14 #include "llvm/Support/DataTypes.h"
15 #include "llvm/Object/Archive.h"
17 namespace llvm {
18 class StringRef;
20 namespace object {
21 class COFFObjectFile;
22 class COFFImportFile;
23 class ELFObjectFileBase;
24 class ELFSectionRef;
25 class MachOObjectFile;
26 class MachOUniversalBinary;
27 class ObjectFile;
28 class Archive;
29 class RelocationRef;
32 extern cl::opt<std::string> TripleName;
33 extern cl::opt<std::string> ArchName;
34 extern cl::opt<std::string> MCPU;
35 extern cl::list<std::string> MAttrs;
36 extern cl::list<std::string> FilterSections;
37 extern cl::opt<bool> AllHeaders;
38 extern cl::opt<bool> Demangle;
39 extern cl::opt<bool> Disassemble;
40 extern cl::opt<bool> DisassembleAll;
41 extern cl::opt<bool> NoShowRawInsn;
42 extern cl::opt<bool> NoLeadingAddr;
43 extern cl::opt<bool> PrivateHeaders;
44 extern cl::opt<bool> FileHeaders;
45 extern cl::opt<bool> FirstPrivateHeader;
46 extern cl::opt<bool> ExportsTrie;
47 extern cl::opt<bool> Rebase;
48 extern cl::opt<bool> Bind;
49 extern cl::opt<bool> LazyBind;
50 extern cl::opt<bool> WeakBind;
51 extern cl::opt<bool> RawClangAST;
52 extern cl::opt<bool> UniversalHeaders;
53 extern cl::opt<bool> ArchiveHeaders;
54 extern cl::opt<bool> IndirectSymbols;
55 extern cl::opt<bool> DataInCode;
56 extern cl::opt<bool> LinkOptHints;
57 extern cl::opt<bool> InfoPlist;
58 extern cl::opt<bool> DylibsUsed;
59 extern cl::opt<bool> DylibId;
60 extern cl::opt<bool> ObjcMetaData;
61 extern cl::opt<std::string> DisSymName;
62 extern cl::opt<bool> NonVerbose;
63 extern cl::opt<bool> Relocations;
64 extern cl::opt<bool> DynamicRelocations;
65 extern cl::opt<bool> SectionHeaders;
66 extern cl::opt<bool> SectionContents;
67 extern cl::opt<bool> SymbolTable;
68 extern cl::opt<bool> UnwindInfo;
69 extern cl::opt<bool> PrintImmHex;
70 extern cl::opt<DIDumpType> DwarfDumpType;
72 typedef std::function<bool(llvm::object::SectionRef const &)> FilterPredicate;
74 class SectionFilterIterator {
75 public:
76 SectionFilterIterator(FilterPredicate P,
77 llvm::object::section_iterator const &I,
78 llvm::object::section_iterator const &E)
79 : Predicate(std::move(P)), Iterator(I), End(E) {
80 ScanPredicate();
82 const llvm::object::SectionRef &operator*() const { return *Iterator; }
83 SectionFilterIterator &operator++() {
84 ++Iterator;
85 ScanPredicate();
86 return *this;
88 bool operator!=(SectionFilterIterator const &Other) const {
89 return Iterator != Other.Iterator;
92 private:
93 void ScanPredicate() {
94 while (Iterator != End && !Predicate(*Iterator)) {
95 ++Iterator;
98 FilterPredicate Predicate;
99 llvm::object::section_iterator Iterator;
100 llvm::object::section_iterator End;
103 class SectionFilter {
104 public:
105 SectionFilter(FilterPredicate P, llvm::object::ObjectFile const &O)
106 : Predicate(std::move(P)), Object(O) {}
107 SectionFilterIterator begin() {
108 return SectionFilterIterator(Predicate, Object.section_begin(),
109 Object.section_end());
111 SectionFilterIterator end() {
112 return SectionFilterIterator(Predicate, Object.section_end(),
113 Object.section_end());
116 private:
117 FilterPredicate Predicate;
118 llvm::object::ObjectFile const &Object;
121 // Various helper functions.
122 SectionFilter ToolSectionFilter(llvm::object::ObjectFile const &O);
124 std::error_code
125 getELFRelocationValueString(const object::ELFObjectFileBase *Obj,
126 const object::RelocationRef &Rel,
127 llvm::SmallVectorImpl<char> &Result);
128 std::error_code
129 getCOFFRelocationValueString(const object::COFFObjectFile *Obj,
130 const object::RelocationRef &Rel,
131 llvm::SmallVectorImpl<char> &Result);
132 std::error_code
133 getWasmRelocationValueString(const object::WasmObjectFile *Obj,
134 const object::RelocationRef &RelRef,
135 llvm::SmallVectorImpl<char> &Result);
136 std::error_code
137 getMachORelocationValueString(const object::MachOObjectFile *Obj,
138 const object::RelocationRef &RelRef,
139 llvm::SmallVectorImpl<char> &Result);
141 uint64_t getELFSectionLMA(const object::ELFSectionRef& Sec);
143 void error(std::error_code ec);
144 bool isRelocAddressLess(object::RelocationRef A, object::RelocationRef B);
145 void parseInputMachO(StringRef Filename);
146 void parseInputMachO(object::MachOUniversalBinary *UB);
147 void printCOFFUnwindInfo(const object::COFFObjectFile *O);
148 void printMachOUnwindInfo(const object::MachOObjectFile *O);
149 void printMachOExportsTrie(const object::MachOObjectFile *O);
150 void printMachORebaseTable(object::MachOObjectFile *O);
151 void printMachOBindTable(object::MachOObjectFile *O);
152 void printMachOLazyBindTable(object::MachOObjectFile *O);
153 void printMachOWeakBindTable(object::MachOObjectFile *O);
154 void printELFFileHeader(const object::ObjectFile *O);
155 void printELFDynamicSection(const object::ObjectFile *Obj);
156 void printCOFFFileHeader(const object::ObjectFile *O);
157 void printCOFFSymbolTable(const object::COFFImportFile *I);
158 void printCOFFSymbolTable(const object::COFFObjectFile *O);
159 void printMachOFileHeader(const object::ObjectFile *O);
160 void printMachOLoadCommands(const object::ObjectFile *O);
161 void printWasmFileHeader(const object::ObjectFile *O);
162 void printExportsTrie(const object::ObjectFile *O);
163 void printRebaseTable(object::ObjectFile *O);
164 void printBindTable(object::ObjectFile *O);
165 void printLazyBindTable(object::ObjectFile *O);
166 void printWeakBindTable(object::ObjectFile *O);
167 void printRawClangAST(const object::ObjectFile *O);
168 void printRelocations(const object::ObjectFile *O);
169 void printDynamicRelocations(const object::ObjectFile *O);
170 void printSectionHeaders(const object::ObjectFile *O);
171 void printSectionContents(const object::ObjectFile *O);
172 void printSymbolTable(const object::ObjectFile *O, StringRef ArchiveName,
173 StringRef ArchitectureName = StringRef());
174 void warn(StringRef Message);
175 LLVM_ATTRIBUTE_NORETURN void error(Twine Message);
176 LLVM_ATTRIBUTE_NORETURN void report_error(StringRef File, Twine Message);
177 LLVM_ATTRIBUTE_NORETURN void report_error(StringRef File, std::error_code EC);
178 LLVM_ATTRIBUTE_NORETURN void report_error(StringRef File, llvm::Error E);
179 LLVM_ATTRIBUTE_NORETURN void report_error(StringRef FileName,
180 StringRef ArchiveName,
181 llvm::Error E,
182 StringRef ArchitectureName
183 = StringRef());
184 LLVM_ATTRIBUTE_NORETURN void report_error(StringRef ArchiveName,
185 const object::Archive::Child &C,
186 llvm::Error E,
187 StringRef ArchitectureName
188 = StringRef());
190 } // end namespace llvm
192 #endif