1 //===-- llvm-readobj.h ----------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H
11 #define LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H
13 #include "llvm/Support/CommandLine.h"
14 #include "llvm/Support/Compiler.h"
15 #include "llvm/Support/ErrorOr.h"
16 #include "llvm/Support/Error.h"
24 // Various helper functions.
25 LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
26 void error(std::error_code EC);
27 void error(llvm::Error EC);
28 template <typename T> T error(llvm::Expected<T> &&E) {
33 template <class T> T unwrapOrError(ErrorOr<T> EO) {
36 reportError(EO.getError().message());
38 template <class T> T unwrapOrError(Expected<T> EO) {
42 raw_string_ostream OS(Buf);
43 logAllUnhandledErrors(EO.takeError(), OS);
47 bool relocAddressLess(object::RelocationRef A,
48 object::RelocationRef B);
52 extern llvm::cl::opt<bool> SectionRelocations;
53 extern llvm::cl::opt<bool> SectionSymbols;
54 extern llvm::cl::opt<bool> SectionData;
55 extern llvm::cl::opt<bool> DynamicSymbols;
56 extern llvm::cl::opt<bool> ExpandRelocs;
57 extern llvm::cl::opt<bool> RawRelr;
58 extern llvm::cl::opt<bool> CodeViewSubsectionBytes;
59 enum OutputStyleTy { LLVM, GNU };
60 extern llvm::cl::opt<OutputStyleTy> Output;
63 #define LLVM_READOBJ_ENUM_ENT(ns, enum) \
66 #define LLVM_READOBJ_ENUM_CLASS_ENT(enum_class, enum) \
67 { #enum, std::underlying_type<enum_class>::type(enum_class::enum) }