1 //===-- llvm-readobj.h ----------------------------------------------------===//
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_LLVM_READOBJ_H
10 #define LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H
12 #include "llvm/Support/CommandLine.h"
13 #include "llvm/Support/Compiler.h"
14 #include "llvm/Support/ErrorOr.h"
15 #include "llvm/Support/Error.h"
23 // Various helper functions.
24 LLVM_ATTRIBUTE_NORETURN
void reportError(Twine Msg
);
25 void error(std::error_code EC
);
26 void error(llvm::Error EC
);
27 template <typename T
> T
error(llvm::Expected
<T
> &&E
) {
32 template <class T
> T
unwrapOrError(ErrorOr
<T
> EO
) {
35 reportError(EO
.getError().message());
37 template <class T
> T
unwrapOrError(Expected
<T
> EO
) {
41 raw_string_ostream
OS(Buf
);
42 logAllUnhandledErrors(EO
.takeError(), OS
);
46 bool relocAddressLess(object::RelocationRef A
,
47 object::RelocationRef B
);
51 extern llvm::cl::opt
<bool> SectionRelocations
;
52 extern llvm::cl::opt
<bool> SectionSymbols
;
53 extern llvm::cl::opt
<bool> SectionData
;
54 extern llvm::cl::opt
<bool> ExpandRelocs
;
55 extern llvm::cl::opt
<bool> RawRelr
;
56 extern llvm::cl::opt
<bool> CodeViewSubsectionBytes
;
57 extern llvm::cl::opt
<bool> Demangle
;
58 enum OutputStyleTy
{ LLVM
, GNU
};
59 extern llvm::cl::opt
<OutputStyleTy
> Output
;
62 #define LLVM_READOBJ_ENUM_ENT(ns, enum) \
65 #define LLVM_READOBJ_ENUM_CLASS_ENT(enum_class, enum) \
66 { #enum, std::underlying_type<enum_class>::type(enum_class::enum) }