109467b48Spatrick //===-- llvm-readobj.h ----------------------------------------------------===// 209467b48Spatrick // 309467b48Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 409467b48Spatrick // See https://llvm.org/LICENSE.txt for license information. 509467b48Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 609467b48Spatrick // 709467b48Spatrick //===----------------------------------------------------------------------===// 809467b48Spatrick 909467b48Spatrick #ifndef LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H 1009467b48Spatrick #define LLVM_TOOLS_LLVM_READOBJ_LLVM_READOBJ_H 1109467b48Spatrick 12*d415bd75Srobert #include "ObjDumper.h" 13*d415bd75Srobert 14*d415bd75Srobert #include "llvm/ADT/SmallVector.h" 1509467b48Spatrick #include "llvm/Support/CommandLine.h" 1609467b48Spatrick #include "llvm/Support/Compiler.h" 1709467b48Spatrick #include "llvm/Support/Error.h" 18*d415bd75Srobert #include "llvm/Support/ErrorOr.h" 1909467b48Spatrick #include <string> 2009467b48Spatrick 2109467b48Spatrick namespace llvm { 2209467b48Spatrick namespace object { 2309467b48Spatrick class RelocationRef; 2409467b48Spatrick } 2509467b48Spatrick 2609467b48Spatrick // Various helper functions. 27*d415bd75Srobert [[noreturn]] void reportError(Error Err, StringRef Input); 2809467b48Spatrick void reportWarning(Error Err, StringRef Input); 2909467b48Spatrick unwrapOrError(StringRef Input,Expected<T> EO)3009467b48Spatrick template <class T> T unwrapOrError(StringRef Input, Expected<T> EO) { 3109467b48Spatrick if (EO) 3209467b48Spatrick return *EO; 3309467b48Spatrick reportError(EO.takeError(), Input); 3409467b48Spatrick } 3509467b48Spatrick } // namespace llvm 3609467b48Spatrick 3709467b48Spatrick namespace opts { 3873471bf0Spatrick extern bool SectionRelocations; 3973471bf0Spatrick extern bool SectionSymbols; 4073471bf0Spatrick extern bool SectionData; 4173471bf0Spatrick extern bool ExpandRelocs; 4273471bf0Spatrick extern bool RawRelr; 4373471bf0Spatrick extern bool CodeViewSubsectionBytes; 4473471bf0Spatrick extern bool Demangle; 45*d415bd75Srobert enum OutputStyleTy { LLVM, GNU, JSON, UNKNOWN }; 4673471bf0Spatrick extern OutputStyleTy Output; 4709467b48Spatrick } // namespace opts 4809467b48Spatrick 4909467b48Spatrick #define LLVM_READOBJ_ENUM_ENT(ns, enum) \ 5009467b48Spatrick { #enum, ns::enum } 5109467b48Spatrick 5209467b48Spatrick #define LLVM_READOBJ_ENUM_CLASS_ENT(enum_class, enum) \ 53*d415bd75Srobert { #enum, std::underlying_type_t<enum_class>(enum_class::enum) } 5409467b48Spatrick 5509467b48Spatrick #endif 56