1 //===-- llvm-readobj.h ----------------------------------------------------===// 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 10 #ifndef LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H 11 #define LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H 12 13 #include "llvm/Support/CommandLine.h" 14 #include "llvm/Support/Compiler.h" 15 #include "llvm/Support/ErrorOr.h" 16 #include "llvm/Support/Error.h" 17 #include <string> 18 19 namespace llvm { 20 namespace object { 21 class RelocationRef; 22 } 23 24 // Various helper functions. 25 LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg); 26 void error(std::error_code ec); unwrapOrError(ErrorOr<T> EO)27 template <class T> T unwrapOrError(ErrorOr<T> EO) { 28 if (EO) 29 return *EO; 30 reportError(EO.getError().message()); 31 } unwrapOrError(Expected<T> EO)32 template <class T> T unwrapOrError(Expected<T> EO) { 33 if (EO) 34 return *EO; 35 std::string Buf; 36 raw_string_ostream OS(Buf); 37 logAllUnhandledErrors(EO.takeError(), OS, ""); 38 OS.flush(); 39 reportError(Buf); 40 } 41 bool relocAddressLess(object::RelocationRef A, 42 object::RelocationRef B); 43 } // namespace llvm 44 45 namespace opts { 46 extern llvm::cl::list<std::string> InputFilenames; 47 extern llvm::cl::opt<bool> FileHeaders; 48 extern llvm::cl::opt<bool> Sections; 49 extern llvm::cl::opt<bool> SectionRelocations; 50 extern llvm::cl::opt<bool> SectionSymbols; 51 extern llvm::cl::opt<bool> SectionData; 52 extern llvm::cl::opt<bool> Relocations; 53 extern llvm::cl::opt<bool> Symbols; 54 extern llvm::cl::opt<bool> DynamicSymbols; 55 extern llvm::cl::opt<bool> UnwindInfo; 56 extern llvm::cl::opt<bool> ExpandRelocs; 57 extern llvm::cl::opt<bool> CodeView; 58 extern llvm::cl::opt<bool> CodeViewSubsectionBytes; 59 extern llvm::cl::opt<bool> ARMAttributes; 60 extern llvm::cl::opt<bool> MipsPLTGOT; 61 enum OutputStyleTy { LLVM, GNU }; 62 extern llvm::cl::opt<OutputStyleTy> Output; 63 } // namespace opts 64 65 #define LLVM_READOBJ_ENUM_ENT(ns, enum) \ 66 { #enum, ns::enum } 67 68 #define LLVM_READOBJ_ENUM_CLASS_ENT(enum_class, enum) \ 69 { #enum, std::underlying_type<enum_class>::type(enum_class::enum) } 70 71 #endif 72