diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 13:44:06 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 13:44:06 +0000 |
commit | 7ab83427af0f77b59941ceba41d509d7d097b065 (patch) | |
tree | cc41c05b1db454e3d802f34df75e636ee922ad87 /include/llvm/Support | |
parent | d288ef4c1788d3a951a7558c68312c2d320612b1 (diff) |
Notes
Diffstat (limited to 'include/llvm/Support')
48 files changed, 755 insertions, 7503 deletions
diff --git a/include/llvm/Support/AMDGPUCodeObjectMetadata.h b/include/llvm/Support/AMDGPUCodeObjectMetadata.h new file mode 100644 index 0000000000000..d274c5ee91842 --- /dev/null +++ b/include/llvm/Support/AMDGPUCodeObjectMetadata.h @@ -0,0 +1,422 @@ +//===--- AMDGPUCodeObjectMetadata.h -----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +/// \file +/// \brief AMDGPU Code Object Metadata definitions and in-memory +/// representations. +/// +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_AMDGPUCODEOBJECTMETADATA_H +#define LLVM_SUPPORT_AMDGPUCODEOBJECTMETADATA_H + +#include <cstdint> +#include <string> +#include <system_error> +#include <vector> + +namespace llvm { +namespace AMDGPU { + +//===----------------------------------------------------------------------===// +// Code Object Metadata. +//===----------------------------------------------------------------------===// +namespace CodeObject { + +/// \brief Code object metadata major version. +constexpr uint32_t MetadataVersionMajor = 1; +/// \brief Code object metadata minor version. +constexpr uint32_t MetadataVersionMinor = 0; + +/// \brief Code object metadata beginning assembler directive. +constexpr char MetadataAssemblerDirectiveBegin[] = + ".amdgpu_code_object_metadata"; +/// \brief Code object metadata ending assembler directive. +constexpr char MetadataAssemblerDirectiveEnd[] = + ".end_amdgpu_code_object_metadata"; + +/// \brief Access qualifiers. +enum class AccessQualifier : uint8_t { + Default = 0, + ReadOnly = 1, + WriteOnly = 2, + ReadWrite = 3, + Unknown = 0xff +}; + +/// \brief Address space qualifiers. +enum class AddressSpaceQualifier : uint8_t { + Private = 0, + Global = 1, + Constant = 2, + Local = 3, + Generic = 4, + Region = 5, + Unknown = 0xff +}; + +/// \brief Value kinds. +enum class ValueKind : uint8_t { + ByValue = 0, + GlobalBuffer = 1, + DynamicSharedPointer = 2, + Sampler = 3, + Image = 4, + Pipe = 5, + Queue = 6, + HiddenGlobalOffsetX = 7, + HiddenGlobalOffsetY = 8, + HiddenGlobalOffsetZ = 9, + HiddenNone = 10, + HiddenPrintfBuffer = 11, + HiddenDefaultQueue = 12, + HiddenCompletionAction = 13, + Unknown = 0xff +}; + +/// \brief Value types. +enum class ValueType : uint8_t { + Struct = 0, + I8 = 1, + U8 = 2, + I16 = 3, + U16 = 4, + F16 = 5, + I32 = 6, + U32 = 7, + F32 = 8, + I64 = 9, + U64 = 10, + F64 = 11, + Unknown = 0xff +}; + +//===----------------------------------------------------------------------===// +// Kernel Metadata. +//===----------------------------------------------------------------------===// +namespace Kernel { + +//===----------------------------------------------------------------------===// +// Kernel Attributes Metadata. +//===----------------------------------------------------------------------===// +namespace Attrs { + +namespace Key { +/// \brief Key for Kernel::Attr::Metadata::mReqdWorkGroupSize. +constexpr char ReqdWorkGroupSize[] = "ReqdWorkGroupSize"; +/// \brief Key for Kernel::Attr::Metadata::mWorkGroupSizeHint. +constexpr char WorkGroupSizeHint[] = "WorkGroupSizeHint"; +/// \brief Key for Kernel::Attr::Metadata::mVecTypeHint. +constexpr char VecTypeHint[] = "VecTypeHint"; +} // end namespace Key + +/// \brief In-memory representation of kernel attributes metadata. +struct Metadata final { + /// \brief 'reqd_work_group_size' attribute. Optional. + std::vector<uint32_t> mReqdWorkGroupSize = std::vector<uint32_t>(); + /// \brief 'work_group_size_hint' attribute. Optional. + std::vector<uint32_t> mWorkGroupSizeHint = std::vector<uint32_t>(); + /// \brief 'vec_type_hint' attribute. Optional. + std::string mVecTypeHint = std::string(); + + /// \brief Default constructor. + Metadata() = default; + + /// \returns True if kernel attributes metadata is empty, false otherwise. + bool empty() const { + return mReqdWorkGroupSize.empty() && + mWorkGroupSizeHint.empty() && + mVecTypeHint.empty(); + } + + /// \returns True if kernel attributes metadata is not empty, false otherwise. + bool notEmpty() const { + return !empty(); + } +}; + +} // end namespace Attrs + +//===----------------------------------------------------------------------===// +// Kernel Argument Metadata. +//===----------------------------------------------------------------------===// +namespace Arg { + +namespace Key { +/// \brief Key for Kernel::Arg::Metadata::mSize. +constexpr char Size[] = "Size"; +/// \brief Key for Kernel::Arg::Metadata::mAlign. +constexpr char Align[] = "Align"; +/// \brief Key for Kernel::Arg::Metadata::mValueKind. +constexpr char ValueKind[] = "ValueKind"; +/// \brief Key for Kernel::Arg::Metadata::mValueType. +constexpr char ValueType[] = "ValueType"; +/// \brief Key for Kernel::Arg::Metadata::mPointeeAlign. +constexpr char PointeeAlign[] = "PointeeAlign"; +/// \brief Key for Kernel::Arg::Metadata::mAccQual. +constexpr char AccQual[] = "AccQual"; +/// \brief Key for Kernel::Arg::Metadata::mAddrSpaceQual. +constexpr char AddrSpaceQual[] = "AddrSpaceQual"; +/// \brief Key for Kernel::Arg::Metadata::mIsConst. +constexpr char IsConst[] = "IsConst"; +/// \brief Key for Kernel::Arg::Metadata::mIsPipe. +constexpr char IsPipe[] = "IsPipe"; +/// \brief Key for Kernel::Arg::Metadata::mIsRestrict. +constexpr char IsRestrict[] = "IsRestrict"; +/// \brief Key for Kernel::Arg::Metadata::mIsVolatile. +constexpr char IsVolatile[] = "IsVolatile"; +/// \brief Key for Kernel::Arg::Metadata::mName. +constexpr char Name[] = "Name"; +/// \brief Key for Kernel::Arg::Metadata::mTypeName. +constexpr char TypeName[] = "TypeName"; +} // end namespace Key + +/// \brief In-memory representation of kernel argument metadata. +struct Metadata final { + /// \brief Size in bytes. Required. + uint32_t mSize = 0; + /// \brief Alignment in bytes. Required. + uint32_t mAlign = 0; + /// \brief Value kind. Required. + ValueKind mValueKind = ValueKind::Unknown; + /// \brief Value type. Required. + ValueType mValueType = ValueType::Unknown; + /// \brief Pointee alignment in bytes. Optional. + uint32_t mPointeeAlign = 0; + /// \brief Access qualifier. Optional. + AccessQualifier mAccQual = AccessQualifier::Unknown; + /// \brief Address space qualifier. Optional. + AddressSpaceQualifier mAddrSpaceQual = AddressSpaceQualifier::Unknown; + /// \brief True if 'const' qualifier is specified. Optional. + bool mIsConst = false; + /// \brief True if 'pipe' qualifier is specified. Optional. + bool mIsPipe = false; + /// \brief True if 'restrict' qualifier is specified. Optional. + bool mIsRestrict = false; + /// \brief True if 'volatile' qualifier is specified. Optional. + bool mIsVolatile = false; + /// \brief Name. Optional. + std::string mName = std::string(); + /// \brief Type name. Optional. + std::string mTypeName = std::string(); + + /// \brief Default constructor. + Metadata() = default; +}; + +} // end namespace Arg + +//===----------------------------------------------------------------------===// +// Kernel Code Properties Metadata. +//===----------------------------------------------------------------------===// +namespace CodeProps { + +namespace Key { +/// \brief Key for Kernel::CodeProps::Metadata::mKernargSegmentSize. +constexpr char KernargSegmentSize[] = "KernargSegmentSize"; +/// \brief Key for Kernel::CodeProps::Metadata::mWorkgroupGroupSegmentSize. +constexpr char WorkgroupGroupSegmentSize[] = "WorkgroupGroupSegmentSize"; +/// \brief Key for Kernel::CodeProps::Metadata::mWorkitemPrivateSegmentSize. +constexpr char WorkitemPrivateSegmentSize[] = "WorkitemPrivateSegmentSize"; +/// \brief Key for Kernel::CodeProps::Metadata::mWavefrontNumSGPRs. +constexpr char WavefrontNumSGPRs[] = "WavefrontNumSGPRs"; +/// \brief Key for Kernel::CodeProps::Metadata::mWorkitemNumVGPRs. +constexpr char WorkitemNumVGPRs[] = "WorkitemNumVGPRs"; +/// \brief Key for Kernel::CodeProps::Metadata::mKernargSegmentAlign. +constexpr char KernargSegmentAlign[] = "KernargSegmentAlign"; +/// \brief Key for Kernel::CodeProps::Metadata::mGroupSegmentAlign. +constexpr char GroupSegmentAlign[] = "GroupSegmentAlign"; +/// \brief Key for Kernel::CodeProps::Metadata::mPrivateSegmentAlign. +constexpr char PrivateSegmentAlign[] = "PrivateSegmentAlign"; +/// \brief Key for Kernel::CodeProps::Metadata::mWavefrontSize. +constexpr char WavefrontSize[] = "WavefrontSize"; +} // end namespace Key + +/// \brief In-memory representation of kernel code properties metadata. +struct Metadata final { + /// \brief Size in bytes of the kernarg segment memory. Kernarg segment memory + /// holds the values of the arguments to the kernel. Optional. + uint64_t mKernargSegmentSize = 0; + /// \brief Size in bytes of the group segment memory required by a workgroup. + /// This value does not include any dynamically allocated group segment memory + /// that may be added when the kernel is dispatched. Optional. + uint32_t mWorkgroupGroupSegmentSize = 0; + /// \brief Size in bytes of the private segment memory required by a workitem. + /// Private segment memory includes arg, spill and private segments. Optional. + uint32_t mWorkitemPrivateSegmentSize = 0; + /// \brief Total number of SGPRs used by a wavefront. Optional. + uint16_t mWavefrontNumSGPRs = 0; + /// \brief Total number of VGPRs used by a workitem. Optional. + uint16_t mWorkitemNumVGPRs = 0; + /// \brief Maximum byte alignment of variables used by the kernel in the + /// kernarg memory segment. Expressed as a power of two. Optional. + uint8_t mKernargSegmentAlign = 0; + /// \brief Maximum byte alignment of variables used by the kernel in the + /// group memory segment. Expressed as a power of two. Optional. + uint8_t mGroupSegmentAlign = 0; + /// \brief Maximum byte alignment of variables used by the kernel in the + /// private memory segment. Expressed as a power of two. Optional. + uint8_t mPrivateSegmentAlign = 0; + /// \brief Wavefront size. Expressed as a power of two. Optional. + uint8_t mWavefrontSize = 0; + + /// \brief Default constructor. + Metadata() = default; + + /// \returns True if kernel code properties metadata is empty, false + /// otherwise. + bool empty() const { + return !notEmpty(); + } + + /// \returns True if kernel code properties metadata is not empty, false + /// otherwise. + bool notEmpty() const { + return mKernargSegmentSize || mWorkgroupGroupSegmentSize || + mWorkitemPrivateSegmentSize || mWavefrontNumSGPRs || + mWorkitemNumVGPRs || mKernargSegmentAlign || mGroupSegmentAlign || + mPrivateSegmentAlign || mWavefrontSize; + } +}; + +} // end namespace CodeProps + +//===----------------------------------------------------------------------===// +// Kernel Debug Properties Metadata. +//===----------------------------------------------------------------------===// +namespace DebugProps { + +namespace Key { +/// \brief Key for Kernel::DebugProps::Metadata::mDebuggerABIVersion. +constexpr char DebuggerABIVersion[] = "DebuggerABIVersion"; +/// \brief Key for Kernel::DebugProps::Metadata::mReservedNumVGPRs. +constexpr char ReservedNumVGPRs[] = "ReservedNumVGPRs"; +/// \brief Key for Kernel::DebugProps::Metadata::mReservedFirstVGPR. +constexpr char ReservedFirstVGPR[] = "ReservedFirstVGPR"; +/// \brief Key for Kernel::DebugProps::Metadata::mPrivateSegmentBufferSGPR. +constexpr char PrivateSegmentBufferSGPR[] = "PrivateSegmentBufferSGPR"; +/// \brief Key for +/// Kernel::DebugProps::Metadata::mWavefrontPrivateSegmentOffsetSGPR. +constexpr char WavefrontPrivateSegmentOffsetSGPR[] = + "WavefrontPrivateSegmentOffsetSGPR"; +} // end namespace Key + +/// \brief In-memory representation of kernel debug properties metadata. +struct Metadata final { + /// \brief Debugger ABI version. Optional. + std::vector<uint32_t> mDebuggerABIVersion = std::vector<uint32_t>(); + /// \brief Consecutive number of VGPRs reserved for debugger use. Must be 0 if + /// mDebuggerABIVersion is not set. Optional. + uint16_t mReservedNumVGPRs = 0; + /// \brief First fixed VGPR reserved. Must be uint16_t(-1) if + /// mDebuggerABIVersion is not set or mReservedFirstVGPR is 0. Optional. + uint16_t mReservedFirstVGPR = uint16_t(-1); + /// \brief Fixed SGPR of the first of 4 SGPRs used to hold the scratch V# used + /// for the entire kernel execution. Must be uint16_t(-1) if + /// mDebuggerABIVersion is not set or SGPR not used or not known. Optional. + uint16_t mPrivateSegmentBufferSGPR = uint16_t(-1); + /// \brief Fixed SGPR used to hold the wave scratch offset for the entire + /// kernel execution. Must be uint16_t(-1) if mDebuggerABIVersion is not set + /// or SGPR is not used or not known. Optional. + uint16_t mWavefrontPrivateSegmentOffsetSGPR = uint16_t(-1); + + /// \brief Default constructor. + Metadata() = default; + + /// \returns True if kernel debug properties metadata is empty, false + /// otherwise. + bool empty() const { + return !notEmpty(); + } + + /// \returns True if kernel debug properties metadata is not empty, false + /// otherwise. + bool notEmpty() const { + return !mDebuggerABIVersion.empty(); + } +}; + +} // end namespace DebugProps + +namespace Key { +/// \brief Key for Kernel::Metadata::mName. +constexpr char Name[] = "Name"; +/// \brief Key for Kernel::Metadata::mLanguage. +constexpr char Language[] = "Language"; +/// \brief Key for Kernel::Metadata::mLanguageVersion. +constexpr char LanguageVersion[] = "LanguageVersion"; +/// \brief Key for Kernel::Metadata::mAttrs. +constexpr char Attrs[] = "Attrs"; +/// \brief Key for Kernel::Metadata::mArgs. +constexpr char Args[] = "Args"; +/// \brief Key for Kernel::Metadata::mCodeProps. +constexpr char CodeProps[] = "CodeProps"; +/// \brief Key for Kernel::Metadata::mDebugProps. +constexpr char DebugProps[] = "DebugProps"; +} // end namespace Key + +/// \brief In-memory representation of kernel metadata. +struct Metadata final { + /// \brief Name. Required. + std::string mName = std::string(); + /// \brief Language. Optional. + std::string mLanguage = std::string(); + /// \brief Language version. Optional. + std::vector<uint32_t> mLanguageVersion = std::vector<uint32_t>(); + /// \brief Attributes metadata. Optional. + Attrs::Metadata mAttrs = Attrs::Metadata(); + /// \brief Arguments metadata. Optional. + std::vector<Arg::Metadata> mArgs = std::vector<Arg::Metadata>(); + /// \brief Code properties metadata. Optional. + CodeProps::Metadata mCodeProps = CodeProps::Metadata(); + /// \brief Debug properties metadata. Optional. + DebugProps::Metadata mDebugProps = DebugProps::Metadata(); + + /// \brief Default constructor. + Metadata() = default; +}; + +} // end namespace Kernel + +namespace Key { +/// \brief Key for CodeObject::Metadata::mVersion. +constexpr char Version[] = "Version"; +/// \brief Key for CodeObject::Metadata::mPrintf. +constexpr char Printf[] = "Printf"; +/// \brief Key for CodeObject::Metadata::mKernels. +constexpr char Kernels[] = "Kernels"; +} // end namespace Key + +/// \brief In-memory representation of code object metadata. +struct Metadata final { + /// \brief Code object metadata version. Required. + std::vector<uint32_t> mVersion = std::vector<uint32_t>(); + /// \brief Printf metadata. Optional. + std::vector<std::string> mPrintf = std::vector<std::string>(); + /// \brief Kernels metadata. Optional. + std::vector<Kernel::Metadata> mKernels = std::vector<Kernel::Metadata>(); + + /// \brief Default constructor. + Metadata() = default; + + /// \brief Converts \p YamlString to \p CodeObjectMetadata. + static std::error_code fromYamlString(std::string YamlString, + Metadata &CodeObjectMetadata); + + /// \brief Converts \p CodeObjectMetadata to \p YamlString. + static std::error_code toYamlString(Metadata CodeObjectMetadata, + std::string &YamlString); +}; + +} // end namespace CodeObject +} // end namespace AMDGPU +} // end namespace llvm + +#endif // LLVM_SUPPORT_AMDGPUCODEOBJECTMETADATA_H diff --git a/include/llvm/Support/BinaryStreamArray.h b/include/llvm/Support/BinaryStreamArray.h index 77c99ffff919b..65ec15f6d9e07 100644 --- a/include/llvm/Support/BinaryStreamArray.h +++ b/include/llvm/Support/BinaryStreamArray.h @@ -42,36 +42,114 @@ namespace llvm { /// having to specify a second template argument to VarStreamArray (documented /// below). template <typename T> struct VarStreamArrayExtractor { - struct ContextType {}; - // Method intentionally deleted. You must provide an explicit specialization - // with one of the following two methods implemented. - static Error extract(BinaryStreamRef Stream, uint32_t &Len, T &Item) = delete; + // with the following method implemented. + Error operator()(BinaryStreamRef Stream, uint32_t &Len, + T &Item) const = delete; +}; + +/// VarStreamArray represents an array of variable length records backed by a +/// stream. This could be a contiguous sequence of bytes in memory, it could +/// be a file on disk, or it could be a PDB stream where bytes are stored as +/// discontiguous blocks in a file. Usually it is desirable to treat arrays +/// as contiguous blocks of memory, but doing so with large PDB files, for +/// example, could mean allocating huge amounts of memory just to allow +/// re-ordering of stream data to be contiguous before iterating over it. By +/// abstracting this out, we need not duplicate this memory, and we can +/// iterate over arrays in arbitrarily formatted streams. Elements are parsed +/// lazily on iteration, so there is no upfront cost associated with building +/// or copying a VarStreamArray, no matter how large it may be. +/// +/// You create a VarStreamArray by specifying a ValueType and an Extractor type. +/// If you do not specify an Extractor type, you are expected to specialize +/// VarStreamArrayExtractor<T> for your ValueType. +/// +/// By default an Extractor is default constructed in the class, but in some +/// cases you might find it useful for an Extractor to maintain state across +/// extractions. In this case you can provide your own Extractor through a +/// secondary constructor. The following examples show various ways of +/// creating a VarStreamArray. +/// +/// // Will use VarStreamArrayExtractor<MyType> as the extractor. +/// VarStreamArray<MyType> MyTypeArray; +/// +/// // Will use a default-constructed MyExtractor as the extractor. +/// VarStreamArray<MyType, MyExtractor> MyTypeArray2; +/// +/// // Will use the specific instance of MyExtractor provided. +/// // MyExtractor need not be default-constructible in this case. +/// MyExtractor E(SomeContext); +/// VarStreamArray<MyType, MyExtractor> MyTypeArray3(E); +/// + +template <typename ValueType, typename Extractor> class VarStreamArrayIterator; + +template <typename ValueType, + typename Extractor = VarStreamArrayExtractor<ValueType>> +class VarStreamArray { + friend class VarStreamArrayIterator<ValueType, Extractor>; + +public: + typedef VarStreamArrayIterator<ValueType, Extractor> Iterator; + + VarStreamArray() = default; + + explicit VarStreamArray(const Extractor &E) : E(E) {} + + explicit VarStreamArray(BinaryStreamRef Stream) : Stream(Stream) {} - static Error extract(BinaryStreamRef Stream, uint32_t &Len, T &Item, - const ContextType &Ctx) = delete; + VarStreamArray(BinaryStreamRef Stream, const Extractor &E) + : Stream(Stream), E(E) {} + + Iterator begin(bool *HadError = nullptr) const { + return Iterator(*this, E, HadError); + } + + bool valid() const { return Stream.valid(); } + + Iterator end() const { return Iterator(E); } + + bool empty() const { return Stream.getLength() == 0; } + + /// \brief given an offset into the array's underlying stream, return an + /// iterator to the record at that offset. This is considered unsafe + /// since the behavior is undefined if \p Offset does not refer to the + /// beginning of a valid record. + Iterator at(uint32_t Offset) const { + return Iterator(*this, E, Offset, nullptr); + } + + const Extractor &getExtractor() const { return E; } + Extractor &getExtractor() { return E; } + + BinaryStreamRef getUnderlyingStream() const { return Stream; } + void setUnderlyingStream(BinaryStreamRef S) { Stream = S; } + +private: + BinaryStreamRef Stream; + Extractor E; }; -template <typename ArrayType, typename Value, typename Extractor, - typename WrappedCtx> +template <typename ValueType, typename Extractor> class VarStreamArrayIterator - : public iterator_facade_base< - VarStreamArrayIterator<ArrayType, Value, Extractor, WrappedCtx>, - std::forward_iterator_tag, Value> { - typedef VarStreamArrayIterator<ArrayType, Value, Extractor, WrappedCtx> - IterType; + : public iterator_facade_base<VarStreamArrayIterator<ValueType, Extractor>, + std::forward_iterator_tag, ValueType> { + typedef VarStreamArrayIterator<ValueType, Extractor> IterType; + typedef VarStreamArray<ValueType, Extractor> ArrayType; public: - VarStreamArrayIterator() = default; - VarStreamArrayIterator(const ArrayType &Array, const WrappedCtx &Ctx, - BinaryStreamRef Stream, bool *HadError = nullptr, - uint32_t Offset = 0) - : IterRef(Stream), Ctx(&Ctx), Array(&Array), AbsOffset(Offset), - HadError(HadError) { + VarStreamArrayIterator(const ArrayType &Array, const Extractor &E, + bool *HadError) + : VarStreamArrayIterator(Array, E, 0, HadError) {} + + VarStreamArrayIterator(const ArrayType &Array, const Extractor &E, + uint32_t Offset, bool *HadError) + : IterRef(Array.Stream.drop_front(Offset)), Extract(E), + Array(&Array), AbsOffset(Offset), HadError(HadError) { if (IterRef.getLength() == 0) moveToEnd(); else { - auto EC = Ctx.template invoke<Extractor>(IterRef, ThisLen, ThisValue); + auto EC = Extract(IterRef, ThisLen, ThisValue); if (EC) { consumeError(std::move(EC)); markError(); @@ -79,13 +157,8 @@ public: } } - VarStreamArrayIterator(const ArrayType &Array, const WrappedCtx &Ctx, - bool *HadError = nullptr) - : VarStreamArrayIterator(Array, Ctx, Array.Stream, HadError) {} - - VarStreamArrayIterator(const WrappedCtx &Ctx) : Ctx(&Ctx) {} - VarStreamArrayIterator(const VarStreamArrayIterator &Other) = default; - + VarStreamArrayIterator() = default; + explicit VarStreamArrayIterator(const Extractor &E) : Extract(E) {} ~VarStreamArrayIterator() = default; bool operator==(const IterType &R) const { @@ -103,12 +176,12 @@ public: return false; } - const Value &operator*() const { + const ValueType &operator*() const { assert(Array && !HasError); return ThisValue; } - Value &operator*() { + ValueType &operator*() { assert(Array && !HasError); return ThisValue; } @@ -125,7 +198,7 @@ public: moveToEnd(); } else { // There is some data after the current record. - auto EC = Ctx->template invoke<Extractor>(IterRef, ThisLen, ThisValue); + auto EC = Extract(IterRef, ThisLen, ThisValue); if (EC) { consumeError(std::move(EC)); markError(); @@ -153,9 +226,9 @@ private: *HadError = true; } - Value ThisValue; + ValueType ThisValue; BinaryStreamRef IterRef; - const WrappedCtx *Ctx{nullptr}; + Extractor Extract; const ArrayType *Array{nullptr}; uint32_t ThisLen{0}; uint32_t AbsOffset{0}; @@ -163,127 +236,6 @@ private: bool *HadError{nullptr}; }; -template <typename T, typename Context> struct ContextWrapper { - ContextWrapper() = default; - - explicit ContextWrapper(Context &&Ctx) : Ctx(Ctx) {} - - template <typename Extractor> - Error invoke(BinaryStreamRef Stream, uint32_t &Len, T &Item) const { - return Extractor::extract(Stream, Len, Item, Ctx); - } - - Context Ctx; -}; - -template <typename T> struct ContextWrapper<T, void> { - ContextWrapper() = default; - - template <typename Extractor> - Error invoke(BinaryStreamRef Stream, uint32_t &Len, T &Item) const { - return Extractor::extract(Stream, Len, Item); - } -}; - -/// VarStreamArray represents an array of variable length records backed by a -/// stream. This could be a contiguous sequence of bytes in memory, it could -/// be a file on disk, or it could be a PDB stream where bytes are stored as -/// discontiguous blocks in a file. Usually it is desirable to treat arrays -/// as contiguous blocks of memory, but doing so with large PDB files, for -/// example, could mean allocating huge amounts of memory just to allow -/// re-ordering of stream data to be contiguous before iterating over it. By -/// abstracting this out, we need not duplicate this memory, and we can -/// iterate over arrays in arbitrarily formatted streams. Elements are parsed -/// lazily on iteration, so there is no upfront cost associated with building -/// or copying a VarStreamArray, no matter how large it may be. -/// -/// You create a VarStreamArray by specifying a ValueType and an Extractor type. -/// If you do not specify an Extractor type, you are expected to specialize -/// VarStreamArrayExtractor<T> for your ValueType. -/// -/// The default extractor type is stateless, but by specializing -/// VarStreamArrayExtractor or defining your own custom extractor type and -/// adding the appropriate ContextType typedef to the class, you can pass a -/// context field during construction of the VarStreamArray that will be -/// passed to each call to extract. -/// -template <typename Value, typename Extractor, typename WrappedCtx> -class VarStreamArrayBase { - typedef VarStreamArrayBase<Value, Extractor, WrappedCtx> MyType; - -public: - typedef VarStreamArrayIterator<MyType, Value, Extractor, WrappedCtx> Iterator; - friend Iterator; - - VarStreamArrayBase() = default; - - VarStreamArrayBase(BinaryStreamRef Stream, const WrappedCtx &Ctx) - : Stream(Stream), Ctx(Ctx) {} - - VarStreamArrayBase(const MyType &Other) - : Stream(Other.Stream), Ctx(Other.Ctx) {} - - Iterator begin(bool *HadError = nullptr) const { - if (empty()) - return end(); - - return Iterator(*this, Ctx, Stream, HadError); - } - - bool valid() const { return Stream.valid(); } - - Iterator end() const { return Iterator(Ctx); } - - bool empty() const { return Stream.getLength() == 0; } - - /// \brief given an offset into the array's underlying stream, return an - /// iterator to the record at that offset. This is considered unsafe - /// since the behavior is undefined if \p Offset does not refer to the - /// beginning of a valid record. - Iterator at(uint32_t Offset) const { - return Iterator(*this, Ctx, Stream.drop_front(Offset), nullptr, Offset); - } - - BinaryStreamRef getUnderlyingStream() const { return Stream; } - -private: - BinaryStreamRef Stream; - WrappedCtx Ctx; -}; - -template <typename Value, typename Extractor, typename Context> -class VarStreamArrayImpl - : public VarStreamArrayBase<Value, Extractor, - ContextWrapper<Value, Context>> { - typedef ContextWrapper<Value, Context> WrappedContext; - typedef VarStreamArrayImpl<Value, Extractor, Context> MyType; - typedef VarStreamArrayBase<Value, Extractor, WrappedContext> BaseType; - -public: - typedef Context ContextType; - - VarStreamArrayImpl() = default; - VarStreamArrayImpl(BinaryStreamRef Stream, Context &&Ctx) - : BaseType(Stream, WrappedContext(std::forward<Context>(Ctx))) {} -}; - -template <typename Value, typename Extractor> -class VarStreamArrayImpl<Value, Extractor, void> - : public VarStreamArrayBase<Value, Extractor, ContextWrapper<Value, void>> { - typedef ContextWrapper<Value, void> WrappedContext; - typedef VarStreamArrayImpl<Value, Extractor, void> MyType; - typedef VarStreamArrayBase<Value, Extractor, WrappedContext> BaseType; - -public: - VarStreamArrayImpl() = default; - VarStreamArrayImpl(BinaryStreamRef Stream) - : BaseType(Stream, WrappedContext()) {} -}; - -template <typename Value, typename Extractor = VarStreamArrayExtractor<Value>> -using VarStreamArray = - VarStreamArrayImpl<Value, Extractor, typename Extractor::ContextType>; - template <typename T> class FixedStreamArrayIterator; /// FixedStreamArray is similar to VarStreamArray, except with each record diff --git a/include/llvm/Support/BinaryStreamReader.h b/include/llvm/Support/BinaryStreamReader.h index 29e8a2ab08aad..738c042add3e3 100644 --- a/include/llvm/Support/BinaryStreamReader.h +++ b/include/llvm/Support/BinaryStreamReader.h @@ -198,25 +198,7 @@ public: BinaryStreamRef S; if (auto EC = readStreamRef(S, Size)) return EC; - Array = VarStreamArray<T, U>(S); - return Error::success(); - } - - /// Read a VarStreamArray of size \p Size bytes and store the result into - /// \p Array. Updates the stream's offset to point after the newly read - /// array. Never causes a copy (although iterating the elements of the - /// VarStreamArray may, depending upon the implementation of the underlying - /// stream). - /// - /// \returns a success error code if the data was successfully read, otherwise - /// returns an appropriate error code. - template <typename T, typename U, typename ContextType> - Error readArray(VarStreamArray<T, U> &Array, uint32_t Size, - ContextType &&Context) { - BinaryStreamRef S; - if (auto EC = readStreamRef(S, Size)) - return EC; - Array = VarStreamArray<T, U>(S, std::move(Context)); + Array.setUnderlyingStream(S); return Error::success(); } diff --git a/include/llvm/Support/CBindingWrapping.h b/include/llvm/Support/CBindingWrapping.h index d4633aa7d3c6c..f60f99d376ad4 100644 --- a/include/llvm/Support/CBindingWrapping.h +++ b/include/llvm/Support/CBindingWrapping.h @@ -14,8 +14,8 @@ #ifndef LLVM_SUPPORT_CBINDINGWRAPPING_H #define LLVM_SUPPORT_CBINDINGWRAPPING_H -#include "llvm/Support/Casting.h" #include "llvm-c/Types.h" +#include "llvm/Support/Casting.h" #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ inline ty *unwrap(ref P) { \ diff --git a/include/llvm/Support/COFF.h b/include/llvm/Support/COFF.h deleted file mode 100644 index bc2098e2b5cf6..0000000000000 --- a/include/llvm/Support/COFF.h +++ /dev/null @@ -1,724 +0,0 @@ -//===-- llvm/Support/COFF.h -------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains an definitions used in Windows COFF Files. -// -// Structures and enums defined within this file where created using -// information from Microsoft's publicly available PE/COFF format document: -// -// Microsoft Portable Executable and Common Object File Format Specification -// Revision 8.1 - February 15, 2008 -// -// As of 5/2/2010, hosted by Microsoft at: -// http://www.microsoft.com/whdc/system/platform/firmware/pecoff.mspx -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_COFF_H -#define LLVM_SUPPORT_COFF_H - -#include "llvm/Support/DataTypes.h" -#include <cassert> -#include <cstring> - -namespace llvm { -namespace COFF { - - // The maximum number of sections that a COFF object can have (inclusive). - const int32_t MaxNumberOfSections16 = 65279; - - // The PE signature bytes that follows the DOS stub header. - static const char PEMagic[] = { 'P', 'E', '\0', '\0' }; - - static const char BigObjMagic[] = { - '\xc7', '\xa1', '\xba', '\xd1', '\xee', '\xba', '\xa9', '\x4b', - '\xaf', '\x20', '\xfa', '\xf6', '\x6a', '\xa4', '\xdc', '\xb8', - }; - - static const char ClGlObjMagic[] = { - '\x38', '\xfe', '\xb3', '\x0c', '\xa5', '\xd9', '\xab', '\x4d', - '\xac', '\x9b', '\xd6', '\xb6', '\x22', '\x26', '\x53', '\xc2', - }; - - // Sizes in bytes of various things in the COFF format. - enum { - Header16Size = 20, - Header32Size = 56, - NameSize = 8, - Symbol16Size = 18, - Symbol32Size = 20, - SectionSize = 40, - RelocationSize = 10 - }; - - struct header { - uint16_t Machine; - int32_t NumberOfSections; - uint32_t TimeDateStamp; - uint32_t PointerToSymbolTable; - uint32_t NumberOfSymbols; - uint16_t SizeOfOptionalHeader; - uint16_t Characteristics; - }; - - struct BigObjHeader { - enum : uint16_t { MinBigObjectVersion = 2 }; - - uint16_t Sig1; ///< Must be IMAGE_FILE_MACHINE_UNKNOWN (0). - uint16_t Sig2; ///< Must be 0xFFFF. - uint16_t Version; - uint16_t Machine; - uint32_t TimeDateStamp; - uint8_t UUID[16]; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t NumberOfSections; - uint32_t PointerToSymbolTable; - uint32_t NumberOfSymbols; - }; - - enum MachineTypes { - MT_Invalid = 0xffff, - - IMAGE_FILE_MACHINE_UNKNOWN = 0x0, - IMAGE_FILE_MACHINE_AM33 = 0x13, - IMAGE_FILE_MACHINE_AMD64 = 0x8664, - IMAGE_FILE_MACHINE_ARM = 0x1C0, - IMAGE_FILE_MACHINE_ARMNT = 0x1C4, - IMAGE_FILE_MACHINE_ARM64 = 0xAA64, - IMAGE_FILE_MACHINE_EBC = 0xEBC, - IMAGE_FILE_MACHINE_I386 = 0x14C, - IMAGE_FILE_MACHINE_IA64 = 0x200, - IMAGE_FILE_MACHINE_M32R = 0x9041, - IMAGE_FILE_MACHINE_MIPS16 = 0x266, - IMAGE_FILE_MACHINE_MIPSFPU = 0x366, - IMAGE_FILE_MACHINE_MIPSFPU16 = 0x466, - IMAGE_FILE_MACHINE_POWERPC = 0x1F0, - IMAGE_FILE_MACHINE_POWERPCFP = 0x1F1, - IMAGE_FILE_MACHINE_R4000 = 0x166, - IMAGE_FILE_MACHINE_SH3 = 0x1A2, - IMAGE_FILE_MACHINE_SH3DSP = 0x1A3, - IMAGE_FILE_MACHINE_SH4 = 0x1A6, - IMAGE_FILE_MACHINE_SH5 = 0x1A8, - IMAGE_FILE_MACHINE_THUMB = 0x1C2, - IMAGE_FILE_MACHINE_WCEMIPSV2 = 0x169 - }; - - enum Characteristics { - C_Invalid = 0, - - /// The file does not contain base relocations and must be loaded at its - /// preferred base. If this cannot be done, the loader will error. - IMAGE_FILE_RELOCS_STRIPPED = 0x0001, - /// The file is valid and can be run. - IMAGE_FILE_EXECUTABLE_IMAGE = 0x0002, - /// COFF line numbers have been stripped. This is deprecated and should be - /// 0. - IMAGE_FILE_LINE_NUMS_STRIPPED = 0x0004, - /// COFF symbol table entries for local symbols have been removed. This is - /// deprecated and should be 0. - IMAGE_FILE_LOCAL_SYMS_STRIPPED = 0x0008, - /// Aggressively trim working set. This is deprecated and must be 0. - IMAGE_FILE_AGGRESSIVE_WS_TRIM = 0x0010, - /// Image can handle > 2GiB addresses. - IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x0020, - /// Little endian: the LSB precedes the MSB in memory. This is deprecated - /// and should be 0. - IMAGE_FILE_BYTES_REVERSED_LO = 0x0080, - /// Machine is based on a 32bit word architecture. - IMAGE_FILE_32BIT_MACHINE = 0x0100, - /// Debugging info has been removed. - IMAGE_FILE_DEBUG_STRIPPED = 0x0200, - /// If the image is on removable media, fully load it and copy it to swap. - IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP = 0x0400, - /// If the image is on network media, fully load it and copy it to swap. - IMAGE_FILE_NET_RUN_FROM_SWAP = 0x0800, - /// The image file is a system file, not a user program. - IMAGE_FILE_SYSTEM = 0x1000, - /// The image file is a DLL. - IMAGE_FILE_DLL = 0x2000, - /// This file should only be run on a uniprocessor machine. - IMAGE_FILE_UP_SYSTEM_ONLY = 0x4000, - /// Big endian: the MSB precedes the LSB in memory. This is deprecated - /// and should be 0. - IMAGE_FILE_BYTES_REVERSED_HI = 0x8000 - }; - - enum ResourceTypeID { - RID_Cursor = 1, - RID_Bitmap = 2, - RID_Icon = 3, - RID_Menu = 4, - RID_Dialog = 5, - RID_String = 6, - RID_FontDir = 7, - RID_Font = 8, - RID_Accelerator = 9, - RID_RCData = 10, - RID_MessageTable = 11, - RID_Group_Cursor = 12, - RID_Group_Icon = 14, - RID_Version = 16, - RID_DLGInclude = 17, - RID_PlugPlay = 19, - RID_VXD = 20, - RID_AniCursor = 21, - RID_AniIcon = 22, - RID_HTML = 23, - RID_Manifest = 24, - }; - - struct symbol { - char Name[NameSize]; - uint32_t Value; - int32_t SectionNumber; - uint16_t Type; - uint8_t StorageClass; - uint8_t NumberOfAuxSymbols; - }; - - enum SymbolSectionNumber : int32_t { - IMAGE_SYM_DEBUG = -2, - IMAGE_SYM_ABSOLUTE = -1, - IMAGE_SYM_UNDEFINED = 0 - }; - - /// Storage class tells where and what the symbol represents - enum SymbolStorageClass { - SSC_Invalid = 0xff, - - IMAGE_SYM_CLASS_END_OF_FUNCTION = -1, ///< Physical end of function - IMAGE_SYM_CLASS_NULL = 0, ///< No symbol - IMAGE_SYM_CLASS_AUTOMATIC = 1, ///< Stack variable - IMAGE_SYM_CLASS_EXTERNAL = 2, ///< External symbol - IMAGE_SYM_CLASS_STATIC = 3, ///< Static - IMAGE_SYM_CLASS_REGISTER = 4, ///< Register variable - IMAGE_SYM_CLASS_EXTERNAL_DEF = 5, ///< External definition - IMAGE_SYM_CLASS_LABEL = 6, ///< Label - IMAGE_SYM_CLASS_UNDEFINED_LABEL = 7, ///< Undefined label - IMAGE_SYM_CLASS_MEMBER_OF_STRUCT = 8, ///< Member of structure - IMAGE_SYM_CLASS_ARGUMENT = 9, ///< Function argument - IMAGE_SYM_CLASS_STRUCT_TAG = 10, ///< Structure tag - IMAGE_SYM_CLASS_MEMBER_OF_UNION = 11, ///< Member of union - IMAGE_SYM_CLASS_UNION_TAG = 12, ///< Union tag - IMAGE_SYM_CLASS_TYPE_DEFINITION = 13, ///< Type definition - IMAGE_SYM_CLASS_UNDEFINED_STATIC = 14, ///< Undefined static - IMAGE_SYM_CLASS_ENUM_TAG = 15, ///< Enumeration tag - IMAGE_SYM_CLASS_MEMBER_OF_ENUM = 16, ///< Member of enumeration - IMAGE_SYM_CLASS_REGISTER_PARAM = 17, ///< Register parameter - IMAGE_SYM_CLASS_BIT_FIELD = 18, ///< Bit field - /// ".bb" or ".eb" - beginning or end of block - IMAGE_SYM_CLASS_BLOCK = 100, - /// ".bf" or ".ef" - beginning or end of function - IMAGE_SYM_CLASS_FUNCTION = 101, - IMAGE_SYM_CLASS_END_OF_STRUCT = 102, ///< End of structure - IMAGE_SYM_CLASS_FILE = 103, ///< File name - /// Line number, reformatted as symbol - IMAGE_SYM_CLASS_SECTION = 104, - IMAGE_SYM_CLASS_WEAK_EXTERNAL = 105, ///< Duplicate tag - /// External symbol in dmert public lib - IMAGE_SYM_CLASS_CLR_TOKEN = 107 - }; - - enum SymbolBaseType { - IMAGE_SYM_TYPE_NULL = 0, ///< No type information or unknown base type. - IMAGE_SYM_TYPE_VOID = 1, ///< Used with void pointers and functions. - IMAGE_SYM_TYPE_CHAR = 2, ///< A character (signed byte). - IMAGE_SYM_TYPE_SHORT = 3, ///< A 2-byte signed integer. - IMAGE_SYM_TYPE_INT = 4, ///< A natural integer type on the target. - IMAGE_SYM_TYPE_LONG = 5, ///< A 4-byte signed integer. - IMAGE_SYM_TYPE_FLOAT = 6, ///< A 4-byte floating-point number. - IMAGE_SYM_TYPE_DOUBLE = 7, ///< An 8-byte floating-point number. - IMAGE_SYM_TYPE_STRUCT = 8, ///< A structure. - IMAGE_SYM_TYPE_UNION = 9, ///< An union. - IMAGE_SYM_TYPE_ENUM = 10, ///< An enumerated type. - IMAGE_SYM_TYPE_MOE = 11, ///< A member of enumeration (a specific value). - IMAGE_SYM_TYPE_BYTE = 12, ///< A byte; unsigned 1-byte integer. - IMAGE_SYM_TYPE_WORD = 13, ///< A word; unsigned 2-byte integer. - IMAGE_SYM_TYPE_UINT = 14, ///< An unsigned integer of natural size. - IMAGE_SYM_TYPE_DWORD = 15 ///< An unsigned 4-byte integer. - }; - - enum SymbolComplexType { - IMAGE_SYM_DTYPE_NULL = 0, ///< No complex type; simple scalar variable. - IMAGE_SYM_DTYPE_POINTER = 1, ///< A pointer to base type. - IMAGE_SYM_DTYPE_FUNCTION = 2, ///< A function that returns a base type. - IMAGE_SYM_DTYPE_ARRAY = 3, ///< An array of base type. - - /// Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT)) - SCT_COMPLEX_TYPE_SHIFT = 4 - }; - - enum AuxSymbolType { - IMAGE_AUX_SYMBOL_TYPE_TOKEN_DEF = 1 - }; - - struct section { - char Name[NameSize]; - uint32_t VirtualSize; - uint32_t VirtualAddress; - uint32_t SizeOfRawData; - uint32_t PointerToRawData; - uint32_t PointerToRelocations; - uint32_t PointerToLineNumbers; - uint16_t NumberOfRelocations; - uint16_t NumberOfLineNumbers; - uint32_t Characteristics; - }; - - enum SectionCharacteristics : uint32_t { - SC_Invalid = 0xffffffff, - - IMAGE_SCN_TYPE_NOLOAD = 0x00000002, - IMAGE_SCN_TYPE_NO_PAD = 0x00000008, - IMAGE_SCN_CNT_CODE = 0x00000020, - IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040, - IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080, - IMAGE_SCN_LNK_OTHER = 0x00000100, - IMAGE_SCN_LNK_INFO = 0x00000200, - IMAGE_SCN_LNK_REMOVE = 0x00000800, - IMAGE_SCN_LNK_COMDAT = 0x00001000, - IMAGE_SCN_GPREL = 0x00008000, - IMAGE_SCN_MEM_PURGEABLE = 0x00020000, - IMAGE_SCN_MEM_16BIT = 0x00020000, - IMAGE_SCN_MEM_LOCKED = 0x00040000, - IMAGE_SCN_MEM_PRELOAD = 0x00080000, - IMAGE_SCN_ALIGN_1BYTES = 0x00100000, - IMAGE_SCN_ALIGN_2BYTES = 0x00200000, - IMAGE_SCN_ALIGN_4BYTES = 0x00300000, - IMAGE_SCN_ALIGN_8BYTES = 0x00400000, - IMAGE_SCN_ALIGN_16BYTES = 0x00500000, - IMAGE_SCN_ALIGN_32BYTES = 0x00600000, - IMAGE_SCN_ALIGN_64BYTES = 0x00700000, - IMAGE_SCN_ALIGN_128BYTES = 0x00800000, - IMAGE_SCN_ALIGN_256BYTES = 0x00900000, - IMAGE_SCN_ALIGN_512BYTES = 0x00A00000, - IMAGE_SCN_ALIGN_1024BYTES = 0x00B00000, - IMAGE_SCN_ALIGN_2048BYTES = 0x00C00000, - IMAGE_SCN_ALIGN_4096BYTES = 0x00D00000, - IMAGE_SCN_ALIGN_8192BYTES = 0x00E00000, - IMAGE_SCN_LNK_NRELOC_OVFL = 0x01000000, - IMAGE_SCN_MEM_DISCARDABLE = 0x02000000, - IMAGE_SCN_MEM_NOT_CACHED = 0x04000000, - IMAGE_SCN_MEM_NOT_PAGED = 0x08000000, - IMAGE_SCN_MEM_SHARED = 0x10000000, - IMAGE_SCN_MEM_EXECUTE = 0x20000000, - IMAGE_SCN_MEM_READ = 0x40000000, - IMAGE_SCN_MEM_WRITE = 0x80000000 - }; - - struct relocation { - uint32_t VirtualAddress; - uint32_t SymbolTableIndex; - uint16_t Type; - }; - - enum RelocationTypeI386 { - IMAGE_REL_I386_ABSOLUTE = 0x0000, - IMAGE_REL_I386_DIR16 = 0x0001, - IMAGE_REL_I386_REL16 = 0x0002, - IMAGE_REL_I386_DIR32 = 0x0006, - IMAGE_REL_I386_DIR32NB = 0x0007, - IMAGE_REL_I386_SEG12 = 0x0009, - IMAGE_REL_I386_SECTION = 0x000A, - IMAGE_REL_I386_SECREL = 0x000B, - IMAGE_REL_I386_TOKEN = 0x000C, - IMAGE_REL_I386_SECREL7 = 0x000D, - IMAGE_REL_I386_REL32 = 0x0014 - }; - - enum RelocationTypeAMD64 { - IMAGE_REL_AMD64_ABSOLUTE = 0x0000, - IMAGE_REL_AMD64_ADDR64 = 0x0001, - IMAGE_REL_AMD64_ADDR32 = 0x0002, - IMAGE_REL_AMD64_ADDR32NB = 0x0003, - IMAGE_REL_AMD64_REL32 = 0x0004, - IMAGE_REL_AMD64_REL32_1 = 0x0005, - IMAGE_REL_AMD64_REL32_2 = 0x0006, - IMAGE_REL_AMD64_REL32_3 = 0x0007, - IMAGE_REL_AMD64_REL32_4 = 0x0008, - IMAGE_REL_AMD64_REL32_5 = 0x0009, - IMAGE_REL_AMD64_SECTION = 0x000A, - IMAGE_REL_AMD64_SECREL = 0x000B, - IMAGE_REL_AMD64_SECREL7 = 0x000C, - IMAGE_REL_AMD64_TOKEN = 0x000D, - IMAGE_REL_AMD64_SREL32 = 0x000E, - IMAGE_REL_AMD64_PAIR = 0x000F, - IMAGE_REL_AMD64_SSPAN32 = 0x0010 - }; - - enum RelocationTypesARM { - IMAGE_REL_ARM_ABSOLUTE = 0x0000, - IMAGE_REL_ARM_ADDR32 = 0x0001, - IMAGE_REL_ARM_ADDR32NB = 0x0002, - IMAGE_REL_ARM_BRANCH24 = 0x0003, - IMAGE_REL_ARM_BRANCH11 = 0x0004, - IMAGE_REL_ARM_TOKEN = 0x0005, - IMAGE_REL_ARM_BLX24 = 0x0008, - IMAGE_REL_ARM_BLX11 = 0x0009, - IMAGE_REL_ARM_SECTION = 0x000E, - IMAGE_REL_ARM_SECREL = 0x000F, - IMAGE_REL_ARM_MOV32A = 0x0010, - IMAGE_REL_ARM_MOV32T = 0x0011, - IMAGE_REL_ARM_BRANCH20T = 0x0012, - IMAGE_REL_ARM_BRANCH24T = 0x0014, - IMAGE_REL_ARM_BLX23T = 0x0015 - }; - - enum RelocationTypesARM64 { - IMAGE_REL_ARM64_ABSOLUTE = 0x0000, - IMAGE_REL_ARM64_ADDR32 = 0x0001, - IMAGE_REL_ARM64_ADDR32NB = 0x0002, - IMAGE_REL_ARM64_BRANCH26 = 0x0003, - IMAGE_REL_ARM64_PAGEBASE_REL2 = 0x0004, - IMAGE_REL_ARM64_REL21 = 0x0005, - IMAGE_REL_ARM64_PAGEOFFSET_12A = 0x0006, - IMAGE_REL_ARM64_PAGEOFFSET_12L = 0x0007, - IMAGE_REL_ARM64_SECREL = 0x0008, - IMAGE_REL_ARM64_SECREL_LOW12A = 0x0009, - IMAGE_REL_ARM64_SECREL_HIGH12A = 0x000A, - IMAGE_REL_ARM64_SECREL_LOW12L = 0x000B, - IMAGE_REL_ARM64_TOKEN = 0x000C, - IMAGE_REL_ARM64_SECTION = 0x000D, - IMAGE_REL_ARM64_ADDR64 = 0x000E, - IMAGE_REL_ARM64_BRANCH19 = 0x000F, - IMAGE_REL_ARM64_BRANCH14 = 0x0010, - }; - - enum COMDATType { - IMAGE_COMDAT_SELECT_NODUPLICATES = 1, - IMAGE_COMDAT_SELECT_ANY, - IMAGE_COMDAT_SELECT_SAME_SIZE, - IMAGE_COMDAT_SELECT_EXACT_MATCH, - IMAGE_COMDAT_SELECT_ASSOCIATIVE, - IMAGE_COMDAT_SELECT_LARGEST, - IMAGE_COMDAT_SELECT_NEWEST - }; - - // Auxiliary Symbol Formats - struct AuxiliaryFunctionDefinition { - uint32_t TagIndex; - uint32_t TotalSize; - uint32_t PointerToLinenumber; - uint32_t PointerToNextFunction; - char unused[2]; - }; - - struct AuxiliarybfAndefSymbol { - uint8_t unused1[4]; - uint16_t Linenumber; - uint8_t unused2[6]; - uint32_t PointerToNextFunction; - uint8_t unused3[2]; - }; - - struct AuxiliaryWeakExternal { - uint32_t TagIndex; - uint32_t Characteristics; - uint8_t unused[10]; - }; - - enum WeakExternalCharacteristics { - IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY = 1, - IMAGE_WEAK_EXTERN_SEARCH_LIBRARY = 2, - IMAGE_WEAK_EXTERN_SEARCH_ALIAS = 3 - }; - - struct AuxiliarySectionDefinition { - uint32_t Length; - uint16_t NumberOfRelocations; - uint16_t NumberOfLinenumbers; - uint32_t CheckSum; - uint32_t Number; - uint8_t Selection; - char unused; - }; - - struct AuxiliaryCLRToken { - uint8_t AuxType; - uint8_t unused1; - uint32_t SymbolTableIndex; - char unused2[12]; - }; - - union Auxiliary { - AuxiliaryFunctionDefinition FunctionDefinition; - AuxiliarybfAndefSymbol bfAndefSymbol; - AuxiliaryWeakExternal WeakExternal; - AuxiliarySectionDefinition SectionDefinition; - }; - - /// @brief The Import Directory Table. - /// - /// There is a single array of these and one entry per imported DLL. - struct ImportDirectoryTableEntry { - uint32_t ImportLookupTableRVA; - uint32_t TimeDateStamp; - uint32_t ForwarderChain; - uint32_t NameRVA; - uint32_t ImportAddressTableRVA; - }; - - /// @brief The PE32 Import Lookup Table. - /// - /// There is an array of these for each imported DLL. It represents either - /// the ordinal to import from the target DLL, or a name to lookup and import - /// from the target DLL. - /// - /// This also happens to be the same format used by the Import Address Table - /// when it is initially written out to the image. - struct ImportLookupTableEntry32 { - uint32_t data; - - /// @brief Is this entry specified by ordinal, or name? - bool isOrdinal() const { return data & 0x80000000; } - - /// @brief Get the ordinal value of this entry. isOrdinal must be true. - uint16_t getOrdinal() const { - assert(isOrdinal() && "ILT entry is not an ordinal!"); - return data & 0xFFFF; - } - - /// @brief Set the ordinal value and set isOrdinal to true. - void setOrdinal(uint16_t o) { - data = o; - data |= 0x80000000; - } - - /// @brief Get the Hint/Name entry RVA. isOrdinal must be false. - uint32_t getHintNameRVA() const { - assert(!isOrdinal() && "ILT entry is not a Hint/Name RVA!"); - return data; - } - - /// @brief Set the Hint/Name entry RVA and set isOrdinal to false. - void setHintNameRVA(uint32_t rva) { data = rva; } - }; - - /// @brief The DOS compatible header at the front of all PEs. - struct DOSHeader { - uint16_t Magic; - uint16_t UsedBytesInTheLastPage; - uint16_t FileSizeInPages; - uint16_t NumberOfRelocationItems; - uint16_t HeaderSizeInParagraphs; - uint16_t MinimumExtraParagraphs; - uint16_t MaximumExtraParagraphs; - uint16_t InitialRelativeSS; - uint16_t InitialSP; - uint16_t Checksum; - uint16_t InitialIP; - uint16_t InitialRelativeCS; - uint16_t AddressOfRelocationTable; - uint16_t OverlayNumber; - uint16_t Reserved[4]; - uint16_t OEMid; - uint16_t OEMinfo; - uint16_t Reserved2[10]; - uint32_t AddressOfNewExeHeader; - }; - - struct PE32Header { - enum { - PE32 = 0x10b, - PE32_PLUS = 0x20b - }; - - uint16_t Magic; - uint8_t MajorLinkerVersion; - uint8_t MinorLinkerVersion; - uint32_t SizeOfCode; - uint32_t SizeOfInitializedData; - uint32_t SizeOfUninitializedData; - uint32_t AddressOfEntryPoint; // RVA - uint32_t BaseOfCode; // RVA - uint32_t BaseOfData; // RVA - uint32_t ImageBase; - uint32_t SectionAlignment; - uint32_t FileAlignment; - uint16_t MajorOperatingSystemVersion; - uint16_t MinorOperatingSystemVersion; - uint16_t MajorImageVersion; - uint16_t MinorImageVersion; - uint16_t MajorSubsystemVersion; - uint16_t MinorSubsystemVersion; - uint32_t Win32VersionValue; - uint32_t SizeOfImage; - uint32_t SizeOfHeaders; - uint32_t CheckSum; - uint16_t Subsystem; - // FIXME: This should be DllCharacteristics to match the COFF spec. - uint16_t DLLCharacteristics; - uint32_t SizeOfStackReserve; - uint32_t SizeOfStackCommit; - uint32_t SizeOfHeapReserve; - uint32_t SizeOfHeapCommit; - uint32_t LoaderFlags; - // FIXME: This should be NumberOfRvaAndSizes to match the COFF spec. - uint32_t NumberOfRvaAndSize; - }; - - struct DataDirectory { - uint32_t RelativeVirtualAddress; - uint32_t Size; - }; - - enum DataDirectoryIndex { - EXPORT_TABLE = 0, - IMPORT_TABLE, - RESOURCE_TABLE, - EXCEPTION_TABLE, - CERTIFICATE_TABLE, - BASE_RELOCATION_TABLE, - DEBUG_DIRECTORY, - ARCHITECTURE, - GLOBAL_PTR, - TLS_TABLE, - LOAD_CONFIG_TABLE, - BOUND_IMPORT, - IAT, - DELAY_IMPORT_DESCRIPTOR, - CLR_RUNTIME_HEADER, - - NUM_DATA_DIRECTORIES - }; - - enum WindowsSubsystem { - IMAGE_SUBSYSTEM_UNKNOWN = 0, ///< An unknown subsystem. - IMAGE_SUBSYSTEM_NATIVE = 1, ///< Device drivers and native Windows processes - IMAGE_SUBSYSTEM_WINDOWS_GUI = 2, ///< The Windows GUI subsystem. - IMAGE_SUBSYSTEM_WINDOWS_CUI = 3, ///< The Windows character subsystem. - IMAGE_SUBSYSTEM_OS2_CUI = 5, ///< The OS/2 character subsytem. - IMAGE_SUBSYSTEM_POSIX_CUI = 7, ///< The POSIX character subsystem. - IMAGE_SUBSYSTEM_NATIVE_WINDOWS = 8, ///< Native Windows 9x driver. - IMAGE_SUBSYSTEM_WINDOWS_CE_GUI = 9, ///< Windows CE. - IMAGE_SUBSYSTEM_EFI_APPLICATION = 10, ///< An EFI application. - IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER = 11, ///< An EFI driver with boot - /// services. - IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER = 12, ///< An EFI driver with run-time - /// services. - IMAGE_SUBSYSTEM_EFI_ROM = 13, ///< An EFI ROM image. - IMAGE_SUBSYSTEM_XBOX = 14, ///< XBOX. - IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16 ///< A BCD application. - }; - - enum DLLCharacteristics { - /// ASLR with 64 bit address space. - IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA = 0x0020, - /// DLL can be relocated at load time. - IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE = 0x0040, - /// Code integrity checks are enforced. - IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY = 0x0080, - ///< Image is NX compatible. - IMAGE_DLL_CHARACTERISTICS_NX_COMPAT = 0x0100, - /// Isolation aware, but do not isolate the image. - IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION = 0x0200, - /// Does not use structured exception handling (SEH). No SEH handler may be - /// called in this image. - IMAGE_DLL_CHARACTERISTICS_NO_SEH = 0x0400, - /// Do not bind the image. - IMAGE_DLL_CHARACTERISTICS_NO_BIND = 0x0800, - ///< Image should execute in an AppContainer. - IMAGE_DLL_CHARACTERISTICS_APPCONTAINER = 0x1000, - ///< A WDM driver. - IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER = 0x2000, - ///< Image supports Control Flow Guard. - IMAGE_DLL_CHARACTERISTICS_GUARD_CF = 0x4000, - /// Terminal Server aware. - IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000 - }; - - enum DebugType { - IMAGE_DEBUG_TYPE_UNKNOWN = 0, - IMAGE_DEBUG_TYPE_COFF = 1, - IMAGE_DEBUG_TYPE_CODEVIEW = 2, - IMAGE_DEBUG_TYPE_FPO = 3, - IMAGE_DEBUG_TYPE_MISC = 4, - IMAGE_DEBUG_TYPE_EXCEPTION = 5, - IMAGE_DEBUG_TYPE_FIXUP = 6, - IMAGE_DEBUG_TYPE_OMAP_TO_SRC = 7, - IMAGE_DEBUG_TYPE_OMAP_FROM_SRC = 8, - IMAGE_DEBUG_TYPE_BORLAND = 9, - IMAGE_DEBUG_TYPE_RESERVED10 = 10, - IMAGE_DEBUG_TYPE_CLSID = 11, - IMAGE_DEBUG_TYPE_VC_FEATURE = 12, - IMAGE_DEBUG_TYPE_POGO = 13, - IMAGE_DEBUG_TYPE_ILTCG = 14, - IMAGE_DEBUG_TYPE_MPX = 15, - IMAGE_DEBUG_TYPE_REPRO = 16, - }; - - enum BaseRelocationType { - IMAGE_REL_BASED_ABSOLUTE = 0, - IMAGE_REL_BASED_HIGH = 1, - IMAGE_REL_BASED_LOW = 2, - IMAGE_REL_BASED_HIGHLOW = 3, - IMAGE_REL_BASED_HIGHADJ = 4, - IMAGE_REL_BASED_MIPS_JMPADDR = 5, - IMAGE_REL_BASED_ARM_MOV32A = 5, - IMAGE_REL_BASED_ARM_MOV32T = 7, - IMAGE_REL_BASED_MIPS_JMPADDR16 = 9, - IMAGE_REL_BASED_DIR64 = 10 - }; - - enum ImportType { - IMPORT_CODE = 0, - IMPORT_DATA = 1, - IMPORT_CONST = 2 - }; - - enum ImportNameType { - /// Import is by ordinal. This indicates that the value in the Ordinal/Hint - /// field of the import header is the import's ordinal. If this constant is - /// not specified, then the Ordinal/Hint field should always be interpreted - /// as the import's hint. - IMPORT_ORDINAL = 0, - /// The import name is identical to the public symbol name - IMPORT_NAME = 1, - /// The import name is the public symbol name, but skipping the leading ?, - /// @, or optionally _. - IMPORT_NAME_NOPREFIX = 2, - /// The import name is the public symbol name, but skipping the leading ?, - /// @, or optionally _, and truncating at the first @. - IMPORT_NAME_UNDECORATE = 3 - }; - - struct ImportHeader { - uint16_t Sig1; ///< Must be IMAGE_FILE_MACHINE_UNKNOWN (0). - uint16_t Sig2; ///< Must be 0xFFFF. - uint16_t Version; - uint16_t Machine; - uint32_t TimeDateStamp; - uint32_t SizeOfData; - uint16_t OrdinalHint; - uint16_t TypeInfo; - - ImportType getType() const { - return static_cast<ImportType>(TypeInfo & 0x3); - } - - ImportNameType getNameType() const { - return static_cast<ImportNameType>((TypeInfo & 0x1C) >> 2); - } - }; - - enum CodeViewIdentifiers { - DEBUG_SECTION_MAGIC = 0x4, - }; - - inline bool isReservedSectionNumber(int32_t SectionNumber) { - return SectionNumber <= 0; - } - -} // End namespace COFF. -} // End namespace llvm. - -#endif diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h index 89d2af052dc16..baa2a814e9a16 100644 --- a/include/llvm/Support/Casting.h +++ b/include/llvm/Support/Casting.h @@ -1,4 +1,4 @@ -//===-- llvm/Support/Casting.h - Allow flexible, checked, casts -*- C++ -*-===// +//===- llvm/Support/Casting.h - Allow flexible, checked, casts --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -19,6 +19,7 @@ #include "llvm/Support/type_traits.h" #include <cassert> #include <memory> +#include <type_traits> namespace llvm { @@ -31,18 +32,19 @@ namespace llvm { // template selection process... the default implementation is a noop. // template<typename From> struct simplify_type { - typedef From SimpleType; // The real type this represents... + using SimpleType = From; // The real type this represents... // An accessor to get the real value... static SimpleType &getSimplifiedValue(From &Val) { return Val; } }; template<typename From> struct simplify_type<const From> { - typedef typename simplify_type<From>::SimpleType NonConstSimpleType; - typedef typename add_const_past_pointer<NonConstSimpleType>::type - SimpleType; - typedef typename add_lvalue_reference_if_not_pointer<SimpleType>::type - RetType; + using NonConstSimpleType = typename simplify_type<From>::SimpleType; + using SimpleType = + typename add_const_past_pointer<NonConstSimpleType>::type; + using RetType = + typename add_lvalue_reference_if_not_pointer<SimpleType>::type; + static RetType getSimplifiedValue(const From& Val) { return simplify_type<From>::getSimplifiedValue(const_cast<From&>(Val)); } @@ -148,36 +150,35 @@ template <class X, class Y> LLVM_NODISCARD inline bool isa(const Y &Val) { template<class To, class From> struct cast_retty; - // Calculate what type the 'cast' function should return, based on a requested // type of To and a source type of From. template<class To, class From> struct cast_retty_impl { - typedef To& ret_type; // Normal case, return Ty& + using ret_type = To &; // Normal case, return Ty& }; template<class To, class From> struct cast_retty_impl<To, const From> { - typedef const To &ret_type; // Normal case, return Ty& + using ret_type = const To &; // Normal case, return Ty& }; template<class To, class From> struct cast_retty_impl<To, From*> { - typedef To* ret_type; // Pointer arg case, return Ty* + using ret_type = To *; // Pointer arg case, return Ty* }; template<class To, class From> struct cast_retty_impl<To, const From*> { - typedef const To* ret_type; // Constant pointer arg case, return const Ty* + using ret_type = const To *; // Constant pointer arg case, return const Ty* }; template<class To, class From> struct cast_retty_impl<To, const From*const> { - typedef const To* ret_type; // Constant pointer arg case, return const Ty* + using ret_type = const To *; // Constant pointer arg case, return const Ty* }; template <class To, class From> struct cast_retty_impl<To, std::unique_ptr<From>> { private: - typedef typename cast_retty_impl<To, From *>::ret_type PointerType; - typedef typename std::remove_pointer<PointerType>::type ResultType; + using PointerType = typename cast_retty_impl<To, From *>::ret_type; + using ResultType = typename std::remove_pointer<PointerType>::type; public: - typedef std::unique_ptr<ResultType> ret_type; + using ret_type = std::unique_ptr<ResultType>; }; template<class To, class From, class SimpleFrom> @@ -185,19 +186,19 @@ struct cast_retty_wrap { // When the simplified type and the from type are not the same, use the type // simplifier to reduce the type, then reuse cast_retty_impl to get the // resultant type. - typedef typename cast_retty<To, SimpleFrom>::ret_type ret_type; + using ret_type = typename cast_retty<To, SimpleFrom>::ret_type; }; template<class To, class FromTy> struct cast_retty_wrap<To, FromTy, FromTy> { // When the simplified type is equal to the from type, use it directly. - typedef typename cast_retty_impl<To,FromTy>::ret_type ret_type; + using ret_type = typename cast_retty_impl<To,FromTy>::ret_type; }; template<class To, class From> struct cast_retty { - typedef typename cast_retty_wrap<To, From, - typename simplify_type<From>::SimpleType>::ret_type ret_type; + using ret_type = typename cast_retty_wrap< + To, From, typename simplify_type<From>::SimpleType>::ret_type; }; // Ensure the non-simple values are converted using the simplify_type template @@ -393,6 +394,6 @@ LLVM_NODISCARD inline auto unique_dyn_cast_or_null(std::unique_ptr<Y> &&Val) return unique_dyn_cast_or_null<X, Y>(Val); } -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_SUPPORT_CASTING_H diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index ae32e20d6daba..771b0a8c26a98 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -21,18 +21,19 @@ #define LLVM_SUPPORT_COMMANDLINE_H #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/iterator_range.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" #include <cassert> #include <climits> #include <cstddef> +#include <functional> #include <initializer_list> #include <string> #include <type_traits> @@ -41,6 +42,7 @@ namespace llvm { class StringSaver; +class raw_ostream; /// cl Namespace - This namespace contains all of the command line option /// processing machinery. It is intentionally a short name to make qualified @@ -64,12 +66,15 @@ bool ParseCommandLineOptions(int argc, const char *const *argv, void ParseEnvironmentOptions(const char *progName, const char *envvar, const char *Overview = ""); +// Function pointer type for printing version information. +using VersionPrinterTy = std::function<void(raw_ostream &)>; + ///===---------------------------------------------------------------------===// /// SetVersionPrinter - Override the default (LLVM specific) version printer /// used to print out the version when --version is given /// on the command line. This allows other systems using the /// CommandLine utilities to print their own version string. -void SetVersionPrinter(void (*func)()); +void SetVersionPrinter(VersionPrinterTy func); ///===---------------------------------------------------------------------===// /// AddExtraVersionPrinter - Add an extra printer to use in addition to the @@ -78,7 +83,7 @@ void SetVersionPrinter(void (*func)()); /// which will be called after the basic LLVM version /// printing is complete. Each can then add additional /// information specific to the tool. -void AddExtraVersionPrinter(void (*func)()); +void AddExtraVersionPrinter(VersionPrinterTy func); // PrintOptionValues - Print option values. // With -print-options print the difference between option values and defaults. @@ -242,7 +247,7 @@ class Option { // Out of line virtual function to provide home for the class. virtual void anchor(); - int NumOccurrences; // The number of times specified + int NumOccurrences = 0; // The number of times specified // Occurrences, HiddenFlag, and Formatting are all enum types but to avoid // problems with signed enums in bitfields. unsigned Occurrences : 3; // enum NumOccurrencesFlag @@ -252,8 +257,8 @@ class Option { unsigned HiddenFlag : 2; // enum OptionHidden unsigned Formatting : 2; // enum FormattingFlags unsigned Misc : 3; - unsigned Position; // Position of last occurrence of the option - unsigned AdditionalVals; // Greater than 0 for multi-valued option. + unsigned Position = 0; // Position of last occurrence of the option + unsigned AdditionalVals = 0; // Greater than 0 for multi-valued option. public: StringRef ArgStr; // The argument string itself (ex: "help", "o") @@ -261,7 +266,7 @@ public: StringRef ValueStr; // String describing what the value of this option is OptionCategory *Category; // The Category this option belongs to SmallPtrSet<SubCommand *, 4> Subs; // The subcommands this option belongs to. - bool FullyInitialized; // Has addArguemnt been called? + bool FullyInitialized = false; // Has addArguemnt been called? inline enum NumOccurrencesFlag getNumOccurrencesFlag() const { return (enum NumOccurrencesFlag)Occurrences; @@ -316,10 +321,8 @@ public: protected: explicit Option(enum NumOccurrencesFlag OccurrencesFlag, enum OptionHidden Hidden) - : NumOccurrences(0), Occurrences(OccurrencesFlag), Value(0), - HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0), Position(0), - AdditionalVals(0), Category(&GeneralCategory), FullyInitialized(false) { - } + : Occurrences(OccurrencesFlag), Value(0), HiddenFlag(Hidden), + Formatting(NormalFormatting), Misc(0), Category(&GeneralCategory) {} inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; } @@ -447,8 +450,8 @@ struct GenericOptionValue { protected: GenericOptionValue() = default; GenericOptionValue(const GenericOptionValue&) = default; - ~GenericOptionValue() = default; GenericOptionValue &operator=(const GenericOptionValue &) = default; + ~GenericOptionValue() = default; private: virtual void anchor(); @@ -461,7 +464,7 @@ template <class DataType> struct OptionValue; template <class DataType, bool isClass> struct OptionValueBase : public GenericOptionValue { // Temporary storage for argument passing. - typedef OptionValue<DataType> WrapperType; + using WrapperType = OptionValue<DataType>; bool hasValue() const { return false; } @@ -487,8 +490,8 @@ template <class DataType> class OptionValueCopy : public GenericOptionValue { protected: OptionValueCopy(const OptionValueCopy&) = default; + OptionValueCopy &operator=(const OptionValueCopy &) = default; ~OptionValueCopy() = default; - OptionValueCopy &operator=(const OptionValueCopy&) = default; public: OptionValueCopy() = default; @@ -519,13 +522,13 @@ public: // Non-class option values. template <class DataType> struct OptionValueBase<DataType, false> : OptionValueCopy<DataType> { - typedef DataType WrapperType; + using WrapperType = DataType; protected: OptionValueBase() = default; OptionValueBase(const OptionValueBase&) = default; + OptionValueBase &operator=(const OptionValueBase &) = default; ~OptionValueBase() = default; - OptionValueBase &operator=(const OptionValueBase&) = default; }; // Top-level option class. @@ -548,7 +551,7 @@ enum boolOrDefault { BOU_UNSET, BOU_TRUE, BOU_FALSE }; template <> struct OptionValue<cl::boolOrDefault> final : OptionValueCopy<cl::boolOrDefault> { - typedef cl::boolOrDefault WrapperType; + using WrapperType = cl::boolOrDefault; OptionValue() = default; @@ -565,7 +568,7 @@ private: template <> struct OptionValue<std::string> final : OptionValueCopy<std::string> { - typedef StringRef WrapperType; + using WrapperType = StringRef; OptionValue() = default; @@ -736,13 +739,15 @@ protected: public: OptionInfo(StringRef name, DataType v, StringRef helpStr) : GenericOptionInfo(name, helpStr), V(v) {} + OptionValue<DataType> V; }; SmallVector<OptionInfo, 8> Values; public: parser(Option &O) : generic_parser_base(O) {} - typedef DataType parser_data_type; + + using parser_data_type = DataType; // Implement virtual functions needed by generic_parser_base unsigned getNumOptions() const override { return unsigned(Values.size()); } @@ -837,10 +842,10 @@ protected: // template <class DataType> class basic_parser : public basic_parser_impl { public: - basic_parser(Option &O) : basic_parser_impl(O) {} + using parser_data_type = DataType; + using OptVal = OptionValue<DataType>; - typedef DataType parser_data_type; - typedef OptionValue<DataType> OptVal; + basic_parser(Option &O) : basic_parser_impl(O) {} protected: ~basic_parser() = default; @@ -1292,6 +1297,7 @@ class opt : public Option, enum ValueExpected getValueExpectedFlagDefault() const override { return Parser.getValueExpectedFlagDefault(); } + void getExtraOptionNames(SmallVectorImpl<StringRef> &OptionNames) override { return Parser.getExtraOptionNames(OptionNames); } @@ -1300,6 +1306,7 @@ class opt : public Option, size_t getOptionWidth() const override { return Parser.getOptionWidth(*this); } + void printOptionInfo(size_t GlobalWidth) const override { Parser.printOptionInfo(*this, GlobalWidth); } @@ -1384,16 +1391,18 @@ template <class DataType> class list_storage<DataType, bool> { std::vector<DataType> Storage; public: - typedef typename std::vector<DataType>::iterator iterator; + using iterator = typename std::vector<DataType>::iterator; iterator begin() { return Storage.begin(); } iterator end() { return Storage.end(); } - typedef typename std::vector<DataType>::const_iterator const_iterator; + using const_iterator = typename std::vector<DataType>::const_iterator; + const_iterator begin() const { return Storage.begin(); } const_iterator end() const { return Storage.end(); } - typedef typename std::vector<DataType>::size_type size_type; + using size_type = typename std::vector<DataType>::size_type; + size_type size() const { return Storage.size(); } bool empty() const { return Storage.empty(); } @@ -1401,8 +1410,9 @@ public: void push_back(const DataType &value) { Storage.push_back(value); } void push_back(DataType &&value) { Storage.push_back(value); } - typedef typename std::vector<DataType>::reference reference; - typedef typename std::vector<DataType>::const_reference const_reference; + using reference = typename std::vector<DataType>::reference; + using const_reference = typename std::vector<DataType>::const_reference; + reference operator[](size_type pos) { return Storage[pos]; } const_reference operator[](size_type pos) const { return Storage[pos]; } @@ -1453,6 +1463,7 @@ class list : public Option, public list_storage<DataType, StorageClass> { enum ValueExpected getValueExpectedFlagDefault() const override { return Parser.getValueExpectedFlagDefault(); } + void getExtraOptionNames(SmallVectorImpl<StringRef> &OptionNames) override { return Parser.getExtraOptionNames(OptionNames); } @@ -1473,6 +1484,7 @@ class list : public Option, public list_storage<DataType, StorageClass> { size_t getOptionWidth() const override { return Parser.getOptionWidth(*this); } + void printOptionInfo(size_t GlobalWidth) const override { Parser.printOptionInfo(*this, GlobalWidth); } @@ -1592,6 +1604,7 @@ class bits : public Option, public bits_storage<DataType, Storage> { enum ValueExpected getValueExpectedFlagDefault() const override { return Parser.getValueExpectedFlagDefault(); } + void getExtraOptionNames(SmallVectorImpl<StringRef> &OptionNames) override { return Parser.getExtraOptionNames(OptionNames); } @@ -1612,6 +1625,7 @@ class bits : public Option, public bits_storage<DataType, Storage> { size_t getOptionWidth() const override { return Parser.getOptionWidth(*this); } + void printOptionInfo(size_t GlobalWidth) const override { Parser.printOptionInfo(*this, GlobalWidth); } @@ -1824,9 +1838,9 @@ void TokenizeWindowsCommandLine(StringRef Source, StringSaver &Saver, /// \brief String tokenization function type. Should be compatible with either /// Windows or Unix command line tokenizers. -typedef void (*TokenizerCallback)(StringRef Source, StringSaver &Saver, - SmallVectorImpl<const char *> &NewArgv, - bool MarkEOLs); +using TokenizerCallback = void (*)(StringRef Source, StringSaver &Saver, + SmallVectorImpl<const char *> &NewArgv, + bool MarkEOLs); /// \brief Expand response files on a command line recursively using the given /// StringSaver and tokenization strategy. Argv should contain the command line @@ -1880,6 +1894,7 @@ void ResetAllOptionOccurrences(); void ResetCommandLineParser(); } // end namespace cl + } // end namespace llvm #endif // LLVM_SUPPORT_COMMANDLINE_H diff --git a/include/llvm/Support/ConvertUTF.h b/include/llvm/Support/ConvertUTF.h index f714c0ed997ed..bd439f3602169 100644 --- a/include/llvm/Support/ConvertUTF.h +++ b/include/llvm/Support/ConvertUTF.h @@ -90,8 +90,8 @@ #ifndef LLVM_SUPPORT_CONVERTUTF_H #define LLVM_SUPPORT_CONVERTUTF_H -#include <string> #include <cstddef> +#include <string> // Wrap everything in namespace llvm so that programs can link with llvm and // their own version of the unicode libraries. diff --git a/include/llvm/Support/DataTypes.h.cmake b/include/llvm/Support/DataTypes.h.cmake index 541dbc3d635d7..a58e2e454b7d1 100644 --- a/include/llvm/Support/DataTypes.h.cmake +++ b/include/llvm/Support/DataTypes.h.cmake @@ -85,11 +85,11 @@ typedef u_int64_t uint64_t; #else /* _MSC_VER */ #ifdef __cplusplus -#include <cstdlib> #include <cstddef> +#include <cstdlib> #else -#include <stdlib.h> #include <stddef.h> +#include <stdlib.h> #endif #include <sys/types.h> diff --git a/include/llvm/Support/Dwarf.def b/include/llvm/Support/Dwarf.def deleted file mode 100644 index 3df3300de4668..0000000000000 --- a/include/llvm/Support/Dwarf.def +++ /dev/null @@ -1,838 +0,0 @@ -//===- llvm/Support/Dwarf.def - Dwarf definitions ---------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Macros for running through Dwarf enumerators. -// -//===----------------------------------------------------------------------===// - -// TODO: Add other DW-based macros. -#if !(defined HANDLE_DW_TAG || defined HANDLE_DW_AT || \ - defined HANDLE_DW_FORM || defined HANDLE_DW_OP || \ - defined HANDLE_DW_LANG || defined HANDLE_DW_ATE || \ - defined HANDLE_DW_VIRTUALITY || defined HANDLE_DW_DEFAULTED || \ - defined HANDLE_DW_CC || defined HANDLE_DW_LNS || \ - defined HANDLE_DW_LNE || defined HANDLE_DW_LNCT || \ - defined HANDLE_DW_MACRO || defined HANDLE_DW_RLE || \ - defined HANDLE_DW_CFA || defined HANDLE_DW_APPLE_PROPERTY || \ - defined HANDLE_DW_UT) -#error "Missing macro definition of HANDLE_DW*" -#endif - -#ifndef HANDLE_DW_TAG -#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR) -#endif - -#ifndef HANDLE_DW_AT -#define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) -#endif - -#ifndef HANDLE_DW_FORM -#define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR) -#endif - -#ifndef HANDLE_DW_OP -#define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR) -#endif - -#ifndef HANDLE_DW_LANG -#define HANDLE_DW_LANG(ID, NAME, VERSION, VENDOR) -#endif - -#ifndef HANDLE_DW_ATE -#define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) -#endif - -#ifndef HANDLE_DW_VIRTUALITY -#define HANDLE_DW_VIRTUALITY(ID, NAME) -#endif - -#ifndef HANDLE_DW_DEFAULTED -#define HANDLE_DW_DEFAULTED(ID, NAME) -#endif - -#ifndef HANDLE_DW_CC -#define HANDLE_DW_CC(ID, NAME) -#endif - -#ifndef HANDLE_DW_LNS -#define HANDLE_DW_LNS(ID, NAME) -#endif - -#ifndef HANDLE_DW_LNE -#define HANDLE_DW_LNE(ID, NAME) -#endif - -#ifndef HANDLE_DW_LNCT -#define HANDLE_DW_LNCT(ID, NAME) -#endif - -#ifndef HANDLE_DW_MACRO -#define HANDLE_DW_MACRO(ID, NAME) -#endif - -#ifndef HANDLE_DW_RLE -#define HANDLE_DW_RLE(ID, NAME) -#endif - -#ifndef HANDLE_DW_CFA -#define HANDLE_DW_CFA(ID, NAME) -#endif - -#ifndef HANDLE_DW_APPLE_PROPERTY -#define HANDLE_DW_APPLE_PROPERTY(ID, NAME) -#endif - -#ifndef HANDLE_DW_UT -#define HANDLE_DW_UT(ID, NAME) -#endif - -HANDLE_DW_TAG(0x0000, null, 2, DWARF) -HANDLE_DW_TAG(0x0001, array_type, 2, DWARF) -HANDLE_DW_TAG(0x0002, class_type, 2, DWARF) -HANDLE_DW_TAG(0x0003, entry_point, 2, DWARF) -HANDLE_DW_TAG(0x0004, enumeration_type, 2, DWARF) -HANDLE_DW_TAG(0x0005, formal_parameter, 2, DWARF) -HANDLE_DW_TAG(0x0008, imported_declaration, 2, DWARF) -HANDLE_DW_TAG(0x000a, label, 2, DWARF) -HANDLE_DW_TAG(0x000b, lexical_block, 2, DWARF) -HANDLE_DW_TAG(0x000d, member, 2, DWARF) -HANDLE_DW_TAG(0x000f, pointer_type, 2, DWARF) -HANDLE_DW_TAG(0x0010, reference_type, 2, DWARF) -HANDLE_DW_TAG(0x0011, compile_unit, 2, DWARF) -HANDLE_DW_TAG(0x0012, string_type, 2, DWARF) -HANDLE_DW_TAG(0x0013, structure_type, 2, DWARF) -HANDLE_DW_TAG(0x0015, subroutine_type, 2, DWARF) -HANDLE_DW_TAG(0x0016, typedef, 2, DWARF) -HANDLE_DW_TAG(0x0017, union_type, 2, DWARF) -HANDLE_DW_TAG(0x0018, unspecified_parameters, 2, DWARF) -HANDLE_DW_TAG(0x0019, variant, 2, DWARF) -HANDLE_DW_TAG(0x001a, common_block, 2, DWARF) -HANDLE_DW_TAG(0x001b, common_inclusion, 2, DWARF) -HANDLE_DW_TAG(0x001c, inheritance, 2, DWARF) -HANDLE_DW_TAG(0x001d, inlined_subroutine, 2, DWARF) -HANDLE_DW_TAG(0x001e, module, 2, DWARF) -HANDLE_DW_TAG(0x001f, ptr_to_member_type, 2, DWARF) -HANDLE_DW_TAG(0x0020, set_type, 2, DWARF) -HANDLE_DW_TAG(0x0021, subrange_type, 2, DWARF) -HANDLE_DW_TAG(0x0022, with_stmt, 2, DWARF) -HANDLE_DW_TAG(0x0023, access_declaration, 2, DWARF) -HANDLE_DW_TAG(0x0024, base_type, 2, DWARF) -HANDLE_DW_TAG(0x0025, catch_block, 2, DWARF) -HANDLE_DW_TAG(0x0026, const_type, 2, DWARF) -HANDLE_DW_TAG(0x0027, constant, 2, DWARF) -HANDLE_DW_TAG(0x0028, enumerator, 2, DWARF) -HANDLE_DW_TAG(0x0029, file_type, 2, DWARF) -HANDLE_DW_TAG(0x002a, friend, 2, DWARF) -HANDLE_DW_TAG(0x002b, namelist, 2, DWARF) -HANDLE_DW_TAG(0x002c, namelist_item, 2, DWARF) -HANDLE_DW_TAG(0x002d, packed_type, 2, DWARF) -HANDLE_DW_TAG(0x002e, subprogram, 2, DWARF) -HANDLE_DW_TAG(0x002f, template_type_parameter, 2, DWARF) -HANDLE_DW_TAG(0x0030, template_value_parameter, 2, DWARF) -HANDLE_DW_TAG(0x0031, thrown_type, 2, DWARF) -HANDLE_DW_TAG(0x0032, try_block, 2, DWARF) -HANDLE_DW_TAG(0x0033, variant_part, 2, DWARF) -HANDLE_DW_TAG(0x0034, variable, 2, DWARF) -HANDLE_DW_TAG(0x0035, volatile_type, 2, DWARF) -// New in DWARF v3: -HANDLE_DW_TAG(0x0036, dwarf_procedure, 3, DWARF) -HANDLE_DW_TAG(0x0037, restrict_type, 3, DWARF) -HANDLE_DW_TAG(0x0038, interface_type, 3, DWARF) -HANDLE_DW_TAG(0x0039, namespace, 3, DWARF) -HANDLE_DW_TAG(0x003a, imported_module, 3, DWARF) -HANDLE_DW_TAG(0x003b, unspecified_type, 3, DWARF) -HANDLE_DW_TAG(0x003c, partial_unit, 3, DWARF) -HANDLE_DW_TAG(0x003d, imported_unit, 3, DWARF) -HANDLE_DW_TAG(0x003f, condition, 3, DWARF) -HANDLE_DW_TAG(0x0040, shared_type, 3, DWARF) -// New in DWARF v4: -HANDLE_DW_TAG(0x0041, type_unit, 4, DWARF) -HANDLE_DW_TAG(0x0042, rvalue_reference_type, 4, DWARF) -HANDLE_DW_TAG(0x0043, template_alias, 4, DWARF) -// New in DWARF v5: -HANDLE_DW_TAG(0x0044, coarray_type, 5, DWARF) -HANDLE_DW_TAG(0x0045, generic_subrange, 5, DWARF) -HANDLE_DW_TAG(0x0046, dynamic_type, 5, DWARF) -HANDLE_DW_TAG(0x0047, atomic_type, 5, DWARF) -HANDLE_DW_TAG(0x0048, call_site, 5, DWARF) -HANDLE_DW_TAG(0x0049, call_site_parameter, 5, DWARF) -HANDLE_DW_TAG(0x004a, skeleton_unit, 5, DWARF) -HANDLE_DW_TAG(0x004b, immutable_type, 5, DWARF) -// Vendor extensions: -HANDLE_DW_TAG(0x4081, MIPS_loop, 0, MIPS) -HANDLE_DW_TAG(0x4101, format_label, 0, GNU) -HANDLE_DW_TAG(0x4102, function_template, 0, GNU) -HANDLE_DW_TAG(0x4103, class_template, 0, GNU) -HANDLE_DW_TAG(0x4106, GNU_template_template_param, 0, GNU) -HANDLE_DW_TAG(0x4107, GNU_template_parameter_pack, 0, GNU) -HANDLE_DW_TAG(0x4108, GNU_formal_parameter_pack, 0, GNU) -HANDLE_DW_TAG(0x4200, APPLE_property, 0, APPLE) -HANDLE_DW_TAG(0xb000, BORLAND_property, 0, BORLAND) -HANDLE_DW_TAG(0xb001, BORLAND_Delphi_string, 0, BORLAND) -HANDLE_DW_TAG(0xb002, BORLAND_Delphi_dynamic_array, 0, BORLAND) -HANDLE_DW_TAG(0xb003, BORLAND_Delphi_set, 0, BORLAND) -HANDLE_DW_TAG(0xb004, BORLAND_Delphi_variant, 0, BORLAND) - -// Attributes. -HANDLE_DW_AT(0x01, sibling, 2, DWARF) -HANDLE_DW_AT(0x02, location, 2, DWARF) -HANDLE_DW_AT(0x03, name, 2, DWARF) -HANDLE_DW_AT(0x09, ordering, 2, DWARF) -HANDLE_DW_AT(0x0b, byte_size, 2, DWARF) -HANDLE_DW_AT(0x0c, bit_offset, 2, DWARF) -HANDLE_DW_AT(0x0d, bit_size, 2, DWARF) -HANDLE_DW_AT(0x10, stmt_list, 2, DWARF) -HANDLE_DW_AT(0x11, low_pc, 2, DWARF) -HANDLE_DW_AT(0x12, high_pc, 2, DWARF) -HANDLE_DW_AT(0x13, language, 2, DWARF) -HANDLE_DW_AT(0x15, discr, 2, DWARF) -HANDLE_DW_AT(0x16, discr_value, 2, DWARF) -HANDLE_DW_AT(0x17, visibility, 2, DWARF) -HANDLE_DW_AT(0x18, import, 2, DWARF) -HANDLE_DW_AT(0x19, string_length, 2, DWARF) -HANDLE_DW_AT(0x1a, common_reference, 2, DWARF) -HANDLE_DW_AT(0x1b, comp_dir, 2, DWARF) -HANDLE_DW_AT(0x1c, const_value, 2, DWARF) -HANDLE_DW_AT(0x1d, containing_type, 2, DWARF) -HANDLE_DW_AT(0x1e, default_value, 2, DWARF) -HANDLE_DW_AT(0x20, inline, 2, DWARF) -HANDLE_DW_AT(0x21, is_optional, 2, DWARF) -HANDLE_DW_AT(0x22, lower_bound, 2, DWARF) -HANDLE_DW_AT(0x25, producer, 2, DWARF) -HANDLE_DW_AT(0x27, prototyped, 2, DWARF) -HANDLE_DW_AT(0x2a, return_addr, 2, DWARF) -HANDLE_DW_AT(0x2c, start_scope, 2, DWARF) -HANDLE_DW_AT(0x2e, bit_stride, 2, DWARF) -HANDLE_DW_AT(0x2f, upper_bound, 2, DWARF) -HANDLE_DW_AT(0x31, abstract_origin, 2, DWARF) -HANDLE_DW_AT(0x32, accessibility, 2, DWARF) -HANDLE_DW_AT(0x33, address_class, 2, DWARF) -HANDLE_DW_AT(0x34, artificial, 2, DWARF) -HANDLE_DW_AT(0x35, base_types, 2, DWARF) -HANDLE_DW_AT(0x36, calling_convention, 2, DWARF) -HANDLE_DW_AT(0x37, count, 2, DWARF) -HANDLE_DW_AT(0x38, data_member_location, 2, DWARF) -HANDLE_DW_AT(0x39, decl_column, 2, DWARF) -HANDLE_DW_AT(0x3a, decl_file, 2, DWARF) -HANDLE_DW_AT(0x3b, decl_line, 2, DWARF) -HANDLE_DW_AT(0x3c, declaration, 2, DWARF) -HANDLE_DW_AT(0x3d, discr_list, 2, DWARF) -HANDLE_DW_AT(0x3e, encoding, 2, DWARF) -HANDLE_DW_AT(0x3f, external, 2, DWARF) -HANDLE_DW_AT(0x40, frame_base, 2, DWARF) -HANDLE_DW_AT(0x41, friend, 2, DWARF) -HANDLE_DW_AT(0x42, identifier_case, 2, DWARF) -HANDLE_DW_AT(0x43, macro_info, 2, DWARF) -HANDLE_DW_AT(0x44, namelist_item, 2, DWARF) -HANDLE_DW_AT(0x45, priority, 2, DWARF) -HANDLE_DW_AT(0x46, segment, 2, DWARF) -HANDLE_DW_AT(0x47, specification, 2, DWARF) -HANDLE_DW_AT(0x48, static_link, 2, DWARF) -HANDLE_DW_AT(0x49, type, 2, DWARF) -HANDLE_DW_AT(0x4a, use_location, 2, DWARF) -HANDLE_DW_AT(0x4b, variable_parameter, 2, DWARF) -HANDLE_DW_AT(0x4c, virtuality, 2, DWARF) -HANDLE_DW_AT(0x4d, vtable_elem_location, 2, DWARF) -// New in DWARF v3: -HANDLE_DW_AT(0x4e, allocated, 3, DWARF) -HANDLE_DW_AT(0x4f, associated, 3, DWARF) -HANDLE_DW_AT(0x50, data_location, 3, DWARF) -HANDLE_DW_AT(0x51, byte_stride, 3, DWARF) -HANDLE_DW_AT(0x52, entry_pc, 3, DWARF) -HANDLE_DW_AT(0x53, use_UTF8, 3, DWARF) -HANDLE_DW_AT(0x54, extension, 3, DWARF) -HANDLE_DW_AT(0x55, ranges, 3, DWARF) -HANDLE_DW_AT(0x56, trampoline, 3, DWARF) -HANDLE_DW_AT(0x57, call_column, 3, DWARF) -HANDLE_DW_AT(0x58, call_file, 3, DWARF) -HANDLE_DW_AT(0x59, call_line, 3, DWARF) -HANDLE_DW_AT(0x5a, description, 3, DWARF) -HANDLE_DW_AT(0x5b, binary_scale, 3, DWARF) -HANDLE_DW_AT(0x5c, decimal_scale, 3, DWARF) -HANDLE_DW_AT(0x5d, small, 3, DWARF) -HANDLE_DW_AT(0x5e, decimal_sign, 3, DWARF) -HANDLE_DW_AT(0x5f, digit_count, 3, DWARF) -HANDLE_DW_AT(0x60, picture_string, 3, DWARF) -HANDLE_DW_AT(0x61, mutable, 3, DWARF) -HANDLE_DW_AT(0x62, threads_scaled, 3, DWARF) -HANDLE_DW_AT(0x63, explicit, 3, DWARF) -HANDLE_DW_AT(0x64, object_pointer, 3, DWARF) -HANDLE_DW_AT(0x65, endianity, 3, DWARF) -HANDLE_DW_AT(0x66, elemental, 3, DWARF) -HANDLE_DW_AT(0x67, pure, 3, DWARF) -HANDLE_DW_AT(0x68, recursive, 3, DWARF) -// New in DWARF v4: -HANDLE_DW_AT(0x69, signature, 4, DWARF) -HANDLE_DW_AT(0x6a, main_subprogram, 4, DWARF) -HANDLE_DW_AT(0x6b, data_bit_offset, 4, DWARF) -HANDLE_DW_AT(0x6c, const_expr, 4, DWARF) -HANDLE_DW_AT(0x6d, enum_class, 4, DWARF) -HANDLE_DW_AT(0x6e, linkage_name, 4, DWARF) -// New in DWARF v5: -HANDLE_DW_AT(0x6f, string_length_bit_size, 5, DWARF) -HANDLE_DW_AT(0x70, string_length_byte_size, 5, DWARF) -HANDLE_DW_AT(0x71, rank, 5, DWARF) -HANDLE_DW_AT(0x72, str_offsets_base, 5, DWARF) -HANDLE_DW_AT(0x73, addr_base, 5, DWARF) -HANDLE_DW_AT(0x74, rnglists_base, 5, DWARF) -HANDLE_DW_AT(0x75, dwo_id, 0, DWARF) ///< Retracted from DWARF v5. -HANDLE_DW_AT(0x76, dwo_name, 5, DWARF) -HANDLE_DW_AT(0x77, reference, 5, DWARF) -HANDLE_DW_AT(0x78, rvalue_reference, 5, DWARF) -HANDLE_DW_AT(0x79, macros, 5, DWARF) -HANDLE_DW_AT(0x7a, call_all_calls, 5, DWARF) -HANDLE_DW_AT(0x7b, call_all_source_calls, 5, DWARF) -HANDLE_DW_AT(0x7c, call_all_tail_calls, 5, DWARF) -HANDLE_DW_AT(0x7d, call_return_pc, 5, DWARF) -HANDLE_DW_AT(0x7e, call_value, 5, DWARF) -HANDLE_DW_AT(0x7f, call_origin, 5, DWARF) -HANDLE_DW_AT(0x80, call_parameter, 5, DWARF) -HANDLE_DW_AT(0x81, call_pc, 5, DWARF) -HANDLE_DW_AT(0x82, call_tail_call, 5, DWARF) -HANDLE_DW_AT(0x83, call_target, 5, DWARF) -HANDLE_DW_AT(0x84, call_target_clobbered, 5, DWARF) -HANDLE_DW_AT(0x85, call_data_location, 5, DWARF) -HANDLE_DW_AT(0x86, call_data_value, 5, DWARF) -HANDLE_DW_AT(0x87, noreturn, 5, DWARF) -HANDLE_DW_AT(0x88, alignment, 5, DWARF) -HANDLE_DW_AT(0x89, export_symbols, 5, DWARF) -HANDLE_DW_AT(0x8a, deleted, 5, DWARF) -HANDLE_DW_AT(0x8b, defaulted, 5, DWARF) -HANDLE_DW_AT(0x8c, loclists_base, 5, DWARF) -// Vendor extensions: -HANDLE_DW_AT(0x2002, MIPS_loop_begin, 0, MIPS) -HANDLE_DW_AT(0x2003, MIPS_tail_loop_begin, 0, MIPS) -HANDLE_DW_AT(0x2004, MIPS_epilog_begin, 0, MIPS) -HANDLE_DW_AT(0x2005, MIPS_loop_unroll_factor, 0, MIPS) -HANDLE_DW_AT(0x2006, MIPS_software_pipeline_depth, 0, MIPS) -HANDLE_DW_AT(0x2007, MIPS_linkage_name, 0, MIPS) -HANDLE_DW_AT(0x2008, MIPS_stride, 0, MIPS) -HANDLE_DW_AT(0x2009, MIPS_abstract_name, 0, MIPS) -HANDLE_DW_AT(0x200a, MIPS_clone_origin, 0, MIPS) -HANDLE_DW_AT(0x200b, MIPS_has_inlines, 0, MIPS) -HANDLE_DW_AT(0x200c, MIPS_stride_byte, 0, MIPS) -HANDLE_DW_AT(0x200d, MIPS_stride_elem, 0, MIPS) -HANDLE_DW_AT(0x200e, MIPS_ptr_dopetype, 0, MIPS) -HANDLE_DW_AT(0x200f, MIPS_allocatable_dopetype, 0, MIPS) -HANDLE_DW_AT(0x2010, MIPS_assumed_shape_dopetype, 0, MIPS) -// This one appears to have only been implemented by Open64 for -// fortran and may conflict with other extensions. -HANDLE_DW_AT(0x2011, MIPS_assumed_size, 0, MIPS) -// GNU extensions -HANDLE_DW_AT(0x2101, sf_names, 0, GNU) -HANDLE_DW_AT(0x2102, src_info, 0, GNU) -HANDLE_DW_AT(0x2103, mac_info, 0, GNU) -HANDLE_DW_AT(0x2104, src_coords, 0, GNU) -HANDLE_DW_AT(0x2105, body_begin, 0, GNU) -HANDLE_DW_AT(0x2106, body_end, 0, GNU) -HANDLE_DW_AT(0x2107, GNU_vector, 0, GNU) -HANDLE_DW_AT(0x2110, GNU_template_name, 0, GNU) -HANDLE_DW_AT(0x210f, GNU_odr_signature, 0, GNU) -HANDLE_DW_AT(0x2119, GNU_macros, 0, GNU) -// Extensions for Fission proposal. -HANDLE_DW_AT(0x2130, GNU_dwo_name, 0, GNU) -HANDLE_DW_AT(0x2131, GNU_dwo_id, 0, GNU) -HANDLE_DW_AT(0x2132, GNU_ranges_base, 0, GNU) -HANDLE_DW_AT(0x2133, GNU_addr_base, 0, GNU) -HANDLE_DW_AT(0x2134, GNU_pubnames, 0, GNU) -HANDLE_DW_AT(0x2135, GNU_pubtypes, 0, GNU) -HANDLE_DW_AT(0x2136, GNU_discriminator, 0, GNU) -// Borland extensions. -HANDLE_DW_AT(0x3b11, BORLAND_property_read, 0, BORLAND) -HANDLE_DW_AT(0x3b12, BORLAND_property_write, 0, BORLAND) -HANDLE_DW_AT(0x3b13, BORLAND_property_implements, 0, BORLAND) -HANDLE_DW_AT(0x3b14, BORLAND_property_index, 0, BORLAND) -HANDLE_DW_AT(0x3b15, BORLAND_property_default, 0, BORLAND) -HANDLE_DW_AT(0x3b20, BORLAND_Delphi_unit, 0, BORLAND) -HANDLE_DW_AT(0x3b21, BORLAND_Delphi_class, 0, BORLAND) -HANDLE_DW_AT(0x3b22, BORLAND_Delphi_record, 0, BORLAND) -HANDLE_DW_AT(0x3b23, BORLAND_Delphi_metaclass, 0, BORLAND) -HANDLE_DW_AT(0x3b24, BORLAND_Delphi_constructor, 0, BORLAND) -HANDLE_DW_AT(0x3b25, BORLAND_Delphi_destructor, 0, BORLAND) -HANDLE_DW_AT(0x3b26, BORLAND_Delphi_anonymous_method, 0, BORLAND) -HANDLE_DW_AT(0x3b27, BORLAND_Delphi_interface, 0, BORLAND) -HANDLE_DW_AT(0x3b28, BORLAND_Delphi_ABI, 0, BORLAND) -HANDLE_DW_AT(0x3b29, BORLAND_Delphi_return, 0, BORLAND) -HANDLE_DW_AT(0x3b30, BORLAND_Delphi_frameptr, 0, BORLAND) -HANDLE_DW_AT(0x3b31, BORLAND_closure, 0, BORLAND) -// LLVM project extensions. -HANDLE_DW_AT(0x3e00, LLVM_include_path, 0, LLVM) -HANDLE_DW_AT(0x3e01, LLVM_config_macros, 0, LLVM) -HANDLE_DW_AT(0x3e02, LLVM_isysroot, 0, LLVM) -// Apple extensions. -HANDLE_DW_AT(0x3fe1, APPLE_optimized, 0, APPLE) -HANDLE_DW_AT(0x3fe2, APPLE_flags, 0, APPLE) -HANDLE_DW_AT(0x3fe3, APPLE_isa, 0, APPLE) -HANDLE_DW_AT(0x3fe4, APPLE_block, 0, APPLE) -HANDLE_DW_AT(0x3fe5, APPLE_major_runtime_vers, 0, APPLE) -HANDLE_DW_AT(0x3fe6, APPLE_runtime_class, 0, APPLE) -HANDLE_DW_AT(0x3fe7, APPLE_omit_frame_ptr, 0, APPLE) -HANDLE_DW_AT(0x3fe8, APPLE_property_name, 0, APPLE) -HANDLE_DW_AT(0x3fe9, APPLE_property_getter, 0, APPLE) -HANDLE_DW_AT(0x3fea, APPLE_property_setter, 0, APPLE) -HANDLE_DW_AT(0x3feb, APPLE_property_attribute, 0, APPLE) -HANDLE_DW_AT(0x3fec, APPLE_objc_complete_type, 0, APPLE) -HANDLE_DW_AT(0x3fed, APPLE_property, 0, APPLE) - -// Attribute form encodings. -HANDLE_DW_FORM(0x01, addr, 2, DWARF) -HANDLE_DW_FORM(0x03, block2, 2, DWARF) -HANDLE_DW_FORM(0x04, block4, 2, DWARF) -HANDLE_DW_FORM(0x05, data2, 2, DWARF) -HANDLE_DW_FORM(0x06, data4, 2, DWARF) -HANDLE_DW_FORM(0x07, data8, 2, DWARF) -HANDLE_DW_FORM(0x08, string, 2, DWARF) -HANDLE_DW_FORM(0x09, block, 2, DWARF) -HANDLE_DW_FORM(0x0a, block1, 2, DWARF) -HANDLE_DW_FORM(0x0b, data1, 2, DWARF) -HANDLE_DW_FORM(0x0c, flag, 2, DWARF) -HANDLE_DW_FORM(0x0d, sdata, 2, DWARF) -HANDLE_DW_FORM(0x0e, strp, 2, DWARF) -HANDLE_DW_FORM(0x0f, udata, 2, DWARF) -HANDLE_DW_FORM(0x10, ref_addr, 2, DWARF) -HANDLE_DW_FORM(0x11, ref1, 2, DWARF) -HANDLE_DW_FORM(0x12, ref2, 2, DWARF) -HANDLE_DW_FORM(0x13, ref4, 2, DWARF) -HANDLE_DW_FORM(0x14, ref8, 2, DWARF) -HANDLE_DW_FORM(0x15, ref_udata, 2, DWARF) -HANDLE_DW_FORM(0x16, indirect, 2, DWARF) -// New in DWARF v4: -HANDLE_DW_FORM(0x17, sec_offset, 4, DWARF) -HANDLE_DW_FORM(0x18, exprloc, 4, DWARF) -HANDLE_DW_FORM(0x19, flag_present, 4, DWARF) -// This was defined out of sequence. -HANDLE_DW_FORM(0x20, ref_sig8, 4, DWARF) -// New in DWARF v5: -HANDLE_DW_FORM(0x1a, strx, 5, DWARF) -HANDLE_DW_FORM(0x1b, addrx, 5, DWARF) -HANDLE_DW_FORM(0x1c, ref_sup4, 5, DWARF) -HANDLE_DW_FORM(0x1d, strp_sup, 5, DWARF) -HANDLE_DW_FORM(0x1e, data16, 5, DWARF) -HANDLE_DW_FORM(0x1f, line_strp, 5, DWARF) -HANDLE_DW_FORM(0x21, implicit_const, 5, DWARF) -HANDLE_DW_FORM(0x22, loclistx, 5, DWARF) -HANDLE_DW_FORM(0x23, rnglistx, 5, DWARF) -HANDLE_DW_FORM(0x24, ref_sup8, 5, DWARF) -HANDLE_DW_FORM(0x25, strx1, 5, DWARF) -HANDLE_DW_FORM(0x26, strx2, 5, DWARF) -HANDLE_DW_FORM(0x27, strx3, 5, DWARF) -HANDLE_DW_FORM(0x28, strx4, 5, DWARF) -HANDLE_DW_FORM(0x29, addrx1, 5, DWARF) -HANDLE_DW_FORM(0x2a, addrx2, 5, DWARF) -HANDLE_DW_FORM(0x2b, addrx3, 5, DWARF) -HANDLE_DW_FORM(0x2c, addrx4, 5, DWARF) -// Extensions for Fission proposal -HANDLE_DW_FORM(0x1f01, GNU_addr_index, 0, GNU) -HANDLE_DW_FORM(0x1f02, GNU_str_index, 0, GNU) -// Alternate debug sections proposal (output of "dwz" tool). -HANDLE_DW_FORM(0x1f20, GNU_ref_alt, 0, GNU) -HANDLE_DW_FORM(0x1f21, GNU_strp_alt, 0, GNU) - -// DWARF Expression operators. -HANDLE_DW_OP(0x03, addr, 2, DWARF) -HANDLE_DW_OP(0x06, deref, 2, DWARF) -HANDLE_DW_OP(0x08, const1u, 2, DWARF) -HANDLE_DW_OP(0x09, const1s, 2, DWARF) -HANDLE_DW_OP(0x0a, const2u, 2, DWARF) -HANDLE_DW_OP(0x0b, const2s, 2, DWARF) -HANDLE_DW_OP(0x0c, const4u, 2, DWARF) -HANDLE_DW_OP(0x0d, const4s, 2, DWARF) -HANDLE_DW_OP(0x0e, const8u, 2, DWARF) -HANDLE_DW_OP(0x0f, const8s, 2, DWARF) -HANDLE_DW_OP(0x10, constu, 2, DWARF) -HANDLE_DW_OP(0x11, consts, 2, DWARF) -HANDLE_DW_OP(0x12, dup, 2, DWARF) -HANDLE_DW_OP(0x13, drop, 2, DWARF) -HANDLE_DW_OP(0x14, over, 2, DWARF) -HANDLE_DW_OP(0x15, pick, 2, DWARF) -HANDLE_DW_OP(0x16, swap, 2, DWARF) -HANDLE_DW_OP(0x17, rot, 2, DWARF) -HANDLE_DW_OP(0x18, xderef, 2, DWARF) -HANDLE_DW_OP(0x19, abs, 2, DWARF) -HANDLE_DW_OP(0x1a, and, 2, DWARF) -HANDLE_DW_OP(0x1b, div, 2, DWARF) -HANDLE_DW_OP(0x1c, minus, 2, DWARF) -HANDLE_DW_OP(0x1d, mod, 2, DWARF) -HANDLE_DW_OP(0x1e, mul, 2, DWARF) -HANDLE_DW_OP(0x1f, neg, 2, DWARF) -HANDLE_DW_OP(0x20, not, 2, DWARF) -HANDLE_DW_OP(0x21, or, 2, DWARF) -HANDLE_DW_OP(0x22, plus, 2, DWARF) -HANDLE_DW_OP(0x23, plus_uconst, 2, DWARF) -HANDLE_DW_OP(0x24, shl, 2, DWARF) -HANDLE_DW_OP(0x25, shr, 2, DWARF) -HANDLE_DW_OP(0x26, shra, 2, DWARF) -HANDLE_DW_OP(0x27, xor, 2, DWARF) -HANDLE_DW_OP(0x28, bra, 2, DWARF) -HANDLE_DW_OP(0x29, eq, 2, DWARF) -HANDLE_DW_OP(0x2a, ge, 2, DWARF) -HANDLE_DW_OP(0x2b, gt, 2, DWARF) -HANDLE_DW_OP(0x2c, le, 2, DWARF) -HANDLE_DW_OP(0x2d, lt, 2, DWARF) -HANDLE_DW_OP(0x2e, ne, 2, DWARF) -HANDLE_DW_OP(0x2f, skip, 2, DWARF) -HANDLE_DW_OP(0x30, lit0, 2, DWARF) -HANDLE_DW_OP(0x31, lit1, 2, DWARF) -HANDLE_DW_OP(0x32, lit2, 2, DWARF) -HANDLE_DW_OP(0x33, lit3, 2, DWARF) -HANDLE_DW_OP(0x34, lit4, 2, DWARF) -HANDLE_DW_OP(0x35, lit5, 2, DWARF) -HANDLE_DW_OP(0x36, lit6, 2, DWARF) -HANDLE_DW_OP(0x37, lit7, 2, DWARF) -HANDLE_DW_OP(0x38, lit8, 2, DWARF) -HANDLE_DW_OP(0x39, lit9, 2, DWARF) -HANDLE_DW_OP(0x3a, lit10, 2, DWARF) -HANDLE_DW_OP(0x3b, lit11, 2, DWARF) -HANDLE_DW_OP(0x3c, lit12, 2, DWARF) -HANDLE_DW_OP(0x3d, lit13, 2, DWARF) -HANDLE_DW_OP(0x3e, lit14, 2, DWARF) -HANDLE_DW_OP(0x3f, lit15, 2, DWARF) -HANDLE_DW_OP(0x40, lit16, 2, DWARF) -HANDLE_DW_OP(0x41, lit17, 2, DWARF) -HANDLE_DW_OP(0x42, lit18, 2, DWARF) -HANDLE_DW_OP(0x43, lit19, 2, DWARF) -HANDLE_DW_OP(0x44, lit20, 2, DWARF) -HANDLE_DW_OP(0x45, lit21, 2, DWARF) -HANDLE_DW_OP(0x46, lit22, 2, DWARF) -HANDLE_DW_OP(0x47, lit23, 2, DWARF) -HANDLE_DW_OP(0x48, lit24, 2, DWARF) -HANDLE_DW_OP(0x49, lit25, 2, DWARF) -HANDLE_DW_OP(0x4a, lit26, 2, DWARF) -HANDLE_DW_OP(0x4b, lit27, 2, DWARF) -HANDLE_DW_OP(0x4c, lit28, 2, DWARF) -HANDLE_DW_OP(0x4d, lit29, 2, DWARF) -HANDLE_DW_OP(0x4e, lit30, 2, DWARF) -HANDLE_DW_OP(0x4f, lit31, 2, DWARF) -HANDLE_DW_OP(0x50, reg0, 2, DWARF) -HANDLE_DW_OP(0x51, reg1, 2, DWARF) -HANDLE_DW_OP(0x52, reg2, 2, DWARF) -HANDLE_DW_OP(0x53, reg3, 2, DWARF) -HANDLE_DW_OP(0x54, reg4, 2, DWARF) -HANDLE_DW_OP(0x55, reg5, 2, DWARF) -HANDLE_DW_OP(0x56, reg6, 2, DWARF) -HANDLE_DW_OP(0x57, reg7, 2, DWARF) -HANDLE_DW_OP(0x58, reg8, 2, DWARF) -HANDLE_DW_OP(0x59, reg9, 2, DWARF) -HANDLE_DW_OP(0x5a, reg10, 2, DWARF) -HANDLE_DW_OP(0x5b, reg11, 2, DWARF) -HANDLE_DW_OP(0x5c, reg12, 2, DWARF) -HANDLE_DW_OP(0x5d, reg13, 2, DWARF) -HANDLE_DW_OP(0x5e, reg14, 2, DWARF) -HANDLE_DW_OP(0x5f, reg15, 2, DWARF) -HANDLE_DW_OP(0x60, reg16, 2, DWARF) -HANDLE_DW_OP(0x61, reg17, 2, DWARF) -HANDLE_DW_OP(0x62, reg18, 2, DWARF) -HANDLE_DW_OP(0x63, reg19, 2, DWARF) -HANDLE_DW_OP(0x64, reg20, 2, DWARF) -HANDLE_DW_OP(0x65, reg21, 2, DWARF) -HANDLE_DW_OP(0x66, reg22, 2, DWARF) -HANDLE_DW_OP(0x67, reg23, 2, DWARF) -HANDLE_DW_OP(0x68, reg24, 2, DWARF) -HANDLE_DW_OP(0x69, reg25, 2, DWARF) -HANDLE_DW_OP(0x6a, reg26, 2, DWARF) -HANDLE_DW_OP(0x6b, reg27, 2, DWARF) -HANDLE_DW_OP(0x6c, reg28, 2, DWARF) -HANDLE_DW_OP(0x6d, reg29, 2, DWARF) -HANDLE_DW_OP(0x6e, reg30, 2, DWARF) -HANDLE_DW_OP(0x6f, reg31, 2, DWARF) -HANDLE_DW_OP(0x70, breg0, 2, DWARF) -HANDLE_DW_OP(0x71, breg1, 2, DWARF) -HANDLE_DW_OP(0x72, breg2, 2, DWARF) -HANDLE_DW_OP(0x73, breg3, 2, DWARF) -HANDLE_DW_OP(0x74, breg4, 2, DWARF) -HANDLE_DW_OP(0x75, breg5, 2, DWARF) -HANDLE_DW_OP(0x76, breg6, 2, DWARF) -HANDLE_DW_OP(0x77, breg7, 2, DWARF) -HANDLE_DW_OP(0x78, breg8, 2, DWARF) -HANDLE_DW_OP(0x79, breg9, 2, DWARF) -HANDLE_DW_OP(0x7a, breg10, 2, DWARF) -HANDLE_DW_OP(0x7b, breg11, 2, DWARF) -HANDLE_DW_OP(0x7c, breg12, 2, DWARF) -HANDLE_DW_OP(0x7d, breg13, 2, DWARF) -HANDLE_DW_OP(0x7e, breg14, 2, DWARF) -HANDLE_DW_OP(0x7f, breg15, 2, DWARF) -HANDLE_DW_OP(0x80, breg16, 2, DWARF) -HANDLE_DW_OP(0x81, breg17, 2, DWARF) -HANDLE_DW_OP(0x82, breg18, 2, DWARF) -HANDLE_DW_OP(0x83, breg19, 2, DWARF) -HANDLE_DW_OP(0x84, breg20, 2, DWARF) -HANDLE_DW_OP(0x85, breg21, 2, DWARF) -HANDLE_DW_OP(0x86, breg22, 2, DWARF) -HANDLE_DW_OP(0x87, breg23, 2, DWARF) -HANDLE_DW_OP(0x88, breg24, 2, DWARF) -HANDLE_DW_OP(0x89, breg25, 2, DWARF) -HANDLE_DW_OP(0x8a, breg26, 2, DWARF) -HANDLE_DW_OP(0x8b, breg27, 2, DWARF) -HANDLE_DW_OP(0x8c, breg28, 2, DWARF) -HANDLE_DW_OP(0x8d, breg29, 2, DWARF) -HANDLE_DW_OP(0x8e, breg30, 2, DWARF) -HANDLE_DW_OP(0x8f, breg31, 2, DWARF) -HANDLE_DW_OP(0x90, regx, 2, DWARF) -HANDLE_DW_OP(0x91, fbreg, 2, DWARF) -HANDLE_DW_OP(0x92, bregx, 2, DWARF) -HANDLE_DW_OP(0x93, piece, 2, DWARF) -HANDLE_DW_OP(0x94, deref_size, 2, DWARF) -HANDLE_DW_OP(0x95, xderef_size, 2, DWARF) -HANDLE_DW_OP(0x96, nop, 2, DWARF) -// New in DWARF v3: -HANDLE_DW_OP(0x97, push_object_address, 3, DWARF) -HANDLE_DW_OP(0x98, call2, 3, DWARF) -HANDLE_DW_OP(0x99, call4, 3, DWARF) -HANDLE_DW_OP(0x9a, call_ref, 3, DWARF) -HANDLE_DW_OP(0x9b, form_tls_address, 3, DWARF) -HANDLE_DW_OP(0x9c, call_frame_cfa, 3, DWARF) -HANDLE_DW_OP(0x9d, bit_piece, 3, DWARF) -// New in DWARF v4: -HANDLE_DW_OP(0x9e, implicit_value, 4, DWARF) -HANDLE_DW_OP(0x9f, stack_value, 4, DWARF) -// New in DWARF v5: -HANDLE_DW_OP(0xa0, implicit_pointer, 5, DWARF) -HANDLE_DW_OP(0xa1, addrx, 5, DWARF) -HANDLE_DW_OP(0xa2, constx, 5, DWARF) -HANDLE_DW_OP(0xa3, entry_value, 5, DWARF) -HANDLE_DW_OP(0xa4, const_type, 5, DWARF) -HANDLE_DW_OP(0xa5, regval_type, 5, DWARF) -HANDLE_DW_OP(0xa6, deref_type, 5, DWARF) -HANDLE_DW_OP(0xa7, xderef_type, 5, DWARF) -HANDLE_DW_OP(0xa8, convert, 5, DWARF) -HANDLE_DW_OP(0xa9, reinterpret, 5, DWARF) -// Vendor extensions: -// Extensions for GNU-style thread-local storage. -HANDLE_DW_OP(0xe0, GNU_push_tls_address, 0, GNU) -// Extensions for Fission proposal. -HANDLE_DW_OP(0xfb, GNU_addr_index, 0, GNU) -HANDLE_DW_OP(0xfc, GNU_const_index, 0, GNU) - -// DWARF languages. -HANDLE_DW_LANG(0x0001, C89, 2, DWARF) -HANDLE_DW_LANG(0x0002, C, 2, DWARF) -HANDLE_DW_LANG(0x0003, Ada83, 2, DWARF) -HANDLE_DW_LANG(0x0004, C_plus_plus, 2, DWARF) -HANDLE_DW_LANG(0x0005, Cobol74, 2, DWARF) -HANDLE_DW_LANG(0x0006, Cobol85, 2, DWARF) -HANDLE_DW_LANG(0x0007, Fortran77, 2, DWARF) -HANDLE_DW_LANG(0x0008, Fortran90, 2, DWARF) -HANDLE_DW_LANG(0x0009, Pascal83, 2, DWARF) -HANDLE_DW_LANG(0x000a, Modula2, 2, DWARF) -// New in DWARF v3: -HANDLE_DW_LANG(0x000b, Java, 3, DWARF) -HANDLE_DW_LANG(0x000c, C99, 3, DWARF) -HANDLE_DW_LANG(0x000d, Ada95, 3, DWARF) -HANDLE_DW_LANG(0x000e, Fortran95, 3, DWARF) -HANDLE_DW_LANG(0x000f, PLI, 3, DWARF) -HANDLE_DW_LANG(0x0010, ObjC, 3, DWARF) -HANDLE_DW_LANG(0x0011, ObjC_plus_plus, 3, DWARF) -HANDLE_DW_LANG(0x0012, UPC, 3, DWARF) -HANDLE_DW_LANG(0x0013, D, 3, DWARF) -// New in DWARF v4: -HANDLE_DW_LANG(0x0014, Python, 4, DWARF) -// New in DWARF v5: -HANDLE_DW_LANG(0x0015, OpenCL, 5, DWARF) -HANDLE_DW_LANG(0x0016, Go, 5, DWARF) -HANDLE_DW_LANG(0x0017, Modula3, 5, DWARF) -HANDLE_DW_LANG(0x0018, Haskell, 5, DWARF) -HANDLE_DW_LANG(0x0019, C_plus_plus_03, 5, DWARF) -HANDLE_DW_LANG(0x001a, C_plus_plus_11, 5, DWARF) -HANDLE_DW_LANG(0x001b, OCaml, 5, DWARF) -HANDLE_DW_LANG(0x001c, Rust, 5, DWARF) -HANDLE_DW_LANG(0x001d, C11, 5, DWARF) -HANDLE_DW_LANG(0x001e, Swift, 5, DWARF) -HANDLE_DW_LANG(0x001f, Julia, 5, DWARF) -HANDLE_DW_LANG(0x0020, Dylan, 5, DWARF) -HANDLE_DW_LANG(0x0021, C_plus_plus_14, 5, DWARF) -HANDLE_DW_LANG(0x0022, Fortran03, 5, DWARF) -HANDLE_DW_LANG(0x0023, Fortran08, 5, DWARF) -HANDLE_DW_LANG(0x0024, RenderScript, 5, DWARF) -HANDLE_DW_LANG(0x0025, BLISS, 5, DWARF) -// Vendor extensions: -HANDLE_DW_LANG(0x8001, Mips_Assembler, 0, MIPS) -HANDLE_DW_LANG(0x8e57, GOOGLE_RenderScript, 0, GOOGLE) -HANDLE_DW_LANG(0xb000, BORLAND_Delphi, 0, BORLAND) - -// DWARF attribute type encodings. -HANDLE_DW_ATE(0x01, address, 2, DWARF) -HANDLE_DW_ATE(0x02, boolean, 2, DWARF) -HANDLE_DW_ATE(0x03, complex_float, 2, DWARF) -HANDLE_DW_ATE(0x04, float, 2, DWARF) -HANDLE_DW_ATE(0x05, signed, 2, DWARF) -HANDLE_DW_ATE(0x06, signed_char, 2, DWARF) -HANDLE_DW_ATE(0x07, unsigned, 2, DWARF) -HANDLE_DW_ATE(0x08, unsigned_char, 2, DWARF) -// New in DWARF v3: -HANDLE_DW_ATE(0x09, imaginary_float, 3, DWARF) -HANDLE_DW_ATE(0x0a, packed_decimal, 3, DWARF) -HANDLE_DW_ATE(0x0b, numeric_string, 3, DWARF) -HANDLE_DW_ATE(0x0c, edited, 3, DWARF) -HANDLE_DW_ATE(0x0d, signed_fixed, 3, DWARF) -HANDLE_DW_ATE(0x0e, unsigned_fixed, 3, DWARF) -HANDLE_DW_ATE(0x0f, decimal_float, 3, DWARF) -// New in DWARF v4: -HANDLE_DW_ATE(0x10, UTF, 4, DWARF) -// New in DWARF v5: -HANDLE_DW_ATE(0x11, UCS, 5, DWARF) -HANDLE_DW_ATE(0x12, ASCII, 5, DWARF) - -// DWARF virtuality codes. -HANDLE_DW_VIRTUALITY(0x00, none) -HANDLE_DW_VIRTUALITY(0x01, virtual) -HANDLE_DW_VIRTUALITY(0x02, pure_virtual) - -// DWARF v5 Defaulted Member Encodings. -HANDLE_DW_DEFAULTED(0x00, no) -HANDLE_DW_DEFAULTED(0x01, in_class) -HANDLE_DW_DEFAULTED(0x02, out_of_class) - -// DWARF calling convention codes. -HANDLE_DW_CC(0x01, normal) -HANDLE_DW_CC(0x02, program) -HANDLE_DW_CC(0x03, nocall) -// New in DWARF v5: -HANDLE_DW_CC(0x04, pass_by_reference) -HANDLE_DW_CC(0x05, pass_by_value) -// Vendor extensions: -HANDLE_DW_CC(0x41, GNU_borland_fastcall_i386) -HANDLE_DW_CC(0xb0, BORLAND_safecall) -HANDLE_DW_CC(0xb1, BORLAND_stdcall) -HANDLE_DW_CC(0xb2, BORLAND_pascal) -HANDLE_DW_CC(0xb3, BORLAND_msfastcall) -HANDLE_DW_CC(0xb4, BORLAND_msreturn) -HANDLE_DW_CC(0xb5, BORLAND_thiscall) -HANDLE_DW_CC(0xb6, BORLAND_fastcall) -HANDLE_DW_CC(0xc0, LLVM_vectorcall) - -// Line Number Extended Opcode Encodings -HANDLE_DW_LNE(0x01, end_sequence) -HANDLE_DW_LNE(0x02, set_address) -HANDLE_DW_LNE(0x03, define_file) -// New in DWARF v4: -HANDLE_DW_LNE(0x04, set_discriminator) - -// Line Number Standard Opcode Encodings. -HANDLE_DW_LNS(0x00, extended_op) -HANDLE_DW_LNS(0x01, copy) -HANDLE_DW_LNS(0x02, advance_pc) -HANDLE_DW_LNS(0x03, advance_line) -HANDLE_DW_LNS(0x04, set_file) -HANDLE_DW_LNS(0x05, set_column) -HANDLE_DW_LNS(0x06, negate_stmt) -HANDLE_DW_LNS(0x07, set_basic_block) -HANDLE_DW_LNS(0x08, const_add_pc) -HANDLE_DW_LNS(0x09, fixed_advance_pc) -// New in DWARF v3: -HANDLE_DW_LNS(0x0a, set_prologue_end) -HANDLE_DW_LNS(0x0b, set_epilogue_begin) -HANDLE_DW_LNS(0x0c, set_isa) - -// DWARF v5 Line number header entry format. -HANDLE_DW_LNCT(0x01, path) -HANDLE_DW_LNCT(0x02, directory_index) -HANDLE_DW_LNCT(0x03, timestamp) -HANDLE_DW_LNCT(0x04, size) -HANDLE_DW_LNCT(0x05, MD5) - -// DWARF v5 Macro information. -HANDLE_DW_MACRO(0x01, define) -HANDLE_DW_MACRO(0x02, undef) -HANDLE_DW_MACRO(0x03, start_file) -HANDLE_DW_MACRO(0x04, end_file) -HANDLE_DW_MACRO(0x05, define_strp) -HANDLE_DW_MACRO(0x06, undef_strp) -HANDLE_DW_MACRO(0x07, import) -HANDLE_DW_MACRO(0x08, define_sup) -HANDLE_DW_MACRO(0x09, undef_sup) -HANDLE_DW_MACRO(0x0a, import_sup) -HANDLE_DW_MACRO(0x0b, define_strx) -HANDLE_DW_MACRO(0x0c, undef_strx) - -// DWARF v5 Range List Entry encoding values. -HANDLE_DW_RLE(0x00, end_of_list) -HANDLE_DW_RLE(0x01, base_addressx) -HANDLE_DW_RLE(0x02, startx_endx) -HANDLE_DW_RLE(0x03, startx_length) -HANDLE_DW_RLE(0x04, offset_pair) -HANDLE_DW_RLE(0x05, base_address) -HANDLE_DW_RLE(0x06, start_end) -HANDLE_DW_RLE(0x07, start_length) - -// Call frame instruction encodings. -HANDLE_DW_CFA(0x00, nop) -HANDLE_DW_CFA(0x40, advance_loc) -HANDLE_DW_CFA(0x80, offset) -HANDLE_DW_CFA(0xc0, restore) -HANDLE_DW_CFA(0x01, set_loc) -HANDLE_DW_CFA(0x02, advance_loc1) -HANDLE_DW_CFA(0x03, advance_loc2) -HANDLE_DW_CFA(0x04, advance_loc4) -HANDLE_DW_CFA(0x05, offset_extended) -HANDLE_DW_CFA(0x06, restore_extended) -HANDLE_DW_CFA(0x07, undefined) -HANDLE_DW_CFA(0x08, same_value) -HANDLE_DW_CFA(0x09, register) -HANDLE_DW_CFA(0x0a, remember_state) -HANDLE_DW_CFA(0x0b, restore_state) -HANDLE_DW_CFA(0x0c, def_cfa) -HANDLE_DW_CFA(0x0d, def_cfa_register) -HANDLE_DW_CFA(0x0e, def_cfa_offset) -// New in DWARF v3: -HANDLE_DW_CFA(0x0f, def_cfa_expression) -HANDLE_DW_CFA(0x10, expression) -HANDLE_DW_CFA(0x11, offset_extended_sf) -HANDLE_DW_CFA(0x12, def_cfa_sf) -HANDLE_DW_CFA(0x13, def_cfa_offset_sf) -HANDLE_DW_CFA(0x14, val_offset) -HANDLE_DW_CFA(0x15, val_offset_sf) -HANDLE_DW_CFA(0x16, val_expression) -// Vendor extensions: -HANDLE_DW_CFA(0x1d, MIPS_advance_loc8) -HANDLE_DW_CFA(0x2d, GNU_window_save) -HANDLE_DW_CFA(0x2e, GNU_args_size) - -// Apple Objective-C Property Attributes. -// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind! -HANDLE_DW_APPLE_PROPERTY(0x01, readonly) -HANDLE_DW_APPLE_PROPERTY(0x02, getter) -HANDLE_DW_APPLE_PROPERTY(0x04, assign) -HANDLE_DW_APPLE_PROPERTY(0x08, readwrite) -HANDLE_DW_APPLE_PROPERTY(0x10, retain) -HANDLE_DW_APPLE_PROPERTY(0x20, copy) -HANDLE_DW_APPLE_PROPERTY(0x40, nonatomic) -HANDLE_DW_APPLE_PROPERTY(0x80, setter) -HANDLE_DW_APPLE_PROPERTY(0x100, atomic) -HANDLE_DW_APPLE_PROPERTY(0x200, weak) -HANDLE_DW_APPLE_PROPERTY(0x400, strong) -HANDLE_DW_APPLE_PROPERTY(0x800, unsafe_unretained) -HANDLE_DW_APPLE_PROPERTY(0x1000, nullability) -HANDLE_DW_APPLE_PROPERTY(0x2000, null_resettable) -HANDLE_DW_APPLE_PROPERTY(0x4000, class) - -// DWARF v5 Unit Types. -HANDLE_DW_UT(0x01, compile) -HANDLE_DW_UT(0x02, type) -HANDLE_DW_UT(0x03, partial) -HANDLE_DW_UT(0x04, skeleton) -HANDLE_DW_UT(0x05, split_compile) -HANDLE_DW_UT(0x06, split_type) - -#undef HANDLE_DW_TAG -#undef HANDLE_DW_AT -#undef HANDLE_DW_FORM -#undef HANDLE_DW_OP -#undef HANDLE_DW_LANG -#undef HANDLE_DW_ATE -#undef HANDLE_DW_VIRTUALITY -#undef HANDLE_DW_DEFAULTED -#undef HANDLE_DW_CC -#undef HANDLE_DW_LNS -#undef HANDLE_DW_LNE -#undef HANDLE_DW_LNCT -#undef HANDLE_DW_MACRO -#undef HANDLE_DW_RLE -#undef HANDLE_DW_CFA -#undef HANDLE_DW_APPLE_PROPERTY -#undef HANDLE_DW_UT diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h deleted file mode 100644 index 3061b7b5fa0f0..0000000000000 --- a/include/llvm/Support/Dwarf.h +++ /dev/null @@ -1,497 +0,0 @@ -//===-- llvm/Support/Dwarf.h ---Dwarf Constants------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// \file -// \brief This file contains constants used for implementing Dwarf -// debug support. -// -// For details on the Dwarf specfication see the latest DWARF Debugging -// Information Format standard document on http://www.dwarfstd.org. This -// file often includes support for non-released standard features. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_DWARF_H -#define LLVM_SUPPORT_DWARF_H - -#include "llvm/Support/Compiler.h" -#include "llvm/Support/DataTypes.h" - -namespace llvm { -class StringRef; - -namespace dwarf { - -//===----------------------------------------------------------------------===// -// DWARF constants as gleaned from the DWARF Debugging Information Format V.5 -// reference manual http://www.dwarfstd.org/. -// - -// Do not mix the following two enumerations sets. DW_TAG_invalid changes the -// enumeration base type. - -enum LLVMConstants : uint32_t { - // LLVM mock tags (see also llvm/Support/Dwarf.def). - DW_TAG_invalid = ~0U, // Tag for invalid results. - DW_VIRTUALITY_invalid = ~0U, // Virtuality for invalid results. - DW_MACINFO_invalid = ~0U, // Macinfo type for invalid results. - - // Other constants. - DWARF_VERSION = 4, // Default dwarf version we output. - DW_PUBTYPES_VERSION = 2, // Section version number for .debug_pubtypes. - DW_PUBNAMES_VERSION = 2, // Section version number for .debug_pubnames. - DW_ARANGES_VERSION = 2, // Section version number for .debug_aranges. - // Identifiers we use to distinguish vendor extensions. - DWARF_VENDOR_DWARF = 0, // Defined in v2 or later of the DWARF standard. - DWARF_VENDOR_APPLE = 1, - DWARF_VENDOR_BORLAND = 2, - DWARF_VENDOR_GNU = 3, - DWARF_VENDOR_GOOGLE = 4, - DWARF_VENDOR_LLVM = 5, - DWARF_VENDOR_MIPS = 6 -}; - -// Special ID values that distinguish a CIE from a FDE in DWARF CFI. -// Not inside an enum because a 64-bit value is needed. -const uint32_t DW_CIE_ID = UINT32_MAX; -const uint64_t DW64_CIE_ID = UINT64_MAX; - -enum Tag : uint16_t { -#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR) DW_TAG_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_TAG_lo_user = 0x4080, - DW_TAG_hi_user = 0xffff, - DW_TAG_user_base = 0x1000 // Recommended base for user tags. -}; - -inline bool isType(Tag T) { - switch (T) { - case DW_TAG_array_type: - case DW_TAG_class_type: - case DW_TAG_interface_type: - case DW_TAG_enumeration_type: - case DW_TAG_pointer_type: - case DW_TAG_reference_type: - case DW_TAG_rvalue_reference_type: - case DW_TAG_string_type: - case DW_TAG_structure_type: - case DW_TAG_subroutine_type: - case DW_TAG_union_type: - case DW_TAG_ptr_to_member_type: - case DW_TAG_set_type: - case DW_TAG_subrange_type: - case DW_TAG_base_type: - case DW_TAG_const_type: - case DW_TAG_file_type: - case DW_TAG_packed_type: - case DW_TAG_volatile_type: - case DW_TAG_typedef: - return true; - default: - return false; - } -} - -/// Attributes. -enum Attribute : uint16_t { -#define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) DW_AT_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_AT_lo_user = 0x2000, - DW_AT_hi_user = 0x3fff, -}; - -enum Form : uint16_t { -#define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR) DW_FORM_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_FORM_lo_user = 0x1f00, ///< Not specified by DWARF. -}; - -enum LocationAtom { -#define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR) DW_OP_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_OP_lo_user = 0xe0, - DW_OP_hi_user = 0xff, - DW_OP_LLVM_fragment = 0x1000 ///< Only used in LLVM metadata. -}; - -enum TypeKind { -#define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) DW_ATE_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_ATE_lo_user = 0x80, - DW_ATE_hi_user = 0xff -}; - -enum DecimalSignEncoding { - // Decimal sign attribute values - DW_DS_unsigned = 0x01, - DW_DS_leading_overpunch = 0x02, - DW_DS_trailing_overpunch = 0x03, - DW_DS_leading_separate = 0x04, - DW_DS_trailing_separate = 0x05 -}; - -enum EndianityEncoding { - // Endianity attribute values - DW_END_default = 0x00, - DW_END_big = 0x01, - DW_END_little = 0x02, - DW_END_lo_user = 0x40, - DW_END_hi_user = 0xff -}; - -enum AccessAttribute { - // Accessibility codes - DW_ACCESS_public = 0x01, - DW_ACCESS_protected = 0x02, - DW_ACCESS_private = 0x03 -}; - -enum VisibilityAttribute { - // Visibility codes - DW_VIS_local = 0x01, - DW_VIS_exported = 0x02, - DW_VIS_qualified = 0x03 -}; - -enum VirtualityAttribute { -#define HANDLE_DW_VIRTUALITY(ID, NAME) DW_VIRTUALITY_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_VIRTUALITY_max = 0x02 -}; - -enum DefaultedMemberAttribute { -#define HANDLE_DW_DEFAULTED(ID, NAME) DW_DEFAULTED_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_DEFAULTED_max = 0x02 -}; - -enum SourceLanguage { -#define HANDLE_DW_LANG(ID, NAME, VERSION, VENDOR) DW_LANG_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_LANG_lo_user = 0x8000, - DW_LANG_hi_user = 0xffff -}; - -enum CaseSensitivity { - // Identifier case codes - DW_ID_case_sensitive = 0x00, - DW_ID_up_case = 0x01, - DW_ID_down_case = 0x02, - DW_ID_case_insensitive = 0x03 -}; - -enum CallingConvention { - // Calling convention codes -#define HANDLE_DW_CC(ID, NAME) DW_CC_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_CC_lo_user = 0x40, - DW_CC_hi_user = 0xff -}; - -enum InlineAttribute { - // Inline codes - DW_INL_not_inlined = 0x00, - DW_INL_inlined = 0x01, - DW_INL_declared_not_inlined = 0x02, - DW_INL_declared_inlined = 0x03 -}; - -enum ArrayDimensionOrdering { - // Array ordering - DW_ORD_row_major = 0x00, - DW_ORD_col_major = 0x01 -}; - -enum DiscriminantList { - // Discriminant descriptor values - DW_DSC_label = 0x00, - DW_DSC_range = 0x01 -}; - -/// Line Number Standard Opcode Encodings. -enum LineNumberOps : uint8_t { -#define HANDLE_DW_LNS(ID, NAME) DW_LNS_##NAME = ID, -#include "llvm/Support/Dwarf.def" -}; - -/// Line Number Extended Opcode Encodings. -enum LineNumberExtendedOps { -#define HANDLE_DW_LNE(ID, NAME) DW_LNE_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_LNE_lo_user = 0x80, - DW_LNE_hi_user = 0xff -}; - -enum LineNumberEntryFormat { -#define HANDLE_DW_LNCT(ID, NAME) DW_LNCT_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_LNCT_lo_user = 0x2000, - DW_LNCT_hi_user = 0x3fff, -}; - -enum MacinfoRecordType { - // Macinfo Type Encodings - DW_MACINFO_define = 0x01, - DW_MACINFO_undef = 0x02, - DW_MACINFO_start_file = 0x03, - DW_MACINFO_end_file = 0x04, - DW_MACINFO_vendor_ext = 0xff -}; - -/// DWARF v5 macro information entry type encodings. -enum MacroEntryType { -#define HANDLE_DW_MACRO(ID, NAME) DW_MACRO_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_MACRO_lo_user = 0xe0, - DW_MACRO_hi_user = 0xff -}; - -/// DWARF v5 range list entry encoding values. -enum RangeListEntries { -#define HANDLE_DW_RLE(ID, NAME) DW_RLE_##NAME = ID, -#include "llvm/Support/Dwarf.def" -}; - - -/// Call frame instruction encodings. -enum CallFrameInfo { -#define HANDLE_DW_CFA(ID, NAME) DW_CFA_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_CFA_extended = 0x00, - - DW_CFA_lo_user = 0x1c, - DW_CFA_hi_user = 0x3f -}; - -enum Constants { - // Children flag - DW_CHILDREN_no = 0x00, - DW_CHILDREN_yes = 0x01, - - DW_EH_PE_absptr = 0x00, - DW_EH_PE_omit = 0xff, - DW_EH_PE_uleb128 = 0x01, - DW_EH_PE_udata2 = 0x02, - DW_EH_PE_udata4 = 0x03, - DW_EH_PE_udata8 = 0x04, - DW_EH_PE_sleb128 = 0x09, - DW_EH_PE_sdata2 = 0x0A, - DW_EH_PE_sdata4 = 0x0B, - DW_EH_PE_sdata8 = 0x0C, - DW_EH_PE_signed = 0x08, - DW_EH_PE_pcrel = 0x10, - DW_EH_PE_textrel = 0x20, - DW_EH_PE_datarel = 0x30, - DW_EH_PE_funcrel = 0x40, - DW_EH_PE_aligned = 0x50, - DW_EH_PE_indirect = 0x80 -}; - -/// Constants for location lists in DWARF v5. -enum LocationListEntry : unsigned char { - DW_LLE_end_of_list = 0x00, - DW_LLE_base_addressx = 0x01, - DW_LLE_startx_endx = 0x02, - DW_LLE_startx_length = 0x03, - DW_LLE_offset_pair = 0x04, - DW_LLE_default_location = 0x05, - DW_LLE_base_address = 0x06, - DW_LLE_start_end = 0x07, - DW_LLE_start_length = 0x08 -}; - -/// Constants for the DW_APPLE_PROPERTY_attributes attribute. -/// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind! -enum ApplePropertyAttributes { -#define HANDLE_DW_APPLE_PROPERTY(ID, NAME) DW_APPLE_PROPERTY_##NAME = ID, -#include "llvm/Support/Dwarf.def" -}; - -/// Constants for unit types in DWARF v5. -enum UnitType : unsigned char { -#define HANDLE_DW_UT(ID, NAME) DW_UT_##NAME = ID, -#include "llvm/Support/Dwarf.def" - DW_UT_lo_user = 0x80, - DW_UT_hi_user = 0xff -}; - -// Constants for the DWARF v5 Accelerator Table Proposal -enum AcceleratorTable { - // Data layout descriptors. - DW_ATOM_null = 0u, // Marker as the end of a list of atoms. - DW_ATOM_die_offset = 1u, // DIE offset in the debug_info section. - DW_ATOM_cu_offset = 2u, // Offset of the compile unit header that contains the - // item in question. - DW_ATOM_die_tag = 3u, // A tag entry. - DW_ATOM_type_flags = 4u, // Set of flags for a type. - - // DW_ATOM_type_flags values. - - // Always set for C++, only set for ObjC if this is the @implementation for a - // class. - DW_FLAG_type_implementation = 2u, - - // Hash functions. - - // Daniel J. Bernstein hash. - DW_hash_function_djb = 0u -}; - -// Constants for the GNU pubnames/pubtypes extensions supporting gdb index. -enum GDBIndexEntryKind { - GIEK_NONE, - GIEK_TYPE, - GIEK_VARIABLE, - GIEK_FUNCTION, - GIEK_OTHER, - GIEK_UNUSED5, - GIEK_UNUSED6, - GIEK_UNUSED7 -}; - -enum GDBIndexEntryLinkage { - GIEL_EXTERNAL, - GIEL_STATIC -}; - -/// \defgroup DwarfConstantsDumping Dwarf constants dumping functions -/// -/// All these functions map their argument's value back to the -/// corresponding enumerator name or return nullptr if the value isn't -/// known. -/// -/// @{ -StringRef TagString(unsigned Tag); -StringRef ChildrenString(unsigned Children); -StringRef AttributeString(unsigned Attribute); -StringRef FormEncodingString(unsigned Encoding); -StringRef OperationEncodingString(unsigned Encoding); -StringRef AttributeEncodingString(unsigned Encoding); -StringRef DecimalSignString(unsigned Sign); -StringRef EndianityString(unsigned Endian); -StringRef AccessibilityString(unsigned Access); -StringRef VisibilityString(unsigned Visibility); -StringRef VirtualityString(unsigned Virtuality); -StringRef LanguageString(unsigned Language); -StringRef CaseString(unsigned Case); -StringRef ConventionString(unsigned Convention); -StringRef InlineCodeString(unsigned Code); -StringRef ArrayOrderString(unsigned Order); -StringRef DiscriminantString(unsigned Discriminant); -StringRef LNStandardString(unsigned Standard); -StringRef LNExtendedString(unsigned Encoding); -StringRef MacinfoString(unsigned Encoding); -StringRef CallFrameString(unsigned Encoding); -StringRef ApplePropertyString(unsigned); -StringRef UnitTypeString(unsigned); -StringRef AtomTypeString(unsigned Atom); -StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind); -StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage); -/// @} - -/// \defgroup DwarfConstantsParsing Dwarf constants parsing functions -/// -/// These functions map their strings back to the corresponding enumeration -/// value or return 0 if there is none, except for these exceptions: -/// -/// \li \a getTag() returns \a DW_TAG_invalid on invalid input. -/// \li \a getVirtuality() returns \a DW_VIRTUALITY_invalid on invalid input. -/// \li \a getMacinfo() returns \a DW_MACINFO_invalid on invalid input. -/// -/// @{ -unsigned getTag(StringRef TagString); -unsigned getOperationEncoding(StringRef OperationEncodingString); -unsigned getVirtuality(StringRef VirtualityString); -unsigned getLanguage(StringRef LanguageString); -unsigned getCallingConvention(StringRef LanguageString); -unsigned getAttributeEncoding(StringRef EncodingString); -unsigned getMacinfo(StringRef MacinfoString); -/// @} - -/// \defgroup DwarfConstantsVersioning Dwarf version for constants -/// -/// For constants defined by DWARF, returns the DWARF version when the constant -/// was first defined. For vendor extensions, if there is a version-related -/// policy for when to emit it, returns a version number for that policy. -/// Otherwise returns 0. -/// -/// @{ -unsigned TagVersion(Tag T); -unsigned AttributeVersion(Attribute A); -unsigned FormVersion(Form F); -unsigned OperationVersion(LocationAtom O); -unsigned AttributeEncodingVersion(TypeKind E); -unsigned LanguageVersion(SourceLanguage L); -/// @} - -/// \defgroup DwarfConstantsVendor Dwarf "vendor" for constants -/// -/// These functions return an identifier describing "who" defined the constant, -/// either the DWARF standard itself or the vendor who defined the extension. -/// -/// @{ -unsigned TagVendor(Tag T); -unsigned AttributeVendor(Attribute A); -unsigned FormVendor(Form F); -unsigned OperationVendor(LocationAtom O); -unsigned AttributeEncodingVendor(TypeKind E); -unsigned LanguageVendor(SourceLanguage L); -/// @} - -/// Tells whether the specified form is defined in the specified version, -/// or is an extension if extensions are allowed. -bool isValidFormForVersion(Form F, unsigned Version, bool ExtensionsOk = true); - -/// \brief Returns the symbolic string representing Val when used as a value -/// for attribute Attr. -StringRef AttributeValueString(uint16_t Attr, unsigned Val); - -/// \brief Decsribes an entry of the various gnu_pub* debug sections. -/// -/// The gnu_pub* kind looks like: -/// -/// 0-3 reserved -/// 4-6 symbol kind -/// 7 0 == global, 1 == static -/// -/// A gdb_index descriptor includes the above kind, shifted 24 bits up with the -/// offset of the cu within the debug_info section stored in those 24 bits. -struct PubIndexEntryDescriptor { - GDBIndexEntryKind Kind; - GDBIndexEntryLinkage Linkage; - PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Linkage) - : Kind(Kind), Linkage(Linkage) {} - /* implicit */ PubIndexEntryDescriptor(GDBIndexEntryKind Kind) - : Kind(Kind), Linkage(GIEL_EXTERNAL) {} - explicit PubIndexEntryDescriptor(uint8_t Value) - : Kind(static_cast<GDBIndexEntryKind>((Value & KIND_MASK) >> - KIND_OFFSET)), - Linkage(static_cast<GDBIndexEntryLinkage>((Value & LINKAGE_MASK) >> - LINKAGE_OFFSET)) {} - uint8_t toBits() const { - return Kind << KIND_OFFSET | Linkage << LINKAGE_OFFSET; - } - -private: - enum { - KIND_OFFSET = 4, - KIND_MASK = 7 << KIND_OFFSET, - LINKAGE_OFFSET = 7, - LINKAGE_MASK = 1 << LINKAGE_OFFSET - }; -}; - -/// Constants that define the DWARF format as 32 or 64 bit. -enum DwarfFormat { DWARF32, DWARF64 }; - -} // End of namespace dwarf - -} // End of namespace llvm - -#endif diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h deleted file mode 100644 index 33f20a809d6ca..0000000000000 --- a/include/llvm/Support/ELF.h +++ /dev/null @@ -1,1375 +0,0 @@ -//===-- llvm/Support/ELF.h - ELF constants and data structures --*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This header contains common, non-processor-specific data structures and -// constants for the ELF file format. -// -// The details of the ELF32 bits in this file are largely based on the Tool -// Interface Standard (TIS) Executable and Linking Format (ELF) Specification -// Version 1.2, May 1995. The ELF64 stuff is based on ELF-64 Object File Format -// Version 1.5, Draft 2, May 1998 as well as OpenBSD header files. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_ELF_H -#define LLVM_SUPPORT_ELF_H - -#include "llvm/Support/Compiler.h" -#include "llvm/Support/DataTypes.h" -#include <cstring> - -namespace llvm { - -namespace ELF { - -typedef uint32_t Elf32_Addr; // Program address -typedef uint32_t Elf32_Off; // File offset -typedef uint16_t Elf32_Half; -typedef uint32_t Elf32_Word; -typedef int32_t Elf32_Sword; - -typedef uint64_t Elf64_Addr; -typedef uint64_t Elf64_Off; -typedef uint16_t Elf64_Half; -typedef uint32_t Elf64_Word; -typedef int32_t Elf64_Sword; -typedef uint64_t Elf64_Xword; -typedef int64_t Elf64_Sxword; - -// Object file magic string. -static const char ElfMagic[] = {0x7f, 'E', 'L', 'F', '\0'}; - -// e_ident size and indices. -enum { - EI_MAG0 = 0, // File identification index. - EI_MAG1 = 1, // File identification index. - EI_MAG2 = 2, // File identification index. - EI_MAG3 = 3, // File identification index. - EI_CLASS = 4, // File class. - EI_DATA = 5, // Data encoding. - EI_VERSION = 6, // File version. - EI_OSABI = 7, // OS/ABI identification. - EI_ABIVERSION = 8, // ABI version. - EI_PAD = 9, // Start of padding bytes. - EI_NIDENT = 16 // Number of bytes in e_ident. -}; - -struct Elf32_Ehdr { - unsigned char e_ident[EI_NIDENT]; // ELF Identification bytes - Elf32_Half e_type; // Type of file (see ET_* below) - Elf32_Half e_machine; // Required architecture for this file (see EM_*) - Elf32_Word e_version; // Must be equal to 1 - Elf32_Addr e_entry; // Address to jump to in order to start program - Elf32_Off e_phoff; // Program header table's file offset, in bytes - Elf32_Off e_shoff; // Section header table's file offset, in bytes - Elf32_Word e_flags; // Processor-specific flags - Elf32_Half e_ehsize; // Size of ELF header, in bytes - Elf32_Half e_phentsize; // Size of an entry in the program header table - Elf32_Half e_phnum; // Number of entries in the program header table - Elf32_Half e_shentsize; // Size of an entry in the section header table - Elf32_Half e_shnum; // Number of entries in the section header table - Elf32_Half e_shstrndx; // Sect hdr table index of sect name string table - bool checkMagic() const { - return (memcmp(e_ident, ElfMagic, strlen(ElfMagic))) == 0; - } - unsigned char getFileClass() const { return e_ident[EI_CLASS]; } - unsigned char getDataEncoding() const { return e_ident[EI_DATA]; } -}; - -// 64-bit ELF header. Fields are the same as for ELF32, but with different -// types (see above). -struct Elf64_Ehdr { - unsigned char e_ident[EI_NIDENT]; - Elf64_Half e_type; - Elf64_Half e_machine; - Elf64_Word e_version; - Elf64_Addr e_entry; - Elf64_Off e_phoff; - Elf64_Off e_shoff; - Elf64_Word e_flags; - Elf64_Half e_ehsize; - Elf64_Half e_phentsize; - Elf64_Half e_phnum; - Elf64_Half e_shentsize; - Elf64_Half e_shnum; - Elf64_Half e_shstrndx; - bool checkMagic() const { - return (memcmp(e_ident, ElfMagic, strlen(ElfMagic))) == 0; - } - unsigned char getFileClass() const { return e_ident[EI_CLASS]; } - unsigned char getDataEncoding() const { return e_ident[EI_DATA]; } -}; - -// File types -enum { - ET_NONE = 0, // No file type - ET_REL = 1, // Relocatable file - ET_EXEC = 2, // Executable file - ET_DYN = 3, // Shared object file - ET_CORE = 4, // Core file - ET_LOPROC = 0xff00, // Beginning of processor-specific codes - ET_HIPROC = 0xffff // Processor-specific -}; - -// Versioning -enum { EV_NONE = 0, EV_CURRENT = 1 }; - -// Machine architectures -// See current registered ELF machine architectures at: -// http://www.uxsglobal.com/developers/gabi/latest/ch4.eheader.html -enum { - EM_NONE = 0, // No machine - EM_M32 = 1, // AT&T WE 32100 - EM_SPARC = 2, // SPARC - EM_386 = 3, // Intel 386 - EM_68K = 4, // Motorola 68000 - EM_88K = 5, // Motorola 88000 - EM_IAMCU = 6, // Intel MCU - EM_860 = 7, // Intel 80860 - EM_MIPS = 8, // MIPS R3000 - EM_S370 = 9, // IBM System/370 - EM_MIPS_RS3_LE = 10, // MIPS RS3000 Little-endian - EM_PARISC = 15, // Hewlett-Packard PA-RISC - EM_VPP500 = 17, // Fujitsu VPP500 - EM_SPARC32PLUS = 18, // Enhanced instruction set SPARC - EM_960 = 19, // Intel 80960 - EM_PPC = 20, // PowerPC - EM_PPC64 = 21, // PowerPC64 - EM_S390 = 22, // IBM System/390 - EM_SPU = 23, // IBM SPU/SPC - EM_V800 = 36, // NEC V800 - EM_FR20 = 37, // Fujitsu FR20 - EM_RH32 = 38, // TRW RH-32 - EM_RCE = 39, // Motorola RCE - EM_ARM = 40, // ARM - EM_ALPHA = 41, // DEC Alpha - EM_SH = 42, // Hitachi SH - EM_SPARCV9 = 43, // SPARC V9 - EM_TRICORE = 44, // Siemens TriCore - EM_ARC = 45, // Argonaut RISC Core - EM_H8_300 = 46, // Hitachi H8/300 - EM_H8_300H = 47, // Hitachi H8/300H - EM_H8S = 48, // Hitachi H8S - EM_H8_500 = 49, // Hitachi H8/500 - EM_IA_64 = 50, // Intel IA-64 processor architecture - EM_MIPS_X = 51, // Stanford MIPS-X - EM_COLDFIRE = 52, // Motorola ColdFire - EM_68HC12 = 53, // Motorola M68HC12 - EM_MMA = 54, // Fujitsu MMA Multimedia Accelerator - EM_PCP = 55, // Siemens PCP - EM_NCPU = 56, // Sony nCPU embedded RISC processor - EM_NDR1 = 57, // Denso NDR1 microprocessor - EM_STARCORE = 58, // Motorola Star*Core processor - EM_ME16 = 59, // Toyota ME16 processor - EM_ST100 = 60, // STMicroelectronics ST100 processor - EM_TINYJ = 61, // Advanced Logic Corp. TinyJ embedded processor family - EM_X86_64 = 62, // AMD x86-64 architecture - EM_PDSP = 63, // Sony DSP Processor - EM_PDP10 = 64, // Digital Equipment Corp. PDP-10 - EM_PDP11 = 65, // Digital Equipment Corp. PDP-11 - EM_FX66 = 66, // Siemens FX66 microcontroller - EM_ST9PLUS = 67, // STMicroelectronics ST9+ 8/16 bit microcontroller - EM_ST7 = 68, // STMicroelectronics ST7 8-bit microcontroller - EM_68HC16 = 69, // Motorola MC68HC16 Microcontroller - EM_68HC11 = 70, // Motorola MC68HC11 Microcontroller - EM_68HC08 = 71, // Motorola MC68HC08 Microcontroller - EM_68HC05 = 72, // Motorola MC68HC05 Microcontroller - EM_SVX = 73, // Silicon Graphics SVx - EM_ST19 = 74, // STMicroelectronics ST19 8-bit microcontroller - EM_VAX = 75, // Digital VAX - EM_CRIS = 76, // Axis Communications 32-bit embedded processor - EM_JAVELIN = 77, // Infineon Technologies 32-bit embedded processor - EM_FIREPATH = 78, // Element 14 64-bit DSP Processor - EM_ZSP = 79, // LSI Logic 16-bit DSP Processor - EM_MMIX = 80, // Donald Knuth's educational 64-bit processor - EM_HUANY = 81, // Harvard University machine-independent object files - EM_PRISM = 82, // SiTera Prism - EM_AVR = 83, // Atmel AVR 8-bit microcontroller - EM_FR30 = 84, // Fujitsu FR30 - EM_D10V = 85, // Mitsubishi D10V - EM_D30V = 86, // Mitsubishi D30V - EM_V850 = 87, // NEC v850 - EM_M32R = 88, // Mitsubishi M32R - EM_MN10300 = 89, // Matsushita MN10300 - EM_MN10200 = 90, // Matsushita MN10200 - EM_PJ = 91, // picoJava - EM_OPENRISC = 92, // OpenRISC 32-bit embedded processor - EM_ARC_COMPACT = 93, // ARC International ARCompact processor (old - // spelling/synonym: EM_ARC_A5) - EM_XTENSA = 94, // Tensilica Xtensa Architecture - EM_VIDEOCORE = 95, // Alphamosaic VideoCore processor - EM_TMM_GPP = 96, // Thompson Multimedia General Purpose Processor - EM_NS32K = 97, // National Semiconductor 32000 series - EM_TPC = 98, // Tenor Network TPC processor - EM_SNP1K = 99, // Trebia SNP 1000 processor - EM_ST200 = 100, // STMicroelectronics (www.st.com) ST200 - EM_IP2K = 101, // Ubicom IP2xxx microcontroller family - EM_MAX = 102, // MAX Processor - EM_CR = 103, // National Semiconductor CompactRISC microprocessor - EM_F2MC16 = 104, // Fujitsu F2MC16 - EM_MSP430 = 105, // Texas Instruments embedded microcontroller msp430 - EM_BLACKFIN = 106, // Analog Devices Blackfin (DSP) processor - EM_SE_C33 = 107, // S1C33 Family of Seiko Epson processors - EM_SEP = 108, // Sharp embedded microprocessor - EM_ARCA = 109, // Arca RISC Microprocessor - EM_UNICORE = 110, // Microprocessor series from PKU-Unity Ltd. and MPRC - // of Peking University - EM_EXCESS = 111, // eXcess: 16/32/64-bit configurable embedded CPU - EM_DXP = 112, // Icera Semiconductor Inc. Deep Execution Processor - EM_ALTERA_NIOS2 = 113, // Altera Nios II soft-core processor - EM_CRX = 114, // National Semiconductor CompactRISC CRX - EM_XGATE = 115, // Motorola XGATE embedded processor - EM_C166 = 116, // Infineon C16x/XC16x processor - EM_M16C = 117, // Renesas M16C series microprocessors - EM_DSPIC30F = 118, // Microchip Technology dsPIC30F Digital Signal - // Controller - EM_CE = 119, // Freescale Communication Engine RISC core - EM_M32C = 120, // Renesas M32C series microprocessors - EM_TSK3000 = 131, // Altium TSK3000 core - EM_RS08 = 132, // Freescale RS08 embedded processor - EM_SHARC = 133, // Analog Devices SHARC family of 32-bit DSP - // processors - EM_ECOG2 = 134, // Cyan Technology eCOG2 microprocessor - EM_SCORE7 = 135, // Sunplus S+core7 RISC processor - EM_DSP24 = 136, // New Japan Radio (NJR) 24-bit DSP Processor - EM_VIDEOCORE3 = 137, // Broadcom VideoCore III processor - EM_LATTICEMICO32 = 138, // RISC processor for Lattice FPGA architecture - EM_SE_C17 = 139, // Seiko Epson C17 family - EM_TI_C6000 = 140, // The Texas Instruments TMS320C6000 DSP family - EM_TI_C2000 = 141, // The Texas Instruments TMS320C2000 DSP family - EM_TI_C5500 = 142, // The Texas Instruments TMS320C55x DSP family - EM_MMDSP_PLUS = 160, // STMicroelectronics 64bit VLIW Data Signal Processor - EM_CYPRESS_M8C = 161, // Cypress M8C microprocessor - EM_R32C = 162, // Renesas R32C series microprocessors - EM_TRIMEDIA = 163, // NXP Semiconductors TriMedia architecture family - EM_HEXAGON = 164, // Qualcomm Hexagon processor - EM_8051 = 165, // Intel 8051 and variants - EM_STXP7X = 166, // STMicroelectronics STxP7x family of configurable - // and extensible RISC processors - EM_NDS32 = 167, // Andes Technology compact code size embedded RISC - // processor family - EM_ECOG1 = 168, // Cyan Technology eCOG1X family - EM_ECOG1X = 168, // Cyan Technology eCOG1X family - EM_MAXQ30 = 169, // Dallas Semiconductor MAXQ30 Core Micro-controllers - EM_XIMO16 = 170, // New Japan Radio (NJR) 16-bit DSP Processor - EM_MANIK = 171, // M2000 Reconfigurable RISC Microprocessor - EM_CRAYNV2 = 172, // Cray Inc. NV2 vector architecture - EM_RX = 173, // Renesas RX family - EM_METAG = 174, // Imagination Technologies META processor - // architecture - EM_MCST_ELBRUS = 175, // MCST Elbrus general purpose hardware architecture - EM_ECOG16 = 176, // Cyan Technology eCOG16 family - EM_CR16 = 177, // National Semiconductor CompactRISC CR16 16-bit - // microprocessor - EM_ETPU = 178, // Freescale Extended Time Processing Unit - EM_SLE9X = 179, // Infineon Technologies SLE9X core - EM_L10M = 180, // Intel L10M - EM_K10M = 181, // Intel K10M - EM_AARCH64 = 183, // ARM AArch64 - EM_AVR32 = 185, // Atmel Corporation 32-bit microprocessor family - EM_STM8 = 186, // STMicroeletronics STM8 8-bit microcontroller - EM_TILE64 = 187, // Tilera TILE64 multicore architecture family - EM_TILEPRO = 188, // Tilera TILEPro multicore architecture family - EM_CUDA = 190, // NVIDIA CUDA architecture - EM_TILEGX = 191, // Tilera TILE-Gx multicore architecture family - EM_CLOUDSHIELD = 192, // CloudShield architecture family - EM_COREA_1ST = 193, // KIPO-KAIST Core-A 1st generation processor family - EM_COREA_2ND = 194, // KIPO-KAIST Core-A 2nd generation processor family - EM_ARC_COMPACT2 = 195, // Synopsys ARCompact V2 - EM_OPEN8 = 196, // Open8 8-bit RISC soft processor core - EM_RL78 = 197, // Renesas RL78 family - EM_VIDEOCORE5 = 198, // Broadcom VideoCore V processor - EM_78KOR = 199, // Renesas 78KOR family - EM_56800EX = 200, // Freescale 56800EX Digital Signal Controller (DSC) - EM_BA1 = 201, // Beyond BA1 CPU architecture - EM_BA2 = 202, // Beyond BA2 CPU architecture - EM_XCORE = 203, // XMOS xCORE processor family - EM_MCHP_PIC = 204, // Microchip 8-bit PIC(r) family - EM_INTEL205 = 205, // Reserved by Intel - EM_INTEL206 = 206, // Reserved by Intel - EM_INTEL207 = 207, // Reserved by Intel - EM_INTEL208 = 208, // Reserved by Intel - EM_INTEL209 = 209, // Reserved by Intel - EM_KM32 = 210, // KM211 KM32 32-bit processor - EM_KMX32 = 211, // KM211 KMX32 32-bit processor - EM_KMX16 = 212, // KM211 KMX16 16-bit processor - EM_KMX8 = 213, // KM211 KMX8 8-bit processor - EM_KVARC = 214, // KM211 KVARC processor - EM_CDP = 215, // Paneve CDP architecture family - EM_COGE = 216, // Cognitive Smart Memory Processor - EM_COOL = 217, // iCelero CoolEngine - EM_NORC = 218, // Nanoradio Optimized RISC - EM_CSR_KALIMBA = 219, // CSR Kalimba architecture family - EM_AMDGPU = 224, // AMD GPU architecture - EM_RISCV = 243, // RISC-V - EM_LANAI = 244, // Lanai 32-bit processor - EM_BPF = 247, // Linux kernel bpf virtual machine - - // A request has been made to the maintainer of the official registry for - // such numbers for an official value for WebAssembly. As soon as one is - // allocated, this enum will be updated to use it. - EM_WEBASSEMBLY = 0x4157, // WebAssembly architecture -}; - -// Object file classes. -enum { - ELFCLASSNONE = 0, - ELFCLASS32 = 1, // 32-bit object file - ELFCLASS64 = 2 // 64-bit object file -}; - -// Object file byte orderings. -enum { - ELFDATANONE = 0, // Invalid data encoding. - ELFDATA2LSB = 1, // Little-endian object file - ELFDATA2MSB = 2 // Big-endian object file -}; - -// OS ABI identification. -enum { - ELFOSABI_NONE = 0, // UNIX System V ABI - ELFOSABI_HPUX = 1, // HP-UX operating system - ELFOSABI_NETBSD = 2, // NetBSD - ELFOSABI_GNU = 3, // GNU/Linux - ELFOSABI_LINUX = 3, // Historical alias for ELFOSABI_GNU. - ELFOSABI_HURD = 4, // GNU/Hurd - ELFOSABI_SOLARIS = 6, // Solaris - ELFOSABI_AIX = 7, // AIX - ELFOSABI_IRIX = 8, // IRIX - ELFOSABI_FREEBSD = 9, // FreeBSD - ELFOSABI_TRU64 = 10, // TRU64 UNIX - ELFOSABI_MODESTO = 11, // Novell Modesto - ELFOSABI_OPENBSD = 12, // OpenBSD - ELFOSABI_OPENVMS = 13, // OpenVMS - ELFOSABI_NSK = 14, // Hewlett-Packard Non-Stop Kernel - ELFOSABI_AROS = 15, // AROS - ELFOSABI_FENIXOS = 16, // FenixOS - ELFOSABI_CLOUDABI = 17, // Nuxi CloudABI - ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000 - ELFOSABI_AMDGPU_HSA = 64, // AMD HSA runtime - ELFOSABI_C6000_LINUX = 65, // Linux TMS320C6000 - ELFOSABI_ARM = 97, // ARM - ELFOSABI_STANDALONE = 255 // Standalone (embedded) application -}; - -#define ELF_RELOC(name, value) name = value, - -// X86_64 relocations. -enum { -#include "ELFRelocs/x86_64.def" -}; - -// i386 relocations. -enum { -#include "ELFRelocs/i386.def" -}; - -// ELF Relocation types for PPC32 -enum { -#include "ELFRelocs/PowerPC.def" -}; - -// Specific e_flags for PPC64 -enum { - // e_flags bits specifying ABI: - // 1 for original ABI using function descriptors, - // 2 for revised ABI without function descriptors, - // 0 for unspecified or not using any features affected by the differences. - EF_PPC64_ABI = 3 -}; - -// Special values for the st_other field in the symbol table entry for PPC64. -enum { - STO_PPC64_LOCAL_BIT = 5, - STO_PPC64_LOCAL_MASK = (7 << STO_PPC64_LOCAL_BIT) -}; -static inline int64_t decodePPC64LocalEntryOffset(unsigned Other) { - unsigned Val = (Other & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT; - return ((1 << Val) >> 2) << 2; -} -static inline unsigned encodePPC64LocalEntryOffset(int64_t Offset) { - unsigned Val = - (Offset >= 4 * 4 ? (Offset >= 8 * 4 ? (Offset >= 16 * 4 ? 6 : 5) : 4) - : (Offset >= 2 * 4 ? 3 : (Offset >= 1 * 4 ? 2 : 0))); - return Val << STO_PPC64_LOCAL_BIT; -} - -// ELF Relocation types for PPC64 -enum { -#include "ELFRelocs/PowerPC64.def" -}; - -// ELF Relocation types for AArch64 -enum { -#include "ELFRelocs/AArch64.def" -}; - -// ARM Specific e_flags -enum : unsigned { - EF_ARM_SOFT_FLOAT = 0x00000200U, - EF_ARM_VFP_FLOAT = 0x00000400U, - EF_ARM_EABI_UNKNOWN = 0x00000000U, - EF_ARM_EABI_VER1 = 0x01000000U, - EF_ARM_EABI_VER2 = 0x02000000U, - EF_ARM_EABI_VER3 = 0x03000000U, - EF_ARM_EABI_VER4 = 0x04000000U, - EF_ARM_EABI_VER5 = 0x05000000U, - EF_ARM_EABIMASK = 0xFF000000U -}; - -// ELF Relocation types for ARM -enum { -#include "ELFRelocs/ARM.def" -}; - -// AVR specific e_flags -enum : unsigned { - EF_AVR_ARCH_AVR1 = 1, - EF_AVR_ARCH_AVR2 = 2, - EF_AVR_ARCH_AVR25 = 25, - EF_AVR_ARCH_AVR3 = 3, - EF_AVR_ARCH_AVR31 = 31, - EF_AVR_ARCH_AVR35 = 35, - EF_AVR_ARCH_AVR4 = 4, - EF_AVR_ARCH_AVR5 = 5, - EF_AVR_ARCH_AVR51 = 51, - EF_AVR_ARCH_AVR6 = 6, - EF_AVR_ARCH_AVRTINY = 100, - EF_AVR_ARCH_XMEGA1 = 101, - EF_AVR_ARCH_XMEGA2 = 102, - EF_AVR_ARCH_XMEGA3 = 103, - EF_AVR_ARCH_XMEGA4 = 104, - EF_AVR_ARCH_XMEGA5 = 105, - EF_AVR_ARCH_XMEGA6 = 106, - EF_AVR_ARCH_XMEGA7 = 107 -}; - -// ELF Relocation types for AVR -enum { -#include "ELFRelocs/AVR.def" -}; - -// Mips Specific e_flags -enum : unsigned { - EF_MIPS_NOREORDER = 0x00000001, // Don't reorder instructions - EF_MIPS_PIC = 0x00000002, // Position independent code - EF_MIPS_CPIC = 0x00000004, // Call object with Position independent code - EF_MIPS_ABI2 = 0x00000020, // File uses N32 ABI - EF_MIPS_32BITMODE = 0x00000100, // Code compiled for a 64-bit machine - // in 32-bit mode - EF_MIPS_FP64 = 0x00000200, // Code compiled for a 32-bit machine - // but uses 64-bit FP registers - EF_MIPS_NAN2008 = 0x00000400, // Uses IEE 754-2008 NaN encoding - - // ABI flags - EF_MIPS_ABI_O32 = 0x00001000, // This file follows the first MIPS 32 bit ABI - EF_MIPS_ABI_O64 = 0x00002000, // O32 ABI extended for 64-bit architecture. - EF_MIPS_ABI_EABI32 = 0x00003000, // EABI in 32 bit mode. - EF_MIPS_ABI_EABI64 = 0x00004000, // EABI in 64 bit mode. - EF_MIPS_ABI = 0x0000f000, // Mask for selecting EF_MIPS_ABI_ variant. - - // MIPS machine variant - EF_MIPS_MACH_NONE = 0x00000000, // A standard MIPS implementation. - EF_MIPS_MACH_3900 = 0x00810000, // Toshiba R3900 - EF_MIPS_MACH_4010 = 0x00820000, // LSI R4010 - EF_MIPS_MACH_4100 = 0x00830000, // NEC VR4100 - EF_MIPS_MACH_4650 = 0x00850000, // MIPS R4650 - EF_MIPS_MACH_4120 = 0x00870000, // NEC VR4120 - EF_MIPS_MACH_4111 = 0x00880000, // NEC VR4111/VR4181 - EF_MIPS_MACH_SB1 = 0x008a0000, // Broadcom SB-1 - EF_MIPS_MACH_OCTEON = 0x008b0000, // Cavium Networks Octeon - EF_MIPS_MACH_XLR = 0x008c0000, // RMI Xlr - EF_MIPS_MACH_OCTEON2 = 0x008d0000, // Cavium Networks Octeon2 - EF_MIPS_MACH_OCTEON3 = 0x008e0000, // Cavium Networks Octeon3 - EF_MIPS_MACH_5400 = 0x00910000, // NEC VR5400 - EF_MIPS_MACH_5900 = 0x00920000, // MIPS R5900 - EF_MIPS_MACH_5500 = 0x00980000, // NEC VR5500 - EF_MIPS_MACH_9000 = 0x00990000, // Unknown - EF_MIPS_MACH_LS2E = 0x00a00000, // ST Microelectronics Loongson 2E - EF_MIPS_MACH_LS2F = 0x00a10000, // ST Microelectronics Loongson 2F - EF_MIPS_MACH_LS3A = 0x00a20000, // Loongson 3A - EF_MIPS_MACH = 0x00ff0000, // EF_MIPS_MACH_xxx selection mask - - // ARCH_ASE - EF_MIPS_MICROMIPS = 0x02000000, // microMIPS - EF_MIPS_ARCH_ASE_M16 = 0x04000000, // Has Mips-16 ISA extensions - EF_MIPS_ARCH_ASE_MDMX = 0x08000000, // Has MDMX multimedia extensions - EF_MIPS_ARCH_ASE = 0x0f000000, // Mask for EF_MIPS_ARCH_ASE_xxx flags - - // ARCH - EF_MIPS_ARCH_1 = 0x00000000, // MIPS1 instruction set - EF_MIPS_ARCH_2 = 0x10000000, // MIPS2 instruction set - EF_MIPS_ARCH_3 = 0x20000000, // MIPS3 instruction set - EF_MIPS_ARCH_4 = 0x30000000, // MIPS4 instruction set - EF_MIPS_ARCH_5 = 0x40000000, // MIPS5 instruction set - EF_MIPS_ARCH_32 = 0x50000000, // MIPS32 instruction set per linux not elf.h - EF_MIPS_ARCH_64 = 0x60000000, // MIPS64 instruction set per linux not elf.h - EF_MIPS_ARCH_32R2 = 0x70000000, // mips32r2, mips32r3, mips32r5 - EF_MIPS_ARCH_64R2 = 0x80000000, // mips64r2, mips64r3, mips64r5 - EF_MIPS_ARCH_32R6 = 0x90000000, // mips32r6 - EF_MIPS_ARCH_64R6 = 0xa0000000, // mips64r6 - EF_MIPS_ARCH = 0xf0000000 // Mask for applying EF_MIPS_ARCH_ variant -}; - -// ELF Relocation types for Mips -enum { -#include "ELFRelocs/Mips.def" -}; - -// Special values for the st_other field in the symbol table entry for MIPS. -enum { - STO_MIPS_OPTIONAL = 0x04, // Symbol whose definition is optional - STO_MIPS_PLT = 0x08, // PLT entry related dynamic table record - STO_MIPS_PIC = 0x20, // PIC func in an object mixes PIC/non-PIC - STO_MIPS_MICROMIPS = 0x80, // MIPS Specific ISA for MicroMips - STO_MIPS_MIPS16 = 0xf0 // MIPS Specific ISA for Mips16 -}; - -// .MIPS.options section descriptor kinds -enum { - ODK_NULL = 0, // Undefined - ODK_REGINFO = 1, // Register usage information - ODK_EXCEPTIONS = 2, // Exception processing options - ODK_PAD = 3, // Section padding options - ODK_HWPATCH = 4, // Hardware patches applied - ODK_FILL = 5, // Linker fill value - ODK_TAGS = 6, // Space for tool identification - ODK_HWAND = 7, // Hardware AND patches applied - ODK_HWOR = 8, // Hardware OR patches applied - ODK_GP_GROUP = 9, // GP group to use for text/data sections - ODK_IDENT = 10, // ID information - ODK_PAGESIZE = 11 // Page size information -}; - -// Hexagon-specific e_flags -enum { - // Object processor version flags, bits[11:0] - EF_HEXAGON_MACH_V2 = 0x00000001, // Hexagon V2 - EF_HEXAGON_MACH_V3 = 0x00000002, // Hexagon V3 - EF_HEXAGON_MACH_V4 = 0x00000003, // Hexagon V4 - EF_HEXAGON_MACH_V5 = 0x00000004, // Hexagon V5 - EF_HEXAGON_MACH_V55 = 0x00000005, // Hexagon V55 - EF_HEXAGON_MACH_V60 = 0x00000060, // Hexagon V60 - EF_HEXAGON_MACH_V62 = 0x00000062, // Hexagon V62 - - // Highest ISA version flags - EF_HEXAGON_ISA_MACH = 0x00000000, // Same as specified in bits[11:0] - // of e_flags - EF_HEXAGON_ISA_V2 = 0x00000010, // Hexagon V2 ISA - EF_HEXAGON_ISA_V3 = 0x00000020, // Hexagon V3 ISA - EF_HEXAGON_ISA_V4 = 0x00000030, // Hexagon V4 ISA - EF_HEXAGON_ISA_V5 = 0x00000040, // Hexagon V5 ISA - EF_HEXAGON_ISA_V55 = 0x00000050, // Hexagon V55 ISA - EF_HEXAGON_ISA_V60 = 0x00000060, // Hexagon V60 ISA - EF_HEXAGON_ISA_V62 = 0x00000062, // Hexagon V62 ISA -}; - -// Hexagon-specific section indexes for common small data -enum { - SHN_HEXAGON_SCOMMON = 0xff00, // Other access sizes - SHN_HEXAGON_SCOMMON_1 = 0xff01, // Byte-sized access - SHN_HEXAGON_SCOMMON_2 = 0xff02, // Half-word-sized access - SHN_HEXAGON_SCOMMON_4 = 0xff03, // Word-sized access - SHN_HEXAGON_SCOMMON_8 = 0xff04 // Double-word-size access -}; - -// ELF Relocation types for Hexagon -enum { -#include "ELFRelocs/Hexagon.def" -}; - -// ELF Relocation type for Lanai. -enum { -#include "ELFRelocs/Lanai.def" -}; - -// ELF Relocation types for RISC-V -enum { -#include "ELFRelocs/RISCV.def" -}; - -// ELF Relocation types for S390/zSeries -enum { -#include "ELFRelocs/SystemZ.def" -}; - -// ELF Relocation type for Sparc. -enum { -#include "ELFRelocs/Sparc.def" -}; - -// ELF Relocation types for WebAssembly -enum { -#include "ELFRelocs/WebAssembly.def" -}; - -// ELF Relocation types for AMDGPU -enum { -#include "ELFRelocs/AMDGPU.def" -}; - -// ELF Relocation types for BPF -enum { -#include "ELFRelocs/BPF.def" -}; - -#undef ELF_RELOC - -// Section header. -struct Elf32_Shdr { - Elf32_Word sh_name; // Section name (index into string table) - Elf32_Word sh_type; // Section type (SHT_*) - Elf32_Word sh_flags; // Section flags (SHF_*) - Elf32_Addr sh_addr; // Address where section is to be loaded - Elf32_Off sh_offset; // File offset of section data, in bytes - Elf32_Word sh_size; // Size of section, in bytes - Elf32_Word sh_link; // Section type-specific header table index link - Elf32_Word sh_info; // Section type-specific extra information - Elf32_Word sh_addralign; // Section address alignment - Elf32_Word sh_entsize; // Size of records contained within the section -}; - -// Section header for ELF64 - same fields as ELF32, different types. -struct Elf64_Shdr { - Elf64_Word sh_name; - Elf64_Word sh_type; - Elf64_Xword sh_flags; - Elf64_Addr sh_addr; - Elf64_Off sh_offset; - Elf64_Xword sh_size; - Elf64_Word sh_link; - Elf64_Word sh_info; - Elf64_Xword sh_addralign; - Elf64_Xword sh_entsize; -}; - -// Special section indices. -enum { - SHN_UNDEF = 0, // Undefined, missing, irrelevant, or meaningless - SHN_LORESERVE = 0xff00, // Lowest reserved index - SHN_LOPROC = 0xff00, // Lowest processor-specific index - SHN_HIPROC = 0xff1f, // Highest processor-specific index - SHN_LOOS = 0xff20, // Lowest operating system-specific index - SHN_HIOS = 0xff3f, // Highest operating system-specific index - SHN_ABS = 0xfff1, // Symbol has absolute value; does not need relocation - SHN_COMMON = 0xfff2, // FORTRAN COMMON or C external global variables - SHN_XINDEX = 0xffff, // Mark that the index is >= SHN_LORESERVE - SHN_HIRESERVE = 0xffff // Highest reserved index -}; - -// Section types. -enum : unsigned { - SHT_NULL = 0, // No associated section (inactive entry). - SHT_PROGBITS = 1, // Program-defined contents. - SHT_SYMTAB = 2, // Symbol table. - SHT_STRTAB = 3, // String table. - SHT_RELA = 4, // Relocation entries; explicit addends. - SHT_HASH = 5, // Symbol hash table. - SHT_DYNAMIC = 6, // Information for dynamic linking. - SHT_NOTE = 7, // Information about the file. - SHT_NOBITS = 8, // Data occupies no space in the file. - SHT_REL = 9, // Relocation entries; no explicit addends. - SHT_SHLIB = 10, // Reserved. - SHT_DYNSYM = 11, // Symbol table. - SHT_INIT_ARRAY = 14, // Pointers to initialization functions. - SHT_FINI_ARRAY = 15, // Pointers to termination functions. - SHT_PREINIT_ARRAY = 16, // Pointers to pre-init functions. - SHT_GROUP = 17, // Section group. - SHT_SYMTAB_SHNDX = 18, // Indices for SHN_XINDEX entries. - SHT_LOOS = 0x60000000, // Lowest operating system-specific type. - SHT_GNU_ATTRIBUTES = 0x6ffffff5, // Object attributes. - SHT_GNU_HASH = 0x6ffffff6, // GNU-style hash table. - SHT_GNU_verdef = 0x6ffffffd, // GNU version definitions. - SHT_GNU_verneed = 0x6ffffffe, // GNU version references. - SHT_GNU_versym = 0x6fffffff, // GNU symbol versions table. - SHT_HIOS = 0x6fffffff, // Highest operating system-specific type. - SHT_LOPROC = 0x70000000, // Lowest processor arch-specific type. - // Fixme: All this is duplicated in MCSectionELF. Why?? - // Exception Index table - SHT_ARM_EXIDX = 0x70000001U, - // BPABI DLL dynamic linking pre-emption map - SHT_ARM_PREEMPTMAP = 0x70000002U, - // Object file compatibility attributes - SHT_ARM_ATTRIBUTES = 0x70000003U, - SHT_ARM_DEBUGOVERLAY = 0x70000004U, - SHT_ARM_OVERLAYSECTION = 0x70000005U, - SHT_HEX_ORDERED = 0x70000000, // Link editor is to sort the entries in - // this section based on their sizes - SHT_X86_64_UNWIND = 0x70000001, // Unwind information - - SHT_MIPS_REGINFO = 0x70000006, // Register usage information - SHT_MIPS_OPTIONS = 0x7000000d, // General options - SHT_MIPS_DWARF = 0x7000001e, // DWARF debugging section. - SHT_MIPS_ABIFLAGS = 0x7000002a, // ABI information. - - SHT_HIPROC = 0x7fffffff, // Highest processor arch-specific type. - SHT_LOUSER = 0x80000000, // Lowest type reserved for applications. - SHT_HIUSER = 0xffffffff // Highest type reserved for applications. -}; - -// Section flags. -enum : unsigned { - // Section data should be writable during execution. - SHF_WRITE = 0x1, - - // Section occupies memory during program execution. - SHF_ALLOC = 0x2, - - // Section contains executable machine instructions. - SHF_EXECINSTR = 0x4, - - // The data in this section may be merged. - SHF_MERGE = 0x10, - - // The data in this section is null-terminated strings. - SHF_STRINGS = 0x20, - - // A field in this section holds a section header table index. - SHF_INFO_LINK = 0x40U, - - // Adds special ordering requirements for link editors. - SHF_LINK_ORDER = 0x80U, - - // This section requires special OS-specific processing to avoid incorrect - // behavior. - SHF_OS_NONCONFORMING = 0x100U, - - // This section is a member of a section group. - SHF_GROUP = 0x200U, - - // This section holds Thread-Local Storage. - SHF_TLS = 0x400U, - - // Identifies a section containing compressed data. - SHF_COMPRESSED = 0x800U, - - // This section is excluded from the final executable or shared library. - SHF_EXCLUDE = 0x80000000U, - - // Start of target-specific flags. - - SHF_MASKOS = 0x0ff00000, - - // Bits indicating processor-specific flags. - SHF_MASKPROC = 0xf0000000, - - /// All sections with the "d" flag are grouped together by the linker to form - /// the data section and the dp register is set to the start of the section by - /// the boot code. - XCORE_SHF_DP_SECTION = 0x10000000, - - /// All sections with the "c" flag are grouped together by the linker to form - /// the constant pool and the cp register is set to the start of the constant - /// pool by the boot code. - XCORE_SHF_CP_SECTION = 0x20000000, - - // If an object file section does not have this flag set, then it may not hold - // more than 2GB and can be freely referred to in objects using smaller code - // models. Otherwise, only objects using larger code models can refer to them. - // For example, a medium code model object can refer to data in a section that - // sets this flag besides being able to refer to data in a section that does - // not set it; likewise, a small code model object can refer only to code in a - // section that does not set this flag. - SHF_X86_64_LARGE = 0x10000000, - - // All sections with the GPREL flag are grouped into a global data area - // for faster accesses - SHF_HEX_GPREL = 0x10000000, - - // Section contains text/data which may be replicated in other sections. - // Linker must retain only one copy. - SHF_MIPS_NODUPES = 0x01000000, - - // Linker must generate implicit hidden weak names. - SHF_MIPS_NAMES = 0x02000000, - - // Section data local to process. - SHF_MIPS_LOCAL = 0x04000000, - - // Do not strip this section. - SHF_MIPS_NOSTRIP = 0x08000000, - - // Section must be part of global data area. - SHF_MIPS_GPREL = 0x10000000, - - // This section should be merged. - SHF_MIPS_MERGE = 0x20000000, - - // Address size to be inferred from section entry size. - SHF_MIPS_ADDR = 0x40000000, - - // Section data is string data by default. - SHF_MIPS_STRING = 0x80000000, - - // Make code section unreadable when in execute-only mode - SHF_ARM_PURECODE = 0x20000000, - - SHF_AMDGPU_HSA_GLOBAL = 0x00100000, - SHF_AMDGPU_HSA_READONLY = 0x00200000, - SHF_AMDGPU_HSA_CODE = 0x00400000, - SHF_AMDGPU_HSA_AGENT = 0x00800000 -}; - -// Section Group Flags -enum : unsigned { - GRP_COMDAT = 0x1, - GRP_MASKOS = 0x0ff00000, - GRP_MASKPROC = 0xf0000000 -}; - -// Symbol table entries for ELF32. -struct Elf32_Sym { - Elf32_Word st_name; // Symbol name (index into string table) - Elf32_Addr st_value; // Value or address associated with the symbol - Elf32_Word st_size; // Size of the symbol - unsigned char st_info; // Symbol's type and binding attributes - unsigned char st_other; // Must be zero; reserved - Elf32_Half st_shndx; // Which section (header table index) it's defined in - - // These accessors and mutators correspond to the ELF32_ST_BIND, - // ELF32_ST_TYPE, and ELF32_ST_INFO macros defined in the ELF specification: - unsigned char getBinding() const { return st_info >> 4; } - unsigned char getType() const { return st_info & 0x0f; } - void setBinding(unsigned char b) { setBindingAndType(b, getType()); } - void setType(unsigned char t) { setBindingAndType(getBinding(), t); } - void setBindingAndType(unsigned char b, unsigned char t) { - st_info = (b << 4) + (t & 0x0f); - } -}; - -// Symbol table entries for ELF64. -struct Elf64_Sym { - Elf64_Word st_name; // Symbol name (index into string table) - unsigned char st_info; // Symbol's type and binding attributes - unsigned char st_other; // Must be zero; reserved - Elf64_Half st_shndx; // Which section (header tbl index) it's defined in - Elf64_Addr st_value; // Value or address associated with the symbol - Elf64_Xword st_size; // Size of the symbol - - // These accessors and mutators are identical to those defined for ELF32 - // symbol table entries. - unsigned char getBinding() const { return st_info >> 4; } - unsigned char getType() const { return st_info & 0x0f; } - void setBinding(unsigned char b) { setBindingAndType(b, getType()); } - void setType(unsigned char t) { setBindingAndType(getBinding(), t); } - void setBindingAndType(unsigned char b, unsigned char t) { - st_info = (b << 4) + (t & 0x0f); - } -}; - -// The size (in bytes) of symbol table entries. -enum { - SYMENTRY_SIZE32 = 16, // 32-bit symbol entry size - SYMENTRY_SIZE64 = 24 // 64-bit symbol entry size. -}; - -// Symbol bindings. -enum { - STB_LOCAL = 0, // Local symbol, not visible outside obj file containing def - STB_GLOBAL = 1, // Global symbol, visible to all object files being combined - STB_WEAK = 2, // Weak symbol, like global but lower-precedence - STB_GNU_UNIQUE = 10, - STB_LOOS = 10, // Lowest operating system-specific binding type - STB_HIOS = 12, // Highest operating system-specific binding type - STB_LOPROC = 13, // Lowest processor-specific binding type - STB_HIPROC = 15 // Highest processor-specific binding type -}; - -// Symbol types. -enum { - STT_NOTYPE = 0, // Symbol's type is not specified - STT_OBJECT = 1, // Symbol is a data object (variable, array, etc.) - STT_FUNC = 2, // Symbol is executable code (function, etc.) - STT_SECTION = 3, // Symbol refers to a section - STT_FILE = 4, // Local, absolute symbol that refers to a file - STT_COMMON = 5, // An uninitialized common block - STT_TLS = 6, // Thread local data object - STT_GNU_IFUNC = 10, // GNU indirect function - STT_LOOS = 10, // Lowest operating system-specific symbol type - STT_HIOS = 12, // Highest operating system-specific symbol type - STT_LOPROC = 13, // Lowest processor-specific symbol type - STT_HIPROC = 15, // Highest processor-specific symbol type - - // AMDGPU symbol types - STT_AMDGPU_HSA_KERNEL = 10, - STT_AMDGPU_HSA_INDIRECT_FUNCTION = 11, - STT_AMDGPU_HSA_METADATA = 12 -}; - -enum { - STV_DEFAULT = 0, // Visibility is specified by binding type - STV_INTERNAL = 1, // Defined by processor supplements - STV_HIDDEN = 2, // Not visible to other components - STV_PROTECTED = 3 // Visible in other components but not preemptable -}; - -// Symbol number. -enum { STN_UNDEF = 0 }; - -// Special relocation symbols used in the MIPS64 ELF relocation entries -enum { - RSS_UNDEF = 0, // None - RSS_GP = 1, // Value of gp - RSS_GP0 = 2, // Value of gp used to create object being relocated - RSS_LOC = 3 // Address of location being relocated -}; - -// Relocation entry, without explicit addend. -struct Elf32_Rel { - Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr) - Elf32_Word r_info; // Symbol table index and type of relocation to apply - - // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE, - // and ELF32_R_INFO macros defined in the ELF specification: - Elf32_Word getSymbol() const { return (r_info >> 8); } - unsigned char getType() const { return (unsigned char)(r_info & 0x0ff); } - void setSymbol(Elf32_Word s) { setSymbolAndType(s, getType()); } - void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); } - void setSymbolAndType(Elf32_Word s, unsigned char t) { - r_info = (s << 8) + t; - } -}; - -// Relocation entry with explicit addend. -struct Elf32_Rela { - Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr) - Elf32_Word r_info; // Symbol table index and type of relocation to apply - Elf32_Sword r_addend; // Compute value for relocatable field by adding this - - // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE, - // and ELF32_R_INFO macros defined in the ELF specification: - Elf32_Word getSymbol() const { return (r_info >> 8); } - unsigned char getType() const { return (unsigned char)(r_info & 0x0ff); } - void setSymbol(Elf32_Word s) { setSymbolAndType(s, getType()); } - void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); } - void setSymbolAndType(Elf32_Word s, unsigned char t) { - r_info = (s << 8) + t; - } -}; - -// Relocation entry, without explicit addend. -struct Elf64_Rel { - Elf64_Addr r_offset; // Location (file byte offset, or program virtual addr). - Elf64_Xword r_info; // Symbol table index and type of relocation to apply. - - // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE, - // and ELF64_R_INFO macros defined in the ELF specification: - Elf64_Word getSymbol() const { return (r_info >> 32); } - Elf64_Word getType() const { return (Elf64_Word)(r_info & 0xffffffffL); } - void setSymbol(Elf64_Word s) { setSymbolAndType(s, getType()); } - void setType(Elf64_Word t) { setSymbolAndType(getSymbol(), t); } - void setSymbolAndType(Elf64_Word s, Elf64_Word t) { - r_info = ((Elf64_Xword)s << 32) + (t & 0xffffffffL); - } -}; - -// Relocation entry with explicit addend. -struct Elf64_Rela { - Elf64_Addr r_offset; // Location (file byte offset, or program virtual addr). - Elf64_Xword r_info; // Symbol table index and type of relocation to apply. - Elf64_Sxword r_addend; // Compute value for relocatable field by adding this. - - // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE, - // and ELF64_R_INFO macros defined in the ELF specification: - Elf64_Word getSymbol() const { return (r_info >> 32); } - Elf64_Word getType() const { return (Elf64_Word)(r_info & 0xffffffffL); } - void setSymbol(Elf64_Word s) { setSymbolAndType(s, getType()); } - void setType(Elf64_Word t) { setSymbolAndType(getSymbol(), t); } - void setSymbolAndType(Elf64_Word s, Elf64_Word t) { - r_info = ((Elf64_Xword)s << 32) + (t & 0xffffffffL); - } -}; - -// Program header for ELF32. -struct Elf32_Phdr { - Elf32_Word p_type; // Type of segment - Elf32_Off p_offset; // File offset where segment is located, in bytes - Elf32_Addr p_vaddr; // Virtual address of beginning of segment - Elf32_Addr p_paddr; // Physical address of beginning of segment (OS-specific) - Elf32_Word p_filesz; // Num. of bytes in file image of segment (may be zero) - Elf32_Word p_memsz; // Num. of bytes in mem image of segment (may be zero) - Elf32_Word p_flags; // Segment flags - Elf32_Word p_align; // Segment alignment constraint -}; - -// Program header for ELF64. -struct Elf64_Phdr { - Elf64_Word p_type; // Type of segment - Elf64_Word p_flags; // Segment flags - Elf64_Off p_offset; // File offset where segment is located, in bytes - Elf64_Addr p_vaddr; // Virtual address of beginning of segment - Elf64_Addr p_paddr; // Physical addr of beginning of segment (OS-specific) - Elf64_Xword p_filesz; // Num. of bytes in file image of segment (may be zero) - Elf64_Xword p_memsz; // Num. of bytes in mem image of segment (may be zero) - Elf64_Xword p_align; // Segment alignment constraint -}; - -// Segment types. -enum { - PT_NULL = 0, // Unused segment. - PT_LOAD = 1, // Loadable segment. - PT_DYNAMIC = 2, // Dynamic linking information. - PT_INTERP = 3, // Interpreter pathname. - PT_NOTE = 4, // Auxiliary information. - PT_SHLIB = 5, // Reserved. - PT_PHDR = 6, // The program header table itself. - PT_TLS = 7, // The thread-local storage template. - PT_LOOS = 0x60000000, // Lowest operating system-specific pt entry type. - PT_HIOS = 0x6fffffff, // Highest operating system-specific pt entry type. - PT_LOPROC = 0x70000000, // Lowest processor-specific program hdr entry type. - PT_HIPROC = 0x7fffffff, // Highest processor-specific program hdr entry type. - - // x86-64 program header types. - // These all contain stack unwind tables. - PT_GNU_EH_FRAME = 0x6474e550, - PT_SUNW_EH_FRAME = 0x6474e550, - PT_SUNW_UNWIND = 0x6464e550, - - PT_GNU_STACK = 0x6474e551, // Indicates stack executability. - PT_GNU_RELRO = 0x6474e552, // Read-only after relocation. - - PT_OPENBSD_RANDOMIZE = 0x65a3dbe6, // Fill with random data. - PT_OPENBSD_WXNEEDED = 0x65a3dbe7, // Program does W^X violations. - PT_OPENBSD_BOOTDATA = 0x65a41be6, // Section for boot arguments. - - // ARM program header types. - PT_ARM_ARCHEXT = 0x70000000, // Platform architecture compatibility info - // These all contain stack unwind tables. - PT_ARM_EXIDX = 0x70000001, - PT_ARM_UNWIND = 0x70000001, - - // MIPS program header types. - PT_MIPS_REGINFO = 0x70000000, // Register usage information. - PT_MIPS_RTPROC = 0x70000001, // Runtime procedure table. - PT_MIPS_OPTIONS = 0x70000002, // Options segment. - PT_MIPS_ABIFLAGS = 0x70000003, // Abiflags segment. - - // AMDGPU program header types. - PT_AMDGPU_HSA_LOAD_GLOBAL_PROGRAM = 0x60000000, - PT_AMDGPU_HSA_LOAD_GLOBAL_AGENT = 0x60000001, - PT_AMDGPU_HSA_LOAD_READONLY_AGENT = 0x60000002, - PT_AMDGPU_HSA_LOAD_CODE_AGENT = 0x60000003, - - // WebAssembly program header types. - PT_WEBASSEMBLY_FUNCTIONS = PT_LOPROC + 0, // Function definitions. -}; - -// Segment flag bits. -enum : unsigned { - PF_X = 1, // Execute - PF_W = 2, // Write - PF_R = 4, // Read - PF_MASKOS = 0x0ff00000, // Bits for operating system-specific semantics. - PF_MASKPROC = 0xf0000000 // Bits for processor-specific semantics. -}; - -// Dynamic table entry for ELF32. -struct Elf32_Dyn { - Elf32_Sword d_tag; // Type of dynamic table entry. - union { - Elf32_Word d_val; // Integer value of entry. - Elf32_Addr d_ptr; // Pointer value of entry. - } d_un; -}; - -// Dynamic table entry for ELF64. -struct Elf64_Dyn { - Elf64_Sxword d_tag; // Type of dynamic table entry. - union { - Elf64_Xword d_val; // Integer value of entry. - Elf64_Addr d_ptr; // Pointer value of entry. - } d_un; -}; - -// Dynamic table entry tags. -enum { - DT_NULL = 0, // Marks end of dynamic array. - DT_NEEDED = 1, // String table offset of needed library. - DT_PLTRELSZ = 2, // Size of relocation entries in PLT. - DT_PLTGOT = 3, // Address associated with linkage table. - DT_HASH = 4, // Address of symbolic hash table. - DT_STRTAB = 5, // Address of dynamic string table. - DT_SYMTAB = 6, // Address of dynamic symbol table. - DT_RELA = 7, // Address of relocation table (Rela entries). - DT_RELASZ = 8, // Size of Rela relocation table. - DT_RELAENT = 9, // Size of a Rela relocation entry. - DT_STRSZ = 10, // Total size of the string table. - DT_SYMENT = 11, // Size of a symbol table entry. - DT_INIT = 12, // Address of initialization function. - DT_FINI = 13, // Address of termination function. - DT_SONAME = 14, // String table offset of a shared objects name. - DT_RPATH = 15, // String table offset of library search path. - DT_SYMBOLIC = 16, // Changes symbol resolution algorithm. - DT_REL = 17, // Address of relocation table (Rel entries). - DT_RELSZ = 18, // Size of Rel relocation table. - DT_RELENT = 19, // Size of a Rel relocation entry. - DT_PLTREL = 20, // Type of relocation entry used for linking. - DT_DEBUG = 21, // Reserved for debugger. - DT_TEXTREL = 22, // Relocations exist for non-writable segments. - DT_JMPREL = 23, // Address of relocations associated with PLT. - DT_BIND_NOW = 24, // Process all relocations before execution. - DT_INIT_ARRAY = 25, // Pointer to array of initialization functions. - DT_FINI_ARRAY = 26, // Pointer to array of termination functions. - DT_INIT_ARRAYSZ = 27, // Size of DT_INIT_ARRAY. - DT_FINI_ARRAYSZ = 28, // Size of DT_FINI_ARRAY. - DT_RUNPATH = 29, // String table offset of lib search path. - DT_FLAGS = 30, // Flags. - DT_ENCODING = 32, // Values from here to DT_LOOS follow the rules - // for the interpretation of the d_un union. - - DT_PREINIT_ARRAY = 32, // Pointer to array of preinit functions. - DT_PREINIT_ARRAYSZ = 33, // Size of the DT_PREINIT_ARRAY array. - - DT_LOOS = 0x60000000, // Start of environment specific tags. - DT_HIOS = 0x6FFFFFFF, // End of environment specific tags. - DT_LOPROC = 0x70000000, // Start of processor specific tags. - DT_HIPROC = 0x7FFFFFFF, // End of processor specific tags. - - DT_GNU_HASH = 0x6FFFFEF5, // Reference to the GNU hash table. - DT_TLSDESC_PLT = - 0x6FFFFEF6, // Location of PLT entry for TLS descriptor resolver calls. - DT_TLSDESC_GOT = 0x6FFFFEF7, // Location of GOT entry used by TLS descriptor - // resolver PLT entry. - DT_RELACOUNT = 0x6FFFFFF9, // ELF32_Rela count. - DT_RELCOUNT = 0x6FFFFFFA, // ELF32_Rel count. - - DT_FLAGS_1 = 0X6FFFFFFB, // Flags_1. - DT_VERSYM = 0x6FFFFFF0, // The address of .gnu.version section. - DT_VERDEF = 0X6FFFFFFC, // The address of the version definition table. - DT_VERDEFNUM = 0X6FFFFFFD, // The number of entries in DT_VERDEF. - DT_VERNEED = 0X6FFFFFFE, // The address of the version Dependency table. - DT_VERNEEDNUM = 0X6FFFFFFF, // The number of entries in DT_VERNEED. - - // Hexagon specific dynamic table entries - DT_HEXAGON_SYMSZ = 0x70000000, - DT_HEXAGON_VER = 0x70000001, - DT_HEXAGON_PLT = 0x70000002, - - // Mips specific dynamic table entry tags. - DT_MIPS_RLD_VERSION = 0x70000001, // 32 bit version number for runtime - // linker interface. - DT_MIPS_TIME_STAMP = 0x70000002, // Time stamp. - DT_MIPS_ICHECKSUM = 0x70000003, // Checksum of external strings - // and common sizes. - DT_MIPS_IVERSION = 0x70000004, // Index of version string - // in string table. - DT_MIPS_FLAGS = 0x70000005, // 32 bits of flags. - DT_MIPS_BASE_ADDRESS = 0x70000006, // Base address of the segment. - DT_MIPS_MSYM = 0x70000007, // Address of .msym section. - DT_MIPS_CONFLICT = 0x70000008, // Address of .conflict section. - DT_MIPS_LIBLIST = 0x70000009, // Address of .liblist section. - DT_MIPS_LOCAL_GOTNO = 0x7000000a, // Number of local global offset - // table entries. - DT_MIPS_CONFLICTNO = 0x7000000b, // Number of entries - // in the .conflict section. - DT_MIPS_LIBLISTNO = 0x70000010, // Number of entries - // in the .liblist section. - DT_MIPS_SYMTABNO = 0x70000011, // Number of entries - // in the .dynsym section. - DT_MIPS_UNREFEXTNO = 0x70000012, // Index of first external dynamic symbol - // not referenced locally. - DT_MIPS_GOTSYM = 0x70000013, // Index of first dynamic symbol - // in global offset table. - DT_MIPS_HIPAGENO = 0x70000014, // Number of page table entries - // in global offset table. - DT_MIPS_RLD_MAP = 0x70000016, // Address of run time loader map, - // used for debugging. - DT_MIPS_DELTA_CLASS = 0x70000017, // Delta C++ class definition. - DT_MIPS_DELTA_CLASS_NO = 0x70000018, // Number of entries - // in DT_MIPS_DELTA_CLASS. - DT_MIPS_DELTA_INSTANCE = 0x70000019, // Delta C++ class instances. - DT_MIPS_DELTA_INSTANCE_NO = 0x7000001A, // Number of entries - // in DT_MIPS_DELTA_INSTANCE. - DT_MIPS_DELTA_RELOC = 0x7000001B, // Delta relocations. - DT_MIPS_DELTA_RELOC_NO = 0x7000001C, // Number of entries - // in DT_MIPS_DELTA_RELOC. - DT_MIPS_DELTA_SYM = 0x7000001D, // Delta symbols that Delta - // relocations refer to. - DT_MIPS_DELTA_SYM_NO = 0x7000001E, // Number of entries - // in DT_MIPS_DELTA_SYM. - DT_MIPS_DELTA_CLASSSYM = 0x70000020, // Delta symbols that hold - // class declarations. - DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021, // Number of entries - // in DT_MIPS_DELTA_CLASSSYM. - DT_MIPS_CXX_FLAGS = 0x70000022, // Flags indicating information - // about C++ flavor. - DT_MIPS_PIXIE_INIT = 0x70000023, // Pixie information. - DT_MIPS_SYMBOL_LIB = 0x70000024, // Address of .MIPS.symlib - DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025, // The GOT index of the first PTE - // for a segment - DT_MIPS_LOCAL_GOTIDX = 0x70000026, // The GOT index of the first PTE - // for a local symbol - DT_MIPS_HIDDEN_GOTIDX = 0x70000027, // The GOT index of the first PTE - // for a hidden symbol - DT_MIPS_PROTECTED_GOTIDX = 0x70000028, // The GOT index of the first PTE - // for a protected symbol - DT_MIPS_OPTIONS = 0x70000029, // Address of `.MIPS.options'. - DT_MIPS_INTERFACE = 0x7000002A, // Address of `.interface'. - DT_MIPS_DYNSTR_ALIGN = 0x7000002B, // Unknown. - DT_MIPS_INTERFACE_SIZE = 0x7000002C, // Size of the .interface section. - DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002D, // Size of rld_text_resolve - // function stored in the GOT. - DT_MIPS_PERF_SUFFIX = 0x7000002E, // Default suffix of DSO to be added - // by rld on dlopen() calls. - DT_MIPS_COMPACT_SIZE = 0x7000002F, // Size of compact relocation - // section (O32). - DT_MIPS_GP_VALUE = 0x70000030, // GP value for auxiliary GOTs. - DT_MIPS_AUX_DYNAMIC = 0x70000031, // Address of auxiliary .dynamic. - DT_MIPS_PLTGOT = 0x70000032, // Address of the base of the PLTGOT. - DT_MIPS_RWPLT = 0x70000034, // Points to the base - // of a writable PLT. - DT_MIPS_RLD_MAP_REL = 0x70000035, // Relative offset of run time loader - // map, used for debugging. - - // Sun machine-independent extensions. - DT_AUXILIARY = 0x7FFFFFFD, // Shared object to load before self - DT_FILTER = 0x7FFFFFFF // Shared object to get values from -}; - -// DT_FLAGS values. -enum { - DF_ORIGIN = 0x01, // The object may reference $ORIGIN. - DF_SYMBOLIC = 0x02, // Search the shared lib before searching the exe. - DF_TEXTREL = 0x04, // Relocations may modify a non-writable segment. - DF_BIND_NOW = 0x08, // Process all relocations on load. - DF_STATIC_TLS = 0x10 // Reject attempts to load dynamically. -}; - -// State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 entry. -enum { - DF_1_NOW = 0x00000001, // Set RTLD_NOW for this object. - DF_1_GLOBAL = 0x00000002, // Set RTLD_GLOBAL for this object. - DF_1_GROUP = 0x00000004, // Set RTLD_GROUP for this object. - DF_1_NODELETE = 0x00000008, // Set RTLD_NODELETE for this object. - DF_1_LOADFLTR = 0x00000010, // Trigger filtee loading at runtime. - DF_1_INITFIRST = 0x00000020, // Set RTLD_INITFIRST for this object. - DF_1_NOOPEN = 0x00000040, // Set RTLD_NOOPEN for this object. - DF_1_ORIGIN = 0x00000080, // $ORIGIN must be handled. - DF_1_DIRECT = 0x00000100, // Direct binding enabled. - DF_1_TRANS = 0x00000200, - DF_1_INTERPOSE = 0x00000400, // Object is used to interpose. - DF_1_NODEFLIB = 0x00000800, // Ignore default lib search path. - DF_1_NODUMP = 0x00001000, // Object can't be dldump'ed. - DF_1_CONFALT = 0x00002000, // Configuration alternative created. - DF_1_ENDFILTEE = 0x00004000, // Filtee terminates filters search. - DF_1_DISPRELDNE = 0x00008000, // Disp reloc applied at build time. - DF_1_DISPRELPND = 0x00010000, // Disp reloc applied at run-time. - DF_1_NODIRECT = 0x00020000, // Object has no-direct binding. - DF_1_IGNMULDEF = 0x00040000, - DF_1_NOKSYMS = 0x00080000, - DF_1_NOHDR = 0x00100000, - DF_1_EDITED = 0x00200000, // Object is modified after built. - DF_1_NORELOC = 0x00400000, - DF_1_SYMINTPOSE = 0x00800000, // Object has individual interposers. - DF_1_GLOBAUDIT = 0x01000000, // Global auditing required. - DF_1_SINGLETON = 0x02000000 // Singleton symbols are used. -}; - -// DT_MIPS_FLAGS values. -enum { - RHF_NONE = 0x00000000, // No flags. - RHF_QUICKSTART = 0x00000001, // Uses shortcut pointers. - RHF_NOTPOT = 0x00000002, // Hash size is not a power of two. - RHS_NO_LIBRARY_REPLACEMENT = 0x00000004, // Ignore LD_LIBRARY_PATH. - RHF_NO_MOVE = 0x00000008, // DSO address may not be relocated. - RHF_SGI_ONLY = 0x00000010, // SGI specific features. - RHF_GUARANTEE_INIT = 0x00000020, // Guarantee that .init will finish - // executing before any non-init - // code in DSO is called. - RHF_DELTA_C_PLUS_PLUS = 0x00000040, // Contains Delta C++ code. - RHF_GUARANTEE_START_INIT = 0x00000080, // Guarantee that .init will start - // executing before any non-init - // code in DSO is called. - RHF_PIXIE = 0x00000100, // Generated by pixie. - RHF_DEFAULT_DELAY_LOAD = 0x00000200, // Delay-load DSO by default. - RHF_REQUICKSTART = 0x00000400, // Object may be requickstarted - RHF_REQUICKSTARTED = 0x00000800, // Object has been requickstarted - RHF_CORD = 0x00001000, // Generated by cord. - RHF_NO_UNRES_UNDEF = 0x00002000, // Object contains no unresolved - // undef symbols. - RHF_RLD_ORDER_SAFE = 0x00004000 // Symbol table is in a safe order. -}; - -// ElfXX_VerDef structure version (GNU versioning) -enum { VER_DEF_NONE = 0, VER_DEF_CURRENT = 1 }; - -// VerDef Flags (ElfXX_VerDef::vd_flags) -enum { VER_FLG_BASE = 0x1, VER_FLG_WEAK = 0x2, VER_FLG_INFO = 0x4 }; - -// Special constants for the version table. (SHT_GNU_versym/.gnu.version) -enum { - VER_NDX_LOCAL = 0, // Unversioned local symbol - VER_NDX_GLOBAL = 1, // Unversioned global symbol - VERSYM_VERSION = 0x7fff, // Version Index mask - VERSYM_HIDDEN = 0x8000 // Hidden bit (non-default version) -}; - -// ElfXX_VerNeed structure version (GNU versioning) -enum { VER_NEED_NONE = 0, VER_NEED_CURRENT = 1 }; - -// SHT_NOTE section types -enum { - NT_FREEBSD_THRMISC = 7, - NT_FREEBSD_PROCSTAT_PROC = 8, - NT_FREEBSD_PROCSTAT_FILES = 9, - NT_FREEBSD_PROCSTAT_VMMAP = 10, - NT_FREEBSD_PROCSTAT_GROUPS = 11, - NT_FREEBSD_PROCSTAT_UMASK = 12, - NT_FREEBSD_PROCSTAT_RLIMIT = 13, - NT_FREEBSD_PROCSTAT_OSREL = 14, - NT_FREEBSD_PROCSTAT_PSSTRINGS = 15, - NT_FREEBSD_PROCSTAT_AUXV = 16, -}; - -enum { - NT_GNU_ABI_TAG = 1, - NT_GNU_HWCAP = 2, - NT_GNU_BUILD_ID = 3, - NT_GNU_GOLD_VERSION = 4, -}; - -enum { - GNU_ABI_TAG_LINUX = 0, - GNU_ABI_TAG_HURD = 1, - GNU_ABI_TAG_SOLARIS = 2, - GNU_ABI_TAG_FREEBSD = 3, - GNU_ABI_TAG_NETBSD = 4, - GNU_ABI_TAG_SYLLABLE = 5, - GNU_ABI_TAG_NACL = 6, -}; - -// Compressed section header for ELF32. -struct Elf32_Chdr { - Elf32_Word ch_type; - Elf32_Word ch_size; - Elf32_Word ch_addralign; -}; - -// Compressed section header for ELF64. -struct Elf64_Chdr { - Elf64_Word ch_type; - Elf64_Word ch_reserved; - Elf64_Xword ch_size; - Elf64_Xword ch_addralign; -}; - -// Legal values for ch_type field of compressed section header. -enum { - ELFCOMPRESS_ZLIB = 1, // ZLIB/DEFLATE algorithm. - ELFCOMPRESS_LOOS = 0x60000000, // Start of OS-specific. - ELFCOMPRESS_HIOS = 0x6fffffff, // End of OS-specific. - ELFCOMPRESS_LOPROC = 0x70000000, // Start of processor-specific. - ELFCOMPRESS_HIPROC = 0x7fffffff // End of processor-specific. -}; - -} // end namespace ELF - -} // end namespace llvm - -#endif diff --git a/include/llvm/Support/ELFRelocs/AArch64.def b/include/llvm/Support/ELFRelocs/AArch64.def deleted file mode 100644 index 4afcd7d1f0939..0000000000000 --- a/include/llvm/Support/ELFRelocs/AArch64.def +++ /dev/null @@ -1,218 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -// Based on ABI release 1.1-beta, dated 6 November 2013. NB: The cover page of -// this document, IHI0056C_beta_aaelf64.pdf, on infocenter.arm.com, still -// labels this as release 1.0. -ELF_RELOC(R_AARCH64_NONE, 0) -ELF_RELOC(R_AARCH64_ABS64, 0x101) -ELF_RELOC(R_AARCH64_ABS32, 0x102) -ELF_RELOC(R_AARCH64_ABS16, 0x103) -ELF_RELOC(R_AARCH64_PREL64, 0x104) -ELF_RELOC(R_AARCH64_PREL32, 0x105) -ELF_RELOC(R_AARCH64_PREL16, 0x106) -ELF_RELOC(R_AARCH64_MOVW_UABS_G0, 0x107) -ELF_RELOC(R_AARCH64_MOVW_UABS_G0_NC, 0x108) -ELF_RELOC(R_AARCH64_MOVW_UABS_G1, 0x109) -ELF_RELOC(R_AARCH64_MOVW_UABS_G1_NC, 0x10a) -ELF_RELOC(R_AARCH64_MOVW_UABS_G2, 0x10b) -ELF_RELOC(R_AARCH64_MOVW_UABS_G2_NC, 0x10c) -ELF_RELOC(R_AARCH64_MOVW_UABS_G3, 0x10d) -ELF_RELOC(R_AARCH64_MOVW_SABS_G0, 0x10e) -ELF_RELOC(R_AARCH64_MOVW_SABS_G1, 0x10f) -ELF_RELOC(R_AARCH64_MOVW_SABS_G2, 0x110) -ELF_RELOC(R_AARCH64_LD_PREL_LO19, 0x111) -ELF_RELOC(R_AARCH64_ADR_PREL_LO21, 0x112) -ELF_RELOC(R_AARCH64_ADR_PREL_PG_HI21, 0x113) -ELF_RELOC(R_AARCH64_ADR_PREL_PG_HI21_NC, 0x114) -ELF_RELOC(R_AARCH64_ADD_ABS_LO12_NC, 0x115) -ELF_RELOC(R_AARCH64_LDST8_ABS_LO12_NC, 0x116) -ELF_RELOC(R_AARCH64_TSTBR14, 0x117) -ELF_RELOC(R_AARCH64_CONDBR19, 0x118) -ELF_RELOC(R_AARCH64_JUMP26, 0x11a) -ELF_RELOC(R_AARCH64_CALL26, 0x11b) -ELF_RELOC(R_AARCH64_LDST16_ABS_LO12_NC, 0x11c) -ELF_RELOC(R_AARCH64_LDST32_ABS_LO12_NC, 0x11d) -ELF_RELOC(R_AARCH64_LDST64_ABS_LO12_NC, 0x11e) -ELF_RELOC(R_AARCH64_MOVW_PREL_G0, 0x11f) -ELF_RELOC(R_AARCH64_MOVW_PREL_G0_NC, 0x120) -ELF_RELOC(R_AARCH64_MOVW_PREL_G1, 0x121) -ELF_RELOC(R_AARCH64_MOVW_PREL_G1_NC, 0x122) -ELF_RELOC(R_AARCH64_MOVW_PREL_G2, 0x123) -ELF_RELOC(R_AARCH64_MOVW_PREL_G2_NC, 0x124) -ELF_RELOC(R_AARCH64_MOVW_PREL_G3, 0x125) -ELF_RELOC(R_AARCH64_LDST128_ABS_LO12_NC, 0x12b) -ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G0, 0x12c) -ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G0_NC, 0x12d) -ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G1, 0x12e) -ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G1_NC, 0x12f) -ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G2, 0x130) -ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G2_NC, 0x131) -ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G3, 0x132) -ELF_RELOC(R_AARCH64_GOTREL64, 0x133) -ELF_RELOC(R_AARCH64_GOTREL32, 0x134) -ELF_RELOC(R_AARCH64_GOT_LD_PREL19, 0x135) -ELF_RELOC(R_AARCH64_LD64_GOTOFF_LO15, 0x136) -ELF_RELOC(R_AARCH64_ADR_GOT_PAGE, 0x137) -ELF_RELOC(R_AARCH64_LD64_GOT_LO12_NC, 0x138) -ELF_RELOC(R_AARCH64_LD64_GOTPAGE_LO15, 0x139) -ELF_RELOC(R_AARCH64_TLSGD_ADR_PREL21, 0x200) -ELF_RELOC(R_AARCH64_TLSGD_ADR_PAGE21, 0x201) -ELF_RELOC(R_AARCH64_TLSGD_ADD_LO12_NC, 0x202) -ELF_RELOC(R_AARCH64_TLSGD_MOVW_G1, 0x203) -ELF_RELOC(R_AARCH64_TLSGD_MOVW_G0_NC, 0x204) -ELF_RELOC(R_AARCH64_TLSLD_ADR_PREL21, 0x205) -ELF_RELOC(R_AARCH64_TLSLD_ADR_PAGE21, 0x206) -ELF_RELOC(R_AARCH64_TLSLD_ADD_LO12_NC, 0x207) -ELF_RELOC(R_AARCH64_TLSLD_MOVW_G1, 0x208) -ELF_RELOC(R_AARCH64_TLSLD_MOVW_G0_NC, 0x209) -ELF_RELOC(R_AARCH64_TLSLD_LD_PREL19, 0x20a) -ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G2, 0x20b) -ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G1, 0x20c) -ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC, 0x20d) -ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G0, 0x20e) -ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC, 0x20f) -ELF_RELOC(R_AARCH64_TLSLD_ADD_DTPREL_HI12, 0x210) -ELF_RELOC(R_AARCH64_TLSLD_ADD_DTPREL_LO12, 0x211) -ELF_RELOC(R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC, 0x212) -ELF_RELOC(R_AARCH64_TLSLD_LDST8_DTPREL_LO12, 0x213) -ELF_RELOC(R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC, 0x214) -ELF_RELOC(R_AARCH64_TLSLD_LDST16_DTPREL_LO12, 0x215) -ELF_RELOC(R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC, 0x216) -ELF_RELOC(R_AARCH64_TLSLD_LDST32_DTPREL_LO12, 0x217) -ELF_RELOC(R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC, 0x218) -ELF_RELOC(R_AARCH64_TLSLD_LDST64_DTPREL_LO12, 0x219) -ELF_RELOC(R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC, 0x21a) -ELF_RELOC(R_AARCH64_TLSIE_MOVW_GOTTPREL_G1, 0x21b) -ELF_RELOC(R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC, 0x21c) -ELF_RELOC(R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21, 0x21d) -ELF_RELOC(R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC, 0x21e) -ELF_RELOC(R_AARCH64_TLSIE_LD_GOTTPREL_PREL19, 0x21f) -ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G2, 0x220) -ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G1, 0x221) -ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G1_NC, 0x222) -ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G0, 0x223) -ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G0_NC, 0x224) -ELF_RELOC(R_AARCH64_TLSLE_ADD_TPREL_HI12, 0x225) -ELF_RELOC(R_AARCH64_TLSLE_ADD_TPREL_LO12, 0x226) -ELF_RELOC(R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, 0x227) -ELF_RELOC(R_AARCH64_TLSLE_LDST8_TPREL_LO12, 0x228) -ELF_RELOC(R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC, 0x229) -ELF_RELOC(R_AARCH64_TLSLE_LDST16_TPREL_LO12, 0x22a) -ELF_RELOC(R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC, 0x22b) -ELF_RELOC(R_AARCH64_TLSLE_LDST32_TPREL_LO12, 0x22c) -ELF_RELOC(R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC, 0x22d) -ELF_RELOC(R_AARCH64_TLSLE_LDST64_TPREL_LO12, 0x22e) -ELF_RELOC(R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC, 0x22f) -ELF_RELOC(R_AARCH64_TLSDESC_LD_PREL19, 0x230) -ELF_RELOC(R_AARCH64_TLSDESC_ADR_PREL21, 0x231) -ELF_RELOC(R_AARCH64_TLSDESC_ADR_PAGE21, 0x232) -ELF_RELOC(R_AARCH64_TLSDESC_LD64_LO12, 0x233) -ELF_RELOC(R_AARCH64_TLSDESC_ADD_LO12, 0x234) -ELF_RELOC(R_AARCH64_TLSDESC_OFF_G1, 0x235) -ELF_RELOC(R_AARCH64_TLSDESC_OFF_G0_NC, 0x236) -ELF_RELOC(R_AARCH64_TLSDESC_LDR, 0x237) -ELF_RELOC(R_AARCH64_TLSDESC_ADD, 0x238) -ELF_RELOC(R_AARCH64_TLSDESC_CALL, 0x239) -ELF_RELOC(R_AARCH64_TLSLE_LDST128_TPREL_LO12, 0x23a) -ELF_RELOC(R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC, 0x23b) -ELF_RELOC(R_AARCH64_TLSLD_LDST128_DTPREL_LO12, 0x23c) -ELF_RELOC(R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC, 0x23d) -ELF_RELOC(R_AARCH64_COPY, 0x400) -ELF_RELOC(R_AARCH64_GLOB_DAT, 0x401) -ELF_RELOC(R_AARCH64_JUMP_SLOT, 0x402) -ELF_RELOC(R_AARCH64_RELATIVE, 0x403) -ELF_RELOC(R_AARCH64_TLS_DTPREL64, 0x404) -ELF_RELOC(R_AARCH64_TLS_DTPMOD64, 0x405) -ELF_RELOC(R_AARCH64_TLS_TPREL64, 0x406) -ELF_RELOC(R_AARCH64_TLSDESC, 0x407) -ELF_RELOC(R_AARCH64_IRELATIVE, 0x408) - -// ELF_RELOC(R_AARCH64_P32_NONE, 0) -ELF_RELOC(R_AARCH64_P32_ABS32, 0x001) -ELF_RELOC(R_AARCH64_P32_ABS16, 0x002) -ELF_RELOC(R_AARCH64_P32_PREL32, 0x003) -ELF_RELOC(R_AARCH64_P32_PREL16, 0x004) -ELF_RELOC(R_AARCH64_P32_MOVW_UABS_G0, 0x005) -ELF_RELOC(R_AARCH64_P32_MOVW_UABS_G0_NC, 0x006) -ELF_RELOC(R_AARCH64_P32_MOVW_UABS_G1, 0x007) -ELF_RELOC(R_AARCH64_P32_MOVW_SABS_G0, 0x008) -ELF_RELOC(R_AARCH64_P32_LD_PREL_LO19, 0x009) -ELF_RELOC(R_AARCH64_P32_ADR_PREL_LO21, 0x00a) -ELF_RELOC(R_AARCH64_P32_ADR_PREL_PG_HI21, 0x00b) -ELF_RELOC(R_AARCH64_P32_ADD_ABS_LO12_NC, 0x00c) -ELF_RELOC(R_AARCH64_P32_LDST8_ABS_LO12_NC, 0x00d) -ELF_RELOC(R_AARCH64_P32_LDST16_ABS_LO12_NC, 0x00e) -ELF_RELOC(R_AARCH64_P32_LDST32_ABS_LO12_NC, 0x00f) -ELF_RELOC(R_AARCH64_P32_LDST64_ABS_LO12_NC, 0x010) -ELF_RELOC(R_AARCH64_P32_LDST128_ABS_LO12_NC, 0x011) -ELF_RELOC(R_AARCH64_P32_TSTBR14, 0x012) -ELF_RELOC(R_AARCH64_P32_CONDBR19, 0x013) -ELF_RELOC(R_AARCH64_P32_JUMP26, 0x014) -ELF_RELOC(R_AARCH64_P32_CALL26, 0x015) -ELF_RELOC(R_AARCH64_P32_MOVW_PREL_G0, 0x016) -ELF_RELOC(R_AARCH64_P32_MOVW_PREL_G0_NC, 0x017) -ELF_RELOC(R_AARCH64_P32_MOVW_PREL_G1, 0x018) -ELF_RELOC(R_AARCH64_P32_GOT_LD_PREL19, 0x019) -ELF_RELOC(R_AARCH64_P32_ADR_GOT_PAGE, 0x01a) -ELF_RELOC(R_AARCH64_P32_LD32_GOT_LO12_NC, 0x01b) -ELF_RELOC(R_AARCH64_P32_LD32_GOTPAGE_LO14, 0x01c) -ELF_RELOC(R_AARCH64_P32_TLSGD_ADR_PREL21, 0x050) -ELF_RELOC(R_AARCH64_P32_TLSGD_ADR_PAGE21, 0x051) -ELF_RELOC(R_AARCH64_P32_TLSGD_ADD_LO12_NC, 0x052) -ELF_RELOC(R_AARCH64_P32_TLSLD_ADR_PREL21, 0x053) -ELF_RELOC(R_AARCH64_P32_TLSLD_ADR_PAGE21, 0x054) -ELF_RELOC(R_AARCH64_P32_TLSLD_ADD_LO12_NC, 0x055) -ELF_RELOC(R_AARCH64_P32_TLSLD_LD_PREL19, 0x056) -ELF_RELOC(R_AARCH64_P32_TLSLD_MOVW_DTPREL_G1, 0x057) -ELF_RELOC(R_AARCH64_P32_TLSLD_MOVW_DTPREL_G0, 0x058) -ELF_RELOC(R_AARCH64_P32_TLSLD_MOVW_DTPREL_G0_NC, 0x059) -ELF_RELOC(R_AARCH64_P32_TLSLD_ADD_DTPREL_HI12, 0x05a) -ELF_RELOC(R_AARCH64_P32_TLSLD_ADD_DTPREL_LO12, 0x05b) -ELF_RELOC(R_AARCH64_P32_TLSLD_ADD_DTPREL_LO12_NC, 0x05c) -ELF_RELOC(R_AARCH64_P32_TLSLD_LDST8_DTPREL_LO12, 0x05d) -ELF_RELOC(R_AARCH64_P32_TLSLD_LDST8_DTPREL_LO12_NC, 0x05e) -ELF_RELOC(R_AARCH64_P32_TLSLD_LDST16_DTPREL_LO12, 0x05f) -ELF_RELOC(R_AARCH64_P32_TLSLD_LDST16_DTPREL_LO12_NC, 0x060) -ELF_RELOC(R_AARCH64_P32_TLSLD_LDST32_DTPREL_LO12, 0x061) -ELF_RELOC(R_AARCH64_P32_TLSLD_LDST32_DTPREL_LO12_NC, 0x062) -ELF_RELOC(R_AARCH64_P32_TLSLD_LDST64_DTPREL_LO12, 0x063) -ELF_RELOC(R_AARCH64_P32_TLSLD_LDST64_DTPREL_LO12_NC, 0x064) -ELF_RELOC(R_AARCH64_P32_TLSLD_LDST128_DTPREL_LO12, 0x065) -ELF_RELOC(R_AARCH64_P32_TLSLD_LDST128_DTPREL_LO12_NC,0x066) -ELF_RELOC(R_AARCH64_P32_TLSIE_ADR_GOTTPREL_PAGE21, 0x067) -ELF_RELOC(R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC, 0x068) -ELF_RELOC(R_AARCH64_P32_TLSIE_LD_GOTTPREL_PREL19, 0x069) -ELF_RELOC(R_AARCH64_P32_TLSLE_MOVW_TPREL_G1, 0x06a) -ELF_RELOC(R_AARCH64_P32_TLSLE_MOVW_TPREL_G0, 0x06b) -ELF_RELOC(R_AARCH64_P32_TLSLE_MOVW_TPREL_G0_NC, 0x06c) -ELF_RELOC(R_AARCH64_P32_TLSLE_ADD_TPREL_HI12, 0x06d) -ELF_RELOC(R_AARCH64_P32_TLSLE_ADD_TPREL_LO12, 0x06e) -ELF_RELOC(R_AARCH64_P32_TLSLE_ADD_TPREL_LO12_NC, 0x06f) -ELF_RELOC(R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12, 0x070) -ELF_RELOC(R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12_NC, 0x071) -ELF_RELOC(R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12, 0x072) -ELF_RELOC(R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12_NC, 0x073) -ELF_RELOC(R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12, 0x074) -ELF_RELOC(R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12_NC, 0x075) -ELF_RELOC(R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12, 0x076) -ELF_RELOC(R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12_NC, 0x077) -ELF_RELOC(R_AARCH64_P32_TLSLE_LDST128_TPREL_LO12, 0x078) -ELF_RELOC(R_AARCH64_P32_TLSLE_LDST128_TPREL_LO12_NC, 0x079) -ELF_RELOC(R_AARCH64_P32_TLSDESC_LD_PREL19, 0x07a) -ELF_RELOC(R_AARCH64_P32_TLSDESC_ADR_PREL21, 0x07b) -ELF_RELOC(R_AARCH64_P32_TLSDESC_ADR_PAGE21, 0x07c) -ELF_RELOC(R_AARCH64_P32_TLSDESC_LD32_LO12, 0x07d) -ELF_RELOC(R_AARCH64_P32_TLSDESC_ADD_LO12, 0x07e) -ELF_RELOC(R_AARCH64_P32_TLSDESC_CALL, 0x07f) -ELF_RELOC(R_AARCH64_P32_COPY, 0x0b4) -ELF_RELOC(R_AARCH64_P32_GLOB_DAT, 0x0b5) -ELF_RELOC(R_AARCH64_P32_JUMP_SLOT, 0x0b6) -ELF_RELOC(R_AARCH64_P32_RELATIVE, 0x0b7) -ELF_RELOC(R_AARCH64_P32_TLS_DTPREL, 0x0b8) -ELF_RELOC(R_AARCH64_P32_TLS_DTPMOD, 0x0b9) -ELF_RELOC(R_AARCH64_P32_TLS_TPREL, 0x0ba) -ELF_RELOC(R_AARCH64_P32_TLSDESC, 0x0bb) -ELF_RELOC(R_AARCH64_P32_IRELATIVE, 0x0bc) diff --git a/include/llvm/Support/ELFRelocs/AMDGPU.def b/include/llvm/Support/ELFRelocs/AMDGPU.def deleted file mode 100644 index c66f88d14ec71..0000000000000 --- a/include/llvm/Support/ELFRelocs/AMDGPU.def +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -ELF_RELOC(R_AMDGPU_NONE, 0) -ELF_RELOC(R_AMDGPU_ABS32_LO, 1) -ELF_RELOC(R_AMDGPU_ABS32_HI, 2) -ELF_RELOC(R_AMDGPU_ABS64, 3) -ELF_RELOC(R_AMDGPU_REL32, 4) -ELF_RELOC(R_AMDGPU_REL64, 5) -ELF_RELOC(R_AMDGPU_ABS32, 6) -ELF_RELOC(R_AMDGPU_GOTPCREL, 7) -ELF_RELOC(R_AMDGPU_GOTPCREL32_LO, 8) -ELF_RELOC(R_AMDGPU_GOTPCREL32_HI, 9) -ELF_RELOC(R_AMDGPU_REL32_LO, 10) -ELF_RELOC(R_AMDGPU_REL32_HI, 11) diff --git a/include/llvm/Support/ELFRelocs/ARM.def b/include/llvm/Support/ELFRelocs/ARM.def deleted file mode 100644 index 730fc5b8836c8..0000000000000 --- a/include/llvm/Support/ELFRelocs/ARM.def +++ /dev/null @@ -1,138 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -// Meets 2.09 ABI Specs. -ELF_RELOC(R_ARM_NONE, 0x00) -ELF_RELOC(R_ARM_PC24, 0x01) -ELF_RELOC(R_ARM_ABS32, 0x02) -ELF_RELOC(R_ARM_REL32, 0x03) -ELF_RELOC(R_ARM_LDR_PC_G0, 0x04) -ELF_RELOC(R_ARM_ABS16, 0x05) -ELF_RELOC(R_ARM_ABS12, 0x06) -ELF_RELOC(R_ARM_THM_ABS5, 0x07) -ELF_RELOC(R_ARM_ABS8, 0x08) -ELF_RELOC(R_ARM_SBREL32, 0x09) -ELF_RELOC(R_ARM_THM_CALL, 0x0a) -ELF_RELOC(R_ARM_THM_PC8, 0x0b) -ELF_RELOC(R_ARM_BREL_ADJ, 0x0c) -ELF_RELOC(R_ARM_TLS_DESC, 0x0d) -ELF_RELOC(R_ARM_THM_SWI8, 0x0e) -ELF_RELOC(R_ARM_XPC25, 0x0f) -ELF_RELOC(R_ARM_THM_XPC22, 0x10) -ELF_RELOC(R_ARM_TLS_DTPMOD32, 0x11) -ELF_RELOC(R_ARM_TLS_DTPOFF32, 0x12) -ELF_RELOC(R_ARM_TLS_TPOFF32, 0x13) -ELF_RELOC(R_ARM_COPY, 0x14) -ELF_RELOC(R_ARM_GLOB_DAT, 0x15) -ELF_RELOC(R_ARM_JUMP_SLOT, 0x16) -ELF_RELOC(R_ARM_RELATIVE, 0x17) -ELF_RELOC(R_ARM_GOTOFF32, 0x18) -ELF_RELOC(R_ARM_BASE_PREL, 0x19) -ELF_RELOC(R_ARM_GOT_BREL, 0x1a) -ELF_RELOC(R_ARM_PLT32, 0x1b) -ELF_RELOC(R_ARM_CALL, 0x1c) -ELF_RELOC(R_ARM_JUMP24, 0x1d) -ELF_RELOC(R_ARM_THM_JUMP24, 0x1e) -ELF_RELOC(R_ARM_BASE_ABS, 0x1f) -ELF_RELOC(R_ARM_ALU_PCREL_7_0, 0x20) -ELF_RELOC(R_ARM_ALU_PCREL_15_8, 0x21) -ELF_RELOC(R_ARM_ALU_PCREL_23_15, 0x22) -ELF_RELOC(R_ARM_LDR_SBREL_11_0_NC, 0x23) -ELF_RELOC(R_ARM_ALU_SBREL_19_12_NC, 0x24) -ELF_RELOC(R_ARM_ALU_SBREL_27_20_CK, 0x25) -ELF_RELOC(R_ARM_TARGET1, 0x26) -ELF_RELOC(R_ARM_SBREL31, 0x27) -ELF_RELOC(R_ARM_V4BX, 0x28) -ELF_RELOC(R_ARM_TARGET2, 0x29) -ELF_RELOC(R_ARM_PREL31, 0x2a) -ELF_RELOC(R_ARM_MOVW_ABS_NC, 0x2b) -ELF_RELOC(R_ARM_MOVT_ABS, 0x2c) -ELF_RELOC(R_ARM_MOVW_PREL_NC, 0x2d) -ELF_RELOC(R_ARM_MOVT_PREL, 0x2e) -ELF_RELOC(R_ARM_THM_MOVW_ABS_NC, 0x2f) -ELF_RELOC(R_ARM_THM_MOVT_ABS, 0x30) -ELF_RELOC(R_ARM_THM_MOVW_PREL_NC, 0x31) -ELF_RELOC(R_ARM_THM_MOVT_PREL, 0x32) -ELF_RELOC(R_ARM_THM_JUMP19, 0x33) -ELF_RELOC(R_ARM_THM_JUMP6, 0x34) -ELF_RELOC(R_ARM_THM_ALU_PREL_11_0, 0x35) -ELF_RELOC(R_ARM_THM_PC12, 0x36) -ELF_RELOC(R_ARM_ABS32_NOI, 0x37) -ELF_RELOC(R_ARM_REL32_NOI, 0x38) -ELF_RELOC(R_ARM_ALU_PC_G0_NC, 0x39) -ELF_RELOC(R_ARM_ALU_PC_G0, 0x3a) -ELF_RELOC(R_ARM_ALU_PC_G1_NC, 0x3b) -ELF_RELOC(R_ARM_ALU_PC_G1, 0x3c) -ELF_RELOC(R_ARM_ALU_PC_G2, 0x3d) -ELF_RELOC(R_ARM_LDR_PC_G1, 0x3e) -ELF_RELOC(R_ARM_LDR_PC_G2, 0x3f) -ELF_RELOC(R_ARM_LDRS_PC_G0, 0x40) -ELF_RELOC(R_ARM_LDRS_PC_G1, 0x41) -ELF_RELOC(R_ARM_LDRS_PC_G2, 0x42) -ELF_RELOC(R_ARM_LDC_PC_G0, 0x43) -ELF_RELOC(R_ARM_LDC_PC_G1, 0x44) -ELF_RELOC(R_ARM_LDC_PC_G2, 0x45) -ELF_RELOC(R_ARM_ALU_SB_G0_NC, 0x46) -ELF_RELOC(R_ARM_ALU_SB_G0, 0x47) -ELF_RELOC(R_ARM_ALU_SB_G1_NC, 0x48) -ELF_RELOC(R_ARM_ALU_SB_G1, 0x49) -ELF_RELOC(R_ARM_ALU_SB_G2, 0x4a) -ELF_RELOC(R_ARM_LDR_SB_G0, 0x4b) -ELF_RELOC(R_ARM_LDR_SB_G1, 0x4c) -ELF_RELOC(R_ARM_LDR_SB_G2, 0x4d) -ELF_RELOC(R_ARM_LDRS_SB_G0, 0x4e) -ELF_RELOC(R_ARM_LDRS_SB_G1, 0x4f) -ELF_RELOC(R_ARM_LDRS_SB_G2, 0x50) -ELF_RELOC(R_ARM_LDC_SB_G0, 0x51) -ELF_RELOC(R_ARM_LDC_SB_G1, 0x52) -ELF_RELOC(R_ARM_LDC_SB_G2, 0x53) -ELF_RELOC(R_ARM_MOVW_BREL_NC, 0x54) -ELF_RELOC(R_ARM_MOVT_BREL, 0x55) -ELF_RELOC(R_ARM_MOVW_BREL, 0x56) -ELF_RELOC(R_ARM_THM_MOVW_BREL_NC, 0x57) -ELF_RELOC(R_ARM_THM_MOVT_BREL, 0x58) -ELF_RELOC(R_ARM_THM_MOVW_BREL, 0x59) -ELF_RELOC(R_ARM_TLS_GOTDESC, 0x5a) -ELF_RELOC(R_ARM_TLS_CALL, 0x5b) -ELF_RELOC(R_ARM_TLS_DESCSEQ, 0x5c) -ELF_RELOC(R_ARM_THM_TLS_CALL, 0x5d) -ELF_RELOC(R_ARM_PLT32_ABS, 0x5e) -ELF_RELOC(R_ARM_GOT_ABS, 0x5f) -ELF_RELOC(R_ARM_GOT_PREL, 0x60) -ELF_RELOC(R_ARM_GOT_BREL12, 0x61) -ELF_RELOC(R_ARM_GOTOFF12, 0x62) -ELF_RELOC(R_ARM_GOTRELAX, 0x63) -ELF_RELOC(R_ARM_GNU_VTENTRY, 0x64) -ELF_RELOC(R_ARM_GNU_VTINHERIT, 0x65) -ELF_RELOC(R_ARM_THM_JUMP11, 0x66) -ELF_RELOC(R_ARM_THM_JUMP8, 0x67) -ELF_RELOC(R_ARM_TLS_GD32, 0x68) -ELF_RELOC(R_ARM_TLS_LDM32, 0x69) -ELF_RELOC(R_ARM_TLS_LDO32, 0x6a) -ELF_RELOC(R_ARM_TLS_IE32, 0x6b) -ELF_RELOC(R_ARM_TLS_LE32, 0x6c) -ELF_RELOC(R_ARM_TLS_LDO12, 0x6d) -ELF_RELOC(R_ARM_TLS_LE12, 0x6e) -ELF_RELOC(R_ARM_TLS_IE12GP, 0x6f) -ELF_RELOC(R_ARM_PRIVATE_0, 0x70) -ELF_RELOC(R_ARM_PRIVATE_1, 0x71) -ELF_RELOC(R_ARM_PRIVATE_2, 0x72) -ELF_RELOC(R_ARM_PRIVATE_3, 0x73) -ELF_RELOC(R_ARM_PRIVATE_4, 0x74) -ELF_RELOC(R_ARM_PRIVATE_5, 0x75) -ELF_RELOC(R_ARM_PRIVATE_6, 0x76) -ELF_RELOC(R_ARM_PRIVATE_7, 0x77) -ELF_RELOC(R_ARM_PRIVATE_8, 0x78) -ELF_RELOC(R_ARM_PRIVATE_9, 0x79) -ELF_RELOC(R_ARM_PRIVATE_10, 0x7a) -ELF_RELOC(R_ARM_PRIVATE_11, 0x7b) -ELF_RELOC(R_ARM_PRIVATE_12, 0x7c) -ELF_RELOC(R_ARM_PRIVATE_13, 0x7d) -ELF_RELOC(R_ARM_PRIVATE_14, 0x7e) -ELF_RELOC(R_ARM_PRIVATE_15, 0x7f) -ELF_RELOC(R_ARM_ME_TOO, 0x80) -ELF_RELOC(R_ARM_THM_TLS_DESCSEQ16, 0x81) -ELF_RELOC(R_ARM_THM_TLS_DESCSEQ32, 0x82) -ELF_RELOC(R_ARM_IRELATIVE, 0xa0) diff --git a/include/llvm/Support/ELFRelocs/AVR.def b/include/llvm/Support/ELFRelocs/AVR.def deleted file mode 100644 index 5692d6cb9aa07..0000000000000 --- a/include/llvm/Support/ELFRelocs/AVR.def +++ /dev/null @@ -1,40 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -ELF_RELOC(R_AVR_NONE, 0) -ELF_RELOC(R_AVR_32, 1) -ELF_RELOC(R_AVR_7_PCREL, 2) -ELF_RELOC(R_AVR_13_PCREL, 3) -ELF_RELOC(R_AVR_16, 4) -ELF_RELOC(R_AVR_16_PM, 5) -ELF_RELOC(R_AVR_LO8_LDI, 6) -ELF_RELOC(R_AVR_HI8_LDI, 7) -ELF_RELOC(R_AVR_HH8_LDI, 8) -ELF_RELOC(R_AVR_LO8_LDI_NEG, 9) -ELF_RELOC(R_AVR_HI8_LDI_NEG, 10) -ELF_RELOC(R_AVR_HH8_LDI_NEG, 11) -ELF_RELOC(R_AVR_LO8_LDI_PM, 12) -ELF_RELOC(R_AVR_HI8_LDI_PM, 13) -ELF_RELOC(R_AVR_HH8_LDI_PM, 14) -ELF_RELOC(R_AVR_LO8_LDI_PM_NEG, 15) -ELF_RELOC(R_AVR_HI8_LDI_PM_NEG, 16) -ELF_RELOC(R_AVR_HH8_LDI_PM_NEG, 17) -ELF_RELOC(R_AVR_CALL, 18) -ELF_RELOC(R_AVR_LDI, 19) -ELF_RELOC(R_AVR_6, 20) -ELF_RELOC(R_AVR_6_ADIW, 21) -ELF_RELOC(R_AVR_MS8_LDI, 22) -ELF_RELOC(R_AVR_MS8_LDI_NEG, 23) -ELF_RELOC(R_AVR_LO8_LDI_GS, 24) -ELF_RELOC(R_AVR_HI8_LDI_GS, 25) -ELF_RELOC(R_AVR_8, 26) -ELF_RELOC(R_AVR_8_LO8, 27) -ELF_RELOC(R_AVR_8_HI8, 28) -ELF_RELOC(R_AVR_8_HLO8, 29) -ELF_RELOC(R_AVR_SYM_DIFF, 30) -ELF_RELOC(R_AVR_16_LDST, 31) -ELF_RELOC(R_AVR_LDS_STS_16, 33) -ELF_RELOC(R_AVR_PORT6, 34) -ELF_RELOC(R_AVR_PORT5, 35) diff --git a/include/llvm/Support/ELFRelocs/BPF.def b/include/llvm/Support/ELFRelocs/BPF.def deleted file mode 100644 index 5dd7f70b6963a..0000000000000 --- a/include/llvm/Support/ELFRelocs/BPF.def +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -// No relocation -ELF_RELOC(R_BPF_NONE, 0) -ELF_RELOC(R_BPF_64_64, 1) -ELF_RELOC(R_BPF_64_32, 10) diff --git a/include/llvm/Support/ELFRelocs/Hexagon.def b/include/llvm/Support/ELFRelocs/Hexagon.def deleted file mode 100644 index 5021e2b26ce5f..0000000000000 --- a/include/llvm/Support/ELFRelocs/Hexagon.def +++ /dev/null @@ -1,106 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -// Release 5 ABI -ELF_RELOC(R_HEX_NONE, 0) -ELF_RELOC(R_HEX_B22_PCREL, 1) -ELF_RELOC(R_HEX_B15_PCREL, 2) -ELF_RELOC(R_HEX_B7_PCREL, 3) -ELF_RELOC(R_HEX_LO16, 4) -ELF_RELOC(R_HEX_HI16, 5) -ELF_RELOC(R_HEX_32, 6) -ELF_RELOC(R_HEX_16, 7) -ELF_RELOC(R_HEX_8, 8) -ELF_RELOC(R_HEX_GPREL16_0, 9) -ELF_RELOC(R_HEX_GPREL16_1, 10) -ELF_RELOC(R_HEX_GPREL16_2, 11) -ELF_RELOC(R_HEX_GPREL16_3, 12) -ELF_RELOC(R_HEX_HL16, 13) -ELF_RELOC(R_HEX_B13_PCREL, 14) -ELF_RELOC(R_HEX_B9_PCREL, 15) -ELF_RELOC(R_HEX_B32_PCREL_X, 16) -ELF_RELOC(R_HEX_32_6_X, 17) -ELF_RELOC(R_HEX_B22_PCREL_X, 18) -ELF_RELOC(R_HEX_B15_PCREL_X, 19) -ELF_RELOC(R_HEX_B13_PCREL_X, 20) -ELF_RELOC(R_HEX_B9_PCREL_X, 21) -ELF_RELOC(R_HEX_B7_PCREL_X, 22) -ELF_RELOC(R_HEX_16_X, 23) -ELF_RELOC(R_HEX_12_X, 24) -ELF_RELOC(R_HEX_11_X, 25) -ELF_RELOC(R_HEX_10_X, 26) -ELF_RELOC(R_HEX_9_X, 27) -ELF_RELOC(R_HEX_8_X, 28) -ELF_RELOC(R_HEX_7_X, 29) -ELF_RELOC(R_HEX_6_X, 30) -ELF_RELOC(R_HEX_32_PCREL, 31) -ELF_RELOC(R_HEX_COPY, 32) -ELF_RELOC(R_HEX_GLOB_DAT, 33) -ELF_RELOC(R_HEX_JMP_SLOT, 34) -ELF_RELOC(R_HEX_RELATIVE, 35) -ELF_RELOC(R_HEX_PLT_B22_PCREL, 36) -ELF_RELOC(R_HEX_GOTREL_LO16, 37) -ELF_RELOC(R_HEX_GOTREL_HI16, 38) -ELF_RELOC(R_HEX_GOTREL_32, 39) -ELF_RELOC(R_HEX_GOT_LO16, 40) -ELF_RELOC(R_HEX_GOT_HI16, 41) -ELF_RELOC(R_HEX_GOT_32, 42) -ELF_RELOC(R_HEX_GOT_16, 43) -ELF_RELOC(R_HEX_DTPMOD_32, 44) -ELF_RELOC(R_HEX_DTPREL_LO16, 45) -ELF_RELOC(R_HEX_DTPREL_HI16, 46) -ELF_RELOC(R_HEX_DTPREL_32, 47) -ELF_RELOC(R_HEX_DTPREL_16, 48) -ELF_RELOC(R_HEX_GD_PLT_B22_PCREL, 49) -ELF_RELOC(R_HEX_GD_GOT_LO16, 50) -ELF_RELOC(R_HEX_GD_GOT_HI16, 51) -ELF_RELOC(R_HEX_GD_GOT_32, 52) -ELF_RELOC(R_HEX_GD_GOT_16, 53) -ELF_RELOC(R_HEX_IE_LO16, 54) -ELF_RELOC(R_HEX_IE_HI16, 55) -ELF_RELOC(R_HEX_IE_32, 56) -ELF_RELOC(R_HEX_IE_GOT_LO16, 57) -ELF_RELOC(R_HEX_IE_GOT_HI16, 58) -ELF_RELOC(R_HEX_IE_GOT_32, 59) -ELF_RELOC(R_HEX_IE_GOT_16, 60) -ELF_RELOC(R_HEX_TPREL_LO16, 61) -ELF_RELOC(R_HEX_TPREL_HI16, 62) -ELF_RELOC(R_HEX_TPREL_32, 63) -ELF_RELOC(R_HEX_TPREL_16, 64) -ELF_RELOC(R_HEX_6_PCREL_X, 65) -ELF_RELOC(R_HEX_GOTREL_32_6_X, 66) -ELF_RELOC(R_HEX_GOTREL_16_X, 67) -ELF_RELOC(R_HEX_GOTREL_11_X, 68) -ELF_RELOC(R_HEX_GOT_32_6_X, 69) -ELF_RELOC(R_HEX_GOT_16_X, 70) -ELF_RELOC(R_HEX_GOT_11_X, 71) -ELF_RELOC(R_HEX_DTPREL_32_6_X, 72) -ELF_RELOC(R_HEX_DTPREL_16_X, 73) -ELF_RELOC(R_HEX_DTPREL_11_X, 74) -ELF_RELOC(R_HEX_GD_GOT_32_6_X, 75) -ELF_RELOC(R_HEX_GD_GOT_16_X, 76) -ELF_RELOC(R_HEX_GD_GOT_11_X, 77) -ELF_RELOC(R_HEX_IE_32_6_X, 78) -ELF_RELOC(R_HEX_IE_16_X, 79) -ELF_RELOC(R_HEX_IE_GOT_32_6_X, 80) -ELF_RELOC(R_HEX_IE_GOT_16_X, 81) -ELF_RELOC(R_HEX_IE_GOT_11_X, 82) -ELF_RELOC(R_HEX_TPREL_32_6_X, 83) -ELF_RELOC(R_HEX_TPREL_16_X, 84) -ELF_RELOC(R_HEX_TPREL_11_X, 85) -ELF_RELOC(R_HEX_LD_PLT_B22_PCREL, 86) -ELF_RELOC(R_HEX_LD_GOT_LO16, 87) -ELF_RELOC(R_HEX_LD_GOT_HI16, 88) -ELF_RELOC(R_HEX_LD_GOT_32, 89) -ELF_RELOC(R_HEX_LD_GOT_16, 90) -ELF_RELOC(R_HEX_LD_GOT_32_6_X, 91) -ELF_RELOC(R_HEX_LD_GOT_16_X, 92) -ELF_RELOC(R_HEX_LD_GOT_11_X, 93) -ELF_RELOC(R_HEX_23_REG, 94) -ELF_RELOC(R_HEX_GD_PLT_B22_PCREL_X, 95) -ELF_RELOC(R_HEX_GD_PLT_B32_PCREL_X, 96) -ELF_RELOC(R_HEX_LD_PLT_B22_PCREL_X, 97) -ELF_RELOC(R_HEX_LD_PLT_B32_PCREL_X, 98) -ELF_RELOC(R_HEX_27_REG, 99) diff --git a/include/llvm/Support/ELFRelocs/Lanai.def b/include/llvm/Support/ELFRelocs/Lanai.def deleted file mode 100644 index 77ecb048403d3..0000000000000 --- a/include/llvm/Support/ELFRelocs/Lanai.def +++ /dev/null @@ -1,19 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -// No relocation -ELF_RELOC(R_LANAI_NONE, 0) -// 21-bit symbol relocation -ELF_RELOC(R_LANAI_21, 1) -// 21-bit symbol relocation with last two bits masked to 0 -ELF_RELOC(R_LANAI_21_F, 2) -// 25-bit branch targets -ELF_RELOC(R_LANAI_25, 3) -// General 32-bit relocation -ELF_RELOC(R_LANAI_32, 4) -// Upper 16-bits of a symbolic relocation -ELF_RELOC(R_LANAI_HI16, 5) -// Lower 16-bits of a symbolic relocation -ELF_RELOC(R_LANAI_LO16, 6) diff --git a/include/llvm/Support/ELFRelocs/Mips.def b/include/llvm/Support/ELFRelocs/Mips.def deleted file mode 100644 index bc0088dff3f43..0000000000000 --- a/include/llvm/Support/ELFRelocs/Mips.def +++ /dev/null @@ -1,117 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -ELF_RELOC(R_MIPS_NONE, 0) -ELF_RELOC(R_MIPS_16, 1) -ELF_RELOC(R_MIPS_32, 2) -ELF_RELOC(R_MIPS_REL32, 3) -ELF_RELOC(R_MIPS_26, 4) -ELF_RELOC(R_MIPS_HI16, 5) -ELF_RELOC(R_MIPS_LO16, 6) -ELF_RELOC(R_MIPS_GPREL16, 7) -ELF_RELOC(R_MIPS_LITERAL, 8) -ELF_RELOC(R_MIPS_GOT16, 9) -ELF_RELOC(R_MIPS_PC16, 10) -ELF_RELOC(R_MIPS_CALL16, 11) -ELF_RELOC(R_MIPS_GPREL32, 12) -ELF_RELOC(R_MIPS_UNUSED1, 13) -ELF_RELOC(R_MIPS_UNUSED2, 14) -ELF_RELOC(R_MIPS_UNUSED3, 15) -ELF_RELOC(R_MIPS_SHIFT5, 16) -ELF_RELOC(R_MIPS_SHIFT6, 17) -ELF_RELOC(R_MIPS_64, 18) -ELF_RELOC(R_MIPS_GOT_DISP, 19) -ELF_RELOC(R_MIPS_GOT_PAGE, 20) -ELF_RELOC(R_MIPS_GOT_OFST, 21) -ELF_RELOC(R_MIPS_GOT_HI16, 22) -ELF_RELOC(R_MIPS_GOT_LO16, 23) -ELF_RELOC(R_MIPS_SUB, 24) -ELF_RELOC(R_MIPS_INSERT_A, 25) -ELF_RELOC(R_MIPS_INSERT_B, 26) -ELF_RELOC(R_MIPS_DELETE, 27) -ELF_RELOC(R_MIPS_HIGHER, 28) -ELF_RELOC(R_MIPS_HIGHEST, 29) -ELF_RELOC(R_MIPS_CALL_HI16, 30) -ELF_RELOC(R_MIPS_CALL_LO16, 31) -ELF_RELOC(R_MIPS_SCN_DISP, 32) -ELF_RELOC(R_MIPS_REL16, 33) -ELF_RELOC(R_MIPS_ADD_IMMEDIATE, 34) -ELF_RELOC(R_MIPS_PJUMP, 35) -ELF_RELOC(R_MIPS_RELGOT, 36) -ELF_RELOC(R_MIPS_JALR, 37) -ELF_RELOC(R_MIPS_TLS_DTPMOD32, 38) -ELF_RELOC(R_MIPS_TLS_DTPREL32, 39) -ELF_RELOC(R_MIPS_TLS_DTPMOD64, 40) -ELF_RELOC(R_MIPS_TLS_DTPREL64, 41) -ELF_RELOC(R_MIPS_TLS_GD, 42) -ELF_RELOC(R_MIPS_TLS_LDM, 43) -ELF_RELOC(R_MIPS_TLS_DTPREL_HI16, 44) -ELF_RELOC(R_MIPS_TLS_DTPREL_LO16, 45) -ELF_RELOC(R_MIPS_TLS_GOTTPREL, 46) -ELF_RELOC(R_MIPS_TLS_TPREL32, 47) -ELF_RELOC(R_MIPS_TLS_TPREL64, 48) -ELF_RELOC(R_MIPS_TLS_TPREL_HI16, 49) -ELF_RELOC(R_MIPS_TLS_TPREL_LO16, 50) -ELF_RELOC(R_MIPS_GLOB_DAT, 51) -ELF_RELOC(R_MIPS_PC21_S2, 60) -ELF_RELOC(R_MIPS_PC26_S2, 61) -ELF_RELOC(R_MIPS_PC18_S3, 62) -ELF_RELOC(R_MIPS_PC19_S2, 63) -ELF_RELOC(R_MIPS_PCHI16, 64) -ELF_RELOC(R_MIPS_PCLO16, 65) -ELF_RELOC(R_MIPS16_26, 100) -ELF_RELOC(R_MIPS16_GPREL, 101) -ELF_RELOC(R_MIPS16_GOT16, 102) -ELF_RELOC(R_MIPS16_CALL16, 103) -ELF_RELOC(R_MIPS16_HI16, 104) -ELF_RELOC(R_MIPS16_LO16, 105) -ELF_RELOC(R_MIPS16_TLS_GD, 106) -ELF_RELOC(R_MIPS16_TLS_LDM, 107) -ELF_RELOC(R_MIPS16_TLS_DTPREL_HI16, 108) -ELF_RELOC(R_MIPS16_TLS_DTPREL_LO16, 109) -ELF_RELOC(R_MIPS16_TLS_GOTTPREL, 110) -ELF_RELOC(R_MIPS16_TLS_TPREL_HI16, 111) -ELF_RELOC(R_MIPS16_TLS_TPREL_LO16, 112) -ELF_RELOC(R_MIPS_COPY, 126) -ELF_RELOC(R_MIPS_JUMP_SLOT, 127) -ELF_RELOC(R_MICROMIPS_26_S1, 133) -ELF_RELOC(R_MICROMIPS_HI16, 134) -ELF_RELOC(R_MICROMIPS_LO16, 135) -ELF_RELOC(R_MICROMIPS_GPREL16, 136) -ELF_RELOC(R_MICROMIPS_LITERAL, 137) -ELF_RELOC(R_MICROMIPS_GOT16, 138) -ELF_RELOC(R_MICROMIPS_PC7_S1, 139) -ELF_RELOC(R_MICROMIPS_PC10_S1, 140) -ELF_RELOC(R_MICROMIPS_PC16_S1, 141) -ELF_RELOC(R_MICROMIPS_CALL16, 142) -ELF_RELOC(R_MICROMIPS_GOT_DISP, 145) -ELF_RELOC(R_MICROMIPS_GOT_PAGE, 146) -ELF_RELOC(R_MICROMIPS_GOT_OFST, 147) -ELF_RELOC(R_MICROMIPS_GOT_HI16, 148) -ELF_RELOC(R_MICROMIPS_GOT_LO16, 149) -ELF_RELOC(R_MICROMIPS_SUB, 150) -ELF_RELOC(R_MICROMIPS_HIGHER, 151) -ELF_RELOC(R_MICROMIPS_HIGHEST, 152) -ELF_RELOC(R_MICROMIPS_CALL_HI16, 153) -ELF_RELOC(R_MICROMIPS_CALL_LO16, 154) -ELF_RELOC(R_MICROMIPS_SCN_DISP, 155) -ELF_RELOC(R_MICROMIPS_JALR, 156) -ELF_RELOC(R_MICROMIPS_HI0_LO16, 157) -ELF_RELOC(R_MICROMIPS_TLS_GD, 162) -ELF_RELOC(R_MICROMIPS_TLS_LDM, 163) -ELF_RELOC(R_MICROMIPS_TLS_DTPREL_HI16, 164) -ELF_RELOC(R_MICROMIPS_TLS_DTPREL_LO16, 165) -ELF_RELOC(R_MICROMIPS_TLS_GOTTPREL, 166) -ELF_RELOC(R_MICROMIPS_TLS_TPREL_HI16, 169) -ELF_RELOC(R_MICROMIPS_TLS_TPREL_LO16, 170) -ELF_RELOC(R_MICROMIPS_GPREL7_S2, 172) -ELF_RELOC(R_MICROMIPS_PC23_S2, 173) -ELF_RELOC(R_MICROMIPS_PC21_S1, 174) -ELF_RELOC(R_MICROMIPS_PC26_S1, 175) -ELF_RELOC(R_MICROMIPS_PC18_S3, 176) -ELF_RELOC(R_MICROMIPS_PC19_S2, 177) -ELF_RELOC(R_MIPS_NUM, 218) -ELF_RELOC(R_MIPS_PC32, 248) -ELF_RELOC(R_MIPS_EH, 249) diff --git a/include/llvm/Support/ELFRelocs/PowerPC.def b/include/llvm/Support/ELFRelocs/PowerPC.def deleted file mode 100644 index e4f8ee0ebe2b8..0000000000000 --- a/include/llvm/Support/ELFRelocs/PowerPC.def +++ /dev/null @@ -1,123 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -// glibc's PowerPC asm/sigcontext.h, when compiling for PPC64, has the -// unfortunate behavior of including asm/elf.h, which defines R_PPC_NONE, etc. -// to their corresponding integer values. As a result, we need to undef them -// here before continuing. - -#undef R_PPC_NONE -#undef R_PPC_ADDR32 -#undef R_PPC_ADDR24 -#undef R_PPC_ADDR16 -#undef R_PPC_ADDR16_LO -#undef R_PPC_ADDR16_HI -#undef R_PPC_ADDR16_HA -#undef R_PPC_ADDR14 -#undef R_PPC_ADDR14_BRTAKEN -#undef R_PPC_ADDR14_BRNTAKEN -#undef R_PPC_REL24 -#undef R_PPC_REL14 -#undef R_PPC_REL14_BRTAKEN -#undef R_PPC_REL14_BRNTAKEN -#undef R_PPC_GOT16 -#undef R_PPC_GOT16_LO -#undef R_PPC_GOT16_HI -#undef R_PPC_GOT16_HA -#undef R_PPC_PLTREL24 -#undef R_PPC_JMP_SLOT -#undef R_PPC_LOCAL24PC -#undef R_PPC_REL32 -#undef R_PPC_TLS -#undef R_PPC_DTPMOD32 -#undef R_PPC_TPREL16 -#undef R_PPC_TPREL16_LO -#undef R_PPC_TPREL16_HI -#undef R_PPC_TPREL16_HA -#undef R_PPC_TPREL32 -#undef R_PPC_DTPREL16 -#undef R_PPC_DTPREL16_LO -#undef R_PPC_DTPREL16_HI -#undef R_PPC_DTPREL16_HA -#undef R_PPC_DTPREL32 -#undef R_PPC_GOT_TLSGD16 -#undef R_PPC_GOT_TLSGD16_LO -#undef R_PPC_GOT_TLSGD16_HI -#undef R_PPC_GOT_TLSGD16_HA -#undef R_PPC_GOT_TLSLD16 -#undef R_PPC_GOT_TLSLD16_LO -#undef R_PPC_GOT_TLSLD16_HI -#undef R_PPC_GOT_TLSLD16_HA -#undef R_PPC_GOT_TPREL16 -#undef R_PPC_GOT_TPREL16_LO -#undef R_PPC_GOT_TPREL16_HI -#undef R_PPC_GOT_TPREL16_HA -#undef R_PPC_GOT_DTPREL16 -#undef R_PPC_GOT_DTPREL16_LO -#undef R_PPC_GOT_DTPREL16_HI -#undef R_PPC_GOT_DTPREL16_HA -#undef R_PPC_TLSGD -#undef R_PPC_TLSLD -#undef R_PPC_REL16 -#undef R_PPC_REL16_LO -#undef R_PPC_REL16_HI -#undef R_PPC_REL16_HA - -ELF_RELOC(R_PPC_NONE, 0) /* No relocation. */ -ELF_RELOC(R_PPC_ADDR32, 1) -ELF_RELOC(R_PPC_ADDR24, 2) -ELF_RELOC(R_PPC_ADDR16, 3) -ELF_RELOC(R_PPC_ADDR16_LO, 4) -ELF_RELOC(R_PPC_ADDR16_HI, 5) -ELF_RELOC(R_PPC_ADDR16_HA, 6) -ELF_RELOC(R_PPC_ADDR14, 7) -ELF_RELOC(R_PPC_ADDR14_BRTAKEN, 8) -ELF_RELOC(R_PPC_ADDR14_BRNTAKEN, 9) -ELF_RELOC(R_PPC_REL24, 10) -ELF_RELOC(R_PPC_REL14, 11) -ELF_RELOC(R_PPC_REL14_BRTAKEN, 12) -ELF_RELOC(R_PPC_REL14_BRNTAKEN, 13) -ELF_RELOC(R_PPC_GOT16, 14) -ELF_RELOC(R_PPC_GOT16_LO, 15) -ELF_RELOC(R_PPC_GOT16_HI, 16) -ELF_RELOC(R_PPC_GOT16_HA, 17) -ELF_RELOC(R_PPC_PLTREL24, 18) -ELF_RELOC(R_PPC_JMP_SLOT, 21) -ELF_RELOC(R_PPC_LOCAL24PC, 23) -ELF_RELOC(R_PPC_REL32, 26) -ELF_RELOC(R_PPC_TLS, 67) -ELF_RELOC(R_PPC_DTPMOD32, 68) -ELF_RELOC(R_PPC_TPREL16, 69) -ELF_RELOC(R_PPC_TPREL16_LO, 70) -ELF_RELOC(R_PPC_TPREL16_HI, 71) -ELF_RELOC(R_PPC_TPREL16_HA, 72) -ELF_RELOC(R_PPC_TPREL32, 73) -ELF_RELOC(R_PPC_DTPREL16, 74) -ELF_RELOC(R_PPC_DTPREL16_LO, 75) -ELF_RELOC(R_PPC_DTPREL16_HI, 76) -ELF_RELOC(R_PPC_DTPREL16_HA, 77) -ELF_RELOC(R_PPC_DTPREL32, 78) -ELF_RELOC(R_PPC_GOT_TLSGD16, 79) -ELF_RELOC(R_PPC_GOT_TLSGD16_LO, 80) -ELF_RELOC(R_PPC_GOT_TLSGD16_HI, 81) -ELF_RELOC(R_PPC_GOT_TLSGD16_HA, 82) -ELF_RELOC(R_PPC_GOT_TLSLD16, 83) -ELF_RELOC(R_PPC_GOT_TLSLD16_LO, 84) -ELF_RELOC(R_PPC_GOT_TLSLD16_HI, 85) -ELF_RELOC(R_PPC_GOT_TLSLD16_HA, 86) -ELF_RELOC(R_PPC_GOT_TPREL16, 87) -ELF_RELOC(R_PPC_GOT_TPREL16_LO, 88) -ELF_RELOC(R_PPC_GOT_TPREL16_HI, 89) -ELF_RELOC(R_PPC_GOT_TPREL16_HA, 90) -ELF_RELOC(R_PPC_GOT_DTPREL16, 91) -ELF_RELOC(R_PPC_GOT_DTPREL16_LO, 92) -ELF_RELOC(R_PPC_GOT_DTPREL16_HI, 93) -ELF_RELOC(R_PPC_GOT_DTPREL16_HA, 94) -ELF_RELOC(R_PPC_TLSGD, 95) -ELF_RELOC(R_PPC_TLSLD, 96) -ELF_RELOC(R_PPC_REL16, 249) -ELF_RELOC(R_PPC_REL16_LO, 250) -ELF_RELOC(R_PPC_REL16_HI, 251) -ELF_RELOC(R_PPC_REL16_HA, 252) diff --git a/include/llvm/Support/ELFRelocs/PowerPC64.def b/include/llvm/Support/ELFRelocs/PowerPC64.def deleted file mode 100644 index 3a47c5a07574b..0000000000000 --- a/include/llvm/Support/ELFRelocs/PowerPC64.def +++ /dev/null @@ -1,181 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -// glibc's PowerPC asm/sigcontext.h, when compiling for PPC64, has the -// unfortunate behavior of including asm/elf.h, which defines R_PPC_NONE, etc. -// to their corresponding integer values. As a result, we need to undef them -// here before continuing. - -#undef R_PPC64_NONE -#undef R_PPC64_ADDR32 -#undef R_PPC64_ADDR24 -#undef R_PPC64_ADDR16 -#undef R_PPC64_ADDR16_LO -#undef R_PPC64_ADDR16_HI -#undef R_PPC64_ADDR16_HA -#undef R_PPC64_ADDR14 -#undef R_PPC64_ADDR14_BRTAKEN -#undef R_PPC64_ADDR14_BRNTAKEN -#undef R_PPC64_REL24 -#undef R_PPC64_REL14 -#undef R_PPC64_REL14_BRTAKEN -#undef R_PPC64_REL14_BRNTAKEN -#undef R_PPC64_GOT16 -#undef R_PPC64_GOT16_LO -#undef R_PPC64_GOT16_HI -#undef R_PPC64_GOT16_HA -#undef R_PPC64_GLOB_DAT -#undef R_PPC64_JMP_SLOT -#undef R_PPC64_RELATIVE -#undef R_PPC64_REL32 -#undef R_PPC64_ADDR64 -#undef R_PPC64_ADDR16_HIGHER -#undef R_PPC64_ADDR16_HIGHERA -#undef R_PPC64_ADDR16_HIGHEST -#undef R_PPC64_ADDR16_HIGHESTA -#undef R_PPC64_REL64 -#undef R_PPC64_TOC16 -#undef R_PPC64_TOC16_LO -#undef R_PPC64_TOC16_HI -#undef R_PPC64_TOC16_HA -#undef R_PPC64_TOC -#undef R_PPC64_ADDR16_DS -#undef R_PPC64_ADDR16_LO_DS -#undef R_PPC64_GOT16_DS -#undef R_PPC64_GOT16_LO_DS -#undef R_PPC64_TOC16_DS -#undef R_PPC64_TOC16_LO_DS -#undef R_PPC64_TLS -#undef R_PPC64_DTPMOD64 -#undef R_PPC64_TPREL16 -#undef R_PPC64_TPREL16_LO -#undef R_PPC64_TPREL16_HI -#undef R_PPC64_TPREL16_HA -#undef R_PPC64_TPREL64 -#undef R_PPC64_DTPREL16 -#undef R_PPC64_DTPREL16_LO -#undef R_PPC64_DTPREL16_HI -#undef R_PPC64_DTPREL16_HA -#undef R_PPC64_DTPREL64 -#undef R_PPC64_GOT_TLSGD16 -#undef R_PPC64_GOT_TLSGD16_LO -#undef R_PPC64_GOT_TLSGD16_HI -#undef R_PPC64_GOT_TLSGD16_HA -#undef R_PPC64_GOT_TLSLD16 -#undef R_PPC64_GOT_TLSLD16_LO -#undef R_PPC64_GOT_TLSLD16_HI -#undef R_PPC64_GOT_TLSLD16_HA -#undef R_PPC64_GOT_TPREL16_DS -#undef R_PPC64_GOT_TPREL16_LO_DS -#undef R_PPC64_GOT_TPREL16_HI -#undef R_PPC64_GOT_TPREL16_HA -#undef R_PPC64_GOT_DTPREL16_DS -#undef R_PPC64_GOT_DTPREL16_LO_DS -#undef R_PPC64_GOT_DTPREL16_HI -#undef R_PPC64_GOT_DTPREL16_HA -#undef R_PPC64_TPREL16_DS -#undef R_PPC64_TPREL16_LO_DS -#undef R_PPC64_TPREL16_HIGHER -#undef R_PPC64_TPREL16_HIGHERA -#undef R_PPC64_TPREL16_HIGHEST -#undef R_PPC64_TPREL16_HIGHESTA -#undef R_PPC64_DTPREL16_DS -#undef R_PPC64_DTPREL16_LO_DS -#undef R_PPC64_DTPREL16_HIGHER -#undef R_PPC64_DTPREL16_HIGHERA -#undef R_PPC64_DTPREL16_HIGHEST -#undef R_PPC64_DTPREL16_HIGHESTA -#undef R_PPC64_TLSGD -#undef R_PPC64_TLSLD -#undef R_PPC64_REL16 -#undef R_PPC64_REL16_LO -#undef R_PPC64_REL16_HI -#undef R_PPC64_REL16_HA - -ELF_RELOC(R_PPC64_NONE, 0) -ELF_RELOC(R_PPC64_ADDR32, 1) -ELF_RELOC(R_PPC64_ADDR24, 2) -ELF_RELOC(R_PPC64_ADDR16, 3) -ELF_RELOC(R_PPC64_ADDR16_LO, 4) -ELF_RELOC(R_PPC64_ADDR16_HI, 5) -ELF_RELOC(R_PPC64_ADDR16_HA, 6) -ELF_RELOC(R_PPC64_ADDR14, 7) -ELF_RELOC(R_PPC64_ADDR14_BRTAKEN, 8) -ELF_RELOC(R_PPC64_ADDR14_BRNTAKEN, 9) -ELF_RELOC(R_PPC64_REL24, 10) -ELF_RELOC(R_PPC64_REL14, 11) -ELF_RELOC(R_PPC64_REL14_BRTAKEN, 12) -ELF_RELOC(R_PPC64_REL14_BRNTAKEN, 13) -ELF_RELOC(R_PPC64_GOT16, 14) -ELF_RELOC(R_PPC64_GOT16_LO, 15) -ELF_RELOC(R_PPC64_GOT16_HI, 16) -ELF_RELOC(R_PPC64_GOT16_HA, 17) -ELF_RELOC(R_PPC64_GLOB_DAT, 20) -ELF_RELOC(R_PPC64_JMP_SLOT, 21) -ELF_RELOC(R_PPC64_RELATIVE, 22) -ELF_RELOC(R_PPC64_REL32, 26) -ELF_RELOC(R_PPC64_ADDR64, 38) -ELF_RELOC(R_PPC64_ADDR16_HIGHER, 39) -ELF_RELOC(R_PPC64_ADDR16_HIGHERA, 40) -ELF_RELOC(R_PPC64_ADDR16_HIGHEST, 41) -ELF_RELOC(R_PPC64_ADDR16_HIGHESTA, 42) -ELF_RELOC(R_PPC64_REL64, 44) -ELF_RELOC(R_PPC64_TOC16, 47) -ELF_RELOC(R_PPC64_TOC16_LO, 48) -ELF_RELOC(R_PPC64_TOC16_HI, 49) -ELF_RELOC(R_PPC64_TOC16_HA, 50) -ELF_RELOC(R_PPC64_TOC, 51) -ELF_RELOC(R_PPC64_ADDR16_DS, 56) -ELF_RELOC(R_PPC64_ADDR16_LO_DS, 57) -ELF_RELOC(R_PPC64_GOT16_DS, 58) -ELF_RELOC(R_PPC64_GOT16_LO_DS, 59) -ELF_RELOC(R_PPC64_TOC16_DS, 63) -ELF_RELOC(R_PPC64_TOC16_LO_DS, 64) -ELF_RELOC(R_PPC64_TLS, 67) -ELF_RELOC(R_PPC64_DTPMOD64, 68) -ELF_RELOC(R_PPC64_TPREL16, 69) -ELF_RELOC(R_PPC64_TPREL16_LO, 70) -ELF_RELOC(R_PPC64_TPREL16_HI, 71) -ELF_RELOC(R_PPC64_TPREL16_HA, 72) -ELF_RELOC(R_PPC64_TPREL64, 73) -ELF_RELOC(R_PPC64_DTPREL16, 74) -ELF_RELOC(R_PPC64_DTPREL16_LO, 75) -ELF_RELOC(R_PPC64_DTPREL16_HI, 76) -ELF_RELOC(R_PPC64_DTPREL16_HA, 77) -ELF_RELOC(R_PPC64_DTPREL64, 78) -ELF_RELOC(R_PPC64_GOT_TLSGD16, 79) -ELF_RELOC(R_PPC64_GOT_TLSGD16_LO, 80) -ELF_RELOC(R_PPC64_GOT_TLSGD16_HI, 81) -ELF_RELOC(R_PPC64_GOT_TLSGD16_HA, 82) -ELF_RELOC(R_PPC64_GOT_TLSLD16, 83) -ELF_RELOC(R_PPC64_GOT_TLSLD16_LO, 84) -ELF_RELOC(R_PPC64_GOT_TLSLD16_HI, 85) -ELF_RELOC(R_PPC64_GOT_TLSLD16_HA, 86) -ELF_RELOC(R_PPC64_GOT_TPREL16_DS, 87) -ELF_RELOC(R_PPC64_GOT_TPREL16_LO_DS, 88) -ELF_RELOC(R_PPC64_GOT_TPREL16_HI, 89) -ELF_RELOC(R_PPC64_GOT_TPREL16_HA, 90) -ELF_RELOC(R_PPC64_GOT_DTPREL16_DS, 91) -ELF_RELOC(R_PPC64_GOT_DTPREL16_LO_DS, 92) -ELF_RELOC(R_PPC64_GOT_DTPREL16_HI, 93) -ELF_RELOC(R_PPC64_GOT_DTPREL16_HA, 94) -ELF_RELOC(R_PPC64_TPREL16_DS, 95) -ELF_RELOC(R_PPC64_TPREL16_LO_DS, 96) -ELF_RELOC(R_PPC64_TPREL16_HIGHER, 97) -ELF_RELOC(R_PPC64_TPREL16_HIGHERA, 98) -ELF_RELOC(R_PPC64_TPREL16_HIGHEST, 99) -ELF_RELOC(R_PPC64_TPREL16_HIGHESTA, 100) -ELF_RELOC(R_PPC64_DTPREL16_DS, 101) -ELF_RELOC(R_PPC64_DTPREL16_LO_DS, 102) -ELF_RELOC(R_PPC64_DTPREL16_HIGHER, 103) -ELF_RELOC(R_PPC64_DTPREL16_HIGHERA, 104) -ELF_RELOC(R_PPC64_DTPREL16_HIGHEST, 105) -ELF_RELOC(R_PPC64_DTPREL16_HIGHESTA, 106) -ELF_RELOC(R_PPC64_TLSGD, 107) -ELF_RELOC(R_PPC64_TLSLD, 108) -ELF_RELOC(R_PPC64_REL16, 249) -ELF_RELOC(R_PPC64_REL16_LO, 250) -ELF_RELOC(R_PPC64_REL16_HI, 251) -ELF_RELOC(R_PPC64_REL16_HA, 252) diff --git a/include/llvm/Support/ELFRelocs/RISCV.def b/include/llvm/Support/ELFRelocs/RISCV.def deleted file mode 100644 index 9ec4955d26dba..0000000000000 --- a/include/llvm/Support/ELFRelocs/RISCV.def +++ /dev/null @@ -1,50 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -ELF_RELOC(R_RISCV_NONE, 0) -ELF_RELOC(R_RISCV_32, 1) -ELF_RELOC(R_RISCV_64, 2) -ELF_RELOC(R_RISCV_RELATIVE, 3) -ELF_RELOC(R_RISCV_COPY, 4) -ELF_RELOC(R_RISCV_JUMP_SLOT, 5) -ELF_RELOC(R_RISCV_TLS_DTPMOD32, 6) -ELF_RELOC(R_RISCV_TLS_DTPMOD64, 7) -ELF_RELOC(R_RISCV_TLS_DTPREL32, 8) -ELF_RELOC(R_RISCV_TLS_DTPREL64, 9) -ELF_RELOC(R_RISCV_TLS_TPREL32, 10) -ELF_RELOC(R_RISCV_TLS_TPREL64, 11) -ELF_RELOC(R_RISCV_BRANCH, 16) -ELF_RELOC(R_RISCV_JAL, 17) -ELF_RELOC(R_RISCV_CALL, 18) -ELF_RELOC(R_RISCV_CALL_PLT, 19) -ELF_RELOC(R_RISCV_GOT_HI20, 20) -ELF_RELOC(R_RISCV_TLS_GOT_HI20, 21) -ELF_RELOC(R_RISCV_TLS_GD_HI20, 22) -ELF_RELOC(R_RISCV_PCREL_HI20, 23) -ELF_RELOC(R_RISCV_PCREL_LO12_I, 24) -ELF_RELOC(R_RISCV_PCREL_LO12_S, 25) -ELF_RELOC(R_RISCV_HI20, 26) -ELF_RELOC(R_RISCV_LO12_I, 27) -ELF_RELOC(R_RISCV_LO12_S, 28) -ELF_RELOC(R_RISCV_TPREL_HI20, 29) -ELF_RELOC(R_RISCV_TPREL_LO12_I, 30) -ELF_RELOC(R_RISCV_TPREL_LO12_S, 31) -ELF_RELOC(R_RISCV_TPREL_ADD, 32) -ELF_RELOC(R_RISCV_ADD8, 33) -ELF_RELOC(R_RISCV_ADD16, 34) -ELF_RELOC(R_RISCV_ADD32, 35) -ELF_RELOC(R_RISCV_ADD64, 36) -ELF_RELOC(R_RISCV_SUB8, 37) -ELF_RELOC(R_RISCV_SUB16, 38) -ELF_RELOC(R_RISCV_SUB32, 39) -ELF_RELOC(R_RISCV_SUB64, 40) -ELF_RELOC(R_RISCV_GNU_VTINHERIT, 41) -ELF_RELOC(R_RISCV_GNU_VTENTRY, 42) -ELF_RELOC(R_RISCV_ALIGN, 43) -ELF_RELOC(R_RISCV_RVC_BRANCH, 44) -ELF_RELOC(R_RISCV_RVC_JUMP, 45) -ELF_RELOC(R_RISCV_RVC_LUI, 46) -ELF_RELOC(R_RISCV_GPREL_I, 47) -ELF_RELOC(R_RISCV_GPREL_S, 48) diff --git a/include/llvm/Support/ELFRelocs/Sparc.def b/include/llvm/Support/ELFRelocs/Sparc.def deleted file mode 100644 index 7e01a4a8a0a06..0000000000000 --- a/include/llvm/Support/ELFRelocs/Sparc.def +++ /dev/null @@ -1,89 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -ELF_RELOC(R_SPARC_NONE, 0) -ELF_RELOC(R_SPARC_8, 1) -ELF_RELOC(R_SPARC_16, 2) -ELF_RELOC(R_SPARC_32, 3) -ELF_RELOC(R_SPARC_DISP8, 4) -ELF_RELOC(R_SPARC_DISP16, 5) -ELF_RELOC(R_SPARC_DISP32, 6) -ELF_RELOC(R_SPARC_WDISP30, 7) -ELF_RELOC(R_SPARC_WDISP22, 8) -ELF_RELOC(R_SPARC_HI22, 9) -ELF_RELOC(R_SPARC_22, 10) -ELF_RELOC(R_SPARC_13, 11) -ELF_RELOC(R_SPARC_LO10, 12) -ELF_RELOC(R_SPARC_GOT10, 13) -ELF_RELOC(R_SPARC_GOT13, 14) -ELF_RELOC(R_SPARC_GOT22, 15) -ELF_RELOC(R_SPARC_PC10, 16) -ELF_RELOC(R_SPARC_PC22, 17) -ELF_RELOC(R_SPARC_WPLT30, 18) -ELF_RELOC(R_SPARC_COPY, 19) -ELF_RELOC(R_SPARC_GLOB_DAT, 20) -ELF_RELOC(R_SPARC_JMP_SLOT, 21) -ELF_RELOC(R_SPARC_RELATIVE, 22) -ELF_RELOC(R_SPARC_UA32, 23) -ELF_RELOC(R_SPARC_PLT32, 24) -ELF_RELOC(R_SPARC_HIPLT22, 25) -ELF_RELOC(R_SPARC_LOPLT10, 26) -ELF_RELOC(R_SPARC_PCPLT32, 27) -ELF_RELOC(R_SPARC_PCPLT22, 28) -ELF_RELOC(R_SPARC_PCPLT10, 29) -ELF_RELOC(R_SPARC_10, 30) -ELF_RELOC(R_SPARC_11, 31) -ELF_RELOC(R_SPARC_64, 32) -ELF_RELOC(R_SPARC_OLO10, 33) -ELF_RELOC(R_SPARC_HH22, 34) -ELF_RELOC(R_SPARC_HM10, 35) -ELF_RELOC(R_SPARC_LM22, 36) -ELF_RELOC(R_SPARC_PC_HH22, 37) -ELF_RELOC(R_SPARC_PC_HM10, 38) -ELF_RELOC(R_SPARC_PC_LM22, 39) -ELF_RELOC(R_SPARC_WDISP16, 40) -ELF_RELOC(R_SPARC_WDISP19, 41) -ELF_RELOC(R_SPARC_7, 43) -ELF_RELOC(R_SPARC_5, 44) -ELF_RELOC(R_SPARC_6, 45) -ELF_RELOC(R_SPARC_DISP64, 46) -ELF_RELOC(R_SPARC_PLT64, 47) -ELF_RELOC(R_SPARC_HIX22, 48) -ELF_RELOC(R_SPARC_LOX10, 49) -ELF_RELOC(R_SPARC_H44, 50) -ELF_RELOC(R_SPARC_M44, 51) -ELF_RELOC(R_SPARC_L44, 52) -ELF_RELOC(R_SPARC_REGISTER, 53) -ELF_RELOC(R_SPARC_UA64, 54) -ELF_RELOC(R_SPARC_UA16, 55) -ELF_RELOC(R_SPARC_TLS_GD_HI22, 56) -ELF_RELOC(R_SPARC_TLS_GD_LO10, 57) -ELF_RELOC(R_SPARC_TLS_GD_ADD, 58) -ELF_RELOC(R_SPARC_TLS_GD_CALL, 59) -ELF_RELOC(R_SPARC_TLS_LDM_HI22, 60) -ELF_RELOC(R_SPARC_TLS_LDM_LO10, 61) -ELF_RELOC(R_SPARC_TLS_LDM_ADD, 62) -ELF_RELOC(R_SPARC_TLS_LDM_CALL, 63) -ELF_RELOC(R_SPARC_TLS_LDO_HIX22, 64) -ELF_RELOC(R_SPARC_TLS_LDO_LOX10, 65) -ELF_RELOC(R_SPARC_TLS_LDO_ADD, 66) -ELF_RELOC(R_SPARC_TLS_IE_HI22, 67) -ELF_RELOC(R_SPARC_TLS_IE_LO10, 68) -ELF_RELOC(R_SPARC_TLS_IE_LD, 69) -ELF_RELOC(R_SPARC_TLS_IE_LDX, 70) -ELF_RELOC(R_SPARC_TLS_IE_ADD, 71) -ELF_RELOC(R_SPARC_TLS_LE_HIX22, 72) -ELF_RELOC(R_SPARC_TLS_LE_LOX10, 73) -ELF_RELOC(R_SPARC_TLS_DTPMOD32, 74) -ELF_RELOC(R_SPARC_TLS_DTPMOD64, 75) -ELF_RELOC(R_SPARC_TLS_DTPOFF32, 76) -ELF_RELOC(R_SPARC_TLS_DTPOFF64, 77) -ELF_RELOC(R_SPARC_TLS_TPOFF32, 78) -ELF_RELOC(R_SPARC_TLS_TPOFF64, 79) -ELF_RELOC(R_SPARC_GOTDATA_HIX22, 80) -ELF_RELOC(R_SPARC_GOTDATA_LOX10, 81) -ELF_RELOC(R_SPARC_GOTDATA_OP_HIX22, 82) -ELF_RELOC(R_SPARC_GOTDATA_OP_LOX10, 83) -ELF_RELOC(R_SPARC_GOTDATA_OP, 84) diff --git a/include/llvm/Support/ELFRelocs/SystemZ.def b/include/llvm/Support/ELFRelocs/SystemZ.def deleted file mode 100644 index d6c0b79d40abe..0000000000000 --- a/include/llvm/Support/ELFRelocs/SystemZ.def +++ /dev/null @@ -1,71 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -ELF_RELOC(R_390_NONE, 0) -ELF_RELOC(R_390_8, 1) -ELF_RELOC(R_390_12, 2) -ELF_RELOC(R_390_16, 3) -ELF_RELOC(R_390_32, 4) -ELF_RELOC(R_390_PC32, 5) -ELF_RELOC(R_390_GOT12, 6) -ELF_RELOC(R_390_GOT32, 7) -ELF_RELOC(R_390_PLT32, 8) -ELF_RELOC(R_390_COPY, 9) -ELF_RELOC(R_390_GLOB_DAT, 10) -ELF_RELOC(R_390_JMP_SLOT, 11) -ELF_RELOC(R_390_RELATIVE, 12) -ELF_RELOC(R_390_GOTOFF, 13) -ELF_RELOC(R_390_GOTPC, 14) -ELF_RELOC(R_390_GOT16, 15) -ELF_RELOC(R_390_PC16, 16) -ELF_RELOC(R_390_PC16DBL, 17) -ELF_RELOC(R_390_PLT16DBL, 18) -ELF_RELOC(R_390_PC32DBL, 19) -ELF_RELOC(R_390_PLT32DBL, 20) -ELF_RELOC(R_390_GOTPCDBL, 21) -ELF_RELOC(R_390_64, 22) -ELF_RELOC(R_390_PC64, 23) -ELF_RELOC(R_390_GOT64, 24) -ELF_RELOC(R_390_PLT64, 25) -ELF_RELOC(R_390_GOTENT, 26) -ELF_RELOC(R_390_GOTOFF16, 27) -ELF_RELOC(R_390_GOTOFF64, 28) -ELF_RELOC(R_390_GOTPLT12, 29) -ELF_RELOC(R_390_GOTPLT16, 30) -ELF_RELOC(R_390_GOTPLT32, 31) -ELF_RELOC(R_390_GOTPLT64, 32) -ELF_RELOC(R_390_GOTPLTENT, 33) -ELF_RELOC(R_390_PLTOFF16, 34) -ELF_RELOC(R_390_PLTOFF32, 35) -ELF_RELOC(R_390_PLTOFF64, 36) -ELF_RELOC(R_390_TLS_LOAD, 37) -ELF_RELOC(R_390_TLS_GDCALL, 38) -ELF_RELOC(R_390_TLS_LDCALL, 39) -ELF_RELOC(R_390_TLS_GD32, 40) -ELF_RELOC(R_390_TLS_GD64, 41) -ELF_RELOC(R_390_TLS_GOTIE12, 42) -ELF_RELOC(R_390_TLS_GOTIE32, 43) -ELF_RELOC(R_390_TLS_GOTIE64, 44) -ELF_RELOC(R_390_TLS_LDM32, 45) -ELF_RELOC(R_390_TLS_LDM64, 46) -ELF_RELOC(R_390_TLS_IE32, 47) -ELF_RELOC(R_390_TLS_IE64, 48) -ELF_RELOC(R_390_TLS_IEENT, 49) -ELF_RELOC(R_390_TLS_LE32, 50) -ELF_RELOC(R_390_TLS_LE64, 51) -ELF_RELOC(R_390_TLS_LDO32, 52) -ELF_RELOC(R_390_TLS_LDO64, 53) -ELF_RELOC(R_390_TLS_DTPMOD, 54) -ELF_RELOC(R_390_TLS_DTPOFF, 55) -ELF_RELOC(R_390_TLS_TPOFF, 56) -ELF_RELOC(R_390_20, 57) -ELF_RELOC(R_390_GOT20, 58) -ELF_RELOC(R_390_GOTPLT20, 59) -ELF_RELOC(R_390_TLS_GOTIE20, 60) -ELF_RELOC(R_390_IRELATIVE, 61) -ELF_RELOC(R_390_PC12DBL, 62) -ELF_RELOC(R_390_PLT12DBL, 63) -ELF_RELOC(R_390_PC24DBL, 64) -ELF_RELOC(R_390_PLT24DBL, 65) diff --git a/include/llvm/Support/ELFRelocs/WebAssembly.def b/include/llvm/Support/ELFRelocs/WebAssembly.def deleted file mode 100644 index 9a34349efb969..0000000000000 --- a/include/llvm/Support/ELFRelocs/WebAssembly.def +++ /dev/null @@ -1,8 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -ELF_RELOC(R_WEBASSEMBLY_NONE, 0) -ELF_RELOC(R_WEBASSEMBLY_DATA, 1) -ELF_RELOC(R_WEBASSEMBLY_FUNCTION, 2) diff --git a/include/llvm/Support/ELFRelocs/i386.def b/include/llvm/Support/ELFRelocs/i386.def deleted file mode 100644 index 1d28cf595cd5c..0000000000000 --- a/include/llvm/Support/ELFRelocs/i386.def +++ /dev/null @@ -1,47 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -// TODO: this is just a subset -ELF_RELOC(R_386_NONE, 0) -ELF_RELOC(R_386_32, 1) -ELF_RELOC(R_386_PC32, 2) -ELF_RELOC(R_386_GOT32, 3) -ELF_RELOC(R_386_PLT32, 4) -ELF_RELOC(R_386_COPY, 5) -ELF_RELOC(R_386_GLOB_DAT, 6) -ELF_RELOC(R_386_JUMP_SLOT, 7) -ELF_RELOC(R_386_RELATIVE, 8) -ELF_RELOC(R_386_GOTOFF, 9) -ELF_RELOC(R_386_GOTPC, 10) -ELF_RELOC(R_386_32PLT, 11) -ELF_RELOC(R_386_TLS_TPOFF, 14) -ELF_RELOC(R_386_TLS_IE, 15) -ELF_RELOC(R_386_TLS_GOTIE, 16) -ELF_RELOC(R_386_TLS_LE, 17) -ELF_RELOC(R_386_TLS_GD, 18) -ELF_RELOC(R_386_TLS_LDM, 19) -ELF_RELOC(R_386_16, 20) -ELF_RELOC(R_386_PC16, 21) -ELF_RELOC(R_386_8, 22) -ELF_RELOC(R_386_PC8, 23) -ELF_RELOC(R_386_TLS_GD_32, 24) -ELF_RELOC(R_386_TLS_GD_PUSH, 25) -ELF_RELOC(R_386_TLS_GD_CALL, 26) -ELF_RELOC(R_386_TLS_GD_POP, 27) -ELF_RELOC(R_386_TLS_LDM_32, 28) -ELF_RELOC(R_386_TLS_LDM_PUSH, 29) -ELF_RELOC(R_386_TLS_LDM_CALL, 30) -ELF_RELOC(R_386_TLS_LDM_POP, 31) -ELF_RELOC(R_386_TLS_LDO_32, 32) -ELF_RELOC(R_386_TLS_IE_32, 33) -ELF_RELOC(R_386_TLS_LE_32, 34) -ELF_RELOC(R_386_TLS_DTPMOD32, 35) -ELF_RELOC(R_386_TLS_DTPOFF32, 36) -ELF_RELOC(R_386_TLS_TPOFF32, 37) -ELF_RELOC(R_386_TLS_GOTDESC, 39) -ELF_RELOC(R_386_TLS_DESC_CALL, 40) -ELF_RELOC(R_386_TLS_DESC, 41) -ELF_RELOC(R_386_IRELATIVE, 42) -ELF_RELOC(R_386_GOT32X, 43) diff --git a/include/llvm/Support/ELFRelocs/x86_64.def b/include/llvm/Support/ELFRelocs/x86_64.def deleted file mode 100644 index 18fdcf9472dc4..0000000000000 --- a/include/llvm/Support/ELFRelocs/x86_64.def +++ /dev/null @@ -1,45 +0,0 @@ - -#ifndef ELF_RELOC -#error "ELF_RELOC must be defined" -#endif - -ELF_RELOC(R_X86_64_NONE, 0) -ELF_RELOC(R_X86_64_64, 1) -ELF_RELOC(R_X86_64_PC32, 2) -ELF_RELOC(R_X86_64_GOT32, 3) -ELF_RELOC(R_X86_64_PLT32, 4) -ELF_RELOC(R_X86_64_COPY, 5) -ELF_RELOC(R_X86_64_GLOB_DAT, 6) -ELF_RELOC(R_X86_64_JUMP_SLOT, 7) -ELF_RELOC(R_X86_64_RELATIVE, 8) -ELF_RELOC(R_X86_64_GOTPCREL, 9) -ELF_RELOC(R_X86_64_32, 10) -ELF_RELOC(R_X86_64_32S, 11) -ELF_RELOC(R_X86_64_16, 12) -ELF_RELOC(R_X86_64_PC16, 13) -ELF_RELOC(R_X86_64_8, 14) -ELF_RELOC(R_X86_64_PC8, 15) -ELF_RELOC(R_X86_64_DTPMOD64, 16) -ELF_RELOC(R_X86_64_DTPOFF64, 17) -ELF_RELOC(R_X86_64_TPOFF64, 18) -ELF_RELOC(R_X86_64_TLSGD, 19) -ELF_RELOC(R_X86_64_TLSLD, 20) -ELF_RELOC(R_X86_64_DTPOFF32, 21) -ELF_RELOC(R_X86_64_GOTTPOFF, 22) -ELF_RELOC(R_X86_64_TPOFF32, 23) -ELF_RELOC(R_X86_64_PC64, 24) -ELF_RELOC(R_X86_64_GOTOFF64, 25) -ELF_RELOC(R_X86_64_GOTPC32, 26) -ELF_RELOC(R_X86_64_GOT64, 27) -ELF_RELOC(R_X86_64_GOTPCREL64, 28) -ELF_RELOC(R_X86_64_GOTPC64, 29) -ELF_RELOC(R_X86_64_GOTPLT64, 30) -ELF_RELOC(R_X86_64_PLTOFF64, 31) -ELF_RELOC(R_X86_64_SIZE32, 32) -ELF_RELOC(R_X86_64_SIZE64, 33) -ELF_RELOC(R_X86_64_GOTPC32_TLSDESC, 34) -ELF_RELOC(R_X86_64_TLSDESC_CALL, 35) -ELF_RELOC(R_X86_64_TLSDESC, 36) -ELF_RELOC(R_X86_64_IRELATIVE, 37) -ELF_RELOC(R_X86_64_GOTPCRELX, 41) -ELF_RELOC(R_X86_64_REX_GOTPCRELX, 42) diff --git a/include/llvm/Support/Endian.h b/include/llvm/Support/Endian.h index 06e089ffa166f..f50d9b502dafb 100644 --- a/include/llvm/Support/Endian.h +++ b/include/llvm/Support/Endian.h @@ -14,27 +14,36 @@ #ifndef LLVM_SUPPORT_ENDIAN_H #define LLVM_SUPPORT_ENDIAN_H +#include "llvm/Support/AlignOf.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Host.h" #include "llvm/Support/SwapByteOrder.h" - -#include <stdint.h> +#include <cassert> +#include <cstddef> +#include <cstdint> +#include <cstring> +#include <type_traits> namespace llvm { namespace support { + enum endianness {big, little, native}; // These are named values for common alignments. enum {aligned = 0, unaligned = 1}; namespace detail { - /// \brief ::value is either alignment, or alignof(T) if alignment is 0. - template<class T, int alignment> - struct PickAlignment { - enum { value = alignment == 0 ? alignof(T) : alignment }; - }; + +/// \brief ::value is either alignment, or alignof(T) if alignment is 0. +template<class T, int alignment> +struct PickAlignment { + enum { value = alignment == 0 ? alignof(T) : alignment }; +}; + } // end namespace detail namespace endian { + constexpr endianness system_endianness() { return sys::IsBigEndianHost ? big : little; } @@ -190,9 +199,11 @@ inline void writeAtBitAlignment(void *memory, value_type value, &val[0], sizeof(value_type) * 2); } } + } // end namespace endian namespace detail { + template<typename value_type, endianness endian, std::size_t alignment> @@ -254,77 +265,78 @@ public: } // end namespace detail -typedef detail::packed_endian_specific_integral - <uint16_t, little, unaligned> ulittle16_t; -typedef detail::packed_endian_specific_integral - <uint32_t, little, unaligned> ulittle32_t; -typedef detail::packed_endian_specific_integral - <uint64_t, little, unaligned> ulittle64_t; - -typedef detail::packed_endian_specific_integral - <int16_t, little, unaligned> little16_t; -typedef detail::packed_endian_specific_integral - <int32_t, little, unaligned> little32_t; -typedef detail::packed_endian_specific_integral - <int64_t, little, unaligned> little64_t; - -typedef detail::packed_endian_specific_integral - <uint16_t, little, aligned> aligned_ulittle16_t; -typedef detail::packed_endian_specific_integral - <uint32_t, little, aligned> aligned_ulittle32_t; -typedef detail::packed_endian_specific_integral - <uint64_t, little, aligned> aligned_ulittle64_t; - -typedef detail::packed_endian_specific_integral - <int16_t, little, aligned> aligned_little16_t; -typedef detail::packed_endian_specific_integral - <int32_t, little, aligned> aligned_little32_t; -typedef detail::packed_endian_specific_integral - <int64_t, little, aligned> aligned_little64_t; - -typedef detail::packed_endian_specific_integral - <uint16_t, big, unaligned> ubig16_t; -typedef detail::packed_endian_specific_integral - <uint32_t, big, unaligned> ubig32_t; -typedef detail::packed_endian_specific_integral - <uint64_t, big, unaligned> ubig64_t; - -typedef detail::packed_endian_specific_integral - <int16_t, big, unaligned> big16_t; -typedef detail::packed_endian_specific_integral - <int32_t, big, unaligned> big32_t; -typedef detail::packed_endian_specific_integral - <int64_t, big, unaligned> big64_t; - -typedef detail::packed_endian_specific_integral - <uint16_t, big, aligned> aligned_ubig16_t; -typedef detail::packed_endian_specific_integral - <uint32_t, big, aligned> aligned_ubig32_t; -typedef detail::packed_endian_specific_integral - <uint64_t, big, aligned> aligned_ubig64_t; - -typedef detail::packed_endian_specific_integral - <int16_t, big, aligned> aligned_big16_t; -typedef detail::packed_endian_specific_integral - <int32_t, big, aligned> aligned_big32_t; -typedef detail::packed_endian_specific_integral - <int64_t, big, aligned> aligned_big64_t; - -typedef detail::packed_endian_specific_integral - <uint16_t, native, unaligned> unaligned_uint16_t; -typedef detail::packed_endian_specific_integral - <uint32_t, native, unaligned> unaligned_uint32_t; -typedef detail::packed_endian_specific_integral - <uint64_t, native, unaligned> unaligned_uint64_t; - -typedef detail::packed_endian_specific_integral - <int16_t, native, unaligned> unaligned_int16_t; -typedef detail::packed_endian_specific_integral - <int32_t, native, unaligned> unaligned_int32_t; -typedef detail::packed_endian_specific_integral - <int64_t, native, unaligned> unaligned_int64_t; +using ulittle16_t = + detail::packed_endian_specific_integral<uint16_t, little, unaligned>; +using ulittle32_t = + detail::packed_endian_specific_integral<uint32_t, little, unaligned>; +using ulittle64_t = + detail::packed_endian_specific_integral<uint64_t, little, unaligned>; + +using little16_t = + detail::packed_endian_specific_integral<int16_t, little, unaligned>; +using little32_t = + detail::packed_endian_specific_integral<int32_t, little, unaligned>; +using little64_t = + detail::packed_endian_specific_integral<int64_t, little, unaligned>; + +using aligned_ulittle16_t = + detail::packed_endian_specific_integral<uint16_t, little, aligned>; +using aligned_ulittle32_t = + detail::packed_endian_specific_integral<uint32_t, little, aligned>; +using aligned_ulittle64_t = + detail::packed_endian_specific_integral<uint64_t, little, aligned>; + +using aligned_little16_t = + detail::packed_endian_specific_integral<int16_t, little, aligned>; +using aligned_little32_t = + detail::packed_endian_specific_integral<int32_t, little, aligned>; +using aligned_little64_t = + detail::packed_endian_specific_integral<int64_t, little, aligned>; + +using ubig16_t = + detail::packed_endian_specific_integral<uint16_t, big, unaligned>; +using ubig32_t = + detail::packed_endian_specific_integral<uint32_t, big, unaligned>; +using ubig64_t = + detail::packed_endian_specific_integral<uint64_t, big, unaligned>; + +using big16_t = + detail::packed_endian_specific_integral<int16_t, big, unaligned>; +using big32_t = + detail::packed_endian_specific_integral<int32_t, big, unaligned>; +using big64_t = + detail::packed_endian_specific_integral<int64_t, big, unaligned>; + +using aligned_ubig16_t = + detail::packed_endian_specific_integral<uint16_t, big, aligned>; +using aligned_ubig32_t = + detail::packed_endian_specific_integral<uint32_t, big, aligned>; +using aligned_ubig64_t = + detail::packed_endian_specific_integral<uint64_t, big, aligned>; + +using aligned_big16_t = + detail::packed_endian_specific_integral<int16_t, big, aligned>; +using aligned_big32_t = + detail::packed_endian_specific_integral<int32_t, big, aligned>; +using aligned_big64_t = + detail::packed_endian_specific_integral<int64_t, big, aligned>; + +using unaligned_uint16_t = + detail::packed_endian_specific_integral<uint16_t, native, unaligned>; +using unaligned_uint32_t = + detail::packed_endian_specific_integral<uint32_t, native, unaligned>; +using unaligned_uint64_t = + detail::packed_endian_specific_integral<uint64_t, native, unaligned>; + +using unaligned_int16_t = + detail::packed_endian_specific_integral<int16_t, native, unaligned>; +using unaligned_int32_t = + detail::packed_endian_specific_integral<int32_t, native, unaligned>; +using unaligned_int64_t = + detail::packed_endian_specific_integral<int64_t, native, unaligned>; namespace endian { + template <typename T> inline T read(const void *P, endianness E) { return read<T, unaligned>(P, E); } @@ -394,8 +406,10 @@ inline void write64le(void *P, uint64_t V) { write64<little>(P, V); } inline void write16be(void *P, uint16_t V) { write16<big>(P, V); } inline void write32be(void *P, uint32_t V) { write32<big>(P, V); } inline void write64be(void *P, uint64_t V) { write64<big>(P, V); } + } // end namespace endian + } // end namespace support } // end namespace llvm -#endif +#endif // LLVM_SUPPORT_ENDIAN_H diff --git a/include/llvm/Support/Error.h b/include/llvm/Support/Error.h index a3482f5a58b53..1e27e0b821f05 100644 --- a/include/llvm/Support/Error.h +++ b/include/llvm/Support/Error.h @@ -1,4 +1,4 @@ -//===----- llvm/Support/Error.h - Recoverable error handling ----*- C++ -*-===// +//===- llvm/Support/Error.h - Recoverable error handling --------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -22,6 +22,7 @@ #include "llvm/Support/AlignOf.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> @@ -167,7 +168,7 @@ class LLVM_NODISCARD Error { protected: /// Create a success value. Prefer using 'Error::success()' for readability - Error() : Payload(nullptr) { + Error() { setPtr(nullptr); setChecked(false); } @@ -182,7 +183,7 @@ public: /// Move-construct an error value. The newly constructed error is considered /// unchecked, even if the source error had been checked. The original error /// becomes a checked Success value, regardless of its original state. - Error(Error &&Other) : Payload(nullptr) { + Error(Error &&Other) { setChecked(true); *this = std::move(Other); } @@ -299,7 +300,7 @@ private: return Tmp; } - ErrorInfoBase *Payload; + ErrorInfoBase *Payload = nullptr; }; /// Subclass of Error for the sole purpose of identifying the success path in @@ -327,7 +328,6 @@ template <typename ErrT, typename... ArgTs> Error make_error(ArgTs &&... Args) { template <typename ThisErrT, typename ParentErrT = ErrorInfoBase> class ErrorInfo : public ParentErrT { public: - static const void *classID() { return &ThisErrT::ID; } const void *dynamicClassID() const override { return &ThisErrT::ID; } @@ -645,20 +645,22 @@ private: template <class T> class LLVM_NODISCARD Expected { template <class T1> friend class ExpectedAsOutParameter; template <class OtherT> friend class Expected; + static const bool isRef = std::is_reference<T>::value; - typedef ReferenceStorage<typename std::remove_reference<T>::type> wrap; - typedef std::unique_ptr<ErrorInfoBase> error_type; + using wrap = ReferenceStorage<typename std::remove_reference<T>::type>; + + using error_type = std::unique_ptr<ErrorInfoBase>; public: - typedef typename std::conditional<isRef, wrap, T>::type storage_type; - typedef T value_type; + using storage_type = typename std::conditional<isRef, wrap, T>::type; + using value_type = T; private: - typedef typename std::remove_reference<T>::type &reference; - typedef const typename std::remove_reference<T>::type &const_reference; - typedef typename std::remove_reference<T>::type *pointer; - typedef const typename std::remove_reference<T>::type *const_pointer; + using reference = typename std::remove_reference<T>::type &; + using const_reference = const typename std::remove_reference<T>::type &; + using pointer = typename std::remove_reference<T>::type *; + using const_pointer = const typename std::remove_reference<T>::type *; public: /// Create an Expected<T> error value from the given Error. @@ -891,7 +893,6 @@ private: template <typename T> class ExpectedAsOutParameter { public: - ExpectedAsOutParameter(Expected<T> *ValOrErr) : ValOrErr(ValOrErr) { if (ValOrErr) diff --git a/include/llvm/Support/ErrorOr.h b/include/llvm/Support/ErrorOr.h index 877f4063cd232..061fb65db465c 100644 --- a/include/llvm/Support/ErrorOr.h +++ b/include/llvm/Support/ErrorOr.h @@ -16,13 +16,14 @@ #ifndef LLVM_SUPPORT_ERROROR_H #define LLVM_SUPPORT_ERROROR_H -#include "llvm/ADT/PointerIntPair.h" #include "llvm/Support/AlignOf.h" #include <cassert> #include <system_error> #include <type_traits> +#include <utility> namespace llvm { + /// \brief Stores a reference that can be changed. template <typename T> class ReferenceStorage { @@ -67,17 +68,19 @@ public: template<class T> class ErrorOr { template <class OtherT> friend class ErrorOr; + static const bool isRef = std::is_reference<T>::value; - typedef ReferenceStorage<typename std::remove_reference<T>::type> wrap; + + using wrap = ReferenceStorage<typename std::remove_reference<T>::type>; public: - typedef typename std::conditional<isRef, wrap, T>::type storage_type; + using storage_type = typename std::conditional<isRef, wrap, T>::type; private: - typedef typename std::remove_reference<T>::type &reference; - typedef const typename std::remove_reference<T>::type &const_reference; - typedef typename std::remove_reference<T>::type *pointer; - typedef const typename std::remove_reference<T>::type *const_pointer; + using reference = typename std::remove_reference<T>::type &; + using const_reference = const typename std::remove_reference<T>::type &; + using pointer = typename std::remove_reference<T>::type *; + using const_pointer = const typename std::remove_reference<T>::type *; public: template <class E> @@ -282,6 +285,7 @@ typename std::enable_if<std::is_error_code_enum<E>::value || operator==(const ErrorOr<T> &Err, E Code) { return Err.getError() == Code; } + } // end namespace llvm #endif // LLVM_SUPPORT_ERROROR_H diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index 7caefb5359b87..21c5fcdb71450 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -233,50 +233,6 @@ public: void permissions(perms p) { Perms = p; } }; -/// file_magic - An "enum class" enumeration of file types based on magic (the first -/// N bytes of the file). -struct file_magic { - enum Impl { - unknown = 0, ///< Unrecognized file - bitcode, ///< Bitcode file - archive, ///< ar style archive file - elf, ///< ELF Unknown type - elf_relocatable, ///< ELF Relocatable object file - elf_executable, ///< ELF Executable image - elf_shared_object, ///< ELF dynamically linked shared lib - elf_core, ///< ELF core image - macho_object, ///< Mach-O Object file - macho_executable, ///< Mach-O Executable - macho_fixed_virtual_memory_shared_lib, ///< Mach-O Shared Lib, FVM - macho_core, ///< Mach-O Core File - macho_preload_executable, ///< Mach-O Preloaded Executable - macho_dynamically_linked_shared_lib, ///< Mach-O dynlinked shared lib - macho_dynamic_linker, ///< The Mach-O dynamic linker - macho_bundle, ///< Mach-O Bundle file - macho_dynamically_linked_shared_lib_stub, ///< Mach-O Shared lib stub - macho_dsym_companion, ///< Mach-O dSYM companion file - macho_kext_bundle, ///< Mach-O kext bundle file - macho_universal_binary, ///< Mach-O universal binary - coff_cl_gl_object, ///< Microsoft cl.exe's intermediate code file - coff_object, ///< COFF object file - coff_import_library, ///< COFF import library - pecoff_executable, ///< PECOFF executable file - windows_resource, ///< Windows compiled resource file (.res) - wasm_object ///< WebAssembly Object file - }; - - bool is_object() const { - return V != unknown; - } - - file_magic() = default; - file_magic(Impl V) : V(V) {} - operator Impl() const { return V; } - -private: - Impl V = unknown; -}; - /// @} /// @name Physical Operators /// @{ @@ -770,17 +726,6 @@ std::error_code openFileForWrite(const Twine &Name, int &ResultFD, std::error_code openFileForRead(const Twine &Name, int &ResultFD, SmallVectorImpl<char> *RealPath = nullptr); -/// @brief Identify the type of a binary file based on how magical it is. -file_magic identify_magic(StringRef magic); - -/// @brief Get and identify \a path's type based on its content. -/// -/// @param path Input path. -/// @param result Set to the type of file, or file_magic::unknown. -/// @returns errc::success if result has been successfully set, otherwise a -/// platform-specific error_code. -std::error_code identify_magic(const Twine &path, file_magic &result); - std::error_code getUniqueID(const Twine Path, UniqueID &Result); /// @brief Get disk space usage information. diff --git a/include/llvm/Support/FormatVariadic.h b/include/llvm/Support/FormatVariadic.h index 3a4668687cc94..c1153e84dfb56 100644 --- a/include/llvm/Support/FormatVariadic.h +++ b/include/llvm/Support/FormatVariadic.h @@ -27,8 +27,8 @@ #define LLVM_SUPPORT_FORMATVARIADIC_H #include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallString.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/FormatCommon.h" #include "llvm/Support/FormatProviders.h" diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index 73fddca8e35bb..268c53c50252f 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -16,12 +16,12 @@ #define LLVM_SUPPORT_GCOV_H #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/iterator.h" -#include "llvm/ADT/iterator_range.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/iterator.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" #include <cassert> diff --git a/include/llvm/Support/GenericDomTree.h b/include/llvm/Support/GenericDomTree.h index 851ff7d80403f..80a2dfcbad889 100644 --- a/include/llvm/Support/GenericDomTree.h +++ b/include/llvm/Support/GenericDomTree.h @@ -26,9 +26,9 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> #include <cassert> diff --git a/include/llvm/Support/LowLevelTypeImpl.h b/include/llvm/Support/LowLevelTypeImpl.h index e18e58b7b5b23..c79dd0c295079 100644 --- a/include/llvm/Support/LowLevelTypeImpl.h +++ b/include/llvm/Support/LowLevelTypeImpl.h @@ -27,9 +27,9 @@ #ifndef LLVM_SUPPORT_LOWLEVELTYPEIMPL_H #define LLVM_SUPPORT_LOWLEVELTYPEIMPL_H -#include <cassert> #include "llvm/ADT/DenseMapInfo.h" #include "llvm/CodeGen/MachineValueType.h" +#include <cassert> namespace llvm { diff --git a/include/llvm/Support/MachO.def b/include/llvm/Support/MachO.def deleted file mode 100644 index 95de48d2b19eb..0000000000000 --- a/include/llvm/Support/MachO.def +++ /dev/null @@ -1,120 +0,0 @@ -//,,,-- llvm/Support/MachO.def - The MachO file definitions -----*- C++ -*-,,,// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//,,,----------------------------------------------------------------------,,,// -// -// Definitions for MachO files -// -//,,,----------------------------------------------------------------------,,,// - -#ifdef HANDLE_LOAD_COMMAND - -HANDLE_LOAD_COMMAND(LC_SEGMENT, 0x00000001u, segment_command) -HANDLE_LOAD_COMMAND(LC_SYMTAB, 0x00000002u, symtab_command) -// LC_SYMSEG is obsolete and no longer supported. -HANDLE_LOAD_COMMAND(LC_SYMSEG, 0x00000003u, symseg_command) -HANDLE_LOAD_COMMAND(LC_THREAD, 0x00000004u, thread_command) -HANDLE_LOAD_COMMAND(LC_UNIXTHREAD, 0x00000005u, thread_command) -// LC_LOADFVMLIB is obsolete and no longer supported. -HANDLE_LOAD_COMMAND(LC_LOADFVMLIB, 0x00000006u, fvmlib_command) -// LC_IDFVMLIB is obsolete and no longer supported. -HANDLE_LOAD_COMMAND(LC_IDFVMLIB, 0x00000007u, fvmlib_command) -// LC_IDENT is obsolete and no longer supported. -HANDLE_LOAD_COMMAND(LC_IDENT, 0x00000008u, ident_command) -// LC_FVMFILE is obsolete and no longer supported. -HANDLE_LOAD_COMMAND(LC_FVMFILE, 0x00000009u, fvmfile_command) -// LC_PREPAGE is obsolete and no longer supported. -HANDLE_LOAD_COMMAND(LC_PREPAGE, 0x0000000Au, load_command) -HANDLE_LOAD_COMMAND(LC_DYSYMTAB, 0x0000000Bu, dysymtab_command) -HANDLE_LOAD_COMMAND(LC_LOAD_DYLIB, 0x0000000Cu, dylib_command) -HANDLE_LOAD_COMMAND(LC_ID_DYLIB, 0x0000000Du, dylib_command) -HANDLE_LOAD_COMMAND(LC_LOAD_DYLINKER, 0x0000000Eu, dylinker_command) -HANDLE_LOAD_COMMAND(LC_ID_DYLINKER, 0x0000000Fu, dylinker_command) -// LC_PREBOUND_DYLIB is obsolete and no longer supported. -HANDLE_LOAD_COMMAND(LC_PREBOUND_DYLIB, 0x00000010u, prebound_dylib_command) -HANDLE_LOAD_COMMAND(LC_ROUTINES, 0x00000011u, routines_command) -HANDLE_LOAD_COMMAND(LC_SUB_FRAMEWORK, 0x00000012u, sub_framework_command) -HANDLE_LOAD_COMMAND(LC_SUB_UMBRELLA, 0x00000013u, sub_umbrella_command) -HANDLE_LOAD_COMMAND(LC_SUB_CLIENT, 0x00000014u, sub_client_command) -HANDLE_LOAD_COMMAND(LC_SUB_LIBRARY, 0x00000015u, sub_library_command) -// LC_TWOLEVEL_HINTS is obsolete and no longer supported. -HANDLE_LOAD_COMMAND(LC_TWOLEVEL_HINTS, 0x00000016u, twolevel_hints_command) -// LC_PREBIND_CKSUM is obsolete and no longer supported. -HANDLE_LOAD_COMMAND(LC_PREBIND_CKSUM, 0x00000017u, prebind_cksum_command) -// LC_LOAD_WEAK_DYLIB is obsolete and no longer supported. -HANDLE_LOAD_COMMAND(LC_LOAD_WEAK_DYLIB, 0x80000018u, dylib_command) -HANDLE_LOAD_COMMAND(LC_SEGMENT_64, 0x00000019u, segment_command_64) -HANDLE_LOAD_COMMAND(LC_ROUTINES_64, 0x0000001Au, routines_command_64) -HANDLE_LOAD_COMMAND(LC_UUID, 0x0000001Bu, uuid_command) -HANDLE_LOAD_COMMAND(LC_RPATH, 0x8000001Cu, rpath_command) -HANDLE_LOAD_COMMAND(LC_CODE_SIGNATURE, 0x0000001Du, linkedit_data_command) -HANDLE_LOAD_COMMAND(LC_SEGMENT_SPLIT_INFO, 0x0000001Eu, linkedit_data_command) -HANDLE_LOAD_COMMAND(LC_REEXPORT_DYLIB, 0x8000001Fu, dylib_command) -HANDLE_LOAD_COMMAND(LC_LAZY_LOAD_DYLIB, 0x00000020u, dylib_command) -HANDLE_LOAD_COMMAND(LC_ENCRYPTION_INFO, 0x00000021u, encryption_info_command) -HANDLE_LOAD_COMMAND(LC_DYLD_INFO, 0x00000022u, dyld_info_command) -HANDLE_LOAD_COMMAND(LC_DYLD_INFO_ONLY, 0x80000022u, dyld_info_command) -HANDLE_LOAD_COMMAND(LC_LOAD_UPWARD_DYLIB, 0x80000023u, dylib_command) -HANDLE_LOAD_COMMAND(LC_VERSION_MIN_MACOSX, 0x00000024u, version_min_command) -HANDLE_LOAD_COMMAND(LC_VERSION_MIN_IPHONEOS, 0x00000025u, version_min_command) -HANDLE_LOAD_COMMAND(LC_FUNCTION_STARTS, 0x00000026u, linkedit_data_command) -HANDLE_LOAD_COMMAND(LC_DYLD_ENVIRONMENT, 0x00000027u, dylinker_command) -HANDLE_LOAD_COMMAND(LC_MAIN, 0x80000028u, entry_point_command) -HANDLE_LOAD_COMMAND(LC_DATA_IN_CODE, 0x00000029u, linkedit_data_command) -HANDLE_LOAD_COMMAND(LC_SOURCE_VERSION, 0x0000002Au, source_version_command) -HANDLE_LOAD_COMMAND(LC_DYLIB_CODE_SIGN_DRS, 0x0000002Bu, linkedit_data_command) -HANDLE_LOAD_COMMAND(LC_ENCRYPTION_INFO_64, 0x0000002Cu, - encryption_info_command_64) -HANDLE_LOAD_COMMAND(LC_LINKER_OPTION, 0x0000002Du, linker_option_command) -HANDLE_LOAD_COMMAND(LC_LINKER_OPTIMIZATION_HINT, 0x0000002Eu, linkedit_data_command) -HANDLE_LOAD_COMMAND(LC_VERSION_MIN_TVOS, 0x0000002Fu, version_min_command) -HANDLE_LOAD_COMMAND(LC_VERSION_MIN_WATCHOS, 0x00000030u, version_min_command) -HANDLE_LOAD_COMMAND(LC_NOTE, 0x00000031u, note_command) -HANDLE_LOAD_COMMAND(LC_BUILD_VERSION, 0x00000032u, build_version_command) - -#endif - -#ifdef LOAD_COMMAND_STRUCT - -LOAD_COMMAND_STRUCT(dyld_info_command) -LOAD_COMMAND_STRUCT(dylib_command) -LOAD_COMMAND_STRUCT(dylinker_command) -LOAD_COMMAND_STRUCT(dysymtab_command) -LOAD_COMMAND_STRUCT(encryption_info_command) -LOAD_COMMAND_STRUCT(encryption_info_command_64) -LOAD_COMMAND_STRUCT(entry_point_command) -LOAD_COMMAND_STRUCT(fvmfile_command) -LOAD_COMMAND_STRUCT(fvmlib_command) -LOAD_COMMAND_STRUCT(ident_command) -LOAD_COMMAND_STRUCT(linkedit_data_command) -LOAD_COMMAND_STRUCT(linker_option_command) -LOAD_COMMAND_STRUCT(load_command) -LOAD_COMMAND_STRUCT(prebind_cksum_command) -LOAD_COMMAND_STRUCT(prebound_dylib_command) -LOAD_COMMAND_STRUCT(routines_command) -LOAD_COMMAND_STRUCT(routines_command_64) -LOAD_COMMAND_STRUCT(rpath_command) -LOAD_COMMAND_STRUCT(segment_command) -LOAD_COMMAND_STRUCT(segment_command_64) -LOAD_COMMAND_STRUCT(source_version_command) -LOAD_COMMAND_STRUCT(sub_client_command) -LOAD_COMMAND_STRUCT(sub_framework_command) -LOAD_COMMAND_STRUCT(sub_library_command) -LOAD_COMMAND_STRUCT(sub_umbrella_command) -LOAD_COMMAND_STRUCT(symseg_command) -LOAD_COMMAND_STRUCT(symtab_command) -LOAD_COMMAND_STRUCT(thread_command) -LOAD_COMMAND_STRUCT(twolevel_hints_command) -LOAD_COMMAND_STRUCT(uuid_command) -LOAD_COMMAND_STRUCT(version_min_command) -LOAD_COMMAND_STRUCT(note_command) -LOAD_COMMAND_STRUCT(build_version_command) - -#endif - -#undef HANDLE_LOAD_COMMAND -#undef LOAD_COMMAND_STRUCT diff --git a/include/llvm/Support/MachO.h b/include/llvm/Support/MachO.h deleted file mode 100644 index 3d704292c260a..0000000000000 --- a/include/llvm/Support/MachO.h +++ /dev/null @@ -1,2038 +0,0 @@ -//===-- llvm/Support/MachO.h - The MachO file format ------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines manifest constants for the MachO object file format. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_MACHO_H -#define LLVM_SUPPORT_MACHO_H - -#include "llvm/Support/Compiler.h" -#include "llvm/Support/DataTypes.h" -#include "llvm/Support/Host.h" - -namespace llvm { - namespace MachO { - // Enums from <mach-o/loader.h> - enum : uint32_t { - // Constants for the "magic" field in llvm::MachO::mach_header and - // llvm::MachO::mach_header_64 - MH_MAGIC = 0xFEEDFACEu, - MH_CIGAM = 0xCEFAEDFEu, - MH_MAGIC_64 = 0xFEEDFACFu, - MH_CIGAM_64 = 0xCFFAEDFEu, - FAT_MAGIC = 0xCAFEBABEu, - FAT_CIGAM = 0xBEBAFECAu, - FAT_MAGIC_64 = 0xCAFEBABFu, - FAT_CIGAM_64 = 0xBFBAFECAu - }; - - enum HeaderFileType { - // Constants for the "filetype" field in llvm::MachO::mach_header and - // llvm::MachO::mach_header_64 - MH_OBJECT = 0x1u, - MH_EXECUTE = 0x2u, - MH_FVMLIB = 0x3u, - MH_CORE = 0x4u, - MH_PRELOAD = 0x5u, - MH_DYLIB = 0x6u, - MH_DYLINKER = 0x7u, - MH_BUNDLE = 0x8u, - MH_DYLIB_STUB = 0x9u, - MH_DSYM = 0xAu, - MH_KEXT_BUNDLE = 0xBu - }; - - enum { - // Constant bits for the "flags" field in llvm::MachO::mach_header and - // llvm::MachO::mach_header_64 - MH_NOUNDEFS = 0x00000001u, - MH_INCRLINK = 0x00000002u, - MH_DYLDLINK = 0x00000004u, - MH_BINDATLOAD = 0x00000008u, - MH_PREBOUND = 0x00000010u, - MH_SPLIT_SEGS = 0x00000020u, - MH_LAZY_INIT = 0x00000040u, - MH_TWOLEVEL = 0x00000080u, - MH_FORCE_FLAT = 0x00000100u, - MH_NOMULTIDEFS = 0x00000200u, - MH_NOFIXPREBINDING = 0x00000400u, - MH_PREBINDABLE = 0x00000800u, - MH_ALLMODSBOUND = 0x00001000u, - MH_SUBSECTIONS_VIA_SYMBOLS = 0x00002000u, - MH_CANONICAL = 0x00004000u, - MH_WEAK_DEFINES = 0x00008000u, - MH_BINDS_TO_WEAK = 0x00010000u, - MH_ALLOW_STACK_EXECUTION = 0x00020000u, - MH_ROOT_SAFE = 0x00040000u, - MH_SETUID_SAFE = 0x00080000u, - MH_NO_REEXPORTED_DYLIBS = 0x00100000u, - MH_PIE = 0x00200000u, - MH_DEAD_STRIPPABLE_DYLIB = 0x00400000u, - MH_HAS_TLV_DESCRIPTORS = 0x00800000u, - MH_NO_HEAP_EXECUTION = 0x01000000u, - MH_APP_EXTENSION_SAFE = 0x02000000u - }; - - enum : uint32_t { - // Flags for the "cmd" field in llvm::MachO::load_command - LC_REQ_DYLD = 0x80000000u - }; - -#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \ - LCName = LCValue, - - enum LoadCommandType : uint32_t { - #include "llvm/Support/MachO.def" - }; - -#undef HANDLE_LOAD_COMMAND - - enum : uint32_t { - // Constant bits for the "flags" field in llvm::MachO::segment_command - SG_HIGHVM = 0x1u, - SG_FVMLIB = 0x2u, - SG_NORELOC = 0x4u, - SG_PROTECTED_VERSION_1 = 0x8u, - - // Constant masks for the "flags" field in llvm::MachO::section and - // llvm::MachO::section_64 - SECTION_TYPE = 0x000000ffu, // SECTION_TYPE - SECTION_ATTRIBUTES = 0xffffff00u, // SECTION_ATTRIBUTES - SECTION_ATTRIBUTES_USR = 0xff000000u, // SECTION_ATTRIBUTES_USR - SECTION_ATTRIBUTES_SYS = 0x00ffff00u // SECTION_ATTRIBUTES_SYS - }; - - /// These are the section type and attributes fields. A MachO section can - /// have only one Type, but can have any of the attributes specified. - enum SectionType : uint32_t { - // Constant masks for the "flags[7:0]" field in llvm::MachO::section and - // llvm::MachO::section_64 (mask "flags" with SECTION_TYPE) - - /// S_REGULAR - Regular section. - S_REGULAR = 0x00u, - /// S_ZEROFILL - Zero fill on demand section. - S_ZEROFILL = 0x01u, - /// S_CSTRING_LITERALS - Section with literal C strings. - S_CSTRING_LITERALS = 0x02u, - /// S_4BYTE_LITERALS - Section with 4 byte literals. - S_4BYTE_LITERALS = 0x03u, - /// S_8BYTE_LITERALS - Section with 8 byte literals. - S_8BYTE_LITERALS = 0x04u, - /// S_LITERAL_POINTERS - Section with pointers to literals. - S_LITERAL_POINTERS = 0x05u, - /// S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers. - S_NON_LAZY_SYMBOL_POINTERS = 0x06u, - /// S_LAZY_SYMBOL_POINTERS - Section with lazy symbol pointers. - S_LAZY_SYMBOL_POINTERS = 0x07u, - /// S_SYMBOL_STUBS - Section with symbol stubs, byte size of stub in - /// the Reserved2 field. - S_SYMBOL_STUBS = 0x08u, - /// S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for - /// initialization. - S_MOD_INIT_FUNC_POINTERS = 0x09u, - /// S_MOD_TERM_FUNC_POINTERS - Section with only function pointers for - /// termination. - S_MOD_TERM_FUNC_POINTERS = 0x0au, - /// S_COALESCED - Section contains symbols that are to be coalesced. - S_COALESCED = 0x0bu, - /// S_GB_ZEROFILL - Zero fill on demand section (that can be larger than 4 - /// gigabytes). - S_GB_ZEROFILL = 0x0cu, - /// S_INTERPOSING - Section with only pairs of function pointers for - /// interposing. - S_INTERPOSING = 0x0du, - /// S_16BYTE_LITERALS - Section with only 16 byte literals. - S_16BYTE_LITERALS = 0x0eu, - /// S_DTRACE_DOF - Section contains DTrace Object Format. - S_DTRACE_DOF = 0x0fu, - /// S_LAZY_DYLIB_SYMBOL_POINTERS - Section with lazy symbol pointers to - /// lazy loaded dylibs. - S_LAZY_DYLIB_SYMBOL_POINTERS = 0x10u, - /// S_THREAD_LOCAL_REGULAR - Thread local data section. - S_THREAD_LOCAL_REGULAR = 0x11u, - /// S_THREAD_LOCAL_ZEROFILL - Thread local zerofill section. - S_THREAD_LOCAL_ZEROFILL = 0x12u, - /// S_THREAD_LOCAL_VARIABLES - Section with thread local variable - /// structure data. - S_THREAD_LOCAL_VARIABLES = 0x13u, - /// S_THREAD_LOCAL_VARIABLE_POINTERS - Section with pointers to thread - /// local structures. - S_THREAD_LOCAL_VARIABLE_POINTERS = 0x14u, - /// S_THREAD_LOCAL_INIT_FUNCTION_POINTERS - Section with thread local - /// variable initialization pointers to functions. - S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 0x15u, - - LAST_KNOWN_SECTION_TYPE = S_THREAD_LOCAL_INIT_FUNCTION_POINTERS - }; - - enum : uint32_t { - // Constant masks for the "flags[31:24]" field in llvm::MachO::section and - // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_USR) - - /// S_ATTR_PURE_INSTRUCTIONS - Section contains only true machine - /// instructions. - S_ATTR_PURE_INSTRUCTIONS = 0x80000000u, - /// S_ATTR_NO_TOC - Section contains coalesced symbols that are not to be - /// in a ranlib table of contents. - S_ATTR_NO_TOC = 0x40000000u, - /// S_ATTR_STRIP_STATIC_SYMS - Ok to strip static symbols in this section - /// in files with the MY_DYLDLINK flag. - S_ATTR_STRIP_STATIC_SYMS = 0x20000000u, - /// S_ATTR_NO_DEAD_STRIP - No dead stripping. - S_ATTR_NO_DEAD_STRIP = 0x10000000u, - /// S_ATTR_LIVE_SUPPORT - Blocks are live if they reference live blocks. - S_ATTR_LIVE_SUPPORT = 0x08000000u, - /// S_ATTR_SELF_MODIFYING_CODE - Used with i386 code stubs written on by - /// dyld. - S_ATTR_SELF_MODIFYING_CODE = 0x04000000u, - /// S_ATTR_DEBUG - A debug section. - S_ATTR_DEBUG = 0x02000000u, - - // Constant masks for the "flags[23:8]" field in llvm::MachO::section and - // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_SYS) - - /// S_ATTR_SOME_INSTRUCTIONS - Section contains some machine instructions. - S_ATTR_SOME_INSTRUCTIONS = 0x00000400u, - /// S_ATTR_EXT_RELOC - Section has external relocation entries. - S_ATTR_EXT_RELOC = 0x00000200u, - /// S_ATTR_LOC_RELOC - Section has local relocation entries. - S_ATTR_LOC_RELOC = 0x00000100u, - - // Constant masks for the value of an indirect symbol in an indirect - // symbol table - INDIRECT_SYMBOL_LOCAL = 0x80000000u, - INDIRECT_SYMBOL_ABS = 0x40000000u - }; - - enum DataRegionType { - // Constants for the "kind" field in a data_in_code_entry structure - DICE_KIND_DATA = 1u, - DICE_KIND_JUMP_TABLE8 = 2u, - DICE_KIND_JUMP_TABLE16 = 3u, - DICE_KIND_JUMP_TABLE32 = 4u, - DICE_KIND_ABS_JUMP_TABLE32 = 5u - }; - - enum RebaseType { - REBASE_TYPE_POINTER = 1u, - REBASE_TYPE_TEXT_ABSOLUTE32 = 2u, - REBASE_TYPE_TEXT_PCREL32 = 3u - }; - - enum { - REBASE_OPCODE_MASK = 0xF0u, - REBASE_IMMEDIATE_MASK = 0x0Fu - }; - - enum RebaseOpcode { - REBASE_OPCODE_DONE = 0x00u, - REBASE_OPCODE_SET_TYPE_IMM = 0x10u, - REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB = 0x20u, - REBASE_OPCODE_ADD_ADDR_ULEB = 0x30u, - REBASE_OPCODE_ADD_ADDR_IMM_SCALED = 0x40u, - REBASE_OPCODE_DO_REBASE_IMM_TIMES = 0x50u, - REBASE_OPCODE_DO_REBASE_ULEB_TIMES = 0x60u, - REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB = 0x70u, - REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB = 0x80u - }; - - enum BindType { - BIND_TYPE_POINTER = 1u, - BIND_TYPE_TEXT_ABSOLUTE32 = 2u, - BIND_TYPE_TEXT_PCREL32 = 3u - }; - - enum BindSpecialDylib { - BIND_SPECIAL_DYLIB_SELF = 0, - BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE = -1, - BIND_SPECIAL_DYLIB_FLAT_LOOKUP = -2 - }; - - enum { - BIND_SYMBOL_FLAGS_WEAK_IMPORT = 0x1u, - BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION = 0x8u, - - BIND_OPCODE_MASK = 0xF0u, - BIND_IMMEDIATE_MASK = 0x0Fu - }; - - enum BindOpcode { - BIND_OPCODE_DONE = 0x00u, - BIND_OPCODE_SET_DYLIB_ORDINAL_IMM = 0x10u, - BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB = 0x20u, - BIND_OPCODE_SET_DYLIB_SPECIAL_IMM = 0x30u, - BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM = 0x40u, - BIND_OPCODE_SET_TYPE_IMM = 0x50u, - BIND_OPCODE_SET_ADDEND_SLEB = 0x60u, - BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB = 0x70u, - BIND_OPCODE_ADD_ADDR_ULEB = 0x80u, - BIND_OPCODE_DO_BIND = 0x90u, - BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB = 0xA0u, - BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED = 0xB0u, - BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB = 0xC0u - }; - - enum { - EXPORT_SYMBOL_FLAGS_KIND_MASK = 0x03u, - EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION = 0x04u, - EXPORT_SYMBOL_FLAGS_REEXPORT = 0x08u, - EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER = 0x10u - }; - - enum ExportSymbolKind { - EXPORT_SYMBOL_FLAGS_KIND_REGULAR = 0x00u, - EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL = 0x01u, - EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE = 0x02u - }; - - enum { - // Constant masks for the "n_type" field in llvm::MachO::nlist and - // llvm::MachO::nlist_64 - N_STAB = 0xe0, - N_PEXT = 0x10, - N_TYPE = 0x0e, - N_EXT = 0x01 - }; - - enum NListType : uint8_t { - // Constants for the "n_type & N_TYPE" llvm::MachO::nlist and - // llvm::MachO::nlist_64 - N_UNDF = 0x0u, - N_ABS = 0x2u, - N_SECT = 0xeu, - N_PBUD = 0xcu, - N_INDR = 0xau - }; - - enum SectionOrdinal { - // Constants for the "n_sect" field in llvm::MachO::nlist and - // llvm::MachO::nlist_64 - NO_SECT = 0u, - MAX_SECT = 0xffu - }; - - enum { - // Constant masks for the "n_desc" field in llvm::MachO::nlist and - // llvm::MachO::nlist_64 - // The low 3 bits are the for the REFERENCE_TYPE. - REFERENCE_TYPE = 0x7, - REFERENCE_FLAG_UNDEFINED_NON_LAZY = 0, - REFERENCE_FLAG_UNDEFINED_LAZY = 1, - REFERENCE_FLAG_DEFINED = 2, - REFERENCE_FLAG_PRIVATE_DEFINED = 3, - REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY = 4, - REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY = 5, - // Flag bits (some overlap with the library ordinal bits). - N_ARM_THUMB_DEF = 0x0008u, - REFERENCED_DYNAMICALLY = 0x0010u, - N_NO_DEAD_STRIP = 0x0020u, - N_WEAK_REF = 0x0040u, - N_WEAK_DEF = 0x0080u, - N_SYMBOL_RESOLVER = 0x0100u, - N_ALT_ENTRY = 0x0200u, - // For undefined symbols coming from libraries, see GET_LIBRARY_ORDINAL() - // as these are in the top 8 bits. - SELF_LIBRARY_ORDINAL = 0x0, - MAX_LIBRARY_ORDINAL = 0xfd, - DYNAMIC_LOOKUP_ORDINAL = 0xfe, - EXECUTABLE_ORDINAL = 0xff - }; - - enum StabType { - // Constant values for the "n_type" field in llvm::MachO::nlist and - // llvm::MachO::nlist_64 when "(n_type & N_STAB) != 0" - N_GSYM = 0x20u, - N_FNAME = 0x22u, - N_FUN = 0x24u, - N_STSYM = 0x26u, - N_LCSYM = 0x28u, - N_BNSYM = 0x2Eu, - N_PC = 0x30u, - N_AST = 0x32u, - N_OPT = 0x3Cu, - N_RSYM = 0x40u, - N_SLINE = 0x44u, - N_ENSYM = 0x4Eu, - N_SSYM = 0x60u, - N_SO = 0x64u, - N_OSO = 0x66u, - N_LSYM = 0x80u, - N_BINCL = 0x82u, - N_SOL = 0x84u, - N_PARAMS = 0x86u, - N_VERSION = 0x88u, - N_OLEVEL = 0x8Au, - N_PSYM = 0xA0u, - N_EINCL = 0xA2u, - N_ENTRY = 0xA4u, - N_LBRAC = 0xC0u, - N_EXCL = 0xC2u, - N_RBRAC = 0xE0u, - N_BCOMM = 0xE2u, - N_ECOMM = 0xE4u, - N_ECOML = 0xE8u, - N_LENG = 0xFEu - }; - - enum : uint32_t { - // Constant values for the r_symbolnum field in an - // llvm::MachO::relocation_info structure when r_extern is 0. - R_ABS = 0, - - // Constant bits for the r_address field in an - // llvm::MachO::relocation_info structure. - R_SCATTERED = 0x80000000 - }; - - enum RelocationInfoType { - // Constant values for the r_type field in an - // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info - // structure. - GENERIC_RELOC_VANILLA = 0, - GENERIC_RELOC_PAIR = 1, - GENERIC_RELOC_SECTDIFF = 2, - GENERIC_RELOC_PB_LA_PTR = 3, - GENERIC_RELOC_LOCAL_SECTDIFF = 4, - GENERIC_RELOC_TLV = 5, - - // Constant values for the r_type field in a PowerPC architecture - // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info - // structure. - PPC_RELOC_VANILLA = GENERIC_RELOC_VANILLA, - PPC_RELOC_PAIR = GENERIC_RELOC_PAIR, - PPC_RELOC_BR14 = 2, - PPC_RELOC_BR24 = 3, - PPC_RELOC_HI16 = 4, - PPC_RELOC_LO16 = 5, - PPC_RELOC_HA16 = 6, - PPC_RELOC_LO14 = 7, - PPC_RELOC_SECTDIFF = 8, - PPC_RELOC_PB_LA_PTR = 9, - PPC_RELOC_HI16_SECTDIFF = 10, - PPC_RELOC_LO16_SECTDIFF = 11, - PPC_RELOC_HA16_SECTDIFF = 12, - PPC_RELOC_JBSR = 13, - PPC_RELOC_LO14_SECTDIFF = 14, - PPC_RELOC_LOCAL_SECTDIFF = 15, - - // Constant values for the r_type field in an ARM architecture - // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info - // structure. - ARM_RELOC_VANILLA = GENERIC_RELOC_VANILLA, - ARM_RELOC_PAIR = GENERIC_RELOC_PAIR, - ARM_RELOC_SECTDIFF = GENERIC_RELOC_SECTDIFF, - ARM_RELOC_LOCAL_SECTDIFF = 3, - ARM_RELOC_PB_LA_PTR = 4, - ARM_RELOC_BR24 = 5, - ARM_THUMB_RELOC_BR22 = 6, - ARM_THUMB_32BIT_BRANCH = 7, // obsolete - ARM_RELOC_HALF = 8, - ARM_RELOC_HALF_SECTDIFF = 9, - - // Constant values for the r_type field in an ARM64 architecture - // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info - // structure. - - // For pointers. - ARM64_RELOC_UNSIGNED = 0, - // Must be followed by an ARM64_RELOC_UNSIGNED - ARM64_RELOC_SUBTRACTOR = 1, - // A B/BL instruction with 26-bit displacement. - ARM64_RELOC_BRANCH26 = 2, - // PC-rel distance to page of target. - ARM64_RELOC_PAGE21 = 3, - // Offset within page, scaled by r_length. - ARM64_RELOC_PAGEOFF12 = 4, - // PC-rel distance to page of GOT slot. - ARM64_RELOC_GOT_LOAD_PAGE21 = 5, - // Offset within page of GOT slot, scaled by r_length. - ARM64_RELOC_GOT_LOAD_PAGEOFF12 = 6, - // For pointers to GOT slots. - ARM64_RELOC_POINTER_TO_GOT = 7, - // PC-rel distance to page of TLVP slot. - ARM64_RELOC_TLVP_LOAD_PAGE21 = 8, - // Offset within page of TLVP slot, scaled by r_length. - ARM64_RELOC_TLVP_LOAD_PAGEOFF12 = 9, - // Must be followed by ARM64_RELOC_PAGE21 or ARM64_RELOC_PAGEOFF12. - ARM64_RELOC_ADDEND = 10, - - // Constant values for the r_type field in an x86_64 architecture - // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info - // structure - X86_64_RELOC_UNSIGNED = 0, - X86_64_RELOC_SIGNED = 1, - X86_64_RELOC_BRANCH = 2, - X86_64_RELOC_GOT_LOAD = 3, - X86_64_RELOC_GOT = 4, - X86_64_RELOC_SUBTRACTOR = 5, - X86_64_RELOC_SIGNED_1 = 6, - X86_64_RELOC_SIGNED_2 = 7, - X86_64_RELOC_SIGNED_4 = 8, - X86_64_RELOC_TLV = 9 - }; - - // Values for segment_command.initprot. - // From <mach/vm_prot.h> - enum { - VM_PROT_READ = 0x1, - VM_PROT_WRITE = 0x2, - VM_PROT_EXECUTE = 0x4 - }; - - // Values for platform field in build_version_command. - enum { - PLATFORM_MACOS = 1, - PLATFORM_IOS = 2, - PLATFORM_TVOS = 3, - PLATFORM_WATCHOS = 4, - PLATFORM_BRIDGEOS = 5 - }; - - // Values for tools enum in build_tool_version. - enum { - TOOL_CLANG = 1, - TOOL_SWIFT = 2, - TOOL_LD = 3 - }; - - // Structs from <mach-o/loader.h> - - struct mach_header { - uint32_t magic; - uint32_t cputype; - uint32_t cpusubtype; - uint32_t filetype; - uint32_t ncmds; - uint32_t sizeofcmds; - uint32_t flags; - }; - - struct mach_header_64 { - uint32_t magic; - uint32_t cputype; - uint32_t cpusubtype; - uint32_t filetype; - uint32_t ncmds; - uint32_t sizeofcmds; - uint32_t flags; - uint32_t reserved; - }; - - struct load_command { - uint32_t cmd; - uint32_t cmdsize; - }; - - struct segment_command { - uint32_t cmd; - uint32_t cmdsize; - char segname[16]; - uint32_t vmaddr; - uint32_t vmsize; - uint32_t fileoff; - uint32_t filesize; - uint32_t maxprot; - uint32_t initprot; - uint32_t nsects; - uint32_t flags; - }; - - struct segment_command_64 { - uint32_t cmd; - uint32_t cmdsize; - char segname[16]; - uint64_t vmaddr; - uint64_t vmsize; - uint64_t fileoff; - uint64_t filesize; - uint32_t maxprot; - uint32_t initprot; - uint32_t nsects; - uint32_t flags; - }; - - struct section { - char sectname[16]; - char segname[16]; - uint32_t addr; - uint32_t size; - uint32_t offset; - uint32_t align; - uint32_t reloff; - uint32_t nreloc; - uint32_t flags; - uint32_t reserved1; - uint32_t reserved2; - }; - - struct section_64 { - char sectname[16]; - char segname[16]; - uint64_t addr; - uint64_t size; - uint32_t offset; - uint32_t align; - uint32_t reloff; - uint32_t nreloc; - uint32_t flags; - uint32_t reserved1; - uint32_t reserved2; - uint32_t reserved3; - }; - - struct fvmlib { - uint32_t name; - uint32_t minor_version; - uint32_t header_addr; - }; - - // The fvmlib_command is obsolete and no longer supported. - struct fvmlib_command { - uint32_t cmd; - uint32_t cmdsize; - struct fvmlib fvmlib; - }; - - struct dylib { - uint32_t name; - uint32_t timestamp; - uint32_t current_version; - uint32_t compatibility_version; - }; - - struct dylib_command { - uint32_t cmd; - uint32_t cmdsize; - struct dylib dylib; - }; - - struct sub_framework_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t umbrella; - }; - - struct sub_client_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t client; - }; - - struct sub_umbrella_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t sub_umbrella; - }; - - struct sub_library_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t sub_library; - }; - - // The prebound_dylib_command is obsolete and no longer supported. - struct prebound_dylib_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t name; - uint32_t nmodules; - uint32_t linked_modules; - }; - - struct dylinker_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t name; - }; - - struct thread_command { - uint32_t cmd; - uint32_t cmdsize; - }; - - struct routines_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t init_address; - uint32_t init_module; - uint32_t reserved1; - uint32_t reserved2; - uint32_t reserved3; - uint32_t reserved4; - uint32_t reserved5; - uint32_t reserved6; - }; - - struct routines_command_64 { - uint32_t cmd; - uint32_t cmdsize; - uint64_t init_address; - uint64_t init_module; - uint64_t reserved1; - uint64_t reserved2; - uint64_t reserved3; - uint64_t reserved4; - uint64_t reserved5; - uint64_t reserved6; - }; - - struct symtab_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t symoff; - uint32_t nsyms; - uint32_t stroff; - uint32_t strsize; - }; - - struct dysymtab_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t ilocalsym; - uint32_t nlocalsym; - uint32_t iextdefsym; - uint32_t nextdefsym; - uint32_t iundefsym; - uint32_t nundefsym; - uint32_t tocoff; - uint32_t ntoc; - uint32_t modtaboff; - uint32_t nmodtab; - uint32_t extrefsymoff; - uint32_t nextrefsyms; - uint32_t indirectsymoff; - uint32_t nindirectsyms; - uint32_t extreloff; - uint32_t nextrel; - uint32_t locreloff; - uint32_t nlocrel; - }; - - struct dylib_table_of_contents { - uint32_t symbol_index; - uint32_t module_index; - }; - - struct dylib_module { - uint32_t module_name; - uint32_t iextdefsym; - uint32_t nextdefsym; - uint32_t irefsym; - uint32_t nrefsym; - uint32_t ilocalsym; - uint32_t nlocalsym; - uint32_t iextrel; - uint32_t nextrel; - uint32_t iinit_iterm; - uint32_t ninit_nterm; - uint32_t objc_module_info_addr; - uint32_t objc_module_info_size; - }; - - struct dylib_module_64 { - uint32_t module_name; - uint32_t iextdefsym; - uint32_t nextdefsym; - uint32_t irefsym; - uint32_t nrefsym; - uint32_t ilocalsym; - uint32_t nlocalsym; - uint32_t iextrel; - uint32_t nextrel; - uint32_t iinit_iterm; - uint32_t ninit_nterm; - uint32_t objc_module_info_size; - uint64_t objc_module_info_addr; - }; - - struct dylib_reference { - uint32_t isym:24, - flags:8; - }; - - // The twolevel_hints_command is obsolete and no longer supported. - struct twolevel_hints_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t offset; - uint32_t nhints; - }; - - // The twolevel_hints_command is obsolete and no longer supported. - struct twolevel_hint { - uint32_t isub_image:8, - itoc:24; - }; - - // The prebind_cksum_command is obsolete and no longer supported. - struct prebind_cksum_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t cksum; - }; - - struct uuid_command { - uint32_t cmd; - uint32_t cmdsize; - uint8_t uuid[16]; - }; - - struct rpath_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t path; - }; - - struct linkedit_data_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t dataoff; - uint32_t datasize; - }; - - struct data_in_code_entry { - uint32_t offset; - uint16_t length; - uint16_t kind; - }; - - struct source_version_command { - uint32_t cmd; - uint32_t cmdsize; - uint64_t version; - }; - - struct encryption_info_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t cryptoff; - uint32_t cryptsize; - uint32_t cryptid; - }; - - struct encryption_info_command_64 { - uint32_t cmd; - uint32_t cmdsize; - uint32_t cryptoff; - uint32_t cryptsize; - uint32_t cryptid; - uint32_t pad; - }; - - struct version_min_command { - uint32_t cmd; // LC_VERSION_MIN_MACOSX or - // LC_VERSION_MIN_IPHONEOS - uint32_t cmdsize; // sizeof(struct version_min_command) - uint32_t version; // X.Y.Z is encoded in nibbles xxxx.yy.zz - uint32_t sdk; // X.Y.Z is encoded in nibbles xxxx.yy.zz - }; - - struct note_command { - uint32_t cmd; // LC_NOTE - uint32_t cmdsize; // sizeof(struct note_command) - char data_owner[16]; // owner name for this LC_NOTE - uint64_t offset; // file offset of this data - uint64_t size; // length of data region - }; - - struct build_tool_version { - uint32_t tool; // enum for the tool - uint32_t version; // version of the tool - }; - - struct build_version_command { - uint32_t cmd; // LC_BUILD_VERSION - uint32_t cmdsize; // sizeof(struct build_version_command) + - // ntools * sizeof(struct build_tool_version) - uint32_t platform; // platform - uint32_t minos; // X.Y.Z is encoded in nibbles xxxx.yy.zz - uint32_t sdk; // X.Y.Z is encoded in nibbles xxxx.yy.zz - uint32_t ntools; // number of tool entries following this - }; - - struct dyld_info_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t rebase_off; - uint32_t rebase_size; - uint32_t bind_off; - uint32_t bind_size; - uint32_t weak_bind_off; - uint32_t weak_bind_size; - uint32_t lazy_bind_off; - uint32_t lazy_bind_size; - uint32_t export_off; - uint32_t export_size; - }; - - struct linker_option_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t count; - }; - - // The symseg_command is obsolete and no longer supported. - struct symseg_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t offset; - uint32_t size; - }; - - // The ident_command is obsolete and no longer supported. - struct ident_command { - uint32_t cmd; - uint32_t cmdsize; - }; - - // The fvmfile_command is obsolete and no longer supported. - struct fvmfile_command { - uint32_t cmd; - uint32_t cmdsize; - uint32_t name; - uint32_t header_addr; - }; - - struct tlv_descriptor_32 { - uint32_t thunk; - uint32_t key; - uint32_t offset; - }; - - struct tlv_descriptor_64 { - uint64_t thunk; - uint64_t key; - uint64_t offset; - }; - - struct tlv_descriptor { - uintptr_t thunk; - uintptr_t key; - uintptr_t offset; - }; - - struct entry_point_command { - uint32_t cmd; - uint32_t cmdsize; - uint64_t entryoff; - uint64_t stacksize; - }; - - // Structs from <mach-o/fat.h> - struct fat_header { - uint32_t magic; - uint32_t nfat_arch; - }; - - struct fat_arch { - uint32_t cputype; - uint32_t cpusubtype; - uint32_t offset; - uint32_t size; - uint32_t align; - }; - - struct fat_arch_64 { - uint32_t cputype; - uint32_t cpusubtype; - uint64_t offset; - uint64_t size; - uint32_t align; - uint32_t reserved; - }; - - // Structs from <mach-o/reloc.h> - struct relocation_info { - int32_t r_address; - uint32_t r_symbolnum:24, - r_pcrel:1, - r_length:2, - r_extern:1, - r_type:4; - }; - - struct scattered_relocation_info { -#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN) - uint32_t r_scattered:1, - r_pcrel:1, - r_length:2, - r_type:4, - r_address:24; -#else - uint32_t r_address:24, - r_type:4, - r_length:2, - r_pcrel:1, - r_scattered:1; -#endif - int32_t r_value; - }; - - // Structs NOT from <mach-o/reloc.h>, but that make LLVM's life easier - struct any_relocation_info { - uint32_t r_word0, r_word1; - }; - - // Structs from <mach-o/nlist.h> - struct nlist_base { - uint32_t n_strx; - uint8_t n_type; - uint8_t n_sect; - uint16_t n_desc; - }; - - struct nlist { - uint32_t n_strx; - uint8_t n_type; - uint8_t n_sect; - int16_t n_desc; - uint32_t n_value; - }; - - struct nlist_64 { - uint32_t n_strx; - uint8_t n_type; - uint8_t n_sect; - uint16_t n_desc; - uint64_t n_value; - }; - - // Byte order swapping functions for MachO structs - - inline void swapStruct(fat_header &mh) { - sys::swapByteOrder(mh.magic); - sys::swapByteOrder(mh.nfat_arch); - } - - inline void swapStruct(fat_arch &mh) { - sys::swapByteOrder(mh.cputype); - sys::swapByteOrder(mh.cpusubtype); - sys::swapByteOrder(mh.offset); - sys::swapByteOrder(mh.size); - sys::swapByteOrder(mh.align); - } - - inline void swapStruct(fat_arch_64 &mh) { - sys::swapByteOrder(mh.cputype); - sys::swapByteOrder(mh.cpusubtype); - sys::swapByteOrder(mh.offset); - sys::swapByteOrder(mh.size); - sys::swapByteOrder(mh.align); - sys::swapByteOrder(mh.reserved); - } - - inline void swapStruct(mach_header &mh) { - sys::swapByteOrder(mh.magic); - sys::swapByteOrder(mh.cputype); - sys::swapByteOrder(mh.cpusubtype); - sys::swapByteOrder(mh.filetype); - sys::swapByteOrder(mh.ncmds); - sys::swapByteOrder(mh.sizeofcmds); - sys::swapByteOrder(mh.flags); - } - - inline void swapStruct(mach_header_64 &H) { - sys::swapByteOrder(H.magic); - sys::swapByteOrder(H.cputype); - sys::swapByteOrder(H.cpusubtype); - sys::swapByteOrder(H.filetype); - sys::swapByteOrder(H.ncmds); - sys::swapByteOrder(H.sizeofcmds); - sys::swapByteOrder(H.flags); - sys::swapByteOrder(H.reserved); - } - - inline void swapStruct(load_command &lc) { - sys::swapByteOrder(lc.cmd); - sys::swapByteOrder(lc.cmdsize); - } - - inline void swapStruct(symtab_command &lc) { - sys::swapByteOrder(lc.cmd); - sys::swapByteOrder(lc.cmdsize); - sys::swapByteOrder(lc.symoff); - sys::swapByteOrder(lc.nsyms); - sys::swapByteOrder(lc.stroff); - sys::swapByteOrder(lc.strsize); - } - - inline void swapStruct(segment_command_64 &seg) { - sys::swapByteOrder(seg.cmd); - sys::swapByteOrder(seg.cmdsize); - sys::swapByteOrder(seg.vmaddr); - sys::swapByteOrder(seg.vmsize); - sys::swapByteOrder(seg.fileoff); - sys::swapByteOrder(seg.filesize); - sys::swapByteOrder(seg.maxprot); - sys::swapByteOrder(seg.initprot); - sys::swapByteOrder(seg.nsects); - sys::swapByteOrder(seg.flags); - } - - inline void swapStruct(segment_command &seg) { - sys::swapByteOrder(seg.cmd); - sys::swapByteOrder(seg.cmdsize); - sys::swapByteOrder(seg.vmaddr); - sys::swapByteOrder(seg.vmsize); - sys::swapByteOrder(seg.fileoff); - sys::swapByteOrder(seg.filesize); - sys::swapByteOrder(seg.maxprot); - sys::swapByteOrder(seg.initprot); - sys::swapByteOrder(seg.nsects); - sys::swapByteOrder(seg.flags); - } - - inline void swapStruct(section_64 §) { - sys::swapByteOrder(sect.addr); - sys::swapByteOrder(sect.size); - sys::swapByteOrder(sect.offset); - sys::swapByteOrder(sect.align); - sys::swapByteOrder(sect.reloff); - sys::swapByteOrder(sect.nreloc); - sys::swapByteOrder(sect.flags); - sys::swapByteOrder(sect.reserved1); - sys::swapByteOrder(sect.reserved2); - } - - inline void swapStruct(section §) { - sys::swapByteOrder(sect.addr); - sys::swapByteOrder(sect.size); - sys::swapByteOrder(sect.offset); - sys::swapByteOrder(sect.align); - sys::swapByteOrder(sect.reloff); - sys::swapByteOrder(sect.nreloc); - sys::swapByteOrder(sect.flags); - sys::swapByteOrder(sect.reserved1); - sys::swapByteOrder(sect.reserved2); - } - - inline void swapStruct(dyld_info_command &info) { - sys::swapByteOrder(info.cmd); - sys::swapByteOrder(info.cmdsize); - sys::swapByteOrder(info.rebase_off); - sys::swapByteOrder(info.rebase_size); - sys::swapByteOrder(info.bind_off); - sys::swapByteOrder(info.bind_size); - sys::swapByteOrder(info.weak_bind_off); - sys::swapByteOrder(info.weak_bind_size); - sys::swapByteOrder(info.lazy_bind_off); - sys::swapByteOrder(info.lazy_bind_size); - sys::swapByteOrder(info.export_off); - sys::swapByteOrder(info.export_size); - } - - inline void swapStruct(dylib_command &d) { - sys::swapByteOrder(d.cmd); - sys::swapByteOrder(d.cmdsize); - sys::swapByteOrder(d.dylib.name); - sys::swapByteOrder(d.dylib.timestamp); - sys::swapByteOrder(d.dylib.current_version); - sys::swapByteOrder(d.dylib.compatibility_version); - } - - inline void swapStruct(sub_framework_command &s) { - sys::swapByteOrder(s.cmd); - sys::swapByteOrder(s.cmdsize); - sys::swapByteOrder(s.umbrella); - } - - inline void swapStruct(sub_umbrella_command &s) { - sys::swapByteOrder(s.cmd); - sys::swapByteOrder(s.cmdsize); - sys::swapByteOrder(s.sub_umbrella); - } - - inline void swapStruct(sub_library_command &s) { - sys::swapByteOrder(s.cmd); - sys::swapByteOrder(s.cmdsize); - sys::swapByteOrder(s.sub_library); - } - - inline void swapStruct(sub_client_command &s) { - sys::swapByteOrder(s.cmd); - sys::swapByteOrder(s.cmdsize); - sys::swapByteOrder(s.client); - } - - inline void swapStruct(routines_command &r) { - sys::swapByteOrder(r.cmd); - sys::swapByteOrder(r.cmdsize); - sys::swapByteOrder(r.init_address); - sys::swapByteOrder(r.init_module); - sys::swapByteOrder(r.reserved1); - sys::swapByteOrder(r.reserved2); - sys::swapByteOrder(r.reserved3); - sys::swapByteOrder(r.reserved4); - sys::swapByteOrder(r.reserved5); - sys::swapByteOrder(r.reserved6); - } - - inline void swapStruct(routines_command_64 &r) { - sys::swapByteOrder(r.cmd); - sys::swapByteOrder(r.cmdsize); - sys::swapByteOrder(r.init_address); - sys::swapByteOrder(r.init_module); - sys::swapByteOrder(r.reserved1); - sys::swapByteOrder(r.reserved2); - sys::swapByteOrder(r.reserved3); - sys::swapByteOrder(r.reserved4); - sys::swapByteOrder(r.reserved5); - sys::swapByteOrder(r.reserved6); - } - - inline void swapStruct(thread_command &t) { - sys::swapByteOrder(t.cmd); - sys::swapByteOrder(t.cmdsize); - } - - inline void swapStruct(dylinker_command &d) { - sys::swapByteOrder(d.cmd); - sys::swapByteOrder(d.cmdsize); - sys::swapByteOrder(d.name); - } - - inline void swapStruct(uuid_command &u) { - sys::swapByteOrder(u.cmd); - sys::swapByteOrder(u.cmdsize); - } - - inline void swapStruct(rpath_command &r) { - sys::swapByteOrder(r.cmd); - sys::swapByteOrder(r.cmdsize); - sys::swapByteOrder(r.path); - } - - inline void swapStruct(source_version_command &s) { - sys::swapByteOrder(s.cmd); - sys::swapByteOrder(s.cmdsize); - sys::swapByteOrder(s.version); - } - - inline void swapStruct(entry_point_command &e) { - sys::swapByteOrder(e.cmd); - sys::swapByteOrder(e.cmdsize); - sys::swapByteOrder(e.entryoff); - sys::swapByteOrder(e.stacksize); - } - - inline void swapStruct(encryption_info_command &e) { - sys::swapByteOrder(e.cmd); - sys::swapByteOrder(e.cmdsize); - sys::swapByteOrder(e.cryptoff); - sys::swapByteOrder(e.cryptsize); - sys::swapByteOrder(e.cryptid); - } - - inline void swapStruct(encryption_info_command_64 &e) { - sys::swapByteOrder(e.cmd); - sys::swapByteOrder(e.cmdsize); - sys::swapByteOrder(e.cryptoff); - sys::swapByteOrder(e.cryptsize); - sys::swapByteOrder(e.cryptid); - sys::swapByteOrder(e.pad); - } - - inline void swapStruct(dysymtab_command &dst) { - sys::swapByteOrder(dst.cmd); - sys::swapByteOrder(dst.cmdsize); - sys::swapByteOrder(dst.ilocalsym); - sys::swapByteOrder(dst.nlocalsym); - sys::swapByteOrder(dst.iextdefsym); - sys::swapByteOrder(dst.nextdefsym); - sys::swapByteOrder(dst.iundefsym); - sys::swapByteOrder(dst.nundefsym); - sys::swapByteOrder(dst.tocoff); - sys::swapByteOrder(dst.ntoc); - sys::swapByteOrder(dst.modtaboff); - sys::swapByteOrder(dst.nmodtab); - sys::swapByteOrder(dst.extrefsymoff); - sys::swapByteOrder(dst.nextrefsyms); - sys::swapByteOrder(dst.indirectsymoff); - sys::swapByteOrder(dst.nindirectsyms); - sys::swapByteOrder(dst.extreloff); - sys::swapByteOrder(dst.nextrel); - sys::swapByteOrder(dst.locreloff); - sys::swapByteOrder(dst.nlocrel); - } - - inline void swapStruct(any_relocation_info &reloc) { - sys::swapByteOrder(reloc.r_word0); - sys::swapByteOrder(reloc.r_word1); - } - - inline void swapStruct(nlist_base &S) { - sys::swapByteOrder(S.n_strx); - sys::swapByteOrder(S.n_desc); - } - - inline void swapStruct(nlist &sym) { - sys::swapByteOrder(sym.n_strx); - sys::swapByteOrder(sym.n_desc); - sys::swapByteOrder(sym.n_value); - } - - inline void swapStruct(nlist_64 &sym) { - sys::swapByteOrder(sym.n_strx); - sys::swapByteOrder(sym.n_desc); - sys::swapByteOrder(sym.n_value); - } - - inline void swapStruct(linkedit_data_command &C) { - sys::swapByteOrder(C.cmd); - sys::swapByteOrder(C.cmdsize); - sys::swapByteOrder(C.dataoff); - sys::swapByteOrder(C.datasize); - } - - inline void swapStruct(linker_option_command &C) { - sys::swapByteOrder(C.cmd); - sys::swapByteOrder(C.cmdsize); - sys::swapByteOrder(C.count); - } - - inline void swapStruct(version_min_command&C) { - sys::swapByteOrder(C.cmd); - sys::swapByteOrder(C.cmdsize); - sys::swapByteOrder(C.version); - sys::swapByteOrder(C.sdk); - } - - inline void swapStruct(note_command &C) { - sys::swapByteOrder(C.cmd); - sys::swapByteOrder(C.cmdsize); - sys::swapByteOrder(C.offset); - sys::swapByteOrder(C.size); - } - - inline void swapStruct(build_version_command&C) { - sys::swapByteOrder(C.cmd); - sys::swapByteOrder(C.cmdsize); - sys::swapByteOrder(C.platform); - sys::swapByteOrder(C.minos); - sys::swapByteOrder(C.sdk); - sys::swapByteOrder(C.ntools); - } - - inline void swapStruct(build_tool_version&C) { - sys::swapByteOrder(C.tool); - sys::swapByteOrder(C.version); - } - - inline void swapStruct(data_in_code_entry &C) { - sys::swapByteOrder(C.offset); - sys::swapByteOrder(C.length); - sys::swapByteOrder(C.kind); - } - - inline void swapStruct(uint32_t &C) { - sys::swapByteOrder(C); - } - - // The prebind_cksum_command is obsolete and no longer supported. - inline void swapStruct(prebind_cksum_command &C) { - sys::swapByteOrder(C.cmd); - sys::swapByteOrder(C.cmdsize); - sys::swapByteOrder(C.cksum); - } - - // The twolevel_hints_command is obsolete and no longer supported. - inline void swapStruct(twolevel_hints_command &C) { - sys::swapByteOrder(C.cmd); - sys::swapByteOrder(C.cmdsize); - sys::swapByteOrder(C.offset); - sys::swapByteOrder(C.nhints); - } - - // The prebound_dylib_command is obsolete and no longer supported. - inline void swapStruct(prebound_dylib_command &C) { - sys::swapByteOrder(C.cmd); - sys::swapByteOrder(C.cmdsize); - sys::swapByteOrder(C.name); - sys::swapByteOrder(C.nmodules); - sys::swapByteOrder(C.linked_modules); - } - - // The fvmfile_command is obsolete and no longer supported. - inline void swapStruct(fvmfile_command &C) { - sys::swapByteOrder(C.cmd); - sys::swapByteOrder(C.cmdsize); - sys::swapByteOrder(C.name); - sys::swapByteOrder(C.header_addr); - } - - // The symseg_command is obsolete and no longer supported. - inline void swapStruct(symseg_command &C) { - sys::swapByteOrder(C.cmd); - sys::swapByteOrder(C.cmdsize); - sys::swapByteOrder(C.offset); - sys::swapByteOrder(C.size); - } - - // The ident_command is obsolete and no longer supported. - inline void swapStruct(ident_command &C) { - sys::swapByteOrder(C.cmd); - sys::swapByteOrder(C.cmdsize); - } - - inline void swapStruct(fvmlib &C) { - sys::swapByteOrder(C.name); - sys::swapByteOrder(C.minor_version); - sys::swapByteOrder(C.header_addr); - } - - // The fvmlib_command is obsolete and no longer supported. - inline void swapStruct(fvmlib_command &C) { - sys::swapByteOrder(C.cmd); - sys::swapByteOrder(C.cmdsize); - swapStruct(C.fvmlib); - } - - // Get/Set functions from <mach-o/nlist.h> - - static inline uint16_t GET_LIBRARY_ORDINAL(uint16_t n_desc) { - return (((n_desc) >> 8u) & 0xffu); - } - - static inline void SET_LIBRARY_ORDINAL(uint16_t &n_desc, uint8_t ordinal) { - n_desc = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8)); - } - - static inline uint8_t GET_COMM_ALIGN (uint16_t n_desc) { - return (n_desc >> 8u) & 0x0fu; - } - - static inline void SET_COMM_ALIGN (uint16_t &n_desc, uint8_t align) { - n_desc = ((n_desc & 0xf0ffu) | ((align & 0x0fu) << 8u)); - } - - // Enums from <mach/machine.h> - enum : uint32_t { - // Capability bits used in the definition of cpu_type. - CPU_ARCH_MASK = 0xff000000, // Mask for architecture bits - CPU_ARCH_ABI64 = 0x01000000 // 64 bit ABI - }; - - // Constants for the cputype field. - enum CPUType { - CPU_TYPE_ANY = -1, - CPU_TYPE_X86 = 7, - CPU_TYPE_I386 = CPU_TYPE_X86, - CPU_TYPE_X86_64 = CPU_TYPE_X86 | CPU_ARCH_ABI64, - /* CPU_TYPE_MIPS = 8, */ - CPU_TYPE_MC98000 = 10, // Old Motorola PowerPC - CPU_TYPE_ARM = 12, - CPU_TYPE_ARM64 = CPU_TYPE_ARM | CPU_ARCH_ABI64, - CPU_TYPE_SPARC = 14, - CPU_TYPE_POWERPC = 18, - CPU_TYPE_POWERPC64 = CPU_TYPE_POWERPC | CPU_ARCH_ABI64 - }; - - enum : uint32_t { - // Capability bits used in the definition of cpusubtype. - CPU_SUBTYPE_MASK = 0xff000000, // Mask for architecture bits - CPU_SUBTYPE_LIB64 = 0x80000000, // 64 bit libraries - - // Special CPU subtype constants. - CPU_SUBTYPE_MULTIPLE = ~0u - }; - - // Constants for the cpusubtype field. - enum CPUSubTypeX86 { - CPU_SUBTYPE_I386_ALL = 3, - CPU_SUBTYPE_386 = 3, - CPU_SUBTYPE_486 = 4, - CPU_SUBTYPE_486SX = 0x84, - CPU_SUBTYPE_586 = 5, - CPU_SUBTYPE_PENT = CPU_SUBTYPE_586, - CPU_SUBTYPE_PENTPRO = 0x16, - CPU_SUBTYPE_PENTII_M3 = 0x36, - CPU_SUBTYPE_PENTII_M5 = 0x56, - CPU_SUBTYPE_CELERON = 0x67, - CPU_SUBTYPE_CELERON_MOBILE = 0x77, - CPU_SUBTYPE_PENTIUM_3 = 0x08, - CPU_SUBTYPE_PENTIUM_3_M = 0x18, - CPU_SUBTYPE_PENTIUM_3_XEON = 0x28, - CPU_SUBTYPE_PENTIUM_M = 0x09, - CPU_SUBTYPE_PENTIUM_4 = 0x0a, - CPU_SUBTYPE_PENTIUM_4_M = 0x1a, - CPU_SUBTYPE_ITANIUM = 0x0b, - CPU_SUBTYPE_ITANIUM_2 = 0x1b, - CPU_SUBTYPE_XEON = 0x0c, - CPU_SUBTYPE_XEON_MP = 0x1c, - - CPU_SUBTYPE_X86_ALL = 3, - CPU_SUBTYPE_X86_64_ALL = 3, - CPU_SUBTYPE_X86_ARCH1 = 4, - CPU_SUBTYPE_X86_64_H = 8 - }; - static inline int CPU_SUBTYPE_INTEL(int Family, int Model) { - return Family | (Model << 4); - } - static inline int CPU_SUBTYPE_INTEL_FAMILY(CPUSubTypeX86 ST) { - return ((int)ST) & 0x0f; - } - static inline int CPU_SUBTYPE_INTEL_MODEL(CPUSubTypeX86 ST) { - return ((int)ST) >> 4; - } - enum { - CPU_SUBTYPE_INTEL_FAMILY_MAX = 15, - CPU_SUBTYPE_INTEL_MODEL_ALL = 0 - }; - - enum CPUSubTypeARM { - CPU_SUBTYPE_ARM_ALL = 0, - CPU_SUBTYPE_ARM_V4T = 5, - CPU_SUBTYPE_ARM_V6 = 6, - CPU_SUBTYPE_ARM_V5 = 7, - CPU_SUBTYPE_ARM_V5TEJ = 7, - CPU_SUBTYPE_ARM_XSCALE = 8, - CPU_SUBTYPE_ARM_V7 = 9, - // unused ARM_V7F = 10, - CPU_SUBTYPE_ARM_V7S = 11, - CPU_SUBTYPE_ARM_V7K = 12, - CPU_SUBTYPE_ARM_V6M = 14, - CPU_SUBTYPE_ARM_V7M = 15, - CPU_SUBTYPE_ARM_V7EM = 16 - }; - - enum CPUSubTypeARM64 { - CPU_SUBTYPE_ARM64_ALL = 0 - }; - - enum CPUSubTypeSPARC { - CPU_SUBTYPE_SPARC_ALL = 0 - }; - - enum CPUSubTypePowerPC { - CPU_SUBTYPE_POWERPC_ALL = 0, - CPU_SUBTYPE_POWERPC_601 = 1, - CPU_SUBTYPE_POWERPC_602 = 2, - CPU_SUBTYPE_POWERPC_603 = 3, - CPU_SUBTYPE_POWERPC_603e = 4, - CPU_SUBTYPE_POWERPC_603ev = 5, - CPU_SUBTYPE_POWERPC_604 = 6, - CPU_SUBTYPE_POWERPC_604e = 7, - CPU_SUBTYPE_POWERPC_620 = 8, - CPU_SUBTYPE_POWERPC_750 = 9, - CPU_SUBTYPE_POWERPC_7400 = 10, - CPU_SUBTYPE_POWERPC_7450 = 11, - CPU_SUBTYPE_POWERPC_970 = 100, - - CPU_SUBTYPE_MC980000_ALL = CPU_SUBTYPE_POWERPC_ALL, - CPU_SUBTYPE_MC98601 = CPU_SUBTYPE_POWERPC_601 - }; - - struct x86_thread_state32_t { - uint32_t eax; - uint32_t ebx; - uint32_t ecx; - uint32_t edx; - uint32_t edi; - uint32_t esi; - uint32_t ebp; - uint32_t esp; - uint32_t ss; - uint32_t eflags; - uint32_t eip; - uint32_t cs; - uint32_t ds; - uint32_t es; - uint32_t fs; - uint32_t gs; - }; - - struct x86_thread_state64_t { - uint64_t rax; - uint64_t rbx; - uint64_t rcx; - uint64_t rdx; - uint64_t rdi; - uint64_t rsi; - uint64_t rbp; - uint64_t rsp; - uint64_t r8; - uint64_t r9; - uint64_t r10; - uint64_t r11; - uint64_t r12; - uint64_t r13; - uint64_t r14; - uint64_t r15; - uint64_t rip; - uint64_t rflags; - uint64_t cs; - uint64_t fs; - uint64_t gs; - }; - - enum x86_fp_control_precis { - x86_FP_PREC_24B = 0, - x86_FP_PREC_53B = 2, - x86_FP_PREC_64B = 3 - }; - - enum x86_fp_control_rc { - x86_FP_RND_NEAR = 0, - x86_FP_RND_DOWN = 1, - x86_FP_RND_UP = 2, - x86_FP_CHOP = 3 - }; - - struct fp_control_t { - unsigned short - invalid :1, - denorm :1, - zdiv :1, - ovrfl :1, - undfl :1, - precis :1, - :2, - pc :2, - rc :2, - :1, - :3; - }; - - struct fp_status_t { - unsigned short - invalid :1, - denorm :1, - zdiv :1, - ovrfl :1, - undfl :1, - precis :1, - stkflt :1, - errsumm :1, - c0 :1, - c1 :1, - c2 :1, - tos :3, - c3 :1, - busy :1; - }; - - struct mmst_reg_t { - char mmst_reg[10]; - char mmst_rsrv[6]; - }; - - struct xmm_reg_t { - char xmm_reg[16]; - }; - - struct x86_float_state64_t { - int32_t fpu_reserved[2]; - fp_control_t fpu_fcw; - fp_status_t fpu_fsw; - uint8_t fpu_ftw; - uint8_t fpu_rsrv1; - uint16_t fpu_fop; - uint32_t fpu_ip; - uint16_t fpu_cs; - uint16_t fpu_rsrv2; - uint32_t fpu_dp; - uint16_t fpu_ds; - uint16_t fpu_rsrv3; - uint32_t fpu_mxcsr; - uint32_t fpu_mxcsrmask; - mmst_reg_t fpu_stmm0; - mmst_reg_t fpu_stmm1; - mmst_reg_t fpu_stmm2; - mmst_reg_t fpu_stmm3; - mmst_reg_t fpu_stmm4; - mmst_reg_t fpu_stmm5; - mmst_reg_t fpu_stmm6; - mmst_reg_t fpu_stmm7; - xmm_reg_t fpu_xmm0; - xmm_reg_t fpu_xmm1; - xmm_reg_t fpu_xmm2; - xmm_reg_t fpu_xmm3; - xmm_reg_t fpu_xmm4; - xmm_reg_t fpu_xmm5; - xmm_reg_t fpu_xmm6; - xmm_reg_t fpu_xmm7; - xmm_reg_t fpu_xmm8; - xmm_reg_t fpu_xmm9; - xmm_reg_t fpu_xmm10; - xmm_reg_t fpu_xmm11; - xmm_reg_t fpu_xmm12; - xmm_reg_t fpu_xmm13; - xmm_reg_t fpu_xmm14; - xmm_reg_t fpu_xmm15; - char fpu_rsrv4[6*16]; - uint32_t fpu_reserved1; - }; - - struct x86_exception_state64_t { - uint16_t trapno; - uint16_t cpu; - uint32_t err; - uint64_t faultvaddr; - }; - - inline void swapStruct(x86_thread_state32_t &x) { - sys::swapByteOrder(x.eax); - sys::swapByteOrder(x.ebx); - sys::swapByteOrder(x.ecx); - sys::swapByteOrder(x.edx); - sys::swapByteOrder(x.edi); - sys::swapByteOrder(x.esi); - sys::swapByteOrder(x.ebp); - sys::swapByteOrder(x.esp); - sys::swapByteOrder(x.ss); - sys::swapByteOrder(x.eflags); - sys::swapByteOrder(x.eip); - sys::swapByteOrder(x.cs); - sys::swapByteOrder(x.ds); - sys::swapByteOrder(x.es); - sys::swapByteOrder(x.fs); - sys::swapByteOrder(x.gs); - } - - inline void swapStruct(x86_thread_state64_t &x) { - sys::swapByteOrder(x.rax); - sys::swapByteOrder(x.rbx); - sys::swapByteOrder(x.rcx); - sys::swapByteOrder(x.rdx); - sys::swapByteOrder(x.rdi); - sys::swapByteOrder(x.rsi); - sys::swapByteOrder(x.rbp); - sys::swapByteOrder(x.rsp); - sys::swapByteOrder(x.r8); - sys::swapByteOrder(x.r9); - sys::swapByteOrder(x.r10); - sys::swapByteOrder(x.r11); - sys::swapByteOrder(x.r12); - sys::swapByteOrder(x.r13); - sys::swapByteOrder(x.r14); - sys::swapByteOrder(x.r15); - sys::swapByteOrder(x.rip); - sys::swapByteOrder(x.rflags); - sys::swapByteOrder(x.cs); - sys::swapByteOrder(x.fs); - sys::swapByteOrder(x.gs); - } - - inline void swapStruct(x86_float_state64_t &x) { - sys::swapByteOrder(x.fpu_reserved[0]); - sys::swapByteOrder(x.fpu_reserved[1]); - // TODO swap: fp_control_t fpu_fcw; - // TODO swap: fp_status_t fpu_fsw; - sys::swapByteOrder(x.fpu_fop); - sys::swapByteOrder(x.fpu_ip); - sys::swapByteOrder(x.fpu_cs); - sys::swapByteOrder(x.fpu_rsrv2); - sys::swapByteOrder(x.fpu_dp); - sys::swapByteOrder(x.fpu_ds); - sys::swapByteOrder(x.fpu_rsrv3); - sys::swapByteOrder(x.fpu_mxcsr); - sys::swapByteOrder(x.fpu_mxcsrmask); - sys::swapByteOrder(x.fpu_reserved1); - } - - inline void swapStruct(x86_exception_state64_t &x) { - sys::swapByteOrder(x.trapno); - sys::swapByteOrder(x.cpu); - sys::swapByteOrder(x.err); - sys::swapByteOrder(x.faultvaddr); - } - - struct x86_state_hdr_t { - uint32_t flavor; - uint32_t count; - }; - - struct x86_thread_state_t { - x86_state_hdr_t tsh; - union { - x86_thread_state64_t ts64; - x86_thread_state32_t ts32; - } uts; - }; - - struct x86_float_state_t { - x86_state_hdr_t fsh; - union { - x86_float_state64_t fs64; - } ufs; - }; - - struct x86_exception_state_t { - x86_state_hdr_t esh; - union { - x86_exception_state64_t es64; - } ues; - }; - - inline void swapStruct(x86_state_hdr_t &x) { - sys::swapByteOrder(x.flavor); - sys::swapByteOrder(x.count); - } - - enum X86ThreadFlavors { - x86_THREAD_STATE32 = 1, - x86_FLOAT_STATE32 = 2, - x86_EXCEPTION_STATE32 = 3, - x86_THREAD_STATE64 = 4, - x86_FLOAT_STATE64 = 5, - x86_EXCEPTION_STATE64 = 6, - x86_THREAD_STATE = 7, - x86_FLOAT_STATE = 8, - x86_EXCEPTION_STATE = 9, - x86_DEBUG_STATE32 = 10, - x86_DEBUG_STATE64 = 11, - x86_DEBUG_STATE = 12 - }; - - inline void swapStruct(x86_thread_state_t &x) { - swapStruct(x.tsh); - if (x.tsh.flavor == x86_THREAD_STATE64) - swapStruct(x.uts.ts64); - } - - inline void swapStruct(x86_float_state_t &x) { - swapStruct(x.fsh); - if (x.fsh.flavor == x86_FLOAT_STATE64) - swapStruct(x.ufs.fs64); - } - - inline void swapStruct(x86_exception_state_t &x) { - swapStruct(x.esh); - if (x.esh.flavor == x86_EXCEPTION_STATE64) - swapStruct(x.ues.es64); - } - - const uint32_t x86_THREAD_STATE32_COUNT = - sizeof(x86_thread_state32_t) / sizeof(uint32_t); - - const uint32_t x86_THREAD_STATE64_COUNT = - sizeof(x86_thread_state64_t) / sizeof(uint32_t); - const uint32_t x86_FLOAT_STATE64_COUNT = - sizeof(x86_float_state64_t) / sizeof(uint32_t); - const uint32_t x86_EXCEPTION_STATE64_COUNT = - sizeof(x86_exception_state64_t) / sizeof(uint32_t); - - const uint32_t x86_THREAD_STATE_COUNT = - sizeof(x86_thread_state_t) / sizeof(uint32_t); - const uint32_t x86_FLOAT_STATE_COUNT = - sizeof(x86_float_state_t) / sizeof(uint32_t); - const uint32_t x86_EXCEPTION_STATE_COUNT = - sizeof(x86_exception_state_t) / sizeof(uint32_t); - - struct arm_thread_state32_t { - uint32_t r[13]; - uint32_t sp; - uint32_t lr; - uint32_t pc; - uint32_t cpsr; - }; - - inline void swapStruct(arm_thread_state32_t &x) { - for (int i = 0; i < 13; i++) - sys::swapByteOrder(x.r[i]); - sys::swapByteOrder(x.sp); - sys::swapByteOrder(x.lr); - sys::swapByteOrder(x.pc); - sys::swapByteOrder(x.cpsr); - } - - struct arm_thread_state64_t { - uint64_t x[29]; - uint64_t fp; - uint64_t lr; - uint64_t sp; - uint64_t pc; - uint32_t cpsr; - uint32_t pad; - }; - - inline void swapStruct(arm_thread_state64_t &x) { - for (int i = 0; i < 29; i++) - sys::swapByteOrder(x.x[i]); - sys::swapByteOrder(x.fp); - sys::swapByteOrder(x.lr); - sys::swapByteOrder(x.sp); - sys::swapByteOrder(x.pc); - sys::swapByteOrder(x.cpsr); - } - - struct arm_state_hdr_t { - uint32_t flavor; - uint32_t count; - }; - - struct arm_thread_state_t { - arm_state_hdr_t tsh; - union { - arm_thread_state32_t ts32; - } uts; - }; - - inline void swapStruct(arm_state_hdr_t &x) { - sys::swapByteOrder(x.flavor); - sys::swapByteOrder(x.count); - } - - enum ARMThreadFlavors { - ARM_THREAD_STATE = 1, - ARM_VFP_STATE = 2, - ARM_EXCEPTION_STATE = 3, - ARM_DEBUG_STATE = 4, - ARN_THREAD_STATE_NONE = 5, - ARM_THREAD_STATE64 = 6, - ARM_EXCEPTION_STATE64 = 7 - }; - - inline void swapStruct(arm_thread_state_t &x) { - swapStruct(x.tsh); - if (x.tsh.flavor == ARM_THREAD_STATE) - swapStruct(x.uts.ts32); - } - - const uint32_t ARM_THREAD_STATE_COUNT = - sizeof(arm_thread_state32_t) / sizeof(uint32_t); - - const uint32_t ARM_THREAD_STATE64_COUNT = - sizeof(arm_thread_state64_t) / sizeof(uint32_t); - - struct ppc_thread_state32_t { - uint32_t srr0; - uint32_t srr1; - uint32_t r0; - uint32_t r1; - uint32_t r2; - uint32_t r3; - uint32_t r4; - uint32_t r5; - uint32_t r6; - uint32_t r7; - uint32_t r8; - uint32_t r9; - uint32_t r10; - uint32_t r11; - uint32_t r12; - uint32_t r13; - uint32_t r14; - uint32_t r15; - uint32_t r16; - uint32_t r17; - uint32_t r18; - uint32_t r19; - uint32_t r20; - uint32_t r21; - uint32_t r22; - uint32_t r23; - uint32_t r24; - uint32_t r25; - uint32_t r26; - uint32_t r27; - uint32_t r28; - uint32_t r29; - uint32_t r30; - uint32_t r31; - uint32_t ct; - uint32_t xer; - uint32_t lr; - uint32_t ctr; - uint32_t mq; - uint32_t vrsave; - }; - - inline void swapStruct(ppc_thread_state32_t &x) { - sys::swapByteOrder(x.srr0); - sys::swapByteOrder(x.srr1); - sys::swapByteOrder(x.r0); - sys::swapByteOrder(x.r1); - sys::swapByteOrder(x.r2); - sys::swapByteOrder(x.r3); - sys::swapByteOrder(x.r4); - sys::swapByteOrder(x.r5); - sys::swapByteOrder(x.r6); - sys::swapByteOrder(x.r7); - sys::swapByteOrder(x.r8); - sys::swapByteOrder(x.r9); - sys::swapByteOrder(x.r10); - sys::swapByteOrder(x.r11); - sys::swapByteOrder(x.r12); - sys::swapByteOrder(x.r13); - sys::swapByteOrder(x.r14); - sys::swapByteOrder(x.r15); - sys::swapByteOrder(x.r16); - sys::swapByteOrder(x.r17); - sys::swapByteOrder(x.r18); - sys::swapByteOrder(x.r19); - sys::swapByteOrder(x.r20); - sys::swapByteOrder(x.r21); - sys::swapByteOrder(x.r22); - sys::swapByteOrder(x.r23); - sys::swapByteOrder(x.r24); - sys::swapByteOrder(x.r25); - sys::swapByteOrder(x.r26); - sys::swapByteOrder(x.r27); - sys::swapByteOrder(x.r28); - sys::swapByteOrder(x.r29); - sys::swapByteOrder(x.r30); - sys::swapByteOrder(x.r31); - sys::swapByteOrder(x.ct); - sys::swapByteOrder(x.xer); - sys::swapByteOrder(x.lr); - sys::swapByteOrder(x.ctr); - sys::swapByteOrder(x.mq); - sys::swapByteOrder(x.vrsave); - } - - struct ppc_state_hdr_t { - uint32_t flavor; - uint32_t count; - }; - - struct ppc_thread_state_t { - ppc_state_hdr_t tsh; - union { - ppc_thread_state32_t ts32; - } uts; - }; - - inline void swapStruct(ppc_state_hdr_t &x) { - sys::swapByteOrder(x.flavor); - sys::swapByteOrder(x.count); - } - - enum PPCThreadFlavors { - PPC_THREAD_STATE = 1, - PPC_FLOAT_STATE = 2, - PPC_EXCEPTION_STATE = 3, - PPC_VECTOR_STATE = 4, - PPC_THREAD_STATE64 = 5, - PPC_EXCEPTION_STATE64 = 6, - PPC_THREAD_STATE_NONE = 7 - }; - - inline void swapStruct(ppc_thread_state_t &x) { - swapStruct(x.tsh); - if (x.tsh.flavor == PPC_THREAD_STATE) - swapStruct(x.uts.ts32); - } - - const uint32_t PPC_THREAD_STATE_COUNT = - sizeof(ppc_thread_state32_t) / sizeof(uint32_t); - - // Define a union of all load command structs - #define LOAD_COMMAND_STRUCT(LCStruct) LCStruct LCStruct##_data; - - union macho_load_command { - #include "llvm/Support/MachO.def" - }; - - } // end namespace MachO -} // end namespace llvm - -#endif diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h index 7f07e8cc3a51e..bb840380d4d38 100644 --- a/include/llvm/Support/MathExtras.h +++ b/include/llvm/Support/MathExtras.h @@ -20,8 +20,8 @@ #include <cassert> #include <climits> #include <cstring> -#include <type_traits> #include <limits> +#include <type_traits> #ifdef _MSC_VER #include <intrin.h> diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h index e8bdc3e89fa7c..73f0251a6b6e3 100644 --- a/include/llvm/Support/MemoryBuffer.h +++ b/include/llvm/Support/MemoryBuffer.h @@ -14,14 +14,14 @@ #ifndef LLVM_SUPPORT_MEMORYBUFFER_H #define LLVM_SUPPORT_MEMORYBUFFER_H +#include "llvm-c/Types.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/ErrorOr.h" -#include "llvm-c/Types.h" -#include <memory> #include <cstddef> #include <cstdint> +#include <memory> namespace llvm { diff --git a/include/llvm/Support/Solaris.h b/include/llvm/Support/Solaris.h index b082285324895..88d83014c468b 100644 --- a/include/llvm/Support/Solaris.h +++ b/include/llvm/Support/Solaris.h @@ -14,8 +14,8 @@ #ifndef LLVM_SUPPORT_SOLARIS_H #define LLVM_SUPPORT_SOLARIS_H -#include <sys/types.h> #include <sys/regset.h> +#include <sys/types.h> /* Solaris doesn't have endian.h. SPARC is the only supported big-endian ISA. */ #define BIG_ENDIAN 4321 diff --git a/include/llvm/Support/SourceMgr.h b/include/llvm/Support/SourceMgr.h index cb90d968c44c5..399f8dcd76fca 100644 --- a/include/llvm/Support/SourceMgr.h +++ b/include/llvm/Support/SourceMgr.h @@ -49,7 +49,7 @@ public: /// Clients that want to handle their own diagnostics in a custom way can /// register a function pointer+context as a diagnostic handler. /// It gets called each time PrintMessage is invoked. - typedef void (*DiagHandlerTy)(const SMDiagnostic &, void *Context); + using DiagHandlerTy = void (*)(const SMDiagnostic &, void *Context); private: struct SrcBuffer { diff --git a/include/llvm/Support/StringPool.h b/include/llvm/Support/StringPool.h index 2ec0c3b76c11f..bb5fd07f0d009 100644 --- a/include/llvm/Support/StringPool.h +++ b/include/llvm/Support/StringPool.h @@ -1,4 +1,4 @@ -//===-- StringPool.h - Interned string pool ---------------------*- C++ -*-===// +//===- StringPool.h - Interned string pool ----------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -30,6 +30,7 @@ #define LLVM_SUPPORT_STRINGPOOL_H #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" #include <cassert> namespace llvm { @@ -43,17 +44,17 @@ namespace llvm { /// PooledString - This is the value of an entry in the pool's interning /// table. struct PooledString { - StringPool *Pool; ///< So the string can remove itself. - unsigned Refcount; ///< Number of referencing PooledStringPtrs. + StringPool *Pool = nullptr; ///< So the string can remove itself. + unsigned Refcount = 0; ///< Number of referencing PooledStringPtrs. public: - PooledString() : Pool(nullptr), Refcount(0) { } + PooledString() = default; }; friend class PooledStringPtr; - typedef StringMap<PooledString> table_t; - typedef StringMapEntry<PooledString> entry_t; + using table_t = StringMap<PooledString>; + using entry_t = StringMapEntry<PooledString>; table_t InternTable; public: @@ -76,11 +77,12 @@ namespace llvm { /// a single pointer, but it does have reference-counting overhead when /// copied. class PooledStringPtr { - typedef StringPool::entry_t entry_t; - entry_t *S; + using entry_t = StringPool::entry_t; + + entry_t *S = nullptr; public: - PooledStringPtr() : S(nullptr) {} + PooledStringPtr() = default; explicit PooledStringPtr(entry_t *E) : S(E) { if (S) ++S->getValue().Refcount; @@ -133,6 +135,6 @@ namespace llvm { inline bool operator!=(const PooledStringPtr &That) const { return S != That.S; } }; -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_SUPPORT_STRINGPOOL_H diff --git a/include/llvm/Support/TargetRegistry.h b/include/llvm/Support/TargetRegistry.h index bd68d24144875..9e9a91b0abdab 100644 --- a/include/llvm/Support/TargetRegistry.h +++ b/include/llvm/Support/TargetRegistry.h @@ -20,10 +20,10 @@ #define LLVM_SUPPORT_TARGETREGISTRY_H #include "llvm-c/Disassembler.h" -#include "llvm/ADT/iterator_range.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" @@ -598,7 +598,7 @@ struct TargetRegistry { /// printRegisteredTargetsForVersion - Print the registered targets /// appropriately for inclusion in a tool's version output. - static void printRegisteredTargetsForVersion(); + static void printRegisteredTargetsForVersion(raw_ostream &OS); /// @name Registry Access /// @{ diff --git a/include/llvm/Support/Wasm.h b/include/llvm/Support/Wasm.h deleted file mode 100644 index e3831827062cb..0000000000000 --- a/include/llvm/Support/Wasm.h +++ /dev/null @@ -1,205 +0,0 @@ -//===- Wasm.h - Wasm object file format -------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines manifest constants for the wasm object file format. -// See: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_WASM_H -#define LLVM_SUPPORT_WASM_H - -#include "llvm/ADT/ArrayRef.h" - -namespace llvm { -namespace wasm { - -// Object file magic string. -const char WasmMagic[] = {'\0', 'a', 's', 'm'}; -// Wasm binary format version -const uint32_t WasmVersion = 0x1; -// Wasm uses a 64k page size -const uint32_t WasmPageSize = 65536; - -struct WasmObjectHeader { - StringRef Magic; - uint32_t Version; -}; - -struct WasmSignature { - std::vector<int32_t> ParamTypes; - int32_t ReturnType; -}; - -struct WasmExport { - StringRef Name; - uint32_t Kind; - uint32_t Index; -}; - -struct WasmLimits { - uint32_t Flags; - uint32_t Initial; - uint32_t Maximum; -}; - -struct WasmTable { - int32_t ElemType; - WasmLimits Limits; -}; - -struct WasmInitExpr { - uint8_t Opcode; - union { - int32_t Int32; - int64_t Int64; - int32_t Float32; - int64_t Float64; - uint32_t Global; - } Value; -}; - -struct WasmGlobal { - int32_t Type; - bool Mutable; - WasmInitExpr InitExpr; -}; - -struct WasmImport { - StringRef Module; - StringRef Field; - uint32_t Kind; - union { - uint32_t SigIndex; - WasmGlobal Global; - WasmTable Table; - WasmLimits Memory; - }; -}; - -struct WasmLocalDecl { - int32_t Type; - uint32_t Count; -}; - -struct WasmFunction { - std::vector<WasmLocalDecl> Locals; - ArrayRef<uint8_t> Body; -}; - -struct WasmDataSegment { - uint32_t Index; - WasmInitExpr Offset; - ArrayRef<uint8_t> Content; -}; - -struct WasmElemSegment { - uint32_t TableIndex; - WasmInitExpr Offset; - std::vector<uint32_t> Functions; -}; - -struct WasmRelocation { - uint32_t Type; // The type of the relocation. - int32_t Index; // Index into function to global index space. - uint64_t Offset; // Offset from the start of the section. - int64_t Addend; // A value to add to the symbol. -}; - -enum : unsigned { - WASM_SEC_CUSTOM = 0, // Custom / User-defined section - WASM_SEC_TYPE = 1, // Function signature declarations - WASM_SEC_IMPORT = 2, // Import declarations - WASM_SEC_FUNCTION = 3, // Function declarations - WASM_SEC_TABLE = 4, // Indirect function table and other tables - WASM_SEC_MEMORY = 5, // Memory attributes - WASM_SEC_GLOBAL = 6, // Global declarations - WASM_SEC_EXPORT = 7, // Exports - WASM_SEC_START = 8, // Start function declaration - WASM_SEC_ELEM = 9, // Elements section - WASM_SEC_CODE = 10, // Function bodies (code) - WASM_SEC_DATA = 11 // Data segments -}; - -// Type immediate encodings used in various contexts. -enum { - WASM_TYPE_I32 = -0x01, - WASM_TYPE_I64 = -0x02, - WASM_TYPE_F32 = -0x03, - WASM_TYPE_F64 = -0x04, - WASM_TYPE_ANYFUNC = -0x10, - WASM_TYPE_FUNC = -0x20, - WASM_TYPE_NORESULT = -0x40, // for blocks with no result values -}; - -// Kinds of externals (for imports and exports). -enum : unsigned { - WASM_EXTERNAL_FUNCTION = 0x0, - WASM_EXTERNAL_TABLE = 0x1, - WASM_EXTERNAL_MEMORY = 0x2, - WASM_EXTERNAL_GLOBAL = 0x3, -}; - -// Opcodes used in initializer expressions. -enum : unsigned { - WASM_OPCODE_END = 0x0b, - WASM_OPCODE_GET_GLOBAL = 0x23, - WASM_OPCODE_I32_CONST = 0x41, - WASM_OPCODE_I64_CONST = 0x42, - WASM_OPCODE_F32_CONST = 0x43, - WASM_OPCODE_F64_CONST = 0x44, -}; - -enum : unsigned { - WASM_NAMES_FUNCTION = 0x1, - WASM_NAMES_LOCAL = 0x2, -}; - -enum : unsigned { - WASM_LIMITS_FLAG_HAS_MAX = 0x1, -}; - -// Subset of types that a value can have -enum class ValType { - I32 = WASM_TYPE_I32, - I64 = WASM_TYPE_I64, - F32 = WASM_TYPE_F32, - F64 = WASM_TYPE_F64, -}; - -// Linking metadata kinds. -enum : unsigned { - WASM_STACK_POINTER = 0x1, -}; - -#define WASM_RELOC(name, value) name = value, - -enum : unsigned { -#include "WasmRelocs/WebAssembly.def" -}; - -#undef WASM_RELOC - -struct Global { - ValType Type; - bool Mutable; - - // The initial value for this global is either the value of an imported - // global, in which case InitialModule and InitialName specify the global - // import, or a value, in which case InitialModule is empty and InitialValue - // holds the value. - StringRef InitialModule; - StringRef InitialName; - uint64_t InitialValue; -}; - -} // end namespace wasm -} // end namespace llvm - -#endif diff --git a/include/llvm/Support/WasmRelocs/WebAssembly.def b/include/llvm/Support/WasmRelocs/WebAssembly.def deleted file mode 100644 index da64e025478de..0000000000000 --- a/include/llvm/Support/WasmRelocs/WebAssembly.def +++ /dev/null @@ -1,13 +0,0 @@ - -#ifndef WASM_RELOC -#error "WASM_RELOC must be defined" -#endif - -WASM_RELOC(R_WEBASSEMBLY_FUNCTION_INDEX_LEB, 0) -WASM_RELOC(R_WEBASSEMBLY_TABLE_INDEX_SLEB, 1) -WASM_RELOC(R_WEBASSEMBLY_TABLE_INDEX_I32, 2) -WASM_RELOC(R_WEBASSEMBLY_GLOBAL_ADDR_LEB, 3) -WASM_RELOC(R_WEBASSEMBLY_GLOBAL_ADDR_SLEB, 4) -WASM_RELOC(R_WEBASSEMBLY_GLOBAL_ADDR_I32, 5) -WASM_RELOC(R_WEBASSEMBLY_TYPE_INDEX_LEB, 6) -WASM_RELOC(R_WEBASSEMBLY_GLOBAL_INDEX_LEB, 7) diff --git a/include/llvm/Support/raw_sha1_ostream.h b/include/llvm/Support/raw_sha1_ostream.h index 329ef9fd069bc..bd55d98b7c1d6 100644 --- a/include/llvm/Support/raw_sha1_ostream.h +++ b/include/llvm/Support/raw_sha1_ostream.h @@ -14,9 +14,9 @@ #ifndef LLVM_SUPPORT_RAW_SHA1_OSTREAM_H #define LLVM_SUPPORT_RAW_SHA1_OSTREAM_H -#include "llvm/Support/raw_ostream.h" -#include "llvm/Support/SHA1.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/SHA1.h" +#include "llvm/Support/raw_ostream.h" namespace llvm { diff --git a/include/llvm/Support/type_traits.h b/include/llvm/Support/type_traits.h index ce4bbf8cb2cc5..cc08783588009 100644 --- a/include/llvm/Support/type_traits.h +++ b/include/llvm/Support/type_traits.h @@ -14,11 +14,10 @@ #ifndef LLVM_SUPPORT_TYPE_TRAITS_H #define LLVM_SUPPORT_TYPE_TRAITS_H +#include "llvm/Support/Compiler.h" #include <type_traits> #include <utility> -#include "llvm/Support/Compiler.h" - #ifndef __has_feature #define LLVM_DEFINED_HAS_FEATURE #define __has_feature(x) 0 @@ -51,7 +50,7 @@ struct isPodLike { // std::pair's are pod-like if their elements are. template<typename T, typename U> -struct isPodLike<std::pair<T, U> > { +struct isPodLike<std::pair<T, U>> { static const bool value = isPodLike<T>::value && isPodLike<U>::value; }; @@ -63,7 +62,7 @@ struct isPodLike<std::pair<T, U> > { /// Also note that enum classes aren't implicitly convertible to integral types, /// the value may therefore need to be explicitly converted before being used. template <typename T> class is_integral_or_enum { - typedef typename std::remove_reference<T>::type UnderlyingT; + using UnderlyingT = typename std::remove_reference<T>::type; public: static const bool value = @@ -76,23 +75,23 @@ public: /// \brief If T is a pointer, just return it. If it is not, return T&. template<typename T, typename Enable = void> -struct add_lvalue_reference_if_not_pointer { typedef T &type; }; +struct add_lvalue_reference_if_not_pointer { using type = T &; }; template <typename T> struct add_lvalue_reference_if_not_pointer< T, typename std::enable_if<std::is_pointer<T>::value>::type> { - typedef T type; + using type = T; }; /// \brief If T is a pointer to X, return a pointer to const X. If it is not, /// return const T. template<typename T, typename Enable = void> -struct add_const_past_pointer { typedef const T type; }; +struct add_const_past_pointer { using type = const T; }; template <typename T> struct add_const_past_pointer< T, typename std::enable_if<std::is_pointer<T>::value>::type> { - typedef const typename std::remove_pointer<T>::type *type; + using type = const typename std::remove_pointer<T>::type *; }; template <typename T, typename Enable = void> @@ -104,7 +103,8 @@ struct const_pointer_or_const_ref< T, typename std::enable_if<std::is_pointer<T>::value>::type> { using type = typename add_const_past_pointer<T>::type; }; -} + +} // end namespace llvm // If the compiler supports detecting whether a class is final, define // an LLVM_IS_FINAL macro. If it cannot be defined properly, this @@ -119,4 +119,4 @@ struct const_pointer_or_const_ref< #undef __has_feature #endif -#endif +#endif // LLVM_SUPPORT_TYPE_TRAITS_H |