blob: b169c00291838ef034bc0b1b7947d5a2bc8de060 [file] [log] [blame]
Eric Christopher9cad53c2013-04-03 18:31:38 +00001//===-- llvm-readobj.h ----------------------------------------------------===//
Michael J. Spencer6a8746b2013-02-20 02:37:12 +00002//
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 Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H
11#define LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H
Michael J. Spencer6a8746b2013-02-20 02:37:12 +000012
Eric Christopher9cad53c2013-04-03 18:31:38 +000013#include "llvm/Support/CommandLine.h"
Reid Kleckner9f235162015-12-04 21:29:53 +000014#include "llvm/Support/Compiler.h"
Rafael Espindolaf04f1842016-02-17 16:21:49 +000015#include "llvm/Support/ErrorOr.h"
Kevin Enderby81e8b7d2016-04-20 21:24:34 +000016#include "llvm/Support/Error.h"
Eric Christopher9cad53c2013-04-03 18:31:38 +000017#include <string>
Michael J. Spencer6a8746b2013-02-20 02:37:12 +000018
19namespace llvm {
Eric Christopher9cad53c2013-04-03 18:31:38 +000020 namespace object {
21 class RelocationRef;
22 }
Michael J. Spencer6a8746b2013-02-20 02:37:12 +000023
Eric Christopher9cad53c2013-04-03 18:31:38 +000024 // Various helper functions.
Reid Kleckner9f235162015-12-04 21:29:53 +000025 LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg);
Rafael Espindolafb3acd62015-07-20 03:23:55 +000026 void error(std::error_code ec);
Rafael Espindolaf04f1842016-02-17 16:21:49 +000027 template <class T> T unwrapOrError(ErrorOr<T> EO) {
28 if (EO)
29 return *EO;
30 reportError(EO.getError().message());
31 }
Kevin Enderby81e8b7d2016-04-20 21:24:34 +000032 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 }
Eric Christopher9cad53c2013-04-03 18:31:38 +000041 bool relocAddressLess(object::RelocationRef A,
42 object::RelocationRef B);
43} // namespace llvm
44
45namespace 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;
Nico Rieckf3f0b792013-04-12 04:01:52 +000056 extern llvm::cl::opt<bool> ExpandRelocs;
Zachary Turner99f02152015-02-18 19:32:05 +000057 extern llvm::cl::opt<bool> CodeView;
58 extern llvm::cl::opt<bool> CodeViewSubsectionBytes;
Saleem Abdulrasool15d16d82014-01-30 04:46:33 +000059 extern llvm::cl::opt<bool> ARMAttributes;
Simon Atanasyan80433902014-06-18 08:47:09 +000060 extern llvm::cl::opt<bool> MipsPLTGOT;
Tim Northoverd59b23a2016-03-01 21:45:22 +000061 enum OutputStyleTy { LLVM, GNU };
62 extern llvm::cl::opt<OutputStyleTy> Output;
Eric Christopher9cad53c2013-04-03 18:31:38 +000063} // namespace opts
64
65#define LLVM_READOBJ_ENUM_ENT(ns, enum) \
66 { #enum, ns::enum }
Michael J. Spencer6a8746b2013-02-20 02:37:12 +000067
Reid Kleckner72e2ba72016-01-13 19:32:35 +000068#define LLVM_READOBJ_ENUM_CLASS_ENT(enum_class, enum) \
69 { #enum, std::underlying_type<enum_class>::type(enum_class::enum) }
70
Michael J. Spencer6a8746b2013-02-20 02:37:12 +000071#endif