ELF.h revision fc61a23506fdad8f38e3437d741a4108339abcfe
1551ccae044b0ff658fe629dd67edd5ffe75d10e8Reid Spencer//===-- llvm/Support/ELF.h - ELF constants and data structures --*- C++ -*-===//
263b3afa98460ce38a1c48d3c44ef6edfdaf37b77Misha Brukman//
36c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke//                     The LLVM Compiler Infrastructure
46c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke//
57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source
67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details.
763b3afa98460ce38a1c48d3c44ef6edfdaf37b77Misha Brukman//
86c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke//===----------------------------------------------------------------------===//
96c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke//
106c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// This header contains common, non-processor-specific data structures and
116c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// constants for the ELF file format.
1263b3afa98460ce38a1c48d3c44ef6edfdaf37b77Misha Brukman//
139a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson// The details of the ELF32 bits in this file are largely based on the Tool
149a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson// Interface Standard (TIS) Executable and Linking Format (ELF) Specification
159a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson// Version 1.2, May 1995. The ELF64 stuff is based on ELF-64 Object File Format
169a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson// Version 1.5, Draft 2, May 1998 as well as OpenBSD header files.
176c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke//
186c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke//===----------------------------------------------------------------------===//
196c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
20551ccae044b0ff658fe629dd67edd5ffe75d10e8Reid Spencer#ifndef LLVM_SUPPORT_ELF_H
21551ccae044b0ff658fe629dd67edd5ffe75d10e8Reid Spencer#define LLVM_SUPPORT_ELF_H
22551ccae044b0ff658fe629dd67edd5ffe75d10e8Reid Spencer
231f6efa3996dd1929fbc129203ce5009b620e6969Michael J. Spencer#include "llvm/Support/DataTypes.h"
246c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke#include <cstring>
256c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
266c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekenamespace llvm {
276c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
286c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekenamespace ELF {
296c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
306c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeketypedef uint32_t Elf32_Addr; // Program address
316c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeketypedef uint16_t Elf32_Half;
326c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeketypedef uint32_t Elf32_Off;  // File offset
336c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeketypedef int32_t  Elf32_Sword;
346c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeketypedef uint32_t Elf32_Word;
356c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
36620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeketypedef uint64_t Elf64_Addr;
37620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeketypedef uint64_t Elf64_Off;
38620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeketypedef int32_t  Elf64_Shalf;
39620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeketypedef int32_t  Elf64_Sword;
40620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeketypedef uint32_t Elf64_Word;
41620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeketypedef int64_t  Elf64_Sxword;
42620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeketypedef uint64_t Elf64_Xword;
43620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeketypedef uint32_t Elf64_Half;
44620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeketypedef uint16_t Elf64_Quarter;
45620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke
466c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// Object file magic string.
47757c1f9d87b516a1e3bc4cd678245b207ae9c559Brian Gaekestatic const char ElfMagic[] = { 0x7f, 'E', 'L', 'F', '\0' };
486c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
499a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson// e_ident size and indices.
509a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilsonenum {
519a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  EI_MAG0       = 0,          // File identification index.
529a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  EI_MAG1       = 1,          // File identification index.
539a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  EI_MAG2       = 2,          // File identification index.
549a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  EI_MAG3       = 3,          // File identification index.
559a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  EI_CLASS      = 4,          // File class.
569a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  EI_DATA       = 5,          // Data encoding.
579a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  EI_VERSION    = 6,          // File version.
589a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  EI_OSABI      = 7,          // OS/ABI identification.
599a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  EI_ABIVERSION = 8,          // ABI version.
609a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  EI_PAD        = 9,          // Start of padding bytes.
619a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  EI_NIDENT     = 16          // Number of bytes in e_ident.
629a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson};
639a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson
646c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekestruct Elf32_Ehdr {
659a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  unsigned char e_ident[EI_NIDENT]; // ELF Identification bytes
666c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Half    e_type;      // Type of file (see ET_* below)
676c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Half    e_machine;   // Required architecture for this file (see EM_*)
686c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word    e_version;   // Must be equal to 1
696c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Addr    e_entry;     // Address to jump to in order to start program
706c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Off     e_phoff;     // Program header table's file offset, in bytes
716c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Off     e_shoff;     // Section header table's file offset, in bytes
726c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word    e_flags;     // Processor-specific flags
736c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Half    e_ehsize;    // Size of ELF header, in bytes
746c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Half    e_phentsize; // Size of an entry in the program header table
756c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Half    e_phnum;     // Number of entries in the program header table
766c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Half    e_shentsize; // Size of an entry in the section header table
776c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Half    e_shnum;     // Number of entries in the section header table
786c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Half    e_shstrndx;  // Sect hdr table index of sect name string table
79fe4591bfc2b147c10d6a7b1a5af56454fb78daceStephen Wilson  bool checkMagic() const {
80314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson    return (memcmp(e_ident, ElfMagic, strlen(ElfMagic))) == 0;
816c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  }
829a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  unsigned char getFileClass() const { return e_ident[EI_CLASS]; }
839a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  unsigned char getDataEncoding() const { return e_ident[EI_DATA]; }
846c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
856c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
86620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke// 64-bit ELF header. Fields are the same as for ELF32, but with different
87620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke// types (see above).
88e9f6f2c0492af8097166f1b7d62f131f20ca5714Brian Gaekestruct Elf64_Ehdr {
899a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  unsigned char e_ident[EI_NIDENT];
90620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Quarter e_type;
91620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Quarter e_machine;
92620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Half    e_version;
93620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Addr    e_entry;
94620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Off     e_phoff;
95620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Off     e_shoff;
96620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Half    e_flags;
97620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Quarter e_ehsize;
98620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Quarter e_phentsize;
99620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Quarter e_phnum;
100620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Quarter e_shentsize;
101620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Quarter e_shnum;
102620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Quarter e_shstrndx;
1039a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  bool checkMagic() const {
1049a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson    return (memcmp(e_ident, ElfMagic, strlen(ElfMagic))) == 0;
1059a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  }
1069a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  unsigned char getFileClass() const { return e_ident[EI_CLASS]; }
1079a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  unsigned char getDataEncoding() const { return e_ident[EI_DATA]; }
108e9f6f2c0492af8097166f1b7d62f131f20ca5714Brian Gaeke};
109620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke
1106c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// File types
1116c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekeenum {
1126c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  ET_NONE   = 0,      // No file type
1136c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  ET_REL    = 1,      // Relocatable file
1146c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  ET_EXEC   = 2,      // Executable file
1156c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  ET_DYN    = 3,      // Shared object file
1166c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  ET_CORE   = 4,      // Core file
1176c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  ET_LOPROC = 0xff00, // Beginning of processor-specific codes
1186c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  ET_HIPROC = 0xffff  // Processor-specific
1196c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
1206c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
1215af8f421b6412e52530608097e39d2602195629fDan Gohman// Versioning
1225af8f421b6412e52530608097e39d2602195629fDan Gohmanenum {
1235af8f421b6412e52530608097e39d2602195629fDan Gohman  EV_NONE = 0,
1245af8f421b6412e52530608097e39d2602195629fDan Gohman  EV_CURRENT = 1
1255af8f421b6412e52530608097e39d2602195629fDan Gohman};
1265af8f421b6412e52530608097e39d2602195629fDan Gohman
1276c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// Machine architectures
1286c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekeenum {
129fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_NONE          = 0, // No machine
130fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_M32           = 1, // AT&T WE 32100
131fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_SPARC         = 2, // SPARC
132fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_386           = 3, // Intel 386
133fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_68K           = 4, // Motorola 68000
134fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_88K           = 5, // Motorola 88000
135fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_486           = 6, // Intel 486 (deprecated)
136fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_860           = 7, // Intel 80860
137fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MIPS          = 8, // MIPS R3000
138fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_S370          = 9, // IBM System/370
139fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MIPS_RS3_LE   = 10, // MIPS RS3000 Little-endian
140fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_PARISC        = 15, // Hewlett-Packard PA-RISC
141fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_VPP500        = 17, // Fujitsu VPP500
142fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_SPARC32PLUS   = 18, // Enhanced instruction set SPARC
143fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_960           = 19, // Intel 80960
144fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_PPC           = 20, // PowerPC
145fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_PPC64         = 21, // PowerPC64
146fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_S390          = 22, // IBM System/390
147fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_SPU           = 23, // IBM SPU/SPC
148fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_V800          = 36, // NEC V800
149fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_FR20          = 37, // Fujitsu FR20
150fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_RH32          = 38, // TRW RH-32
151fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_RCE           = 39, // Motorola RCE
152fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ARM           = 40, // ARM
153fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ALPHA         = 41, // DEC Alpha
154fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_SH            = 42, // Hitachi SH
155fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_SPARCV9       = 43, // SPARC V9
156fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_TRICORE       = 44, // Siemens TriCore
157fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ARC           = 45, // Argonaut RISC Core
158fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_H8_300        = 46, // Hitachi H8/300
159fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_H8_300H       = 47, // Hitachi H8/300H
160fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_H8S           = 48, // Hitachi H8S
161fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_H8_500        = 49, // Hitachi H8/500
162fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_IA_64         = 50, // Intel IA-64 processor architecture
163fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MIPS_X        = 51, // Stanford MIPS-X
164fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_COLDFIRE      = 52, // Motorola ColdFire
165fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_68HC12        = 53, // Motorola M68HC12
166fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MMA           = 54, // Fujitsu MMA Multimedia Accelerator
167fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_PCP           = 55, // Siemens PCP
168fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_NCPU          = 56, // Sony nCPU embedded RISC processor
169fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_NDR1          = 57, // Denso NDR1 microprocessor
170fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_STARCORE      = 58, // Motorola Star*Core processor
171fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ME16          = 59, // Toyota ME16 processor
172fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ST100         = 60, // STMicroelectronics ST100 processor
173fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_TINYJ         = 61, // Advanced Logic Corp. TinyJ embedded processor family
174fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_X86_64        = 62, // AMD x86-64 architecture
175fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_PDSP          = 63, // Sony DSP Processor
176fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_PDP10         = 64, // Digital Equipment Corp. PDP-10
177fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_PDP11         = 65, // Digital Equipment Corp. PDP-11
178fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_FX66          = 66, // Siemens FX66 microcontroller
179fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ST9PLUS       = 67, // STMicroelectronics ST9+ 8/16 bit microcontroller
180fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ST7           = 68, // STMicroelectronics ST7 8-bit microcontroller
181fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_68HC16        = 69, // Motorola MC68HC16 Microcontroller
182fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_68HC11        = 70, // Motorola MC68HC11 Microcontroller
183fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_68HC08        = 71, // Motorola MC68HC08 Microcontroller
184fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_68HC05        = 72, // Motorola MC68HC05 Microcontroller
185fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_SVX           = 73, // Silicon Graphics SVx
186fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ST19          = 74, // STMicroelectronics ST19 8-bit microcontroller
187fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_VAX           = 75, // Digital VAX
188fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_CRIS          = 76, // Axis Communications 32-bit embedded processor
189fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_JAVELIN       = 77, // Infineon Technologies 32-bit embedded processor
190fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_FIREPATH      = 78, // Element 14 64-bit DSP Processor
191fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ZSP           = 79, // LSI Logic 16-bit DSP Processor
192fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MMIX          = 80, // Donald Knuth's educational 64-bit processor
193fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_HUANY         = 81, // Harvard University machine-independent object files
194fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_PRISM         = 82, // SiTera Prism
195fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_AVR           = 83, // Atmel AVR 8-bit microcontroller
196fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_FR30          = 84, // Fujitsu FR30
197fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_D10V          = 85, // Mitsubishi D10V
198fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_D30V          = 86, // Mitsubishi D30V
199fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_V850          = 87, // NEC v850
200fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_M32R          = 88, // Mitsubishi M32R
201fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MN10300       = 89, // Matsushita MN10300
202fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MN10200       = 90, // Matsushita MN10200
203fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_PJ            = 91, // picoJava
204fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_OPENRISC      = 92, // OpenRISC 32-bit embedded processor
205fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ARC_COMPACT   = 93, // ARC International ARCompact processor (old
206fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer                         // spelling/synonym: EM_ARC_A5)
207fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_XTENSA        = 94, // Tensilica Xtensa Architecture
208fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_VIDEOCORE     = 95, // Alphamosaic VideoCore processor
209fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_TMM_GPP       = 96, // Thompson Multimedia General Purpose Processor
210fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_NS32K         = 97, // National Semiconductor 32000 series
211fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_TPC           = 98, // Tenor Network TPC processor
212fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_SNP1K         = 99, // Trebia SNP 1000 processor
213fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ST200         = 100, // STMicroelectronics (www.st.com) ST200
214fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_IP2K          = 101, // Ubicom IP2xxx microcontroller family
215fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MAX           = 102, // MAX Processor
216fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_CR            = 103, // National Semiconductor CompactRISC microprocessor
217fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_F2MC16        = 104, // Fujitsu F2MC16
218fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MSP430        = 105, // Texas Instruments embedded microcontroller msp430
219fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_BLACKFIN      = 106, // Analog Devices Blackfin (DSP) processor
220fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_SE_C33        = 107, // S1C33 Family of Seiko Epson processors
221fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_SEP           = 108, // Sharp embedded microprocessor
222fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ARCA          = 109, // Arca RISC Microprocessor
223fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_UNICORE       = 110, // Microprocessor series from PKU-Unity Ltd. and MPRC
224fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer                          // of Peking University
225fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_EXCESS        = 111, // eXcess: 16/32/64-bit configurable embedded CPU
226fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_DXP           = 112, // Icera Semiconductor Inc. Deep Execution Processor
227fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ALTERA_NIOS2  = 113, // Altera Nios II soft-core processor
228fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_CRX           = 114, // National Semiconductor CompactRISC CRX
229fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_XGATE         = 115, // Motorola XGATE embedded processor
230fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_C166          = 116, // Infineon C16x/XC16x processor
231fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_M16C          = 117, // Renesas M16C series microprocessors
232fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_DSPIC30F      = 118, // Microchip Technology dsPIC30F Digital Signal
233fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer                          // Controller
234fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_CE            = 119, // Freescale Communication Engine RISC core
235fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_M32C          = 120, // Renesas M32C series microprocessors
236fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_TSK3000       = 131, // Altium TSK3000 core
237fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_RS08          = 132, // Freescale RS08 embedded processor
238fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_SHARC         = 133, // Analog Devices SHARC family of 32-bit DSP
239fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer                          // processors
240fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ECOG2         = 134, // Cyan Technology eCOG2 microprocessor
241fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_SCORE7        = 135, // Sunplus S+core7 RISC processor
242fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_DSP24         = 136, // New Japan Radio (NJR) 24-bit DSP Processor
243fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_VIDEOCORE3    = 137, // Broadcom VideoCore III processor
244fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_LATTICEMICO32 = 138, // RISC processor for Lattice FPGA architecture
245fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_SE_C17        = 139, // Seiko Epson C17 family
246fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_TI_C6000      = 140, // The Texas Instruments TMS320C6000 DSP family
247fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_TI_C2000      = 141, // The Texas Instruments TMS320C2000 DSP family
248fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_TI_C5500      = 142, // The Texas Instruments TMS320C55x DSP family
249fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MMDSP_PLUS    = 160, // STMicroelectronics 64bit VLIW Data Signal Processor
250fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_CYPRESS_M8C   = 161, // Cypress M8C microprocessor
251fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_R32C          = 162, // Renesas R32C series microprocessors
252fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_TRIMEDIA      = 163, // NXP Semiconductors TriMedia architecture family
253fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_QDSP6         = 164, // QUALCOMM DSP6 Processor
254fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_8051          = 165, // Intel 8051 and variants
255fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_STXP7X        = 166, // STMicroelectronics STxP7x family of configurable
256fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer                          // and extensible RISC processors
257fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_NDS32         = 167, // Andes Technology compact code size embedded RISC
258fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer                          // processor family
259fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ECOG1         = 168, // Cyan Technology eCOG1X family
260fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ECOG1X        = 168, // Cyan Technology eCOG1X family
261fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MAXQ30        = 169, // Dallas Semiconductor MAXQ30 Core Micro-controllers
262fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_XIMO16        = 170, // New Japan Radio (NJR) 16-bit DSP Processor
263fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MANIK         = 171, // M2000 Reconfigurable RISC Microprocessor
264fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_CRAYNV2       = 172, // Cray Inc. NV2 vector architecture
265fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_RX            = 173, // Renesas RX family
266fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_METAG         = 174, // Imagination Technologies META processor
267fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer                          // architecture
268fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MCST_ELBRUS   = 175, // MCST Elbrus general purpose hardware architecture
269fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ECOG16        = 176, // Cyan Technology eCOG16 family
270fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_CR16          = 177, // National Semiconductor CompactRISC CR16 16-bit
271fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer                          // microprocessor
272fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ETPU          = 178, // Freescale Extended Time Processing Unit
273fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_SLE9X         = 179, // Infineon Technologies SLE9X core
274fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_L10M          = 180, // Intel L10M
275fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_K10M          = 181, // Intel K10M
276fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_AVR32         = 185, // Atmel Corporation 32-bit microprocessor family
277fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_STM8          = 186, // STMicroeletronics STM8 8-bit microcontroller
278fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_TILE64        = 187, // Tilera TILE64 multicore architecture family
279fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_TILEPRO       = 188, // Tilera TILEPro multicore architecture family
280fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MICROBLAZE    = 189, // Xilinx MicroBlaze 32-bit RISC soft processor core
281fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_CUDA          = 190, // NVIDIA CUDA architecture
282fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_TILEGX        = 191, // Tilera TILE-Gx multicore architecture family
283fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_CLOUDSHIELD   = 192, // CloudShield architecture family
284fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_COREA_1ST     = 193, // KIPO-KAIST Core-A 1st generation processor family
285fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_COREA_2ND     = 194, // KIPO-KAIST Core-A 2nd generation processor family
286fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_ARC_COMPACT2  = 195, // Synopsys ARCompact V2
287fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_OPEN8         = 196, // Open8 8-bit RISC soft processor core
288fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_RL78          = 197, // Renesas RL78 family
289fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_VIDEOCORE5    = 198, // Broadcom VideoCore V processor
290fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_78KOR         = 199, // Renesas 78KOR family
291fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_56800EX       = 200, // Freescale 56800EX Digital Signal Controller (DSC)
292fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  EM_MBLAZE        = 47787 // Xilinx MicroBlaze
2936c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
2946c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
2956c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// Object file classes.
2966c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekeenum {
297b84551a14f1c96942eb82408652e633543b0961eMichael J. Spencer  ELFCLASSNONE = 0,
2986c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  ELFCLASS32 = 1, // 32-bit object file
2996c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  ELFCLASS64 = 2  // 64-bit object file
3006c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
3016c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
3026c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// Object file byte orderings.
3036c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekeenum {
3049a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  ELFDATANONE = 0, // Invalid data encoding.
3056c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  ELFDATA2LSB = 1, // Little-endian object file
3066c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  ELFDATA2MSB = 2  // Big-endian object file
3076c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
3086c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
309e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming// OS ABI identification.
3105af8f421b6412e52530608097e39d2602195629fDan Gohmanenum {
311e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_NONE = 0,          // UNIX System V ABI
312e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_HPUX = 1,          // HP-UX operating system
313e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_NETBSD = 2,        // NetBSD
314e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_LINUX = 3,         // GNU/Linux
315e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_HURD = 4,          // GNU/Hurd
316e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_SOLARIS = 6,       // Solaris
317e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_AIX = 7,           // AIX
318e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_IRIX = 8,          // IRIX
319e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_FREEBSD = 9,       // FreeBSD
320e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_TRU64 = 10,        // TRU64 UNIX
321e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_MODESTO = 11,      // Novell Modesto
322e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_OPENBSD = 12,      // OpenBSD
323e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_OPENVMS = 13,      // OpenVMS
324e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_NSK = 14,          // Hewlett-Packard Non-Stop Kernel
325e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_AROS = 15,         // AROS
326e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_FENIXOS = 16,      // FenixOS
327e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
328e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_C6000_LINUX = 65,  // Linux TMS320C6000
329e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_ARM = 97,          // ARM
330e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6Matt Fleming  ELFOSABI_STANDALONE = 255   // Standalone (embedded) application
3315af8f421b6412e52530608097e39d2602195629fDan Gohman};
3325af8f421b6412e52530608097e39d2602195629fDan Gohman
333004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming// X86_64 relocations.
334004c82ad7c0d2da761726f063373c28ffd18e66dMatt Flemingenum {
335004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_NONE       = 0,
336004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_64         = 1,
337004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_PC32       = 2,
338004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_GOT32      = 3,
339004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_PLT32      = 4,
340004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_COPY       = 5,
341004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_GLOB_DAT   = 6,
342004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_JUMP_SLOT  = 7,
343004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_RELATIVE   = 8,
344004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_GOTPCREL   = 9,
345004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_32         = 10,
346004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_32S        = 11,
347004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_16         = 12,
348004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_PC16       = 13,
349004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_8          = 14,
350004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_PC8        = 15,
351004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_DTPMOD64   = 16,
352004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_DTPOFF64   = 17,
353004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_TPOFF64    = 18,
354004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_TLSGD      = 19,
355004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_TLSLD      = 20,
356004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_DTPOFF32   = 21,
357004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_GOTTPOFF   = 22,
358004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_TPOFF32    = 23,
359004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_PC64       = 24,
360004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_GOTOFF64   = 25,
361004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_GOTPC32    = 26,
362fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  R_X86_64_GOT64      = 27,
363fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  R_X86_64_GOTPCREL64 = 28,
364fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  R_X86_64_GOTPC64    = 29,
365fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  R_X86_64_GOTPLT64   = 30,
366fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  R_X86_64_PLTOFF64   = 31,
367004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_SIZE32     = 32,
368004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_SIZE64     = 33,
369004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_GOTPC32_TLSDESC = 34,
370004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_TLSDESC_CALL    = 35,
371004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  R_X86_64_TLSDESC    = 36
372004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming};
373004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming
374e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer// i386 relocations.
375e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer// TODO: this is just a subset
376e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramerenum {
377e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_NONE          = 0,
378e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_32            = 1,
379e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_PC32          = 2,
380e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_GOT32         = 3,
381e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_PLT32         = 4,
382e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_COPY          = 5,
383e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_GLOB_DAT      = 6,
384e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_JUMP_SLOT     = 7,
385e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_RELATIVE      = 8,
386e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_GOTOFF        = 9,
387e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_GOTPC         = 10,
388e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_32PLT         = 11,
3893cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_TPOFF     = 14,
3903cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_IE        = 15,
3913cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_GOTIE     = 16,
3923cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_LE        = 17,
3933cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_GD        = 18,
3943cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_LDM       = 19,
395e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_16            = 20,
396e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_PC16          = 21,
397e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer  R_386_8             = 22,
3983cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_PC8           = 23,
3993cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_GD_32     = 24,
4003cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_GD_PUSH   = 25,
4013cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_GD_CALL   = 26,
4023cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_GD_POP    = 27,
4033cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_LDM_32    = 28,
4043cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_LDM_PUSH  = 29,
4053cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_LDM_CALL  = 30,
4063cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_LDM_POP   = 31,
4073cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_LDO_32    = 32,
4083cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_IE_32     = 33,
4093cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_LE_32     = 34,
4103cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_DTPMOD32  = 35,
4113cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_DTPOFF32  = 36,
4123cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_TPOFF32   = 37,
4133cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_GOTDESC   = 39,
4143cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_DESC_CALL = 40,
4153cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_TLS_DESC      = 41,
4163cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_IRELATIVE     = 42,
4173cede2d0b2b6cc0a06f55da7c2f8e4263ec0091eRafael Espindola  R_386_NUM           = 43
418e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer};
419e5b57347e9485b59dd8d70f8f90d7794f473147aBenjamin Kramer
4204b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck// MBlaze relocations.
4214b04713423c6da988db75c7546baa3db7ddfa119Wesley Peckenum {
4224b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_NONE           = 0,
4234b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_32             = 1,
4244b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_32_PCREL       = 2,
4254b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_64_PCREL       = 3,
4264b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_32_PCREL_LO    = 4,
4274b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_64             = 5,
4284b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_32_LO          = 6,
4294b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_SRO32          = 7,
4304b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_SRW32          = 8,
4314b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_64_NONE        = 9,
4324b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_32_SYM_OP_SYM  = 10,
4334b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_GNU_VTINHERIT  = 11,
4344b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_GNU_VTENTRY    = 12,
4354b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_GOTPC_64       = 13,
4364b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_GOT_64         = 14,
4374b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_PLT_64         = 15,
4384b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_REL            = 16,
4394b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_JUMP_SLOT      = 17,
4404b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_GLOB_DAT       = 18,
4414b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_GOTOFF_64      = 19,
4424b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_GOTOFF_32      = 20,
4434b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck  R_MICROBLAZE_COPY           = 21
4444b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck};
4454b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck
4462c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divackyenum {
4472c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_NONE                  = 0,      /* No relocation. */
4482c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_ADDR32                = 1,
4492c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_ADDR24                = 2,
4502c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_ADDR16                = 3,
4512c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_ADDR16_LO             = 4,
4522c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_ADDR16_HI             = 5,
4532c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_ADDR16_HA             = 6,
4542c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_ADDR14                = 7,
4552c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_ADDR14_BRTAKEN        = 8,
4562c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_ADDR14_BRNTAKEN       = 9,
4572c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_REL24                 = 10,
4582c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_REL14                 = 11,
4592c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_REL14_BRTAKEN         = 12,
4602c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_REL14_BRNTAKEN        = 13,
4612c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky  R_PPC_REL32                 = 26
4622c0d69fad0e658117922f3d96d9b732bedf9fd47Roman Divacky};
4632d7a53aec2c6426eba9e5dd6462cc9e86432b410Jason W Kim
4642d7a53aec2c6426eba9e5dd6462cc9e86432b410Jason W Kim// ARM Specific e_flags
4652d7a53aec2c6426eba9e5dd6462cc9e86432b410Jason W Kimenum { EF_ARM_EABIMASK = 0xFF000000U };
4662d7a53aec2c6426eba9e5dd6462cc9e86432b410Jason W Kim
46713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim// ELF Relocation types for ARM
46813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim// Meets 2.08 ABI Specs.
46913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim
47013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kimenum {
47113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_NONE                  = 0x00,
47213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PC24                  = 0x01,
47313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ABS32                 = 0x02,
47413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_REL32                 = 0x03,
47513534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDR_PC_G0             = 0x04,
47613534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ABS16                 = 0x05,
47713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ABS12                 = 0x06,
47813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_ABS5              = 0x07,
47913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ABS8                  = 0x08,
48013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_SBREL32               = 0x09,
48113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_CALL              = 0x0a,
48213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_PC8               = 0x0b,
48313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_BREL_ADJ              = 0x0c,
48413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_DESC              = 0x0d,
48513534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_SWI8              = 0x0e,
48613534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_XPC25                 = 0x0f,
48713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_XPC22             = 0x10,
48813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_DTPMOD32          = 0x11,
48913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_DTPOFF32          = 0x12,
49013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_TPOFF32           = 0x13,
49113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_COPY                  = 0x14,
49213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_GLOB_DAT              = 0x15,
49313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_JUMP_SLOT             = 0x16,
49413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_RELATIVE              = 0x17,
49513534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_GOTOFF32              = 0x18,
49613534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_BASE_PREL             = 0x19,
49713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_GOT_BREL              = 0x1a,
49813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PLT32                 = 0x1b,
49913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_CALL                  = 0x1c,
50013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_JUMP24                = 0x1d,
50113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_JUMP24            = 0x1e,
50213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_BASE_ABS              = 0x1f,
50313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_PCREL_7_0         = 0x20,
50413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_PCREL_15_8        = 0x21,
50513534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_PCREL_23_15       = 0x22,
50613534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDR_SBREL_11_0_NC     = 0x23,
50713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_SBREL_19_12_NC    = 0x24,
50813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_SBREL_27_20_CK    = 0x25,
50913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TARGET1               = 0x26,
51013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_SBREL31               = 0x27,
51113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_V4BX                  = 0x28,
51213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TARGET2               = 0x29,
51313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PREL31                = 0x2a,
51413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_MOVW_ABS_NC           = 0x2b,
51513534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_MOVT_ABS              = 0x2c,
51613534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_MOVW_PREL_NC          = 0x2d,
51713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_MOVT_PREL             = 0x2e,
51813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_MOVW_ABS_NC       = 0x2f,
51913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_MOVT_ABS          = 0x30,
52013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_MOVW_PREL_NC      = 0x31,
52113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_MOVT_PREL         = 0x32,
52213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_JUMP19            = 0x33,
52313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_JUMP6             = 0x34,
52413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_ALU_PREL_11_0     = 0x35,
52513534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_PC12              = 0x36,
52613534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ABS32_NOI             = 0x37,
52713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_REL32_NOI             = 0x38,
52813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_PC_G0_NC          = 0x39,
52913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_PC_G0             = 0x3a,
53013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_PC_G1_NC          = 0x3b,
53113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_PC_G1             = 0x3c,
53213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_PC_G2             = 0x3d,
53313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDR_PC_G1             = 0x3e,
53413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDR_PC_G2             = 0x3f,
53513534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDRS_PC_G0            = 0x40,
53613534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDRS_PC_G1            = 0x41,
53713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDRS_PC_G2            = 0x42,
53813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDC_PC_G0             = 0x43,
53913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDC_PC_G1             = 0x44,
54013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDC_PC_G2             = 0x45,
54113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_SB_G0_NC          = 0x46,
54213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_SB_G0             = 0x47,
54313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_SB_G1_NC          = 0x48,
54413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_SB_G1             = 0x49,
54513534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ALU_SB_G2             = 0x4a,
54613534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDR_SB_G0             = 0x4b,
54713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDR_SB_G1             = 0x4c,
54813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDR_SB_G2             = 0x4d,
54913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDRS_SB_G0            = 0x4e,
55013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDRS_SB_G1            = 0x4f,
55113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDRS_SB_G2            = 0x50,
55213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDC_SB_G0             = 0x51,
55313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDC_SB_G1             = 0x52,
55413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_LDC_SB_G2             = 0x53,
55513534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_MOVW_BREL_NC          = 0x54,
55613534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_MOVT_BREL             = 0x55,
55713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_MOVW_BREL             = 0x56,
55813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_MOVW_BREL_NC      = 0x57,
55913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_MOVT_BREL         = 0x58,
56013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_MOVW_BREL         = 0x59,
56113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_GOTDESC           = 0x5a,
56213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_CALL              = 0x5b,
56313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_DESCSEQ           = 0x5c,
56413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_TLS_CALL          = 0x5d,
56513534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PLT32_ABS             = 0x5e,
56613534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_GOT_ABS               = 0x5f,
56713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_GOT_PREL              = 0x60,
56813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_GOT_BREL12            = 0x61,
56913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_GOTOFF12              = 0x62,
57013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_GOTRELAX              = 0x63,
57113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_GNU_VTENTRY           = 0x64,
57213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_GNU_VTINHERIT         = 0x65,
57313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_JUMP11            = 0x66,
57413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_JUMP8             = 0x67,
57513534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_GD32              = 0x68,
57613534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_LDM32             = 0x69,
57713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_LDO32             = 0x6a,
57813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_IE32              = 0x6b,
57913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_LE32              = 0x6c,
58013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_LDO12             = 0x6d,
58113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_LE12              = 0x6e,
58213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_TLS_IE12GP            = 0x6f,
58313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_0             = 0x70,
58413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_1             = 0x71,
58513534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_2             = 0x72,
58613534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_3             = 0x73,
58713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_4             = 0x74,
58813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_5             = 0x75,
58913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_6             = 0x76,
59013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_7             = 0x77,
59113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_8             = 0x78,
59213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_9             = 0x79,
59313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_10            = 0x7a,
59413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_11            = 0x7b,
59513534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_12            = 0x7c,
59613534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_13            = 0x7d,
59713534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_14            = 0x7e,
59813534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_PRIVATE_15            = 0x7f,
59913534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_ME_TOO                = 0x80,
60013534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_TLS_DESCSEQ16     = 0x81,
60113534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim  R_ARM_THM_TLS_DESCSEQ32     = 0x82
60213534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim};
60313534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim
60413534672deffb571d90f2c2f0a237c67d5aa0594Jason W Kim
6054b04713423c6da988db75c7546baa3db7ddfa119Wesley Peck
6066c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// Section header.
6076c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekestruct Elf32_Shdr {
6086c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word sh_name;      // Section name (index into string table)
6096c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word sh_type;      // Section type (SHT_*)
6106c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word sh_flags;     // Section flags (SHF_*)
6116c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Addr sh_addr;      // Address where section is to be loaded
6126c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Off  sh_offset;    // File offset of section data, in bytes
6136c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word sh_size;      // Size of section, in bytes
61463b3afa98460ce38a1c48d3c44ef6edfdaf37b77Misha Brukman  Elf32_Word sh_link;      // Section type-specific header table index link
6156c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word sh_info;      // Section type-specific extra information
6166c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word sh_addralign; // Section address alignment
6176c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word sh_entsize;   // Size of records contained within the section
6186c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
6196c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
620620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke// Section header for ELF64 - same fields as ELF32, different types.
621e9f6f2c0492af8097166f1b7d62f131f20ca5714Brian Gaekestruct Elf64_Shdr {
622620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Half  sh_name;
623620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Half  sh_type;
624620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Xword sh_flags;
625620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Addr  sh_addr;
626620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Off   sh_offset;
627620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Xword sh_size;
628620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Half  sh_link;
629620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Half  sh_info;
630620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Xword sh_addralign;
631620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke  Elf64_Xword sh_entsize;
632e9f6f2c0492af8097166f1b7d62f131f20ca5714Brian Gaeke};
633620ee02353d8b65959dc01a66b073adfcdef9eacBrian Gaeke
6346c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// Special section indices.
6356c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekeenum {
6366c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  SHN_UNDEF     = 0,      // Undefined, missing, irrelevant, or meaningless
6376c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  SHN_LORESERVE = 0xff00, // Lowest reserved index
6386c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  SHN_LOPROC    = 0xff00, // Lowest processor-specific index
6396c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  SHN_HIPROC    = 0xff1f, // Highest processor-specific index
640fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  SHN_LOOS      = 0xff20, // Lowest operating system-specific index
641fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  SHN_HIOS      = 0xff3f, // Highest operating system-specific index
6426c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  SHN_ABS       = 0xfff1, // Symbol has absolute value; does not need relocation
6436c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  SHN_COMMON    = 0xfff2, // FORTRAN COMMON or C external global variables
6447be2c33193aeada8c0ff3555ea54b930f204132aRafael Espindola  SHN_XINDEX    = 0xffff, // Mark that the index is >= SHN_LORESERVE
6456c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  SHN_HIRESERVE = 0xffff  // Highest reserved index
6466c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
6476c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
6486c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// Section types.
6496c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekeenum {
650b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_NULL          = 0,  // No associated section (inactive entry).
651b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_PROGBITS      = 1,  // Program-defined contents.
652b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_SYMTAB        = 2,  // Symbol table.
653b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_STRTAB        = 3,  // String table.
654b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_RELA          = 4,  // Relocation entries; explicit addends.
655b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_HASH          = 5,  // Symbol hash table.
656b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_DYNAMIC       = 6,  // Information for dynamic linking.
657b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_NOTE          = 7,  // Information about the file.
658b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_NOBITS        = 8,  // Data occupies no space in the file.
659b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_REL           = 9,  // Relocation entries; no explicit addends.
660b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_SHLIB         = 10, // Reserved.
661b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_DYNSYM        = 11, // Symbol table.
662cbda61a468b4a2b33a54781d65023da7d9c8d291Michael J. Spencer  SHT_INIT_ARRAY    = 14, // Pointers to initialization functions.
663b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_FINI_ARRAY    = 15, // Pointers to termination functions.
664b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_PREINIT_ARRAY = 16, // Pointers to pre-init functions.
665b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_GROUP         = 17, // Section group.
666cbda61a468b4a2b33a54781d65023da7d9c8d291Michael J. Spencer  SHT_SYMTAB_SHNDX  = 18, // Indices for SHN_XINDEX entries.
667b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_LOOS          = 0x60000000, // Lowest operating system-specific type.
668b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_HIOS          = 0x6fffffff, // Highest operating system-specific type.
669b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_LOPROC        = 0x70000000, // Lowest processor architecture-specific type.
670cecbc3d28277ff4916326311cbf87335ed05d106Rafael Espindola  // Fixme: All this is duplicated in MCSectionELF. Why??
671cecbc3d28277ff4916326311cbf87335ed05d106Rafael Espindola  // Exception Index table
672cecbc3d28277ff4916326311cbf87335ed05d106Rafael Espindola  SHT_ARM_EXIDX           = 0x70000001U,
673cecbc3d28277ff4916326311cbf87335ed05d106Rafael Espindola  // BPABI DLL dynamic linking pre-emption map
674cecbc3d28277ff4916326311cbf87335ed05d106Rafael Espindola  SHT_ARM_PREEMPTMAP      = 0x70000002U,
675cecbc3d28277ff4916326311cbf87335ed05d106Rafael Espindola  //  Object file compatibility attributes
676cecbc3d28277ff4916326311cbf87335ed05d106Rafael Espindola  SHT_ARM_ATTRIBUTES      = 0x70000003U,
677cecbc3d28277ff4916326311cbf87335ed05d106Rafael Espindola  SHT_ARM_DEBUGOVERLAY    = 0x70000004U,
678cecbc3d28277ff4916326311cbf87335ed05d106Rafael Espindola  SHT_ARM_OVERLAYSECTION  = 0x70000005U,
679cecbc3d28277ff4916326311cbf87335ed05d106Rafael Espindola
6800cf5e3d51dd455a174a8f00cfa6b63c11e535434Rafael Espindola  SHT_X86_64_UNWIND       = 0x70000001, // Unwind information
6810cf5e3d51dd455a174a8f00cfa6b63c11e535434Rafael Espindola
682b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_HIPROC        = 0x7fffffff, // Highest processor architecture-specific type.
683b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_LOUSER        = 0x80000000, // Lowest type reserved for applications.
684b676d9815dc7ce3a14d655322f307f335708155bMatt Fleming  SHT_HIUSER        = 0xffffffff  // Highest type reserved for applications.
6856c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
6866c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
6876c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// Section flags.
6886c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekeenum {
6891c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  // Section data should be writable during execution.
6901c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  SHF_WRITE = 0x1,
6911c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola
6921c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  // Section occupies memory during program execution.
6931c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  SHF_ALLOC = 0x2,
6941c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola
6951c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  // Section contains executable machine instructions.
6961c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  SHF_EXECINSTR = 0x4,
6971c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola
6981c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  // The data in this section may be merged.
6991c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  SHF_MERGE = 0x10,
7001c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola
7011c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  // The data in this section is null-terminated strings.
7021c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  SHF_STRINGS = 0x20,
7031c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola
7041c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  // A field in this section holds a section header table index.
7051c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  SHF_INFO_LINK = 0x40U,
7061c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola
7071c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  // Adds special ordering requirements for link editors.
7081c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  SHF_LINK_ORDER = 0x80U,
7091c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola
7101c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  // This section requires special OS-specific processing to avoid incorrect
7111c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  // behavior.
7121c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  SHF_OS_NONCONFORMING = 0x100U,
7131c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola
7141c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  // This section is a member of a section group.
7151c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  SHF_GROUP = 0x200U,
7161c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola
7171c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  // This section holds Thread-Local Storage.
7181c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  SHF_TLS = 0x400U,
7191c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola
7201c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  // Start of target-specific flags.
7211c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola
7221c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  /// XCORE_SHF_CP_SECTION - All sections with the "c" flag are grouped
7231c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  /// together by the linker to form the constant pool and the cp register is
7241c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  /// set to the start of the constant pool by the boot code.
7251c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  XCORE_SHF_CP_SECTION = 0x800U,
7261c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola
7271c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  /// XCORE_SHF_DP_SECTION - All sections with the "d" flag are grouped
7281c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  /// together by the linker to form the data section and the dp register is
7291c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  /// set to the start of the section by the boot code.
7301c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  XCORE_SHF_DP_SECTION = 0x1000U,
7311c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola
732fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  SHF_MASKOS   = 0x0ff00000,
733fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer
7341c13026e8f94bd332c0979baa9c777da99d48736Rafael Espindola  // Bits indicating processor-specific flags.
735fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  SHF_MASKPROC = 0xf0000000,
736fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer
737fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  // If an object file section does not have this flag set, then it may not hold
738fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  // more than 2GB and can be freely referred to in objects using smaller code
739fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  // models. Otherwise, only objects using larger code models can refer to them.
740fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  // For example, a medium code model object can refer to data in a section that
741fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  // sets this flag besides being able to refer to data in a section that does
742fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  // not set it; likewise, a small code model object can refer only to code in a
743fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  // section that does not set this flag.
744fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  SHF_X86_64_LARGE = 0x10000000
7456c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
7466c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
7472ff9e83a826c1c2ee0f1c6072d3d97d5b10678eeRafael Espindola// Section Group Flags
7482ff9e83a826c1c2ee0f1c6072d3d97d5b10678eeRafael Espindolaenum {
7492ff9e83a826c1c2ee0f1c6072d3d97d5b10678eeRafael Espindola  GRP_COMDAT = 0x1,
7502ff9e83a826c1c2ee0f1c6072d3d97d5b10678eeRafael Espindola  GRP_MASKOS = 0x0ff00000,
7512ff9e83a826c1c2ee0f1c6072d3d97d5b10678eeRafael Espindola  GRP_MASKPROC = 0xf0000000
7522ff9e83a826c1c2ee0f1c6072d3d97d5b10678eeRafael Espindola};
7532ff9e83a826c1c2ee0f1c6072d3d97d5b10678eeRafael Espindola
7549a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson// Symbol table entries for ELF32.
7556c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekestruct Elf32_Sym {
7566c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word    st_name;  // Symbol name (index into string table)
7576c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Addr    st_value; // Value or address associated with the symbol
7586c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word    st_size;  // Size of the symbol
7596c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  unsigned char st_info;  // Symbol's type and binding attributes
7606c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  unsigned char st_other; // Must be zero; reserved
7616c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Half    st_shndx; // Which section (header table index) it's defined in
76263b3afa98460ce38a1c48d3c44ef6edfdaf37b77Misha Brukman
7636c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  // These accessors and mutators correspond to the ELF32_ST_BIND,
7646c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  // ELF32_ST_TYPE, and ELF32_ST_INFO macros defined in the ELF specification:
765314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  unsigned char getBinding() const { return st_info >> 4; }
766314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  unsigned char getType() const { return st_info & 0x0f; }
767314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setBinding(unsigned char b) { setBindingAndType(b, getType()); }
768314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setType(unsigned char t) { setBindingAndType(getBinding(), t); }
769314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setBindingAndType(unsigned char b, unsigned char t) {
7706c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke    st_info = (b << 4) + (t & 0x0f);
7716c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  }
7726c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
7736c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
7749a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson// Symbol table entries for ELF64.
7759a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilsonstruct Elf64_Sym {
7769a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf64_Word      st_name;  // Symbol name (index into string table)
7779a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  unsigned char   st_info;  // Symbol's type and binding attributes
7789a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  unsigned char   st_other; // Must be zero; reserved
7799a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf64_Half      st_shndx; // Which section (header table index) it's defined in
7809a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf64_Addr      st_value; // Value or address associated with the symbol
7819a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf64_Xword     st_size;  // Size of the symbol
7829a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson
7839a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  // These accessors and mutators are identical to those defined for ELF32
7849a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  // symbol table entries.
7859a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  unsigned char getBinding() const { return st_info >> 4; }
7869a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  unsigned char getType() const { return st_info & 0x0f; }
7879a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  void setBinding(unsigned char b) { setBindingAndType(b, getType()); }
7889a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  void setType(unsigned char t) { setBindingAndType(getBinding(), t); }
7899a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  void setBindingAndType(unsigned char b, unsigned char t) {
7909a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson    st_info = (b << 4) + (t & 0x0f);
7919a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  }
7929a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson};
7939a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson
7946b2e257e74b2c8e2f93bb244e0c80cb73005b74aMatt Fleming// The size (in bytes) of symbol table entries.
7956b2e257e74b2c8e2f93bb244e0c80cb73005b74aMatt Flemingenum {
7966b2e257e74b2c8e2f93bb244e0c80cb73005b74aMatt Fleming  SYMENTRY_SIZE32 = 16, // 32-bit symbol entry size
7976b2e257e74b2c8e2f93bb244e0c80cb73005b74aMatt Fleming  SYMENTRY_SIZE64 = 24  // 64-bit symbol entry size.
7986b2e257e74b2c8e2f93bb244e0c80cb73005b74aMatt Fleming};
7996b2e257e74b2c8e2f93bb244e0c80cb73005b74aMatt Fleming
8006c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// Symbol bindings.
8016c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekeenum {
8026c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  STB_LOCAL = 0,   // Local symbol, not visible outside obj file containing def
8036c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  STB_GLOBAL = 1,  // Global symbol, visible to all object files being combined
8046c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  STB_WEAK = 2,    // Weak symbol, like global but lower-precedence
805fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  STB_LOOS   = 10, // Lowest operating system-specific binding type
806fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  STB_HIOS   = 12, // Highest operating system-specific binding type
8076c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  STB_LOPROC = 13, // Lowest processor-specific binding type
8086c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  STB_HIPROC = 15  // Highest processor-specific binding type
8096c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
8106c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
8116c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// Symbol types.
8126c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekeenum {
8136c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  STT_NOTYPE  = 0,   // Symbol's type is not specified
8146c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  STT_OBJECT  = 1,   // Symbol is a data object (variable, array, etc.)
8156c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  STT_FUNC    = 2,   // Symbol is executable code (function, etc.)
8166c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  STT_SECTION = 3,   // Symbol refers to a section
8176c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  STT_FILE    = 4,   // Local, absolute symbol that refers to a file
818cbda61a468b4a2b33a54781d65023da7d9c8d291Michael J. Spencer  STT_COMMON  = 5,   // An uninitialized common block
81953621a1a7376cba5d0a22c12a171933eb8c6d3f6Eli Friedman  STT_TLS     = 6,   // Thread local data object
820fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  STT_LOOS    = 7,   // Lowest operating system-specific symbol type
821fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  STT_HIOS    = 8,   // Highest operating system-specific symbol type
8226c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  STT_LOPROC  = 13,  // Lowest processor-specific symbol type
8236c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  STT_HIPROC  = 15   // Highest processor-specific symbol type
8246c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
8256c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
82653621a1a7376cba5d0a22c12a171933eb8c6d3f6Eli Friedmanenum {
82753621a1a7376cba5d0a22c12a171933eb8c6d3f6Eli Friedman  STV_DEFAULT   = 0,  // Visibility is specified by binding type
82853621a1a7376cba5d0a22c12a171933eb8c6d3f6Eli Friedman  STV_INTERNAL  = 1,  // Defined by processor supplements
82953621a1a7376cba5d0a22c12a171933eb8c6d3f6Eli Friedman  STV_HIDDEN    = 2,  // Not visible to other components
83053621a1a7376cba5d0a22c12a171933eb8c6d3f6Eli Friedman  STV_PROTECTED = 3   // Visible in other components but not preemptable
83153621a1a7376cba5d0a22c12a171933eb8c6d3f6Eli Friedman};
83253621a1a7376cba5d0a22c12a171933eb8c6d3f6Eli Friedman
8336c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// Relocation entry, without explicit addend.
8346c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekestruct Elf32_Rel {
83563b3afa98460ce38a1c48d3c44ef6edfdaf37b77Misha Brukman  Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr)
8366c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word r_info;   // Symbol table index and type of relocation to apply
83763b3afa98460ce38a1c48d3c44ef6edfdaf37b77Misha Brukman
8386c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE,
8396c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  // and ELF32_R_INFO macros defined in the ELF specification:
840314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  Elf32_Word getSymbol() const { return (r_info >> 8); }
841314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  unsigned char getType() const { return (unsigned char) (r_info & 0x0ff); }
842314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setSymbol(Elf32_Word s) { setSymbolAndType(s, getType()); }
843314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); }
844314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setSymbolAndType(Elf32_Word s, unsigned char t) {
8456c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke    r_info = (s << 8) + t;
8461461520f8cba8ebbdfd832d5396079888f1ab96eDouglas Gregor  }
8476c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
8486c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
8496c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke// Relocation entry with explicit addend.
8506c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekestruct Elf32_Rela {
85163b3afa98460ce38a1c48d3c44ef6edfdaf37b77Misha Brukman  Elf32_Addr  r_offset; // Location (file byte offset, or program virtual addr)
8526c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word  r_info;   // Symbol table index and type of relocation to apply
8536c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Sword r_addend; // Compute value for relocatable field by adding this
85463b3afa98460ce38a1c48d3c44ef6edfdaf37b77Misha Brukman
8556c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE,
8566c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  // and ELF32_R_INFO macros defined in the ELF specification:
857314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  Elf32_Word getSymbol() const { return (r_info >> 8); }
858314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  unsigned char getType() const { return (unsigned char) (r_info & 0x0ff); }
859314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setSymbol(Elf32_Word s) { setSymbolAndType(s, getType()); }
860314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); }
861314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setSymbolAndType(Elf32_Word s, unsigned char t) {
8626c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke    r_info = (s << 8) + t;
8631461520f8cba8ebbdfd832d5396079888f1ab96eDouglas Gregor  }
8646c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
8656c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
866004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming// Relocation entry, without explicit addend.
867004c82ad7c0d2da761726f063373c28ffd18e66dMatt Flemingstruct Elf64_Rel {
868004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  Elf64_Addr r_offset; // Location (file byte offset, or program virtual addr).
869004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  Elf64_Xword r_info;   // Symbol table index and type of relocation to apply.
870004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming
871004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE,
872004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  // and ELF64_R_INFO macros defined in the ELF specification:
873314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  Elf64_Xword getSymbol() const { return (r_info >> 32); }
874314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  unsigned char getType() const {
875004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming    return (unsigned char) (r_info & 0xffffffffL);
876004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  }
877314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setSymbol(Elf32_Word s) { setSymbolAndType(s, getType()); }
878314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); }
879314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setSymbolAndType(Elf64_Xword s, unsigned char t) {
880004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming    r_info = (s << 32) + (t&0xffffffffL);
8811461520f8cba8ebbdfd832d5396079888f1ab96eDouglas Gregor  }
882004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming};
883004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming
884004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming// Relocation entry with explicit addend.
885004c82ad7c0d2da761726f063373c28ffd18e66dMatt Flemingstruct Elf64_Rela {
886004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  Elf64_Addr  r_offset; // Location (file byte offset, or program virtual addr).
887004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  Elf64_Xword  r_info;   // Symbol table index and type of relocation to apply.
888004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  Elf64_Sxword r_addend; // Compute value for relocatable field by adding this.
889004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming
890004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE,
891004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  // and ELF64_R_INFO macros defined in the ELF specification:
892314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  Elf64_Xword getSymbol() const { return (r_info >> 32); }
893314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  unsigned char getType() const {
894004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming    return (unsigned char) (r_info & 0xffffffffL);
895004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming  }
896314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setSymbol(Elf64_Xword s) { setSymbolAndType(s, getType()); }
897314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); }
898314451326ad1ef89241b240a704e104897e4ee81Stephen Wilson  void setSymbolAndType(Elf64_Xword s, unsigned char t) {
899004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming    r_info = (s << 32) + (t&0xffffffffL);
9001461520f8cba8ebbdfd832d5396079888f1ab96eDouglas Gregor  }
901004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming};
902004c82ad7c0d2da761726f063373c28ffd18e66dMatt Fleming
9039a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson// Program header for ELF32.
9046c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekestruct Elf32_Phdr {
9056c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word p_type;   // Type of segment
9066c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Off  p_offset; // File offset where segment is located, in bytes
9076c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Addr p_vaddr;  // Virtual address of beginning of segment
9086c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Addr p_paddr;  // Physical address of beginning of segment (OS-specific)
9096c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word p_filesz; // Num. of bytes in file image of segment (may be zero)
9106c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word p_memsz;  // Num. of bytes in mem image of segment (may be zero)
9116c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word p_flags;  // Segment flags
9126c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  Elf32_Word p_align;  // Segment alignment constraint
9136c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
9146c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
9159a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson// Program header for ELF64.
9169a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilsonstruct Elf64_Phdr {
9179a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf64_Word   p_type;   // Type of segment
9189a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf64_Word   p_flags;  // Segment flags
9199a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf64_Off    p_offset; // File offset where segment is located, in bytes
9209a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf64_Addr   p_vaddr;  // Virtual address of beginning of segment
9219a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf64_Addr   p_paddr;  // Physical address of beginning of segment (OS-specific)
9229a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf64_Xword  p_filesz; // Num. of bytes in file image of segment (may be zero)
9239a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf64_Xword  p_memsz;  // Num. of bytes in mem image of segment (may be zero)
9249a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf64_Xword  p_align;  // Segment alignment constraint
9259a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson};
9269a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson
9274e9ca339b56f082c6b2d7dd7d91f704801c0d4fdMikhail Glushenkov// Segment types.
9286c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaekeenum {
9296c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  PT_NULL    = 0, // Unused segment.
9306c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  PT_LOAD    = 1, // Loadable segment.
9316c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  PT_DYNAMIC = 2, // Dynamic linking information.
9326c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  PT_INTERP  = 3, // Interpreter pathname.
9336c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  PT_NOTE    = 4, // Auxiliary information.
9346c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  PT_SHLIB   = 5, // Reserved.
9356c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  PT_PHDR    = 6, // The program header table itself.
936fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  PT_TLS     = 7, // The thread-local storage template.
937fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  PT_LOOS    = 0x60000000, // Lowest operating system-specific pt entry type.
938fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer
939fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  // x86-64 program header types.
940fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  // These all contain stack unwind tables.
941fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  PT_GNU_EH_FRAME  = 0x6474e550,
942fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  PT_SUNW_EH_FRAME = 0x6474e550,
943fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  PT_SUNW_UNWIND   = 0x6464e550,
944fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer
945fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  PT_HIOS    = 0x6fffffff, // Highest operating system-specific pt entry type.
9466c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  PT_LOPROC  = 0x70000000, // Lowest processor-specific program hdr entry type.
9476c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke  PT_HIPROC  = 0x7fffffff  // Highest processor-specific program hdr entry type.
9486c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke};
9496c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
9504e9ca339b56f082c6b2d7dd7d91f704801c0d4fdMikhail Glushenkov// Segment flag bits.
9514e9ca339b56f082c6b2d7dd7d91f704801c0d4fdMikhail Glushenkovenum {
9524e9ca339b56f082c6b2d7dd7d91f704801c0d4fdMikhail Glushenkov  PF_X        = 1,         // Execute
9534e9ca339b56f082c6b2d7dd7d91f704801c0d4fdMikhail Glushenkov  PF_W        = 2,         // Write
9544e9ca339b56f082c6b2d7dd7d91f704801c0d4fdMikhail Glushenkov  PF_R        = 4,         // Read
955fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  PF_MASKOS   = 0x0ff00000,// Bits for operating system-specific semantics.
956fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  PF_MASKPROC = 0xf0000000 // Bits for processor-specific semantics.
9574e9ca339b56f082c6b2d7dd7d91f704801c0d4fdMikhail Glushenkov};
9584e9ca339b56f082c6b2d7dd7d91f704801c0d4fdMikhail Glushenkov
9599a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson// Dynamic table entry for ELF32.
9609a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilsonstruct Elf32_Dyn
9619a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson{
9629a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf32_Sword d_tag;            // Type of dynamic table entry.
9639a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  union
9649a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  {
9659a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson      Elf32_Word d_val;         // Integer value of entry.
9669a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson      Elf32_Addr d_ptr;         // Pointer value of entry.
9679a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  } d_un;
9689a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson};
9699a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson
9709a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson// Dynamic table entry for ELF64.
9719a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilsonstruct Elf64_Dyn
9729a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson{
9739a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  Elf64_Sxword d_tag;           // Type of dynamic table entry.
9749a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  union
9759a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  {
9769a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson      Elf64_Xword d_val;        // Integer value of entry.
9779a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson      Elf64_Addr  d_ptr;        // Pointer value of entry.
9789a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  } d_un;
9799a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson};
9809a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson
9819a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson// Dynamic table entry tags.
9829a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilsonenum {
9839a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_NULL         = 0,        // Marks end of dynamic array.
9849a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_NEEDED       = 1,        // String table offset of needed library.
9859a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_PLTRELSZ     = 2,        // Size of relocation entries in PLT.
9869a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_PLTGOT       = 3,        // Address associated with linkage table.
9879a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_HASH         = 4,        // Address of symbolic hash table.
9889a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_STRTAB       = 5,        // Address of dynamic string table.
9899a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_SYMTAB       = 6,        // Address of dynamic symbol table.
9909a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_RELA         = 7,        // Address of relocation table (Rela entries).
9919a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_RELASZ       = 8,        // Size of Rela relocation table.
9929a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_RELAENT      = 9,        // Size of a Rela relocation entry.
9939a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_STRSZ        = 10,       // Total size of the string table.
9949a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_SYMENT       = 11,       // Size of a symbol table entry.
9959a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_INIT         = 12,       // Address of initialization function.
9969a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_FINI         = 13,       // Address of termination function.
9979a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_SONAME       = 14,       // String table offset of a shared objects name.
9989a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_RPATH        = 15,       // String table offset of library search path.
9999a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_SYMBOLIC     = 16,       // Changes symbol resolution algorithm.
10009a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_REL          = 17,       // Address of relocation table (Rel entries).
10019a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_RELSZ        = 18,       // Size of Rel relocation table.
10029a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_RELENT       = 19,       // Size of a Rel relocation entry.
10039a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_PLTREL       = 20,       // Type of relocation entry used for linking.
10049a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_DEBUG        = 21,       // Reserved for debugger.
1005cbda61a468b4a2b33a54781d65023da7d9c8d291Michael J. Spencer  DT_TEXTREL      = 22,       // Relocations exist for non-writable segments.
10069a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_JMPREL       = 23,       // Address of relocations associated with PLT.
10079a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_BIND_NOW     = 24,       // Process all relocations before execution.
10089a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_INIT_ARRAY   = 25,       // Pointer to array of initialization functions.
10099a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_FINI_ARRAY   = 26,       // Pointer to array of termination functions.
10109a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_INIT_ARRAYSZ = 27,       // Size of DT_INIT_ARRAY.
10119a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_FINI_ARRAYSZ = 28,       // Size of DT_FINI_ARRAY.
1012fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  DT_RUNPATH      = 29,       // String table offset of lib search path.
1013fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  DT_FLAGS        = 30,       // Flags.
1014fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  DT_ENCODING     = 32,       // Values from here to DT_LOOS follow the rules
1015fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer                              // for the interpretation of the d_un union.
1016fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer
1017fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  DT_PREINIT_ARRAY = 32,      // Pointer to array of preinit functions.
1018fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  DT_PREINIT_ARRAYSZ = 33,    // Size of the DT_PREINIT_ARRAY array.
1019fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer
10209a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_LOOS         = 0x60000000, // Start of environment specific tags.
10219a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_HIOS         = 0x6FFFFFFF, // End of environment specific tags.
10229a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_LOPROC       = 0x70000000, // Start of processor specific tags.
10239a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson  DT_HIPROC       = 0x7FFFFFFF  // End of processor specific tags.
10249a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson};
10259a9ad77847c1be4ffc5ba6304e33ccecbf72e43fStephen Wilson
1026fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer// DT_FLAGS values.
1027fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencerenum {
1028fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  DF_ORIGIN     = 0x01, // The object may reference $ORIGIN.
1029fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  DF_SYMBOLIC   = 0x02, // Search the shared lib before searching the exe.
1030fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  DF_TEXTREL    = 0x04, // Relocations may modify a non-writable segment.
1031fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  DF_BIND_NOW   = 0x08, // Process all relocations on load.
1032fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer  DF_STATIC_TLS = 0x10  // Reject attempts to load dynamically.
1033fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer};
1034fc61a23506fdad8f38e3437d741a4108339abcfeMichael J. Spencer
10356c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke} // end namespace ELF
10366c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke
10376c39a42b5c93b6d0af008dbafed6134d1deaa848Brian Gaeke} // end namespace llvm
1038551ccae044b0ff658fe629dd67edd5ffe75d10e8Reid Spencer
1039551ccae044b0ff658fe629dd67edd5ffe75d10e8Reid Spencer#endif
1040