aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/BinaryFormat
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-18 20:10:56 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-18 20:10:56 +0000
commit044eb2f6afba375a914ac9d8024f8f5142bb912e (patch)
tree1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /include/llvm/BinaryFormat
parenteb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff)
downloadsrc-044eb2f6afba375a914ac9d8024f8f5142bb912e.tar.gz
src-044eb2f6afba375a914ac9d8024f8f5142bb912e.zip
Vendor import of llvm trunk r321017:vendor/llvm/llvm-trunk-r321017
Notes
Notes: svn path=/vendor/llvm/dist/; revision=326938 svn path=/vendor/llvm/llvm-trunk-r321017/; revision=326939; tag=vendor/llvm/llvm-trunk-r321017
Diffstat (limited to 'include/llvm/BinaryFormat')
-rw-r--r--include/llvm/BinaryFormat/COFF.h41
-rw-r--r--include/llvm/BinaryFormat/Dwarf.def40
-rw-r--r--include/llvm/BinaryFormat/Dwarf.h57
-rw-r--r--include/llvm/BinaryFormat/ELF.h120
-rw-r--r--include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def1
-rw-r--r--include/llvm/BinaryFormat/ELFRelocs/ARC.def74
-rw-r--r--include/llvm/BinaryFormat/ELFRelocs/AVR.def5
-rw-r--r--include/llvm/BinaryFormat/ELFRelocs/RISCV.def9
-rw-r--r--include/llvm/BinaryFormat/MachO.h18
-rw-r--r--include/llvm/BinaryFormat/Wasm.h27
-rw-r--r--include/llvm/BinaryFormat/WasmRelocs/WebAssembly.def6
11 files changed, 322 insertions, 76 deletions
diff --git a/include/llvm/BinaryFormat/COFF.h b/include/llvm/BinaryFormat/COFF.h
index b395db6eaa83..e6bb50cadb12 100644
--- a/include/llvm/BinaryFormat/COFF.h
+++ b/include/llvm/BinaryFormat/COFF.h
@@ -91,7 +91,7 @@ struct BigObjHeader {
uint32_t NumberOfSymbols;
};
-enum MachineTypes {
+enum MachineTypes : unsigned {
MT_Invalid = 0xffff,
IMAGE_FILE_MACHINE_UNKNOWN = 0x0,
@@ -118,7 +118,7 @@ enum MachineTypes {
IMAGE_FILE_MACHINE_WCEMIPSV2 = 0x169
};
-enum Characteristics {
+enum Characteristics : unsigned {
C_Invalid = 0,
/// The file does not contain base relocations and must be loaded at its
@@ -158,7 +158,7 @@ enum Characteristics {
IMAGE_FILE_BYTES_REVERSED_HI = 0x8000
};
-enum ResourceTypeID {
+enum ResourceTypeID : unsigned {
RID_Cursor = 1,
RID_Bitmap = 2,
RID_Icon = 3,
@@ -234,7 +234,7 @@ enum SymbolStorageClass {
IMAGE_SYM_CLASS_CLR_TOKEN = 107
};
-enum SymbolBaseType {
+enum SymbolBaseType : unsigned {
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).
@@ -253,7 +253,7 @@ enum SymbolBaseType {
IMAGE_SYM_TYPE_DWORD = 15 ///< An unsigned 4-byte integer.
};
-enum SymbolComplexType {
+enum SymbolComplexType : unsigned {
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.
@@ -325,7 +325,7 @@ struct relocation {
uint16_t Type;
};
-enum RelocationTypeI386 {
+enum RelocationTypeI386 : unsigned {
IMAGE_REL_I386_ABSOLUTE = 0x0000,
IMAGE_REL_I386_DIR16 = 0x0001,
IMAGE_REL_I386_REL16 = 0x0002,
@@ -339,7 +339,7 @@ enum RelocationTypeI386 {
IMAGE_REL_I386_REL32 = 0x0014
};
-enum RelocationTypeAMD64 {
+enum RelocationTypeAMD64 : unsigned {
IMAGE_REL_AMD64_ABSOLUTE = 0x0000,
IMAGE_REL_AMD64_ADDR64 = 0x0001,
IMAGE_REL_AMD64_ADDR32 = 0x0002,
@@ -359,7 +359,7 @@ enum RelocationTypeAMD64 {
IMAGE_REL_AMD64_SSPAN32 = 0x0010
};
-enum RelocationTypesARM {
+enum RelocationTypesARM : unsigned {
IMAGE_REL_ARM_ABSOLUTE = 0x0000,
IMAGE_REL_ARM_ADDR32 = 0x0001,
IMAGE_REL_ARM_ADDR32NB = 0x0002,
@@ -377,7 +377,7 @@ enum RelocationTypesARM {
IMAGE_REL_ARM_BLX23T = 0x0015
};
-enum RelocationTypesARM64 {
+enum RelocationTypesARM64 : unsigned {
IMAGE_REL_ARM64_ABSOLUTE = 0x0000,
IMAGE_REL_ARM64_ADDR32 = 0x0001,
IMAGE_REL_ARM64_ADDR32NB = 0x0002,
@@ -397,7 +397,7 @@ enum RelocationTypesARM64 {
IMAGE_REL_ARM64_BRANCH14 = 0x0010,
};
-enum COMDATType {
+enum COMDATType : unsigned {
IMAGE_COMDAT_SELECT_NODUPLICATES = 1,
IMAGE_COMDAT_SELECT_ANY,
IMAGE_COMDAT_SELECT_SAME_SIZE,
@@ -430,7 +430,7 @@ struct AuxiliaryWeakExternal {
uint8_t unused[10];
};
-enum WeakExternalCharacteristics {
+enum WeakExternalCharacteristics : unsigned {
IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY = 1,
IMAGE_WEAK_EXTERN_SEARCH_LIBRARY = 2,
IMAGE_WEAK_EXTERN_SEARCH_ALIAS = 3
@@ -572,7 +572,7 @@ struct DataDirectory {
uint32_t Size;
};
-enum DataDirectoryIndex {
+enum DataDirectoryIndex : unsigned {
EXPORT_TABLE = 0,
IMPORT_TABLE,
RESOURCE_TABLE,
@@ -592,7 +592,7 @@ enum DataDirectoryIndex {
NUM_DATA_DIRECTORIES
};
-enum WindowsSubsystem {
+enum WindowsSubsystem : unsigned {
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.
@@ -611,7 +611,7 @@ enum WindowsSubsystem {
IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16 ///< A BCD application.
};
-enum DLLCharacteristics {
+enum DLLCharacteristics : unsigned {
/// ASLR with 64 bit address space.
IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA = 0x0020,
/// DLL can be relocated at load time.
@@ -637,7 +637,7 @@ enum DLLCharacteristics {
IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000
};
-enum DebugType {
+enum DebugType : unsigned {
IMAGE_DEBUG_TYPE_UNKNOWN = 0,
IMAGE_DEBUG_TYPE_COFF = 1,
IMAGE_DEBUG_TYPE_CODEVIEW = 2,
@@ -657,7 +657,7 @@ enum DebugType {
IMAGE_DEBUG_TYPE_REPRO = 16,
};
-enum BaseRelocationType {
+enum BaseRelocationType : unsigned {
IMAGE_REL_BASED_ABSOLUTE = 0,
IMAGE_REL_BASED_HIGH = 1,
IMAGE_REL_BASED_LOW = 2,
@@ -670,9 +670,13 @@ enum BaseRelocationType {
IMAGE_REL_BASED_DIR64 = 10
};
-enum ImportType { IMPORT_CODE = 0, IMPORT_DATA = 1, IMPORT_CONST = 2 };
+enum ImportType : unsigned {
+ IMPORT_CODE = 0,
+ IMPORT_DATA = 1,
+ IMPORT_CONST = 2
+};
-enum ImportNameType {
+enum ImportNameType : unsigned {
/// 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
@@ -707,6 +711,7 @@ struct ImportHeader {
enum CodeViewIdentifiers {
DEBUG_SECTION_MAGIC = 0x4,
+ DEBUG_HASHES_SECTION_MAGIC = 0x133C9C5
};
inline bool isReservedSectionNumber(int32_t SectionNumber) {
diff --git a/include/llvm/BinaryFormat/Dwarf.def b/include/llvm/BinaryFormat/Dwarf.def
index 3df3300de466..3ade3ea0d338 100644
--- a/include/llvm/BinaryFormat/Dwarf.def
+++ b/include/llvm/BinaryFormat/Dwarf.def
@@ -20,7 +20,7 @@
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)
+ defined HANDLE_DW_UT || defined HANDLE_DWARF_SECTION)
#error "Missing macro definition of HANDLE_DW*"
#endif
@@ -92,6 +92,10 @@
#define HANDLE_DW_UT(ID, NAME)
#endif
+#ifndef HANDLE_DWARF_SECTION
+#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_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)
@@ -172,6 +176,8 @@ 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(0x4109, GNU_call_site, 0, GNU)
+HANDLE_DW_TAG(0x410a, GNU_call_site_parameter, 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)
@@ -334,6 +340,8 @@ 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(0x2111, GNU_call_site_value, 0, GNU)
+HANDLE_DW_AT(0x2117, GNU_all_call_sites, 0, GNU)
HANDLE_DW_AT(0x2119, GNU_macros, 0, GNU)
// Extensions for Fission proposal.
HANDLE_DW_AT(0x2130, GNU_dwo_name, 0, GNU)
@@ -819,6 +827,35 @@ HANDLE_DW_UT(0x04, skeleton)
HANDLE_DW_UT(0x05, split_compile)
HANDLE_DW_UT(0x06, split_type)
+// DWARF section types. (enum name, ELF name, ELF DWO name, cmdline name)
+// Note that these IDs don't mean anything.
+// TODO: Add Mach-O and COFF names.
+// Official DWARF sections.
+HANDLE_DWARF_SECTION(DebugAbbrev, ".debug_abbrev", "debug-abbrev")
+HANDLE_DWARF_SECTION(DebugAranges, ".debug_aranges", "debug-aranges")
+HANDLE_DWARF_SECTION(DebugInfo, ".debug_info", "debug-info")
+HANDLE_DWARF_SECTION(DebugTypes, ".debug_types", "debug-types")
+HANDLE_DWARF_SECTION(DebugLine, ".debug_line", "debug-line")
+HANDLE_DWARF_SECTION(DebugLoc, ".debug_loc", "debug-loc")
+HANDLE_DWARF_SECTION(DebugFrame, ".debug_frame", "debug-frame")
+HANDLE_DWARF_SECTION(DebugMacro, ".debug_macro", "debug-macro")
+HANDLE_DWARF_SECTION(DebugRanges, ".debug_ranges", "debug-ranges")
+HANDLE_DWARF_SECTION(DebugPubnames, ".debug_pubnames", "debug-pubnames")
+HANDLE_DWARF_SECTION(DebugPubtypes, ".debug_pubtypes", "debug-pubtypes")
+HANDLE_DWARF_SECTION(DebugGnuPubnames, ".debug_gnu_pubnames", "debug-gnu-pubnames")
+HANDLE_DWARF_SECTION(DebugGnuPubtypes, ".debug_gnu_pubtypes", "debug-gnu-pubtypes")
+HANDLE_DWARF_SECTION(DebugStr, ".debug_str", "debug-str")
+HANDLE_DWARF_SECTION(DebugStrOffsets, ".debug_str_offsets", "debug-str-offsets")
+HANDLE_DWARF_SECTION(DebugCUIndex, ".debug_cu_index", "debug-cu-index")
+HANDLE_DWARF_SECTION(DebugTUIndex, ".debug_tu_index", "debug-tu-index")
+// Vendor extensions.
+HANDLE_DWARF_SECTION(AppleNames, ".apple_names", "apple-names")
+HANDLE_DWARF_SECTION(AppleTypes, ".apple_types", "apple-types")
+HANDLE_DWARF_SECTION(AppleNamespaces, ".apple_namespaces", "apple-namespaces")
+HANDLE_DWARF_SECTION(AppleObjC, ".apple_objc", "apple-objc")
+HANDLE_DWARF_SECTION(GdbIndex, ".gdb_index", "gdb-index")
+
+
#undef HANDLE_DW_TAG
#undef HANDLE_DW_AT
#undef HANDLE_DW_FORM
@@ -836,3 +873,4 @@ HANDLE_DW_UT(0x06, split_type)
#undef HANDLE_DW_CFA
#undef HANDLE_DW_APPLE_PROPERTY
#undef HANDLE_DW_UT
+#undef HANDLE_DWARF_SECTION
diff --git a/include/llvm/BinaryFormat/Dwarf.h b/include/llvm/BinaryFormat/Dwarf.h
index 80456a0808f2..a0e5367b412c 100644
--- a/include/llvm/BinaryFormat/Dwarf.h
+++ b/include/llvm/BinaryFormat/Dwarf.h
@@ -7,13 +7,13 @@
//
//===----------------------------------------------------------------------===//
//
-// \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.
+/// \file
+/// 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.
//
//===----------------------------------------------------------------------===//
@@ -57,12 +57,14 @@ enum LLVMConstants : uint32_t {
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.
+/// 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;
+/// @}
-// Identifier of an invalid DIE offset in the .debug_info section.
+/// Identifier of an invalid DIE offset in the .debug_info section.
const uint32_t DW_INVALID_OFFSET = UINT32_MAX;
enum Tag : uint16_t {
@@ -70,7 +72,7 @@ enum Tag : uint16_t {
#include "llvm/BinaryFormat/Dwarf.def"
DW_TAG_lo_user = 0x4080,
DW_TAG_hi_user = 0xffff,
- DW_TAG_user_base = 0x1000 // Recommended base for user tags.
+ DW_TAG_user_base = 0x1000 ///< Recommended base for user tags.
};
inline bool isType(Tag T) {
@@ -323,6 +325,32 @@ enum UnitType : unsigned char {
DW_UT_hi_user = 0xff
};
+inline bool isUnitType(uint8_t UnitType) {
+ switch (UnitType) {
+ case DW_UT_compile:
+ case DW_UT_type:
+ case DW_UT_partial:
+ case DW_UT_skeleton:
+ case DW_UT_split_compile:
+ case DW_UT_split_type:
+ return true;
+ default:
+ return false;
+ }
+}
+
+inline bool isUnitType(dwarf::Tag T) {
+ switch (T) {
+ case DW_TAG_compile_unit:
+ case DW_TAG_type_unit:
+ case DW_TAG_partial_unit:
+ case DW_TAG_skeleton_unit:
+ return true;
+ default:
+ return false;
+ }
+}
+
// Constants for the DWARF v5 Accelerator Table Proposal
enum AcceleratorTable {
// Data layout descriptors.
@@ -447,11 +475,11 @@ unsigned LanguageVendor(SourceLanguage L);
/// 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
+/// 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.
+/// Describes an entry of the various gnu_pub* debug sections.
///
/// The gnu_pub* kind looks like:
///
@@ -489,6 +517,9 @@ private:
/// Constants that define the DWARF format as 32 or 64 bit.
enum DwarfFormat : uint8_t { DWARF32, DWARF64 };
+/// The Bernstein hash function used by the accelerator tables.
+uint32_t djbHash(StringRef Buffer);
+
} // End of namespace dwarf
} // End of namespace llvm
diff --git a/include/llvm/BinaryFormat/ELF.h b/include/llvm/BinaryFormat/ELF.h
index a4450ee13b40..c902972d93bd 100644
--- a/include/llvm/BinaryFormat/ELF.h
+++ b/include/llvm/BinaryFormat/ELF.h
@@ -335,29 +335,33 @@ enum {
// 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
+ 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_FIRST_ARCH = 64, // First architecture-specific OS ABI
+ ELFOSABI_AMDGPU_HSA = 64, // AMD HSA runtime
+ ELFOSABI_AMDGPU_PAL = 65, // AMD PAL runtime
+ ELFOSABI_AMDGPU_MESA3D = 66, // AMD GCN GPUs (GFX6+) for MESA runtime
+ ELFOSABI_ARM = 97, // ARM
+ ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
+ ELFOSABI_C6000_LINUX = 65, // Linux TMS320C6000
+ ELFOSABI_STANDALONE = 255, // Standalone (embedded) application
+ ELFOSABI_LAST_ARCH = 255 // Last Architecture-specific OS ABI
};
#define ELF_RELOC(name, value) name = value,
@@ -430,6 +434,27 @@ enum {
#include "ELFRelocs/ARM.def"
};
+// ARC Specific e_flags
+enum : unsigned {
+ EF_ARC_MACH_MSK = 0x000000ff,
+ EF_ARC_OSABI_MSK = 0x00000f00,
+ E_ARC_MACH_ARC600 = 0x00000002,
+ E_ARC_MACH_ARC601 = 0x00000004,
+ E_ARC_MACH_ARC700 = 0x00000003,
+ EF_ARC_CPU_ARCV2EM = 0x00000005,
+ EF_ARC_CPU_ARCV2HS = 0x00000006,
+ E_ARC_OSABI_ORIG = 0x00000000,
+ E_ARC_OSABI_V2 = 0x00000200,
+ E_ARC_OSABI_V3 = 0x00000300,
+ E_ARC_OSABI_V4 = 0x00000400,
+ EF_ARC_PIC = 0x00000100
+};
+
+// ELF Relocation types for ARC
+enum {
+#include "ELFRelocs/ARC.def"
+};
+
// AVR specific e_flags
enum : unsigned {
EF_AVR_ARCH_AVR1 = 1,
@@ -559,6 +584,7 @@ enum {
EF_HEXAGON_MACH_V55 = 0x00000005, // Hexagon V55
EF_HEXAGON_MACH_V60 = 0x00000060, // Hexagon V60
EF_HEXAGON_MACH_V62 = 0x00000062, // Hexagon V62
+ EF_HEXAGON_MACH_V65 = 0x00000065, // Hexagon V65
// Highest ISA version flags
EF_HEXAGON_ISA_MACH = 0x00000000, // Same as specified in bits[11:0]
@@ -570,6 +596,7 @@ enum {
EF_HEXAGON_ISA_V55 = 0x00000050, // Hexagon V55 ISA
EF_HEXAGON_ISA_V60 = 0x00000060, // Hexagon V60 ISA
EF_HEXAGON_ISA_V62 = 0x00000062, // Hexagon V62 ISA
+ EF_HEXAGON_ISA_V65 = 0x00000065, // Hexagon V65 ISA
};
// Hexagon-specific section indexes for common small data
@@ -591,6 +618,17 @@ enum {
#include "ELFRelocs/Lanai.def"
};
+// RISCV Specific e_flags
+enum : unsigned {
+ EF_RISCV_RVC = 0x0001,
+ EF_RISCV_FLOAT_ABI = 0x0006,
+ EF_RISCV_FLOAT_ABI_SOFT = 0x0000,
+ EF_RISCV_FLOAT_ABI_SINGLE = 0x0002,
+ EF_RISCV_FLOAT_ABI_DOUBLE = 0x0004,
+ EF_RISCV_FLOAT_ABI_QUAD = 0x0006,
+ EF_RISCV_RVE = 0x0008
+};
+
// ELF Relocation types for RISC-V
enum {
#include "ELFRelocs/RISCV.def"
@@ -611,6 +649,15 @@ enum {
#include "ELFRelocs/WebAssembly.def"
};
+// AMDGPU specific e_flags.
+enum : unsigned {
+ // AMDGPU machine architectures.
+ EF_AMDGPU_ARCH_NONE = 0x00000000, // None/unknown.
+ EF_AMDGPU_ARCH_R600 = 0x00000001, // AMD HD2XXX-HD6XXX GPUs.
+ EF_AMDGPU_ARCH_GCN = 0x00000002, // AMD GCN GFX6+ GPUs.
+ EF_AMDGPU_ARCH = 0x0000000f // EF_AMDGPU_ARCH_XXX selection mask.
+};
+
// ELF Relocation types for AMDGPU
enum {
#include "ELFRelocs/AMDGPU.def"
@@ -685,6 +732,10 @@ enum : unsigned {
SHT_GROUP = 17, // Section group.
SHT_SYMTAB_SHNDX = 18, // Indices for SHN_XINDEX entries.
SHT_LOOS = 0x60000000, // Lowest operating system-specific type.
+ // Android packed relocation section types.
+ // https://android.googlesource.com/platform/bionic/+/6f12bfece5dcc01325e0abba56a46b1bcf991c69/tools/relocation_packer/src/elf_file.cc#37
+ SHT_ANDROID_REL = 0x60000001,
+ SHT_ANDROID_RELA = 0x60000002,
SHT_LLVM_ODRTAB = 0x6fff4c00, // LLVM ODR table.
SHT_GNU_ATTRIBUTES = 0x6ffffff5, // Object attributes.
SHT_GNU_HASH = 0x6ffffff6, // GNU-style hash table.
@@ -1121,6 +1172,13 @@ enum {
DT_LOPROC = 0x70000000, // Start of processor specific tags.
DT_HIPROC = 0x7FFFFFFF, // End of processor specific tags.
+ // Android packed relocation section tags.
+ // https://android.googlesource.com/platform/bionic/+/6f12bfece5dcc01325e0abba56a46b1bcf991c69/tools/relocation_packer/src/elf_file.cc#31
+ DT_ANDROID_REL = 0x6000000F,
+ DT_ANDROID_RELSZ = 0x60000010,
+ DT_ANDROID_RELA = 0x60000011,
+ DT_ANDROID_RELASZ = 0x60000012,
+
DT_GNU_HASH = 0x6FFFFEF5, // Reference to the GNU hash table.
DT_TLSDESC_PLT =
0x6FFFFEF6, // Location of PLT entry for TLS descriptor resolver calls.
@@ -1324,6 +1382,14 @@ enum {
NT_GNU_GOLD_VERSION = 4,
};
+// AMDGPU specific notes.
+enum {
+ // Note types with values between 0 and 9 (inclusive) are reserved.
+ NT_AMD_AMDGPU_HSA_METADATA = 10,
+ NT_AMD_AMDGPU_ISA = 11,
+ NT_AMD_AMDGPU_PAL_METADATA = 12
+};
+
enum {
GNU_ABI_TAG_LINUX = 0,
GNU_ABI_TAG_HURD = 1,
@@ -1334,6 +1400,14 @@ enum {
GNU_ABI_TAG_NACL = 6,
};
+// Android packed relocation group flags.
+enum {
+ RELOCATION_GROUPED_BY_INFO_FLAG = 1,
+ RELOCATION_GROUPED_BY_OFFSET_DELTA_FLAG = 2,
+ RELOCATION_GROUPED_BY_ADDEND_FLAG = 4,
+ RELOCATION_GROUP_HAS_ADDEND_FLAG = 8,
+};
+
// Compressed section header for ELF32.
struct Elf32_Chdr {
Elf32_Word ch_type;
diff --git a/include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def b/include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def
index c66f88d14ec7..00b19c4161d0 100644
--- a/include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def
+++ b/include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def
@@ -14,3 +14,4 @@ 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)
+ELF_RELOC(R_AMDGPU_RELATIVE64, 13)
diff --git a/include/llvm/BinaryFormat/ELFRelocs/ARC.def b/include/llvm/BinaryFormat/ELFRelocs/ARC.def
new file mode 100644
index 000000000000..5691fb3458e2
--- /dev/null
+++ b/include/llvm/BinaryFormat/ELFRelocs/ARC.def
@@ -0,0 +1,74 @@
+
+#ifndef ELF_RELOC
+#error "ELF_RELOC must be defined"
+#endif
+
+ELF_RELOC(R_ARC_NONE, 0)
+ELF_RELOC(R_ARC_8, 1)
+ELF_RELOC(R_ARC_16, 2)
+ELF_RELOC(R_ARC_24, 3)
+ELF_RELOC(R_ARC_32, 4)
+ELF_RELOC(R_ARC_N8, 8)
+ELF_RELOC(R_ARC_N16, 9)
+ELF_RELOC(R_ARC_N24, 10)
+ELF_RELOC(R_ARC_N32, 11)
+ELF_RELOC(R_ARC_SDA, 12)
+ELF_RELOC(R_ARC_SECTOFF, 13)
+ELF_RELOC(R_ARC_S21H_PCREL, 14)
+ELF_RELOC(R_ARC_S21W_PCREL, 15)
+ELF_RELOC(R_ARC_S25H_PCREL, 16)
+ELF_RELOC(R_ARC_S25W_PCREL, 17)
+ELF_RELOC(R_ARC_SDA32, 18)
+ELF_RELOC(R_ARC_SDA_LDST, 19)
+ELF_RELOC(R_ARC_SDA_LDST1, 20)
+ELF_RELOC(R_ARC_SDA_LDST2, 21)
+ELF_RELOC(R_ARC_SDA16_LD, 22)
+ELF_RELOC(R_ARC_SDA16_LD1, 23)
+ELF_RELOC(R_ARC_SDA16_LD2, 24)
+ELF_RELOC(R_ARC_S13_PCREL, 25)
+ELF_RELOC(R_ARC_W, 26)
+ELF_RELOC(R_ARC_32_ME, 27)
+ELF_RELOC(R_ARC_32_ME_S, 105)
+ELF_RELOC(R_ARC_N32_ME, 28)
+ELF_RELOC(R_ARC_SECTOFF_ME, 29)
+ELF_RELOC(R_ARC_SDA32_ME, 30)
+ELF_RELOC(R_ARC_W_ME, 31)
+ELF_RELOC(R_AC_SECTOFF_U8, 35)
+ELF_RELOC(R_AC_SECTOFF_U8_1, 36)
+ELF_RELOC(R_AC_SECTOFF_U8_2, 37)
+ELF_RELOC(R_AC_SECTOFF_S9, 38)
+ELF_RELOC(R_AC_SECTOFF_S9_1, 39)
+ELF_RELOC(R_AC_SECTOFF_S9_2, 40)
+ELF_RELOC(R_ARC_SECTOFF_ME_1, 41)
+ELF_RELOC(R_ARC_SECTOFF_ME_2, 42)
+ELF_RELOC(R_ARC_SECTOFF_1, 43)
+ELF_RELOC(R_ARC_SECTOFF_2, 44)
+ELF_RELOC(R_ARC_SDA_12, 45)
+ELF_RELOC(R_ARC_SDA16_ST2, 48)
+ELF_RELOC(R_ARC_32_PCREL, 49)
+ELF_RELOC(R_ARC_PC32, 50)
+ELF_RELOC(R_ARC_GOT32, 59)
+ELF_RELOC(R_ARC_GOTPC32, 51)
+ELF_RELOC(R_ARC_PLT32, 52)
+ELF_RELOC(R_ARC_COPY, 53)
+ELF_RELOC(R_ARC_GLOB_DAT, 54)
+ELF_RELOC(R_ARC_JMP_SLOT, 55)
+ELF_RELOC(R_ARC_RELATIVE, 56)
+ELF_RELOC(R_ARC_GOTOFF, 57)
+ELF_RELOC(R_ARC_GOTPC, 58)
+ELF_RELOC(R_ARC_S21W_PCREL_PLT, 60)
+ELF_RELOC(R_ARC_S25H_PCREL_PLT, 61)
+ELF_RELOC(R_ARC_JLI_SECTOFF, 63)
+ELF_RELOC(R_ARC_TLS_DTPMOD, 66)
+ELF_RELOC(R_ARC_TLS_TPOFF, 68)
+ELF_RELOC(R_ARC_TLS_GD_GOT, 69)
+ELF_RELOC(R_ARC_TLS_GD_LD, 70)
+ELF_RELOC(R_ARC_TLS_GD_CALL, 71)
+ELF_RELOC(R_ARC_TLS_IE_GOT, 72)
+ELF_RELOC(R_ARC_TLS_DTPOFF, 67)
+ELF_RELOC(R_ARC_TLS_DTPOFF_S9, 73)
+ELF_RELOC(R_ARC_TLS_LE_S9, 74)
+ELF_RELOC(R_ARC_TLS_LE_32, 75)
+ELF_RELOC(R_ARC_S25W_PCREL_PLT, 76)
+ELF_RELOC(R_ARC_S21H_PCREL_PLT, 77)
+ELF_RELOC(R_ARC_NPS_CMEM16, 78)
diff --git a/include/llvm/BinaryFormat/ELFRelocs/AVR.def b/include/llvm/BinaryFormat/ELFRelocs/AVR.def
index 5692d6cb9aa0..696fc60b0f5a 100644
--- a/include/llvm/BinaryFormat/ELFRelocs/AVR.def
+++ b/include/llvm/BinaryFormat/ELFRelocs/AVR.def
@@ -33,8 +33,9 @@ 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_DIFF8, 30)
+ELF_RELOC(R_AVR_DIFF16, 31)
+ELF_RELOC(R_AVR_DIFF32, 32)
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/BinaryFormat/ELFRelocs/RISCV.def b/include/llvm/BinaryFormat/ELFRelocs/RISCV.def
index 9ec4955d26db..5cc4c0ec3029 100644
--- a/include/llvm/BinaryFormat/ELFRelocs/RISCV.def
+++ b/include/llvm/BinaryFormat/ELFRelocs/RISCV.def
@@ -48,3 +48,12 @@ 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)
+ELF_RELOC(R_RISCV_TPREL_I, 49)
+ELF_RELOC(R_RISCV_TPREL_S, 50)
+ELF_RELOC(R_RISCV_RELAX, 51)
+ELF_RELOC(R_RISCV_SUB6, 52)
+ELF_RELOC(R_RISCV_SET6, 53)
+ELF_RELOC(R_RISCV_SET8, 54)
+ELF_RELOC(R_RISCV_SET16, 55)
+ELF_RELOC(R_RISCV_SET32, 56)
+ELF_RELOC(R_RISCV_32_PCREL, 57)
diff --git a/include/llvm/BinaryFormat/MachO.h b/include/llvm/BinaryFormat/MachO.h
index 3529c72acd9d..060fbe162ad2 100644
--- a/include/llvm/BinaryFormat/MachO.h
+++ b/include/llvm/BinaryFormat/MachO.h
@@ -481,7 +481,7 @@ enum RelocationInfoType {
enum { VM_PROT_READ = 0x1, VM_PROT_WRITE = 0x2, VM_PROT_EXECUTE = 0x4 };
// Values for platform field in build_version_command.
-enum {
+enum PlatformType {
PLATFORM_MACOS = 1,
PLATFORM_IOS = 2,
PLATFORM_TVOS = 3,
@@ -1373,19 +1373,19 @@ inline void swapStruct(fvmlib_command &C) {
// Get/Set functions from <mach-o/nlist.h>
-static inline uint16_t GET_LIBRARY_ORDINAL(uint16_t n_desc) {
+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) {
+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) {
+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) {
+inline void SET_COMM_ALIGN(uint16_t &n_desc, uint8_t align) {
n_desc = ((n_desc & 0xf0ffu) | ((align & 0x0fu) << 8u));
}
@@ -1449,15 +1449,13 @@ enum CPUSubTypeX86 {
CPU_SUBTYPE_X86_ARCH1 = 4,
CPU_SUBTYPE_X86_64_H = 8
};
-static inline int CPU_SUBTYPE_INTEL(int Family, int Model) {
+inline int CPU_SUBTYPE_INTEL(int Family, int Model) {
return Family | (Model << 4);
}
-static inline int CPU_SUBTYPE_INTEL_FAMILY(CPUSubTypeX86 ST) {
+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;
-}
+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 {
diff --git a/include/llvm/BinaryFormat/Wasm.h b/include/llvm/BinaryFormat/Wasm.h
index 23e30b7a868d..506cd0393e9a 100644
--- a/include/llvm/BinaryFormat/Wasm.h
+++ b/include/llvm/BinaryFormat/Wasm.h
@@ -91,12 +91,17 @@ struct WasmLocalDecl {
struct WasmFunction {
std::vector<WasmLocalDecl> Locals;
ArrayRef<uint8_t> Body;
+ uint32_t CodeSectionOffset;
+ uint32_t Size;
};
struct WasmDataSegment {
uint32_t MemoryIndex;
WasmInitExpr Offset;
ArrayRef<uint8_t> Content;
+ StringRef Name;
+ uint32_t Alignment;
+ uint32_t Flags;
};
struct WasmElemSegment {
@@ -112,9 +117,14 @@ struct WasmRelocation {
int64_t Addend; // A value to add to the symbol.
};
+struct WasmInitFunc {
+ uint32_t Priority;
+ uint32_t FunctionIndex;
+};
+
struct WasmLinkingData {
uint32_t DataSize;
- uint32_t DataAlignment;
+ std::vector<WasmInitFunc> InitFunctions;
};
enum : unsigned {
@@ -180,15 +190,20 @@ enum class ValType {
// Linking metadata kinds.
enum : unsigned {
- WASM_STACK_POINTER = 0x1,
WASM_SYMBOL_INFO = 0x2,
WASM_DATA_SIZE = 0x3,
- WASM_DATA_ALIGNMENT = 0x4,
+ WASM_SEGMENT_INFO = 0x5,
+ WASM_INIT_FUNCS = 0x6,
};
-enum : unsigned {
- WASM_SYMBOL_FLAG_WEAK = 0x1,
-};
+const unsigned WASM_SYMBOL_BINDING_MASK = 0x3;
+const unsigned WASM_SYMBOL_VISIBILITY_MASK = 0x4;
+
+const unsigned WASM_SYMBOL_BINDING_GLOBAL = 0x0;
+const unsigned WASM_SYMBOL_BINDING_WEAK = 0x1;
+const unsigned WASM_SYMBOL_BINDING_LOCAL = 0x2;
+const unsigned WASM_SYMBOL_VISIBILITY_DEFAULT = 0x0;
+const unsigned WASM_SYMBOL_VISIBILITY_HIDDEN = 0x4;
#define WASM_RELOC(name, value) name = value,
diff --git a/include/llvm/BinaryFormat/WasmRelocs/WebAssembly.def b/include/llvm/BinaryFormat/WasmRelocs/WebAssembly.def
index da64e025478d..d6f0e42b33bf 100644
--- a/include/llvm/BinaryFormat/WasmRelocs/WebAssembly.def
+++ b/include/llvm/BinaryFormat/WasmRelocs/WebAssembly.def
@@ -6,8 +6,8 @@
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_MEMORY_ADDR_LEB, 3)
+WASM_RELOC(R_WEBASSEMBLY_MEMORY_ADDR_SLEB, 4)
+WASM_RELOC(R_WEBASSEMBLY_MEMORY_ADDR_I32, 5)
WASM_RELOC(R_WEBASSEMBLY_TYPE_INDEX_LEB, 6)
WASM_RELOC(R_WEBASSEMBLY_GLOBAL_INDEX_LEB, 7)