Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 1 | //===-- llvm-readobj.h ----------------------------------------------------===// |
Michael J. Spencer | 6a8746b | 2013-02-20 02:37:12 +0000 | [diff] [blame] | 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 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H |
| 11 | #define LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H |
Michael J. Spencer | 6a8746b | 2013-02-20 02:37:12 +0000 | [diff] [blame] | 12 | |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 13 | #include "llvm/Support/CommandLine.h" |
Reid Kleckner | 9f23516 | 2015-12-04 21:29:53 +0000 | [diff] [blame] | 14 | #include "llvm/Support/Compiler.h" |
Rafael Espindola | f04f184 | 2016-02-17 16:21:49 +0000 | [diff] [blame] | 15 | #include "llvm/Support/ErrorOr.h" |
Kevin Enderby | 81e8b7d | 2016-04-20 21:24:34 +0000 | [diff] [blame] | 16 | #include "llvm/Support/Error.h" |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 17 | #include <string> |
Michael J. Spencer | 6a8746b | 2013-02-20 02:37:12 +0000 | [diff] [blame] | 18 | |
| 19 | namespace llvm { |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 20 | namespace object { |
| 21 | class RelocationRef; |
| 22 | } |
Michael J. Spencer | 6a8746b | 2013-02-20 02:37:12 +0000 | [diff] [blame] | 23 | |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 24 | // Various helper functions. |
Reid Kleckner | 9f23516 | 2015-12-04 21:29:53 +0000 | [diff] [blame] | 25 | LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg); |
Zachary Turner | 5e3e4bb | 2016-08-05 21:45:34 +0000 | [diff] [blame] | 26 | void error(std::error_code EC); |
Zachary Turner | 660230e | 2016-08-04 19:39:55 +0000 | [diff] [blame] | 27 | void error(llvm::Error EC); |
Rafael Espindola | f04f184 | 2016-02-17 16:21:49 +0000 | [diff] [blame] | 28 | template <class T> T unwrapOrError(ErrorOr<T> EO) { |
| 29 | if (EO) |
| 30 | return *EO; |
| 31 | reportError(EO.getError().message()); |
| 32 | } |
Kevin Enderby | 81e8b7d | 2016-04-20 21:24:34 +0000 | [diff] [blame] | 33 | template <class T> T unwrapOrError(Expected<T> EO) { |
| 34 | if (EO) |
| 35 | return *EO; |
| 36 | std::string Buf; |
| 37 | raw_string_ostream OS(Buf); |
| 38 | logAllUnhandledErrors(EO.takeError(), OS, ""); |
| 39 | OS.flush(); |
| 40 | reportError(Buf); |
| 41 | } |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 42 | bool relocAddressLess(object::RelocationRef A, |
| 43 | object::RelocationRef B); |
| 44 | } // namespace llvm |
| 45 | |
| 46 | namespace opts { |
| 47 | extern llvm::cl::list<std::string> InputFilenames; |
| 48 | extern llvm::cl::opt<bool> FileHeaders; |
| 49 | extern llvm::cl::opt<bool> Sections; |
| 50 | extern llvm::cl::opt<bool> SectionRelocations; |
| 51 | extern llvm::cl::opt<bool> SectionSymbols; |
| 52 | extern llvm::cl::opt<bool> SectionData; |
| 53 | extern llvm::cl::opt<bool> Relocations; |
| 54 | extern llvm::cl::opt<bool> Symbols; |
| 55 | extern llvm::cl::opt<bool> DynamicSymbols; |
| 56 | extern llvm::cl::opt<bool> UnwindInfo; |
Nico Rieck | f3f0b79 | 2013-04-12 04:01:52 +0000 | [diff] [blame] | 57 | extern llvm::cl::opt<bool> ExpandRelocs; |
Zachary Turner | 99f0215 | 2015-02-18 19:32:05 +0000 | [diff] [blame] | 58 | extern llvm::cl::opt<bool> CodeView; |
| 59 | extern llvm::cl::opt<bool> CodeViewSubsectionBytes; |
Saleem Abdulrasool | 15d16d8 | 2014-01-30 04:46:33 +0000 | [diff] [blame] | 60 | extern llvm::cl::opt<bool> ARMAttributes; |
Simon Atanasyan | 8043390 | 2014-06-18 08:47:09 +0000 | [diff] [blame] | 61 | extern llvm::cl::opt<bool> MipsPLTGOT; |
Tim Northover | d59b23a | 2016-03-01 21:45:22 +0000 | [diff] [blame] | 62 | enum OutputStyleTy { LLVM, GNU }; |
| 63 | extern llvm::cl::opt<OutputStyleTy> Output; |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 64 | } // namespace opts |
| 65 | |
| 66 | #define LLVM_READOBJ_ENUM_ENT(ns, enum) \ |
| 67 | { #enum, ns::enum } |
Michael J. Spencer | 6a8746b | 2013-02-20 02:37:12 +0000 | [diff] [blame] | 68 | |
Reid Kleckner | 72e2ba7 | 2016-01-13 19:32:35 +0000 | [diff] [blame] | 69 | #define LLVM_READOBJ_ENUM_CLASS_ENT(enum_class, enum) \ |
| 70 | { #enum, std::underlying_type<enum_class>::type(enum_class::enum) } |
| 71 | |
Michael J. Spencer | 6a8746b | 2013-02-20 02:37:12 +0000 | [diff] [blame] | 72 | #endif |