1 /* 2 Copyright (C) 2001-present by Serge Lamikhov-Center 3 4 Permission is hereby granted, free of charge, to any person obtaining a copy 5 of this software and associated documentation files (the "Software"), to deal 6 in the Software without restriction, including without limitation the rights 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 copies of the Software, and to permit persons to whom the Software is 9 furnished to do so, subject to the following conditions: 10 11 The above copyright notice and this permission notice shall be included in 12 all copies or substantial portions of the Software. 13 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 THE SOFTWARE. 21 */ 22 23 #ifndef ELFTYPES_H 24 #define ELFTYPES_H 25 26 #ifdef __cplusplus 27 namespace ELFIO { 28 #endif 29 30 using Elf_Half = uint16_t; 31 using Elf_Word = uint32_t; 32 using Elf_Sword = int32_t; 33 using Elf_Xword = uint64_t; 34 using Elf_Sxword = int64_t; 35 36 using Elf32_Addr = uint32_t; 37 using Elf32_Off = uint32_t; 38 using Elf64_Addr = uint64_t; 39 using Elf64_Off = uint64_t; 40 41 using Elf32_Half = Elf_Half; 42 using Elf64_Half = Elf_Half; 43 using Elf32_Word = Elf_Word; 44 using Elf64_Word = Elf_Word; 45 using Elf32_Sword = Elf_Sword; 46 using Elf64_Sword = Elf_Sword; 47 48 /////////////////////// 49 // ELF Header Constants 50 51 // File type 52 constexpr Elf_Half ET_NONE = 0; 53 constexpr Elf_Half ET_REL = 1; 54 constexpr Elf_Half ET_EXEC = 2; 55 constexpr Elf_Half ET_DYN = 3; 56 constexpr Elf_Half ET_CORE = 4; 57 constexpr Elf_Half ET_LOOS = 0xFE00; 58 constexpr Elf_Half ET_HIOS = 0xFEFF; 59 constexpr Elf_Half ET_LOPROC = 0xFF00; 60 constexpr Elf_Half ET_HIPROC = 0xFFFF; 61 62 // clang-format off 63 // Machine number 64 constexpr Elf_Half EM_NONE = 0 ; // No machine 65 constexpr Elf_Half EM_M32 = 1 ; // AT&T WE 32100 66 constexpr Elf_Half EM_SPARC = 2 ; // SUN SPARC 67 constexpr Elf_Half EM_386 = 3 ; // Intel 80386 68 constexpr Elf_Half EM_68K = 4 ; // Motorola m68k family 69 constexpr Elf_Half EM_88K = 5 ; // Motorola m88k family 70 constexpr Elf_Half EM_486 = 6 ; // Intel 80486// Reserved for future use 71 constexpr Elf_Half EM_860 = 7 ; // Intel 80860 72 constexpr Elf_Half EM_MIPS = 8 ; // MIPS R3000 (officially, big-endian only) 73 constexpr Elf_Half EM_S370 = 9 ; // IBM System/370 74 constexpr Elf_Half EM_MIPS_RS3_LE = 10; // MIPS R3000 little-endian (Deprecated) 75 constexpr Elf_Half EM_res011 = 11; // Reserved 76 constexpr Elf_Half EM_res012 = 12; // Reserved 77 constexpr Elf_Half EM_res013 = 13; // Reserved 78 constexpr Elf_Half EM_res014 = 14; // Reserved 79 constexpr Elf_Half EM_PARISC = 15; // HPPA 80 constexpr Elf_Half EM_res016 = 16; // Reserved 81 constexpr Elf_Half EM_VPP550 = 17; // Fujitsu VPP500 82 constexpr Elf_Half EM_SPARC32PLUS = 18; // Sun's "v8plus" 83 constexpr Elf_Half EM_960 = 19; // Intel 80960 84 constexpr Elf_Half EM_PPC = 20; // PowerPC 85 constexpr Elf_Half EM_PPC64 = 21; // 64-bit PowerPC 86 constexpr Elf_Half EM_S390 = 22; // IBM S/390 87 constexpr Elf_Half EM_SPU = 23; // Sony/Toshiba/IBM SPU 88 constexpr Elf_Half EM_res024 = 24; // Reserved 89 constexpr Elf_Half EM_res025 = 25; // Reserved 90 constexpr Elf_Half EM_res026 = 26; // Reserved 91 constexpr Elf_Half EM_res027 = 27; // Reserved 92 constexpr Elf_Half EM_res028 = 28; // Reserved 93 constexpr Elf_Half EM_res029 = 29; // Reserved 94 constexpr Elf_Half EM_res030 = 30; // Reserved 95 constexpr Elf_Half EM_res031 = 31; // Reserved 96 constexpr Elf_Half EM_res032 = 32; // Reserved 97 constexpr Elf_Half EM_res033 = 33; // Reserved 98 constexpr Elf_Half EM_res034 = 34; // Reserved 99 constexpr Elf_Half EM_res035 = 35; // Reserved 100 constexpr Elf_Half EM_V800 = 36; // NEC V800 series 101 constexpr Elf_Half EM_FR20 = 37; // Fujitsu FR20 102 constexpr Elf_Half EM_RH32 = 38; // TRW RH32 103 constexpr Elf_Half EM_MCORE = 39; // Motorola M*Core // May also be taken by Fujitsu MMA 104 constexpr Elf_Half EM_RCE = 39; // Old name for MCore 105 constexpr Elf_Half EM_ARM = 40; // ARM 106 constexpr Elf_Half EM_OLD_ALPHA = 41; // Digital Alpha 107 constexpr Elf_Half EM_SH = 42; // Renesas (formerly Hitachi) / SuperH SH 108 constexpr Elf_Half EM_SPARCV9 = 43; // SPARC v9 64-bit 109 constexpr Elf_Half EM_TRICORE = 44; // Siemens Tricore embedded processor 110 constexpr Elf_Half EM_ARC = 45; // ARC Cores 111 constexpr Elf_Half EM_H8_300 = 46; // Renesas (formerly Hitachi) H8/300 112 constexpr Elf_Half EM_H8_300H = 47; // Renesas (formerly Hitachi) H8/300H 113 constexpr Elf_Half EM_H8S = 48; // Renesas (formerly Hitachi) H8S 114 constexpr Elf_Half EM_H8_500 = 49; // Renesas (formerly Hitachi) H8/500 115 constexpr Elf_Half EM_IA_64 = 50; // Intel IA-64 Processor 116 constexpr Elf_Half EM_MIPS_X = 51; // Stanford MIPS-X 117 constexpr Elf_Half EM_COLDFIRE = 52; // Motorola Coldfire 118 constexpr Elf_Half EM_68HC12 = 53; // Motorola M68HC12 119 constexpr Elf_Half EM_MMA = 54; // Fujitsu Multimedia Accelerator 120 constexpr Elf_Half EM_PCP = 55; // Siemens PCP 121 constexpr Elf_Half EM_NCPU = 56; // Sony nCPU embedded RISC processor 122 constexpr Elf_Half EM_NDR1 = 57; // Denso NDR1 microprocesspr 123 constexpr Elf_Half EM_STARCORE = 58; // Motorola Star*Core processor 124 constexpr Elf_Half EM_ME16 = 59; // Toyota ME16 processor 125 constexpr Elf_Half EM_ST100 = 60; // STMicroelectronics ST100 processor 126 constexpr Elf_Half EM_TINYJ = 61; // Advanced Logic Corp. TinyJ embedded processor 127 constexpr Elf_Half EM_X86_64 = 62; // Advanced Micro Devices X86-64 processor 128 constexpr Elf_Half EM_PDSP = 63; // Sony DSP Processor 129 constexpr Elf_Half EM_PDP10 = 64; // Digital Equipment Corp. PDP-10 130 constexpr Elf_Half EM_PDP11 = 65; // Digital Equipment Corp. PDP-11 131 constexpr Elf_Half EM_FX66 = 66; // Siemens FX66 microcontroller 132 constexpr Elf_Half EM_ST9PLUS = 67; // STMicroelectronics ST9+ 8/16 bit microcontroller 133 constexpr Elf_Half EM_ST7 = 68 ; // STMicroelectronics ST7 8-bit microcontroller 134 constexpr Elf_Half EM_68HC16 = 69 ; // Motorola MC68HC16 Microcontroller 135 constexpr Elf_Half EM_68HC11 = 70 ; // Motorola MC68HC11 Microcontroller 136 constexpr Elf_Half EM_68HC08 = 71 ; // Motorola MC68HC08 Microcontroller 137 constexpr Elf_Half EM_68HC05 = 72 ; // Motorola MC68HC05 Microcontroller 138 constexpr Elf_Half EM_SVX = 73 ; // Silicon Graphics SVx 139 constexpr Elf_Half EM_ST19 = 74 ; // STMicroelectronics ST19 8-bit cpu 140 constexpr Elf_Half EM_VAX = 75 ; // Digital VAX 141 constexpr Elf_Half EM_CRIS = 76 ; // Axis Communications 32-bit embedded processor 142 constexpr Elf_Half EM_JAVELIN = 77 ; // Infineon Technologies 32-bit embedded cpu 143 constexpr Elf_Half EM_FIREPATH = 78 ; // Element 14 64-bit DSP processor 144 constexpr Elf_Half EM_ZSP = 79 ; // LSI Logic's 16-bit DSP processor 145 constexpr Elf_Half EM_MMIX = 80 ; // Donald Knuth's educational 64-bit processor 146 constexpr Elf_Half EM_HUANY = 81 ; // Harvard's machine-independent format 147 constexpr Elf_Half EM_PRISM = 82 ; // SiTera Prism 148 constexpr Elf_Half EM_AVR = 83 ; // Atmel AVR 8-bit microcontroller 149 constexpr Elf_Half EM_FR30 = 84 ; // Fujitsu FR30 150 constexpr Elf_Half EM_D10V = 85 ; // Mitsubishi D10V 151 constexpr Elf_Half EM_D30V = 86 ; // Mitsubishi D30V 152 constexpr Elf_Half EM_V850 = 87 ; // NEC v850 153 constexpr Elf_Half EM_M32R = 88 ; // Renesas M32R (formerly Mitsubishi M32R) 154 constexpr Elf_Half EM_MN10300 = 89 ; // Matsushita MN10300 155 constexpr Elf_Half EM_MN10200 = 90 ; // Matsushita MN10200 156 constexpr Elf_Half EM_PJ = 91 ; // picoJava 157 constexpr Elf_Half EM_OPENRISC = 92 ; // OpenRISC 32-bit embedded processor 158 constexpr Elf_Half EM_ARC_A5 = 93 ; // ARC Cores Tangent-A5 159 constexpr Elf_Half EM_XTENSA = 94 ; // Tensilica Xtensa Architecture 160 constexpr Elf_Half EM_VIDEOCORE = 95 ; // Alphamosaic VideoCore processor 161 constexpr Elf_Half EM_TMM_GPP = 96 ; // Thompson Multimedia General Purpose Processor 162 constexpr Elf_Half EM_NS32K = 97 ; // National Semiconductor 32000 series 163 constexpr Elf_Half EM_TPC = 98 ; // Tenor Network TPC processor 164 constexpr Elf_Half EM_SNP1K = 99 ; // Trebia SNP 1000 processor 165 constexpr Elf_Half EM_ST200 = 100; // STMicroelectronics ST200 microcontroller 166 constexpr Elf_Half EM_IP2K = 101; // Ubicom IP2022 micro controller 167 constexpr Elf_Half EM_MAX = 102; // MAX Processor 168 constexpr Elf_Half EM_CR = 103; // National Semiconductor CompactRISC 169 constexpr Elf_Half EM_F2MC16 = 104; // Fujitsu F2MC16 170 constexpr Elf_Half EM_MSP430 = 105; // TI msp430 micro controller 171 constexpr Elf_Half EM_BLACKFIN = 106; // ADI Blackfin 172 constexpr Elf_Half EM_SE_C33 = 107; // S1C33 Family of Seiko Epson processors 173 constexpr Elf_Half EM_SEP = 108; // Sharp embedded microprocessor 174 constexpr Elf_Half EM_ARCA = 109; // Arca RISC Microprocessor 175 constexpr Elf_Half EM_UNICORE = 110; // Microprocessor series from PKU-Unity Ltd. 176 constexpr Elf_Half EM_EXCESS = 111; // eXcess: 16/32/64-bit configurable embedded CPU 177 constexpr Elf_Half EM_DXP = 112; // Icera Semiconductor Inc. Deep Execution Processor 178 constexpr Elf_Half EM_ALTERA_NIOS2 = 113; // Altera Nios II soft-core processor 179 constexpr Elf_Half EM_CRX = 114; // National Semiconductor CRX 180 constexpr Elf_Half EM_XGATE = 115; // Motorola XGATE embedded processor 181 constexpr Elf_Half EM_C166 = 116; // Infineon C16x/XC16x processor 182 constexpr Elf_Half EM_M16C = 117; // Renesas M16C series microprocessors 183 constexpr Elf_Half EM_DSPIC30F = 118; // Microchip Technology dsPIC30F DSignal Controller 184 constexpr Elf_Half EM_CE = 119; // Freescale Communication Engine RISC core 185 constexpr Elf_Half EM_M32C = 120; // Renesas M32C series microprocessors 186 constexpr Elf_Half EM_res121 = 121; // Reserved 187 constexpr Elf_Half EM_res122 = 122; // Reserved 188 constexpr Elf_Half EM_res123 = 123; // Reserved 189 constexpr Elf_Half EM_res124 = 124; // Reserved 190 constexpr Elf_Half EM_res125 = 125; // Reserved 191 constexpr Elf_Half EM_res126 = 126; // Reserved 192 constexpr Elf_Half EM_res127 = 127; // Reserved 193 constexpr Elf_Half EM_res128 = 128; // Reserved 194 constexpr Elf_Half EM_res129 = 129; // Reserved 195 constexpr Elf_Half EM_res130 = 130; // Reserved 196 constexpr Elf_Half EM_TSK3000 = 131; // Altium TSK3000 core 197 constexpr Elf_Half EM_RS08 = 132; // Freescale RS08 embedded processor 198 constexpr Elf_Half EM_res133 = 133; // Reserved 199 constexpr Elf_Half EM_ECOG2 = 134; // Cyan Technology eCOG2 microprocessor 200 constexpr Elf_Half EM_SCORE = 135; // Sunplus Score 201 constexpr Elf_Half EM_SCORE7 = 135; // Sunplus S+core7 RISC processor 202 constexpr Elf_Half EM_DSP24 = 136; // New Japan Radio (NJR) 24-bit DSP Processor 203 constexpr Elf_Half EM_VIDEOCORE3 = 137; // Broadcom VideoCore III processor 204 constexpr Elf_Half EM_LATTICEMICO32 = 138; // RISC processor for Lattice FPGA architecture 205 constexpr Elf_Half EM_SE_C17 = 139; // Seiko Epson C17 family 206 constexpr Elf_Half EM_TI_C6000 = 140; // Texas Instruments TMS320C6000 DSP family 207 constexpr Elf_Half EM_TI_C2000 = 141; // Texas Instruments TMS320C2000 DSP family 208 constexpr Elf_Half EM_TI_C5500 = 142; // Texas Instruments TMS320C55x DSP family 209 constexpr Elf_Half EM_res143 = 143; // Reserved 210 constexpr Elf_Half EM_res144 = 144; // Reserved 211 constexpr Elf_Half EM_res145 = 145; // Reserved 212 constexpr Elf_Half EM_res146 = 146; // Reserved 213 constexpr Elf_Half EM_res147 = 147; // Reserved 214 constexpr Elf_Half EM_res148 = 148; // Reserved 215 constexpr Elf_Half EM_res149 = 149; // Reserved 216 constexpr Elf_Half EM_res150 = 150; // Reserved 217 constexpr Elf_Half EM_res151 = 151; // Reserved 218 constexpr Elf_Half EM_res152 = 152; // Reserved 219 constexpr Elf_Half EM_res153 = 153; // Reserved 220 constexpr Elf_Half EM_res154 = 154; // Reserved 221 constexpr Elf_Half EM_res155 = 155; // Reserved 222 constexpr Elf_Half EM_res156 = 156; // Reserved 223 constexpr Elf_Half EM_res157 = 157; // Reserved 224 constexpr Elf_Half EM_res158 = 158; // Reserved 225 constexpr Elf_Half EM_res159 = 159; // Reserved 226 constexpr Elf_Half EM_MMDSP_PLUS = 160; // STMicroelectronics 64bit VLIW Data Signal Processor 227 constexpr Elf_Half EM_CYPRESS_M8C = 161; // Cypress M8C microprocessor 228 constexpr Elf_Half EM_R32C = 162; // Renesas R32C series microprocessors 229 constexpr Elf_Half EM_TRIMEDIA = 163; // NXP Semiconductors TriMedia architecture family 230 constexpr Elf_Half EM_QDSP6 = 164; // QUALCOMM DSP6 Processor 231 constexpr Elf_Half EM_8051 = 165; // Intel 8051 and variants 232 constexpr Elf_Half EM_STXP7X = 166; // STMicroelectronics STxP7x family 233 constexpr Elf_Half EM_NDS32 = 167; // Andes Technology embedded RISC processor family 234 constexpr Elf_Half EM_ECOG1 = 168; // Cyan Technology eCOG1X family 235 constexpr Elf_Half EM_ECOG1X = 168; // Cyan Technology eCOG1X family 236 constexpr Elf_Half EM_MAXQ30 = 169; // Dallas Semiconductor MAXQ30 Core Micro-controllers 237 constexpr Elf_Half EM_XIMO16 = 170; // New Japan Radio (NJR) 16-bit DSP Processor 238 constexpr Elf_Half EM_MANIK = 171; // M2000 Reconfigurable RISC Microprocessor 239 constexpr Elf_Half EM_CRAYNV2 = 172; // Cray Inc. NV2 vector architecture 240 constexpr Elf_Half EM_RX = 173; // Renesas RX family 241 constexpr Elf_Half EM_METAG = 174; // Imagination Technologies META processor architecture 242 constexpr Elf_Half EM_MCST_ELBRUS = 175; // MCST Elbrus general purpose hardware architecture 243 constexpr Elf_Half EM_ECOG16 = 176; // Cyan Technology eCOG16 family 244 constexpr Elf_Half EM_CR16 = 177; // National Semiconductor CompactRISC 16-bit processor 245 constexpr Elf_Half EM_ETPU = 178; // Freescale Extended Time Processing Unit 246 constexpr Elf_Half EM_SLE9X = 179; // Infineon Technologies SLE9X core 247 constexpr Elf_Half EM_L1OM = 180; // Intel L1OM 248 constexpr Elf_Half EM_INTEL181 = 181; // Reserved by Intel 249 constexpr Elf_Half EM_INTEL182 = 182; // Reserved by Intel 250 constexpr Elf_Half EM_AARCH64 = 183; // ARM AArch64 251 constexpr Elf_Half EM_res184 = 184; // Reserved by ARM 252 constexpr Elf_Half EM_AVR32 = 185; // Atmel Corporation 32-bit microprocessor family 253 constexpr Elf_Half EM_STM8 = 186; // STMicroeletronics STM8 8-bit microcontroller 254 constexpr Elf_Half EM_TILE64 = 187; // Tilera TILE64 multicore architecture family 255 constexpr Elf_Half EM_TILEPRO = 188; // Tilera TILEPro multicore architecture family 256 constexpr Elf_Half EM_MICROBLAZE = 189; // Xilinx MicroBlaze 32-bit RISC soft processor core 257 constexpr Elf_Half EM_CUDA = 190; // NVIDIA CUDA architecture 258 constexpr Elf_Half EM_TILEGX = 191; // Tilera TILE-Gx multicore architecture family 259 constexpr Elf_Half EM_CLOUDSHIELD = 192; // CloudShield architecture family 260 constexpr Elf_Half EM_COREA_1ST = 193; // KIPO-KAIST Core-A 1st generation processor family 261 constexpr Elf_Half EM_COREA_2ND = 194; // KIPO-KAIST Core-A 2nd generation processor family 262 constexpr Elf_Half EM_ARC_COMPACT2 = 195; // Synopsys ARCompact V2 263 constexpr Elf_Half EM_OPEN8 = 196; // Open8 8-bit RISC soft processor core 264 constexpr Elf_Half EM_RL78 = 197; // Renesas RL78 family 265 constexpr Elf_Half EM_VIDEOCORE5 = 198; // Broadcom VideoCore V processor 266 constexpr Elf_Half EM_78KOR = 199; // Renesas 78KOR family 267 constexpr Elf_Half EM_56800EX = 200; // Freescale 56800EX Digital Signal Controller (DSC) 268 constexpr Elf_Half EM_BA1 = 201; // Beyond BA1 CPU architecture 269 constexpr Elf_Half EM_BA2 = 202; // Beyond BA2 CPU architecture 270 constexpr Elf_Half EM_XCORE = 203; // XMOS xCORE processor family 271 constexpr Elf_Half EM_MCHP_PIC = 204; // Microchip 8-bit PIC(r) family 272 constexpr Elf_Half EM_INTEL205 = 205; // Reserved by Intel 273 constexpr Elf_Half EM_INTEL206 = 206; // Reserved by Intel 274 constexpr Elf_Half EM_INTEL207 = 207; // Reserved by Intel 275 constexpr Elf_Half EM_INTEL208 = 208; // Reserved by Intel 276 constexpr Elf_Half EM_INTEL209 = 209; // Reserved by Intel 277 constexpr Elf_Half EM_KM32 = 210; // KM211 KM32 32-bit processor 278 constexpr Elf_Half EM_KMX32 = 211; // KM211 KMX32 32-bit processor 279 constexpr Elf_Half EM_KMX16 = 212; // KM211 KMX16 16-bit processor 280 constexpr Elf_Half EM_KMX8 = 213; // KM211 KMX8 8-bit processor 281 constexpr Elf_Half EM_KVARC = 214; // KM211 KVARC processor 282 constexpr Elf_Half EM_CDP = 215; // Paneve CDP architecture family 283 constexpr Elf_Half EM_COGE = 216; // Cognitive Smart Memory Processor 284 constexpr Elf_Half EM_COOL = 217; // iCelero CoolEngine 285 constexpr Elf_Half EM_NORC = 218; // Nanoradio Optimized RISC 286 constexpr Elf_Half EM_CSR_KALIMBA = 219; // CSR Kalimba architecture family 287 constexpr Elf_Half EM_Z80 = 220; // Zilog Z80 288 constexpr Elf_Half EM_VISIUM = 221; // Controls and Data Services VISIUMcore processor 289 constexpr Elf_Half EM_FT32 = 222; // FTDI Chip FT32 high performance 32-bit RISC architecture 290 constexpr Elf_Half EM_MOXIE = 223; // Moxie processor family 291 constexpr Elf_Half EM_AMDGPU = 224; // AMD GPU architecture 292 constexpr Elf_Half EM_RISCV = 243; // RISC-V 293 constexpr Elf_Half EM_LANAI = 244; // Lanai processor 294 constexpr Elf_Half EM_CEVA = 245; // CEVA Processor Architecture Family 295 constexpr Elf_Half EM_CEVA_X2 = 246; // CEVA X2 Processor Family 296 constexpr Elf_Half EM_BPF = 247; // Linux BPF – in-kernel virtual machine 297 constexpr Elf_Half EM_GRAPHCORE_IPU = 248; // Graphcore Intelligent Processing Unit 298 constexpr Elf_Half EM_IMG1 = 249; // Imagination Technologies 299 constexpr Elf_Half EM_NFP = 250; // Netronome Flow Processor (P) 300 constexpr Elf_Half EM_CSKY = 252; // C-SKY processor family 301 constexpr Elf_Half EM_ARC_COMPACT3_64 = 253; // Synopsys ARCv2.3 64-bit 302 constexpr Elf_Half EM_MCS6502 = 254; // MOS Technology MCS 6502 processor 303 constexpr Elf_Half EM_ARC_COMPACT3 = 255; // Synopsys ARCv2.3 32-bit 304 constexpr Elf_Half EM_KVX = 256; // Kalray VLIW core of the MPPA processor family 305 constexpr Elf_Half EM_65816 = 257; // WDC 65816/65C816 306 constexpr Elf_Half EM_LOONGARCH = 258; // Loongson Loongarch 307 constexpr Elf_Half EM_KF32 = 259; // ChipON KungFu32 308 309 constexpr Elf_Half EM_MT = 0x2530; // Morpho Techologies MT processor 310 constexpr Elf_Half EM_ALPHA = 0x9026; // Alpha 311 constexpr Elf_Half EM_WEBASSEMBLY = 0x4157; // Web Assembly 312 constexpr Elf_Half EM_DLX = 0x5aa5; // OpenDLX 313 constexpr Elf_Half EM_XSTORMY16 = 0xad45; // Sanyo XStormy16 CPU core 314 constexpr Elf_Half EM_IQ2000 = 0xFEBA; // Vitesse IQ2000 315 constexpr Elf_Half EM_M32C_OLD = 0xFEB; 316 constexpr Elf_Half EM_NIOS32 = 0xFEBB; // Altera Nios 317 constexpr Elf_Half EM_CYGNUS_MEP = 0xF00D; // Toshiba MeP Media Engine 318 constexpr Elf_Half EM_ADAPTEVA_EPIPHANY = 0x1223; // Adapteva EPIPHANY 319 constexpr Elf_Half EM_CYGNUS_FRV = 0x5441; // Fujitsu FR-V 320 constexpr Elf_Half EM_S12Z = 0x4DEF; // Freescale S12Z 321 // clang-format on 322 323 // File version 324 constexpr unsigned char EV_NONE = 0; 325 constexpr unsigned char EV_CURRENT = 1; 326 327 // Identification index 328 constexpr unsigned char EI_MAG0 = 0; 329 constexpr unsigned char EI_MAG1 = 1; 330 constexpr unsigned char EI_MAG2 = 2; 331 constexpr unsigned char EI_MAG3 = 3; 332 constexpr unsigned char EI_CLASS = 4; 333 constexpr unsigned char EI_DATA = 5; 334 constexpr unsigned char EI_VERSION = 6; 335 constexpr unsigned char EI_OSABI = 7; 336 constexpr unsigned char EI_ABIVERSION = 8; 337 constexpr unsigned char EI_PAD = 9; 338 constexpr unsigned char EI_NIDENT = 16; 339 340 // Magic number 341 constexpr unsigned char ELFMAG0 = 0x7F; 342 constexpr unsigned char ELFMAG1 = 'E'; 343 constexpr unsigned char ELFMAG2 = 'L'; 344 constexpr unsigned char ELFMAG3 = 'F'; 345 346 // File class 347 constexpr unsigned char ELFCLASSNONE = 0; 348 constexpr unsigned char ELFCLASS32 = 1; 349 constexpr unsigned char ELFCLASS64 = 2; 350 351 // Encoding 352 constexpr unsigned char ELFDATANONE = 0; 353 constexpr unsigned char ELFDATA2LSB = 1; 354 constexpr unsigned char ELFDATA2MSB = 2; 355 356 // clang-format off 357 // OS extensions 358 constexpr unsigned char ELFOSABI_NONE = 0; // No extensions or unspecified 359 constexpr unsigned char ELFOSABI_HPUX = 1; // Hewlett-Packard HP-UX 360 constexpr unsigned char ELFOSABI_NETBSD = 2; // NetBSD 361 constexpr unsigned char ELFOSABI_LINUX = 3; // Linux 362 constexpr unsigned char ELFOSABI_HURD = 4; // GNU Hurd 363 constexpr unsigned char ELFOSABI_SOLARIS = 6; // Sun Solaris 364 constexpr unsigned char ELFOSABI_AIX = 7; // AIX 365 constexpr unsigned char ELFOSABI_IRIX = 8; // IRIX 366 constexpr unsigned char ELFOSABI_FREEBSD = 9; // FreeBSD 367 constexpr unsigned char ELFOSABI_TRU64 = 10; // Compaq TRU64 UNIX 368 constexpr unsigned char ELFOSABI_MODESTO = 11; // Novell Modesto 369 constexpr unsigned char ELFOSABI_OPENBSD = 12; // Open BSD 370 constexpr unsigned char ELFOSABI_OPENVMS = 13; // Open VMS 371 constexpr unsigned char ELFOSABI_NSK = 14; // Hewlett-Packard Non-Stop Kernel 372 constexpr unsigned char ELFOSABI_AROS = 15; // Amiga Research OS 373 constexpr unsigned char ELFOSABI_FENIXOS = 16; // The FenixOS highly scalable multi-core OS 374 constexpr unsigned char ELFOSABI_NUXI = 17; // Nuxi CloudABI 375 constexpr unsigned char ELFOSABI_OPENVOS = 18; // Stratus Technologies OpenVOS 376 constexpr unsigned char ELFOSABI_ARM = 97; // ARM 377 constexpr unsigned char ELFOSABI_STANDALONE = 255; // Standalone (embedded) application 378 379 // 64-255 Architecture-specific value range 380 // AMDGPU OS for HSA compatible compute kernels 381 constexpr unsigned char ELFOSABI_AMDGPU_HSA = 64; 382 // AMDGPU OS for AMD PAL compatible graphics 383 // shaders and compute kernels 384 constexpr unsigned char ELFOSABI_AMDGPU_PAL = 65; 385 // AMDGPU OS for Mesa3D compatible graphics 386 // shaders and compute kernels 387 constexpr unsigned char ELFOSABI_AMDGPU_MESA3D = 66; 388 // clang-format on 389 390 constexpr unsigned char ELFABIVERSION_AMDGPU_HSA_V2 = 0; 391 constexpr unsigned char ELFABIVERSION_AMDGPU_HSA_V3 = 1; 392 constexpr unsigned char ELFABIVERSION_AMDGPU_HSA_V4 = 2; 393 394 // AMDGPU specific e_flags 395 constexpr Elf_Word EF_AMDGPU_MACH = 0x0ff; // AMDGPU processor selection mask. 396 // Indicates if the XNACK target feature is 397 // enabled for all code contained in the ELF. 398 constexpr Elf_Word EF_AMDGPU_XNACK = 0x100; 399 400 constexpr Elf_Word EF_AMDGPU_FEATURE_XNACK_V2 = 0x01; 401 constexpr Elf_Word EF_AMDGPU_FEATURE_TRAP_HANDLER_V2 = 0x02; 402 constexpr Elf_Word EF_AMDGPU_FEATURE_XNACK_V3 = 0x100; 403 constexpr Elf_Word EF_AMDGPU_FEATURE_SRAMECC_V3 = 0x200; 404 constexpr Elf_Word EF_AMDGPU_FEATURE_XNACK_V4 = 0x300; 405 constexpr Elf_Word EF_AMDGPU_FEATURE_XNACK_UNSUPPORTED_V4 = 0x000; 406 constexpr Elf_Word EF_AMDGPU_FEATURE_XNACK_ANY_V4 = 0x100; 407 constexpr Elf_Word EF_AMDGPU_FEATURE_XNACK_OFF_V4 = 0x200; 408 constexpr Elf_Word EF_AMDGPU_FEATURE_XNACK_ON_V4 = 0x300; 409 constexpr Elf_Word EF_AMDGPU_FEATURE_SRAMECC_V4 = 0xc00; 410 constexpr Elf_Word EF_AMDGPU_FEATURE_SRAMECC_UNSUPPORTED_V4 = 0x000; 411 constexpr Elf_Word EF_AMDGPU_FEATURE_SRAMECC_ANY_V4 = 0x400; 412 constexpr Elf_Word EF_AMDGPU_FEATURE_SRAMECC_OFF_V4 = 0x800; 413 constexpr Elf_Word EF_AMDGPU_FEATURE_SRAMECC_ON_V4 = 0xc00; 414 415 // AMDGPU processors 416 constexpr Elf_Word EF_AMDGPU_MACH_NONE = 0x000; // Unspecified processor. 417 constexpr Elf_Word EF_AMDGPU_MACH_R600_R600 = 0x001; 418 constexpr Elf_Word EF_AMDGPU_MACH_R600_R630 = 0x002; 419 constexpr Elf_Word EF_AMDGPU_MACH_R600_RS880 = 0x003; 420 constexpr Elf_Word EF_AMDGPU_MACH_R600_RV670 = 0x004; 421 constexpr Elf_Word EF_AMDGPU_MACH_R600_RV710 = 0x005; 422 constexpr Elf_Word EF_AMDGPU_MACH_R600_RV730 = 0x006; 423 constexpr Elf_Word EF_AMDGPU_MACH_R600_RV770 = 0x007; 424 constexpr Elf_Word EF_AMDGPU_MACH_R600_CEDAR = 0x008; 425 constexpr Elf_Word EF_AMDGPU_MACH_R600_CYPRESS = 0x009; 426 constexpr Elf_Word EF_AMDGPU_MACH_R600_JUNIPER = 0x00a; 427 constexpr Elf_Word EF_AMDGPU_MACH_R600_REDWOOD = 0x00b; 428 constexpr Elf_Word EF_AMDGPU_MACH_R600_SUMO = 0x00c; 429 constexpr Elf_Word EF_AMDGPU_MACH_R600_BARTS = 0x00d; 430 constexpr Elf_Word EF_AMDGPU_MACH_R600_CAICOS = 0x00e; 431 constexpr Elf_Word EF_AMDGPU_MACH_R600_CAYMAN = 0x00f; 432 constexpr Elf_Word EF_AMDGPU_MACH_R600_TURKS = 0x010; 433 constexpr Elf_Word EF_AMDGPU_MACH_R600_RESERVED_FIRST = 0x011; 434 constexpr Elf_Word EF_AMDGPU_MACH_R600_RESERVED_LAST = 0x01f; 435 constexpr Elf_Word EF_AMDGPU_MACH_R600_FIRST = EF_AMDGPU_MACH_R600_R600; 436 constexpr Elf_Word EF_AMDGPU_MACH_R600_LAST = EF_AMDGPU_MACH_R600_TURKS; 437 438 // AMDGCN-based processors. 439 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX600 = 0x020; 440 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX601 = 0x021; 441 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX700 = 0x022; 442 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX701 = 0x023; 443 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX702 = 0x024; 444 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX703 = 0x025; 445 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX704 = 0x026; 446 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_RESERVED_0X27 = 0x027; 447 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX801 = 0x028; 448 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX802 = 0x029; 449 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX803 = 0x02a; 450 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX810 = 0x02b; 451 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX900 = 0x02c; 452 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX902 = 0x02d; 453 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX904 = 0x02e; 454 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX906 = 0x02f; 455 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX908 = 0x030; 456 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX909 = 0x031; 457 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX90C = 0x032; 458 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX1010 = 0x033; 459 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX1011 = 0x034; 460 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX1012 = 0x035; 461 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX1030 = 0x036; 462 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX1031 = 0x037; 463 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX1032 = 0x038; 464 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX1033 = 0x039; 465 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX602 = 0x03a; 466 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX705 = 0x03b; 467 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX805 = 0x03c; 468 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_RESERVED_0X3D = 0x03d; 469 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX1034 = 0x03e; 470 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX90A = 0x03f; 471 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_RESERVED_0X40 = 0x040; 472 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_RESERVED_0X41 = 0x041; 473 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_GFX1013 = 0x042; 474 // First/last AMDGCN-based processors. 475 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_FIRST = EF_AMDGPU_MACH_AMDGCN_GFX600; 476 constexpr Elf_Word EF_AMDGPU_MACH_AMDGCN_LAST = EF_AMDGPU_MACH_AMDGCN_GFX1013; 477 478 ///////////////////// 479 // Sections constants 480 481 // Section indexes 482 constexpr Elf_Word SHN_UNDEF = 0; 483 constexpr Elf_Word SHN_LORESERVE = 0xFF00; 484 constexpr Elf_Word SHN_LOPROC = 0xFF00; 485 constexpr Elf_Word SHN_HIPROC = 0xFF1F; 486 constexpr Elf_Word SHN_LOOS = 0xFF20; 487 constexpr Elf_Word SHN_HIOS = 0xFF3F; 488 constexpr Elf_Word SHN_ABS = 0xFFF1; 489 constexpr Elf_Word SHN_COMMON = 0xFFF2; 490 constexpr Elf_Word SHN_XINDEX = 0xFFFF; 491 constexpr Elf_Word SHN_HIRESERVE = 0xFFFF; 492 493 // Section types 494 constexpr Elf_Word SHT_NULL = 0; 495 constexpr Elf_Word SHT_PROGBITS = 1; 496 constexpr Elf_Word SHT_SYMTAB = 2; 497 constexpr Elf_Word SHT_STRTAB = 3; 498 constexpr Elf_Word SHT_RELA = 4; 499 constexpr Elf_Word SHT_HASH = 5; 500 constexpr Elf_Word SHT_DYNAMIC = 6; 501 constexpr Elf_Word SHT_NOTE = 7; 502 constexpr Elf_Word SHT_NOBITS = 8; 503 constexpr Elf_Word SHT_REL = 9; 504 constexpr Elf_Word SHT_SHLIB = 10; 505 constexpr Elf_Word SHT_DYNSYM = 11; 506 constexpr Elf_Word SHT_INIT_ARRAY = 14; 507 constexpr Elf_Word SHT_FINI_ARRAY = 15; 508 constexpr Elf_Word SHT_PREINIT_ARRAY = 16; 509 constexpr Elf_Word SHT_GROUP = 17; 510 constexpr Elf_Word SHT_SYMTAB_SHNDX = 18; 511 constexpr Elf_Word SHT_GNU_ATTRIBUTES = 0x6ffffff5; 512 constexpr Elf_Word SHT_GNU_HASH = 0x6ffffff6; 513 constexpr Elf_Word SHT_GNU_LIBLIST = 0x6ffffff7; 514 constexpr Elf_Word SHT_CHECKSUM = 0x6ffffff8; 515 constexpr Elf_Word SHT_LOSUNW = 0x6ffffffa; 516 constexpr Elf_Word SHT_SUNW_move = 0x6ffffffa; 517 constexpr Elf_Word SHT_SUNW_COMDAT = 0x6ffffffb; 518 constexpr Elf_Word SHT_SUNW_syminfo = 0x6ffffffc; 519 constexpr Elf_Word SHT_GNU_verdef = 0x6ffffffd; 520 constexpr Elf_Word SHT_GNU_verneed = 0x6ffffffe; 521 constexpr Elf_Word SHT_GNU_versym = 0x6fffffff; 522 constexpr Elf_Word SHT_LOOS = 0x60000000; 523 constexpr Elf_Word SHT_HIOS = 0x6fffffff; 524 constexpr Elf_Word SHT_LOPROC = 0x70000000; 525 constexpr Elf_Word SHT_ARM_EXIDX = 0x70000001; 526 constexpr Elf_Word SHT_ARM_PREEMPTMAP = 0x70000002; 527 constexpr Elf_Word SHT_ARM_ATTRIBUTES = 0x70000003; 528 constexpr Elf_Word SHT_ARM_DEBUGOVERLAY = 0x70000004; 529 constexpr Elf_Word SHT_ARM_OVERLAYSECTION = 0x70000005; 530 constexpr Elf_Word SHT_HIPROC = 0x7FFFFFFF; 531 constexpr Elf_Word SHT_LOUSER = 0x80000000; 532 // Used by Nintendo Wii U 533 constexpr Elf_Word SHT_RPL_EXPORTS = 0x80000001; 534 constexpr Elf_Word SHT_RPL_IMPORTS = 0x80000002; 535 constexpr Elf_Word SHT_RPL_CRCS = 0x80000003; 536 constexpr Elf_Word SHT_RPL_FILEINFO = 0x80000004; 537 constexpr Elf_Word SHT_HIUSER = 0xFFFFFFFF; 538 539 // Section attribute flags 540 constexpr Elf_Xword SHF_WRITE = 0x1; 541 constexpr Elf_Xword SHF_ALLOC = 0x2; 542 constexpr Elf_Xword SHF_EXECINSTR = 0x4; 543 constexpr Elf_Xword SHF_MERGE = 0x10; 544 constexpr Elf_Xword SHF_STRINGS = 0x20; 545 constexpr Elf_Xword SHF_INFO_LINK = 0x40; 546 constexpr Elf_Xword SHF_LINK_ORDER = 0x80; 547 constexpr Elf_Xword SHF_OS_NONCONFORMING = 0x100; 548 constexpr Elf_Xword SHF_GROUP = 0x200; 549 constexpr Elf_Xword SHF_TLS = 0x400; 550 constexpr Elf_Xword SHF_COMPRESSED = 0x800; 551 constexpr Elf_Xword SHF_GNU_RETAIN = 0x200000; 552 constexpr Elf_Xword SHF_GNU_MBIND = 0x01000000; 553 // flag used in Nintendo RPX/RPL to indicate section data is compressed 554 constexpr Elf_Xword SHF_RPX_DEFLATE = 0x08000000; 555 constexpr Elf_Xword SHF_MASKOS = 0x0FF00000; 556 constexpr Elf_Xword SHF_MIPS_GPREL = 0x10000000; 557 constexpr Elf_Xword SHF_ORDERED = 0x40000000; 558 constexpr Elf_Xword SHF_EXCLUDE = 0x80000000; 559 constexpr Elf_Xword SHF_MASKPROC = 0xF0000000; 560 561 // Section group flags 562 constexpr Elf_Word GRP_COMDAT = 0x1; 563 constexpr Elf_Word GRP_MASKOS = 0x0ff00000; 564 constexpr Elf_Word GRP_MASKPROC = 0xf0000000; 565 566 // Symbol binding 567 constexpr unsigned char STB_LOCAL = 0; 568 constexpr unsigned char STB_GLOBAL = 1; 569 constexpr unsigned char STB_WEAK = 2; 570 constexpr unsigned char STB_LOOS = 10; 571 constexpr unsigned char STB_HIOS = 12; 572 constexpr unsigned char STB_MULTIDEF = 13; 573 constexpr unsigned char STB_LOPROC = 13; 574 constexpr unsigned char STB_HIPROC = 15; 575 576 // Values of note segment descriptor types for core files 577 constexpr Elf_Word NT_PRSTATUS = 1; // Contains copy of prstatus struct 578 constexpr Elf_Word NT_FPREGSET = 2; // Contains copy of fpregset struct 579 constexpr Elf_Word NT_PRPSINFO = 3; // Contains copy of prpsinfo struct 580 constexpr Elf_Word NT_TASKSTRUCT = 4; // Contains copy of task struct 581 constexpr Elf_Word NT_AUXV = 6; // Contains copy of Elfxx_auxv_t 582 constexpr Elf_Word NT_SIGINFO = 0x53494749; // Fields of siginfo_t. 583 constexpr Elf_Word NT_FILE = 0x46494c45; // Description of mapped files. 584 585 // Note segments for core files on dir-style procfs systems. 586 constexpr Elf_Word NT_PSTATUS = 10; // Has a struct pstatus 587 constexpr Elf_Word NT_FPREGS = 12; // Has a struct fpregset 588 constexpr Elf_Word NT_PSINFO = 13; // Has a struct psinfo 589 constexpr Elf_Word NT_LWPSTATUS = 16; // Has a struct lwpstatus_t 590 constexpr Elf_Word NT_LWPSINFO = 17; // Has a struct lwpsinfo_t 591 constexpr Elf_Word NT_WIN32PSTATUS = 18; // Has a struct win32_pstatus 592 593 // clang-format off 594 595 // Note name must be "LINUX" 596 constexpr Elf_Word NT_PRXFPREG = 0x46e62b7f; // Contains a user_xfpregs_struct 597 constexpr Elf_Word NT_PPC_VMX = 0x100; // PowerPC Altivec/VMX registers 598 constexpr Elf_Word NT_PPC_VSX = 0x102; // PowerPC VSX registers 599 constexpr Elf_Word NT_PPC_TAR = 0x103; // PowerPC Target Address Register 600 constexpr Elf_Word NT_PPC_PPR = 0x104; // PowerPC Program Priority Register 601 constexpr Elf_Word NT_PPC_DSCR = 0x105; // PowerPC Data Stream Control Register 602 constexpr Elf_Word NT_PPC_EBB = 0x106; // PowerPC Event Based Branch Registers 603 constexpr Elf_Word NT_PPC_PMU = 0x107; // PowerPC Performance Monitor Registers 604 constexpr Elf_Word NT_PPC_TM_CGPR = 0x108; // PowerPC TM checkpointed GPR Registers 605 constexpr Elf_Word NT_PPC_TM_CFPR = 0x109; // PowerPC TM checkpointed FPR Registers 606 constexpr Elf_Word NT_PPC_TM_CVMX = 0x10a; // PowerPC TM checkpointed VMX Registers 607 constexpr Elf_Word NT_PPC_TM_CVSX = 0x10b; // PowerPC TM checkpointed VSX Registers 608 constexpr Elf_Word NT_PPC_TM_SPR = 0x10c; // PowerPC TM Special Purpose Registers 609 constexpr Elf_Word NT_PPC_TM_CTAR = 0x10d; // PowerPC TM checkpointed TAR 610 constexpr Elf_Word NT_PPC_TM_CPPR = 0x10e; // PowerPC TM checkpointed PPR 611 constexpr Elf_Word NT_PPC_TM_CDSCR = 0x10f; // PowerPC TM checkpointed Data SCR 612 constexpr Elf_Word NT_386_TLS = 0x200; // x86 TLS information 613 constexpr Elf_Word NT_386_IOPERM = 0x201; // x86 io permissions 614 constexpr Elf_Word NT_X86_XSTATE = 0x202; // x86 XSAVE extended state 615 constexpr Elf_Word NT_X86_CET = 0x203; // x86 CET state. 616 constexpr Elf_Word NT_S390_HIGH_GPRS = 0x300; // S/390 upper halves of GPRs 617 constexpr Elf_Word NT_S390_TIMER = 0x301; // S390 timer 618 constexpr Elf_Word NT_S390_TODCMP = 0x302; // S390 TOD clock comparator 619 constexpr Elf_Word NT_S390_TODPREG = 0x303; // S390 TOD programmable register 620 constexpr Elf_Word NT_S390_CTRS = 0x304; // S390 control registers 621 constexpr Elf_Word NT_S390_PREFIX = 0x305; // S390 prefix register 622 constexpr Elf_Word NT_S390_LAST_BREAK = 0x306; // S390 breaking event address 623 constexpr Elf_Word NT_S390_SYSTEM_CALL = 0x307; // S390 system call restart data 624 constexpr Elf_Word NT_S390_TDB = 0x308; // S390 transaction diagnostic block 625 constexpr Elf_Word NT_S390_VXRS_LOW = 0x309; // S390 vector registers 0-15 upper half 626 constexpr Elf_Word NT_S390_VXRS_HIGH = 0x30a; // S390 vector registers 16-31 627 constexpr Elf_Word NT_S390_GS_CB = 0x30b; // s390 guarded storage registers 628 constexpr Elf_Word NT_S390_GS_BC = 0x30c; // s390 guarded storage broadcast control block 629 constexpr Elf_Word NT_ARM_VFP = 0x400; // ARM VFP registers 630 constexpr Elf_Word NT_ARM_TLS = 0x401; // AArch TLS registers 631 constexpr Elf_Word NT_ARM_HW_BREAK = 0x402; // AArch hardware breakpoint registers 632 constexpr Elf_Word NT_ARM_HW_WATCH = 0x403; // AArch hardware watchpoint registers 633 constexpr Elf_Word NT_ARM_SVE = 0x405; // AArch SVE registers. 634 constexpr Elf_Word NT_ARM_PAC_MASK = 0x406; // AArch pointer authentication code masks 635 constexpr Elf_Word NT_ARM_PACA_KEYS = 0x407; // ARM pointer authentication address keys 636 constexpr Elf_Word NT_ARM_PACG_KEYS = 0x408; // ARM pointer authentication generic keys 637 constexpr Elf_Word NT_ARM_TAGGED_ADDR_CTRL = 0x409; // AArch64 tagged address control (prctl()) 638 constexpr Elf_Word NT_ARM_PAC_ENABLED_KEYS = 0x40a; // AArch64 pointer authentication enabled keys (prctl()) 639 constexpr Elf_Word NT_ARC_V2 = 0x600; // ARC HS accumulator/extra registers. 640 constexpr Elf_Word NT_LARCH_CPUCFG = 0xa00; // LoongArch CPU config registers 641 constexpr Elf_Word NT_LARCH_CSR = 0xa01; // LoongArch Control State Registers 642 constexpr Elf_Word NT_LARCH_LSX = 0xa02; // LoongArch SIMD eXtension registers 643 constexpr Elf_Word NT_LARCH_LASX = 0xa03; // LoongArch Advanced SIMD eXtension registers 644 constexpr Elf_Word NT_RISCV_CSR = 0x900; // RISC-V Control and Status Registers 645 646 // Note name must be "CORE" 647 constexpr Elf_Word NT_LARCH_LBT = 0xa04; // LoongArch Binary Translation registers 648 649 /* The range 0xff000000 to 0xffffffff is set aside for notes that don't 650 originate from any particular operating system. */ 651 constexpr Elf_Word NT_GDB_TDESC = 0xff000000; // Contains copy of GDB's target description XML. 652 constexpr Elf_Word NT_MEMTAG = 0xff000001; // Contains a copy of the memory tags. 653 /* ARM-specific NT_MEMTAG types. */ 654 constexpr Elf_Word NT_MEMTAG_TYPE_AARCH_MTE = 0x400; // MTE memory tags for AArch64. 655 656 constexpr Elf_Word NT_STAPSDT = 3; // Note segment for SystemTap probes. 657 658 // Note name is "FreeBSD" 659 constexpr Elf_Word NT_FREEBSD_THRMISC = 7; // Thread miscellaneous info. 660 constexpr Elf_Word NT_FREEBSD_PROCSTAT_PROC = 8; // Procstat proc data. 661 constexpr Elf_Word NT_FREEBSD_PROCSTAT_FILES = 9; // Procstat files data. 662 constexpr Elf_Word NT_FREEBSD_PROCSTAT_VMMAP = 10; // Procstat vmmap data. 663 constexpr Elf_Word NT_FREEBSD_PROCSTAT_GROUPS = 11; // Procstat groups data. 664 constexpr Elf_Word NT_FREEBSD_PROCSTAT_UMASK = 12; // Procstat umask data. 665 constexpr Elf_Word NT_FREEBSD_PROCSTAT_RLIMIT = 13; // Procstat rlimit data. 666 constexpr Elf_Word NT_FREEBSD_PROCSTAT_OSREL = 14; // Procstat osreldate data. 667 constexpr Elf_Word NT_FREEBSD_PROCSTAT_PSSTRINGS = 15; // Procstat ps_strings data. 668 constexpr Elf_Word NT_FREEBSD_PROCSTAT_AUXV = 16; // Procstat auxv data. 669 constexpr Elf_Word NT_FREEBSD_PTLWPINFO = 17; // Thread ptrace miscellaneous info. 670 671 // Note name must start with "NetBSD-CORE" 672 constexpr Elf_Word NT_NETBSDCORE_PROCINFO = 1; // Has a struct procinfo 673 constexpr Elf_Word NT_NETBSDCORE_AUXV = 2; // Has auxv data 674 constexpr Elf_Word NT_NETBSDCORE_LWPSTATUS = 24; // Has LWPSTATUS data 675 constexpr Elf_Word NT_NETBSDCORE_FIRSTMACH = 32; // start of machdep note types 676 677 // Note name is "OpenBSD" 678 constexpr Elf_Word NT_OPENBSD_PROCINFO = 10; 679 constexpr Elf_Word NT_OPENBSD_AUXV = 11; 680 constexpr Elf_Word NT_OPENBSD_REGS = 20; 681 constexpr Elf_Word NT_OPENBSD_FPREGS = 21; 682 constexpr Elf_Word NT_OPENBSD_XFPREGS = 22; 683 constexpr Elf_Word NT_OPENBSD_WCOOKIE = 23; 684 685 // Note name must start with "SPU" 686 constexpr Elf_Word NT_SPU = 1; 687 688 // Values of note segment descriptor types for object files 689 constexpr Elf_Word NT_VERSION = 1; // Contains a version string. 690 constexpr Elf_Word NT_ARCH = 2; // Contains an architecture string. 691 constexpr Elf_Word NT_GO_BUILDID = 4; // Contains GO buildid data. 692 693 // Values for notes in non-core files using name "GNU" 694 constexpr Elf_Word NT_GNU_ABI_TAG = 1; 695 constexpr Elf_Word NT_GNU_HWCAP = 2; // Used by ld.so and kernel vDSO. 696 constexpr Elf_Word NT_GNU_BUILD_ID = 3; // Generated by ld --build-id. 697 constexpr Elf_Word NT_GNU_GOLD_VERSION = 4; // Generated by gold. 698 constexpr Elf_Word NT_GNU_PROPERTY_TYPE_0 = 5; // Generated by gcc. 699 // clang-format on 700 701 constexpr Elf_Word NT_GNU_BUILD_ATTRIBUTE_OPEN = 0x100; 702 constexpr Elf_Word NT_GNU_BUILD_ATTRIBUTE_FUNC = 0x101; 703 704 // Symbol types 705 constexpr Elf_Word STT_NOTYPE = 0; 706 constexpr Elf_Word STT_OBJECT = 1; 707 constexpr Elf_Word STT_FUNC = 2; 708 constexpr Elf_Word STT_SECTION = 3; 709 constexpr Elf_Word STT_FILE = 4; 710 constexpr Elf_Word STT_COMMON = 5; 711 constexpr Elf_Word STT_TLS = 6; 712 constexpr Elf_Word STT_LOOS = 10; 713 constexpr Elf_Word STT_AMDGPU_HSA_KERNEL = 10; 714 constexpr Elf_Word STT_HIOS = 12; 715 constexpr Elf_Word STT_LOPROC = 13; 716 constexpr Elf_Word STT_HIPROC = 15; 717 718 // Symbol visibility 719 constexpr unsigned char STV_DEFAULT = 0; 720 constexpr unsigned char STV_INTERNAL = 1; 721 constexpr unsigned char STV_HIDDEN = 2; 722 constexpr unsigned char STV_PROTECTED = 3; 723 724 // Undefined name 725 constexpr Elf_Word STN_UNDEF = 0; 726 727 // Relocation types 728 // X86 729 constexpr unsigned R_386_NONE = 0; 730 constexpr unsigned R_X86_64_NONE = 0; 731 constexpr unsigned R_AMDGPU_NONE = 0; 732 constexpr unsigned R_386_32 = 1; 733 constexpr unsigned R_X86_64_64 = 1; 734 constexpr unsigned R_AMDGPU_ABS32_LO = 1; 735 constexpr unsigned R_386_PC32 = 2; 736 constexpr unsigned R_X86_64_PC32 = 2; 737 constexpr unsigned R_AMDGPU_ABS32_HI = 2; 738 constexpr unsigned R_386_GOT32 = 3; 739 constexpr unsigned R_X86_64_GOT32 = 3; 740 constexpr unsigned R_AMDGPU_ABS64 = 3; 741 constexpr unsigned R_386_PLT32 = 4; 742 constexpr unsigned R_X86_64_PLT32 = 4; 743 constexpr unsigned R_AMDGPU_REL32 = 4; 744 constexpr unsigned R_386_COPY = 5; 745 constexpr unsigned R_X86_64_COPY = 5; 746 constexpr unsigned R_AMDGPU_REL64 = 5; 747 constexpr unsigned R_386_GLOB_DAT = 6; 748 constexpr unsigned R_X86_64_GLOB_DAT = 6; 749 constexpr unsigned R_AMDGPU_ABS32 = 6; 750 constexpr unsigned R_386_JMP_SLOT = 7; 751 constexpr unsigned R_X86_64_JUMP_SLOT = 7; 752 constexpr unsigned R_AMDGPU_GOTPCREL = 7; 753 constexpr unsigned R_386_RELATIVE = 8; 754 constexpr unsigned R_X86_64_RELATIVE = 8; 755 constexpr unsigned R_AMDGPU_GOTPCREL32_LO = 8; 756 constexpr unsigned R_386_GOTOFF = 9; 757 constexpr unsigned R_X86_64_GOTPCREL = 9; 758 constexpr unsigned R_AMDGPU_GOTPCREL32_HI = 9; 759 constexpr unsigned R_386_GOTPC = 10; 760 constexpr unsigned R_X86_64_32 = 10; 761 constexpr unsigned R_AMDGPU_REL32_LO = 10; 762 constexpr unsigned R_386_32PLT = 11; 763 constexpr unsigned R_X86_64_32S = 11; 764 constexpr unsigned R_AMDGPU_REL32_HI = 11; 765 constexpr unsigned R_X86_64_16 = 12; 766 constexpr unsigned R_X86_64_PC16 = 13; 767 constexpr unsigned R_AMDGPU_RELATIVE64 = 13; 768 constexpr unsigned R_386_TLS_TPOFF = 14; 769 constexpr unsigned R_X86_64_8 = 14; 770 constexpr unsigned R_386_TLS_IE = 15; 771 constexpr unsigned R_X86_64_PC8 = 15; 772 constexpr unsigned R_386_TLS_GOTIE = 16; 773 constexpr unsigned R_X86_64_DTPMOD64 = 16; 774 constexpr unsigned R_386_TLS_LE = 17; 775 constexpr unsigned R_X86_64_DTPOFF64 = 17; 776 constexpr unsigned R_386_TLS_GD = 18; 777 constexpr unsigned R_X86_64_TPOFF64 = 18; 778 constexpr unsigned R_386_TLS_LDM = 19; 779 constexpr unsigned R_X86_64_TLSGD = 19; 780 constexpr unsigned R_386_16 = 20; 781 constexpr unsigned R_X86_64_TLSLD = 20; 782 constexpr unsigned R_386_PC16 = 21; 783 constexpr unsigned R_X86_64_DTPOFF32 = 21; 784 constexpr unsigned R_386_8 = 22; 785 constexpr unsigned R_X86_64_GOTTPOFF = 22; 786 constexpr unsigned R_386_PC8 = 23; 787 constexpr unsigned R_X86_64_TPOFF32 = 23; 788 constexpr unsigned R_386_TLS_GD_32 = 24; 789 constexpr unsigned R_X86_64_PC64 = 24; 790 constexpr unsigned R_386_TLS_GD_PUSH = 25; 791 constexpr unsigned R_X86_64_GOTOFF64 = 25; 792 constexpr unsigned R_386_TLS_GD_CALL = 26; 793 constexpr unsigned R_X86_64_GOTPC32 = 26; 794 constexpr unsigned R_386_TLS_GD_POP = 27; 795 constexpr unsigned R_X86_64_GOT64 = 27; 796 constexpr unsigned R_386_TLS_LDM_32 = 28; 797 constexpr unsigned R_X86_64_GOTPCREL64 = 28; 798 constexpr unsigned R_386_TLS_LDM_PUSH = 29; 799 constexpr unsigned R_X86_64_GOTPC64 = 29; 800 constexpr unsigned R_386_TLS_LDM_CALL = 30; 801 constexpr unsigned R_X86_64_GOTPLT64 = 30; 802 constexpr unsigned R_386_TLS_LDM_POP = 31; 803 constexpr unsigned R_X86_64_PLTOFF64 = 31; 804 constexpr unsigned R_386_TLS_LDO_32 = 32; 805 constexpr unsigned R_386_TLS_IE_32 = 33; 806 constexpr unsigned R_386_TLS_LE_32 = 34; 807 constexpr unsigned R_X86_64_GOTPC32_TLSDESC = 34; 808 constexpr unsigned R_386_TLS_DTPMOD32 = 35; 809 constexpr unsigned R_X86_64_TLSDESC_CALL = 35; 810 constexpr unsigned R_386_TLS_DTPOFF32 = 36; 811 constexpr unsigned R_X86_64_TLSDESC = 36; 812 constexpr unsigned R_386_TLS_TPOFF32 = 37; 813 constexpr unsigned R_X86_64_IRELATIVE = 37; 814 constexpr unsigned R_386_SIZE32 = 38; 815 constexpr unsigned R_386_TLS_GOTDESC = 39; 816 constexpr unsigned R_386_TLS_DESC_CALL = 40; 817 constexpr unsigned R_386_TLS_DESC = 41; 818 constexpr unsigned R_386_IRELATIVE = 42; 819 constexpr unsigned R_386_GOT32X = 43; 820 constexpr unsigned R_X86_64_GNU_VTINHERIT = 250; 821 constexpr unsigned R_X86_64_GNU_VTENTRY = 251; 822 // AArch64 823 constexpr unsigned R_AARCH64_NONE = 0; 824 constexpr unsigned R_AARCH64_P32_ABS32 = 1; 825 constexpr unsigned R_AARCH64_P32_COPY = 180; 826 constexpr unsigned R_AARCH64_P32_GLOB_DAT = 181; 827 constexpr unsigned R_AARCH64_P32_JUMP_SLOT = 182; 828 constexpr unsigned R_AARCH64_P32_RELATIVE = 183; 829 constexpr unsigned R_AARCH64_P32_TLS_DTPMOD = 184; 830 constexpr unsigned R_AARCH64_P32_TLS_DTPREL = 185; 831 constexpr unsigned R_AARCH64_P32_TLS_TPREL = 186; 832 constexpr unsigned R_AARCH64_P32_TLSDESC = 187; 833 constexpr unsigned R_AARCH64_P32_IRELATIVE = 188; 834 constexpr unsigned R_AARCH64_ABS64 = 257; 835 constexpr unsigned R_AARCH64_ABS32 = 258; 836 constexpr unsigned R_AARCH64_ABS16 = 259; 837 constexpr unsigned R_AARCH64_PREL64 = 260; 838 constexpr unsigned R_AARCH64_PREL32 = 261; 839 constexpr unsigned R_AARCH64_PREL16 = 262; 840 constexpr unsigned R_AARCH64_MOVW_UABS_G0 = 263; 841 constexpr unsigned R_AARCH64_MOVW_UABS_G0_NC = 264; 842 constexpr unsigned R_AARCH64_MOVW_UABS_G1 = 265; 843 constexpr unsigned R_AARCH64_MOVW_UABS_G1_NC = 266; 844 constexpr unsigned R_AARCH64_MOVW_UABS_G2 = 267; 845 constexpr unsigned R_AARCH64_MOVW_UABS_G2_NC = 268; 846 constexpr unsigned R_AARCH64_MOVW_UABS_G3 = 269; 847 constexpr unsigned R_AARCH64_MOVW_SABS_G0 = 270; 848 constexpr unsigned R_AARCH64_MOVW_SABS_G1 = 271; 849 constexpr unsigned R_AARCH64_MOVW_SABS_G2 = 272; 850 constexpr unsigned R_AARCH64_LD_PREL_LO19 = 273; 851 constexpr unsigned R_AARCH64_ADR_PREL_LO21 = 274; 852 constexpr unsigned R_AARCH64_ADR_PREL_PG_HI21 = 275; 853 constexpr unsigned R_AARCH64_ADR_PREL_PG_HI21_NC = 276; 854 constexpr unsigned R_AARCH64_ADD_ABS_LO12_NC = 277; 855 constexpr unsigned R_AARCH64_LDST8_ABS_LO12_NC = 278; 856 constexpr unsigned R_AARCH64_TSTBR14 = 279; 857 constexpr unsigned R_AARCH64_CONDBR19 = 280; 858 constexpr unsigned R_AARCH64_JUMP26 = 282; 859 constexpr unsigned R_AARCH64_CALL26 = 283; 860 constexpr unsigned R_AARCH64_LDST16_ABS_LO12_NC = 284; 861 constexpr unsigned R_AARCH64_LDST32_ABS_LO12_NC = 285; 862 constexpr unsigned R_AARCH64_LDST64_ABS_LO12_NC = 286; 863 constexpr unsigned R_AARCH64_MOVW_PREL_G0 = 287; 864 constexpr unsigned R_AARCH64_MOVW_PREL_G0_NC = 288; 865 constexpr unsigned R_AARCH64_MOVW_PREL_G1 = 289; 866 constexpr unsigned R_AARCH64_MOVW_PREL_G1_NC = 290; 867 constexpr unsigned R_AARCH64_MOVW_PREL_G2 = 291; 868 constexpr unsigned R_AARCH64_MOVW_PREL_G2_NC = 292; 869 constexpr unsigned R_AARCH64_MOVW_PREL_G3 = 293; 870 constexpr unsigned R_AARCH64_LDST128_ABS_LO12_NC = 299; 871 constexpr unsigned R_AARCH64_MOVW_GOTOFF_G0 = 300; 872 constexpr unsigned R_AARCH64_MOVW_GOTOFF_G0_NC = 301; 873 constexpr unsigned R_AARCH64_MOVW_GOTOFF_G1 = 302; 874 constexpr unsigned R_AARCH64_MOVW_GOTOFF_G1_NC = 303; 875 constexpr unsigned R_AARCH64_MOVW_GOTOFF_G2 = 304; 876 constexpr unsigned R_AARCH64_MOVW_GOTOFF_G2_NC = 305; 877 constexpr unsigned R_AARCH64_MOVW_GOTOFF_G3 = 306; 878 constexpr unsigned R_AARCH64_GOTREL64 = 307; 879 constexpr unsigned R_AARCH64_GOTREL32 = 308; 880 constexpr unsigned R_AARCH64_GOT_LD_PREL19 = 309; 881 constexpr unsigned R_AARCH64_LD64_GOTOFF_LO15 = 310; 882 constexpr unsigned R_AARCH64_ADR_GOT_PAGE = 311; 883 constexpr unsigned R_AARCH64_LD64_GOT_LO12_NC = 312; 884 constexpr unsigned R_AARCH64_LD64_GOTPAGE_LO15 = 313; 885 constexpr unsigned R_AARCH64_TLSGD_ADR_PREL21 = 512; 886 constexpr unsigned R_AARCH64_TLSGD_ADR_PAGE21 = 513; 887 constexpr unsigned R_AARCH64_TLSGD_ADD_LO12_NC = 514; 888 constexpr unsigned R_AARCH64_TLSGD_MOVW_G1 = 515; 889 constexpr unsigned R_AARCH64_TLSGD_MOVW_G0_NC = 516; 890 constexpr unsigned R_AARCH64_TLSLD_ADR_PREL21 = 517; 891 constexpr unsigned R_AARCH64_TLSLD_ADR_PAGE21 = 518; 892 constexpr unsigned R_AARCH64_TLSLD_ADD_LO12_NC = 519; 893 constexpr unsigned R_AARCH64_TLSLD_MOVW_G1 = 520; 894 constexpr unsigned R_AARCH64_TLSLD_MOVW_G0_NC = 521; 895 constexpr unsigned R_AARCH64_TLSLD_LD_PREL19 = 522; 896 constexpr unsigned R_AARCH64_TLSLD_MOVW_DTPREL_G2 = 523; 897 constexpr unsigned R_AARCH64_TLSLD_MOVW_DTPREL_G1 = 524; 898 constexpr unsigned R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC = 525; 899 constexpr unsigned R_AARCH64_TLSLD_MOVW_DTPREL_G0 = 526; 900 constexpr unsigned R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC = 527; 901 constexpr unsigned R_AARCH64_TLSLD_ADD_DTPREL_HI12 = 528; 902 constexpr unsigned R_AARCH64_TLSLD_ADD_DTPREL_LO12 = 529; 903 constexpr unsigned R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC = 530; 904 constexpr unsigned R_AARCH64_TLSLD_LDST8_DTPREL_LO12 = 531; 905 constexpr unsigned R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC = 532; 906 constexpr unsigned R_AARCH64_TLSLD_LDST16_DTPREL_LO12 = 533; 907 constexpr unsigned R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC = 534; 908 constexpr unsigned R_AARCH64_TLSLD_LDST32_DTPREL_LO12 = 535; 909 constexpr unsigned R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC = 536; 910 constexpr unsigned R_AARCH64_TLSLD_LDST64_DTPREL_LO12 = 537; 911 constexpr unsigned R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC = 538; 912 constexpr unsigned R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 = 539; 913 constexpr unsigned R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC = 540; 914 constexpr unsigned R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 = 541; 915 constexpr unsigned R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC = 542; 916 constexpr unsigned R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 = 543; 917 constexpr unsigned R_AARCH64_TLSLE_MOVW_TPREL_G2 = 544; 918 constexpr unsigned R_AARCH64_TLSLE_MOVW_TPREL_G1 = 545; 919 constexpr unsigned R_AARCH64_TLSLE_MOVW_TPREL_G1_NC = 546; 920 constexpr unsigned R_AARCH64_TLSLE_MOVW_TPREL_G0 = 547; 921 constexpr unsigned R_AARCH64_TLSLE_MOVW_TPREL_G0_NC = 548; 922 constexpr unsigned R_AARCH64_TLSLE_ADD_TPREL_HI12 = 549; 923 constexpr unsigned R_AARCH64_TLSLE_ADD_TPREL_LO12 = 550; 924 constexpr unsigned R_AARCH64_TLSLE_ADD_TPREL_LO12_NC = 551; 925 constexpr unsigned R_AARCH64_TLSLE_LDST8_TPREL_LO12 = 552; 926 constexpr unsigned R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC = 553; 927 constexpr unsigned R_AARCH64_TLSLE_LDST16_TPREL_LO12 = 554; 928 constexpr unsigned R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC = 555; 929 constexpr unsigned R_AARCH64_TLSLE_LDST32_TPREL_LO12 = 556; 930 constexpr unsigned R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC = 557; 931 constexpr unsigned R_AARCH64_TLSLE_LDST64_TPREL_LO12 = 558; 932 constexpr unsigned R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC = 559; 933 constexpr unsigned R_AARCH64_TLSDESC_LD_PREL19 = 560; 934 constexpr unsigned R_AARCH64_TLSDESC_ADR_PREL21 = 561; 935 constexpr unsigned R_AARCH64_TLSDESC_ADR_PAGE21 = 562; 936 constexpr unsigned R_AARCH64_TLSDESC_LD64_LO12 = 563; 937 constexpr unsigned R_AARCH64_TLSDESC_ADD_LO12 = 564; 938 constexpr unsigned R_AARCH64_TLSDESC_OFF_G1 = 565; 939 constexpr unsigned R_AARCH64_TLSDESC_OFF_G0_NC = 566; 940 constexpr unsigned R_AARCH64_TLSDESC_LDR = 567; 941 constexpr unsigned R_AARCH64_TLSDESC_ADD = 568; 942 constexpr unsigned R_AARCH64_TLSDESC_CALL = 569; 943 constexpr unsigned R_AARCH64_TLSLE_LDST128_TPREL_LO12 = 570; 944 constexpr unsigned R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC = 571; 945 constexpr unsigned R_AARCH64_TLSLD_LDST128_DTPREL_LO12 = 572; 946 constexpr unsigned R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC = 573; 947 constexpr unsigned R_AARCH64_COPY = 1024; 948 constexpr unsigned R_AARCH64_GLOB_DAT = 1025; 949 constexpr unsigned R_AARCH64_JUMP_SLOT = 1026; 950 constexpr unsigned R_AARCH64_RELATIVE = 1027; 951 constexpr unsigned R_AARCH64_TLS_DTPMOD = 1028; 952 constexpr unsigned R_AARCH64_TLS_DTPMOD64 = 1028; 953 constexpr unsigned R_AARCH64_TLS_DTPREL = 1029; 954 constexpr unsigned R_AARCH64_TLS_DTPREL64 = 1029; 955 constexpr unsigned R_AARCH64_TLS_TPREL = 1030; 956 constexpr unsigned R_AARCH64_TLS_TPREL64 = 1030; 957 constexpr unsigned R_AARCH64_TLSDESC = 1031; 958 959 // Segment types 960 constexpr Elf_Word PT_NULL = 0; 961 constexpr Elf_Word PT_LOAD = 1; 962 constexpr Elf_Word PT_DYNAMIC = 2; 963 constexpr Elf_Word PT_INTERP = 3; 964 constexpr Elf_Word PT_NOTE = 4; 965 constexpr Elf_Word PT_SHLIB = 5; 966 constexpr Elf_Word PT_PHDR = 6; 967 constexpr Elf_Word PT_TLS = 7; 968 constexpr Elf_Word PT_LOOS = 0X60000000; 969 constexpr Elf_Word PT_GNU_EH_FRAME = 0X6474E550; // Frame unwind information 970 constexpr Elf_Word PT_GNU_STACK = 0X6474E551; // Stack flags 971 constexpr Elf_Word PT_GNU_RELRO = 0X6474E552; // Read only after relocs 972 constexpr Elf_Word PT_GNU_PROPERTY = 0X6474E553; // GNU property 973 constexpr Elf_Word PT_GNU_MBIND_LO = 0X6474E555; // Mbind segments start 974 constexpr Elf_Word PT_GNU_MBIND_HI = 0X6474F554; // Mbind segments finish 975 constexpr Elf_Word PT_PAX_FLAGS = 0X65041580; 976 constexpr Elf_Word PT_OPENBSD_RANDOMIZE = 0X65A3DBE6; 977 constexpr Elf_Word PT_OPENBSD_WXNEEDED = 0X65A3DBE7; 978 constexpr Elf_Word PT_OPENBSD_BOOTDATA = 0X65A41BE6; 979 constexpr Elf_Word PT_SUNWBSS = 0X6FFFFFFA; 980 constexpr Elf_Word PT_SUNWSTACK = 0X6FFFFFFB; 981 constexpr Elf_Word PT_HIOS = 0X6FFFFFFF; 982 constexpr Elf_Word PT_LOPROC = 0X70000000; 983 constexpr Elf_Word PT_HIPROC = 0X7FFFFFFF; 984 985 // Segment flags 986 constexpr Elf_Word PF_X = 1; // Execute 987 constexpr Elf_Word PF_W = 2; // Write 988 constexpr Elf_Word PF_R = 4; // Read 989 constexpr Elf_Word PF_MASKOS = 0x0ff00000; // Unspecified 990 constexpr Elf_Word PF_MASKPROC = 0xf0000000; // Unspecified 991 992 // Dynamic Array Tags 993 constexpr Elf_Word DT_NULL = 0; 994 constexpr Elf_Word DT_NEEDED = 1; 995 constexpr Elf_Word DT_PLTRELSZ = 2; 996 constexpr Elf_Word DT_PLTGOT = 3; 997 constexpr Elf_Word DT_HASH = 4; 998 constexpr Elf_Word DT_STRTAB = 5; 999 constexpr Elf_Word DT_SYMTAB = 6; 1000 constexpr Elf_Word DT_RELA = 7; 1001 constexpr Elf_Word DT_RELASZ = 8; 1002 constexpr Elf_Word DT_RELAENT = 9; 1003 constexpr Elf_Word DT_STRSZ = 10; 1004 constexpr Elf_Word DT_SYMENT = 11; 1005 constexpr Elf_Word DT_INIT = 12; 1006 constexpr Elf_Word DT_FINI = 13; 1007 constexpr Elf_Word DT_SONAME = 14; 1008 constexpr Elf_Word DT_RPATH = 15; 1009 constexpr Elf_Word DT_SYMBOLIC = 16; 1010 constexpr Elf_Word DT_REL = 17; 1011 constexpr Elf_Word DT_RELSZ = 18; 1012 constexpr Elf_Word DT_RELENT = 19; 1013 constexpr Elf_Word DT_PLTREL = 20; 1014 constexpr Elf_Word DT_DEBUG = 21; 1015 constexpr Elf_Word DT_TEXTREL = 22; 1016 constexpr Elf_Word DT_JMPREL = 23; 1017 constexpr Elf_Word DT_BIND_NOW = 24; 1018 constexpr Elf_Word DT_INIT_ARRAY = 25; 1019 constexpr Elf_Word DT_FINI_ARRAY = 26; 1020 constexpr Elf_Word DT_INIT_ARRAYSZ = 27; 1021 constexpr Elf_Word DT_FINI_ARRAYSZ = 28; 1022 constexpr Elf_Word DT_RUNPATH = 29; 1023 constexpr Elf_Word DT_FLAGS = 30; 1024 constexpr Elf_Word DT_ENCODING = 32; 1025 constexpr Elf_Word DT_PREINIT_ARRAY = 32; 1026 constexpr Elf_Word DT_PREINIT_ARRAYSZ = 33; 1027 constexpr Elf_Word DT_MAXPOSTAGS = 34; 1028 constexpr Elf_Word DT_LOOS = 0x6000000D; 1029 constexpr Elf_Word DT_HIOS = 0x6ffff000; 1030 constexpr Elf_Word DT_GNU_HASH = 0x6ffffef5; 1031 constexpr Elf_Word DT_TLSDESC_PLT = 0x6ffffef6; 1032 constexpr Elf_Word DT_TLSDESC_GOT = 0x6ffffef7; 1033 constexpr Elf_Word DT_GNU_CONFLICT = 0x6ffffef8; 1034 constexpr Elf_Word DT_GNU_LIBLIST = 0x6ffffef9; 1035 constexpr Elf_Word DT_CONFIG = 0x6ffffefa; 1036 constexpr Elf_Word DT_DEPAUDIT = 0x6ffffefb; 1037 constexpr Elf_Word DT_AUDIT = 0x6ffffefc; 1038 constexpr Elf_Word DT_PLTPAD = 0x6ffffefd; 1039 constexpr Elf_Word DT_MOVETAB = 0x6ffffefe; 1040 constexpr Elf_Word DT_SYMINFO = 0x6ffffeff; 1041 constexpr Elf_Word DT_ADDRRNGHI = 0x6ffffeff; 1042 constexpr Elf_Word DT_VERSYM = 0x6ffffff0; 1043 constexpr Elf_Word DT_RELACOUNT = 0x6ffffff9; 1044 constexpr Elf_Word DT_RELCOUNT = 0x6ffffffa; 1045 constexpr Elf_Word DT_FLAGS_1 = 0x6ffffffb; 1046 constexpr Elf_Word DT_VERDEF = 0x6ffffffc; 1047 constexpr Elf_Word DT_VERDEFNUM = 0x6ffffffd; 1048 constexpr Elf_Word DT_VERNEED = 0x6ffffffe; 1049 constexpr Elf_Word DT_VERNEEDNUM = 0x6fffffff; 1050 constexpr Elf_Word DT_LOPROC = 0x70000000; 1051 constexpr Elf_Word DT_HIPROC = 0x7FFFFFFF; 1052 1053 // DT_FLAGS values 1054 constexpr Elf_Word DF_ORIGIN = 0x1; 1055 constexpr Elf_Word DF_SYMBOLIC = 0x2; 1056 constexpr Elf_Word DF_TEXTREL = 0x4; 1057 constexpr Elf_Word DF_BIND_NOW = 0x8; 1058 constexpr Elf_Word DF_STATIC_TLS = 0x10; 1059 1060 // Legal values for d_tag (dynamic entry type). 1061 constexpr Elf_Word AT_NULL = 0; // End of vector 1062 constexpr Elf_Word AT_IGNORE = 1; // Entry should be ignored 1063 constexpr Elf_Word AT_EXECFD = 2; // File descriptor of program 1064 constexpr Elf_Word AT_PHDR = 3; // Program headers for program 1065 constexpr Elf_Word AT_PHENT = 4; // Size of program header entry 1066 constexpr Elf_Word AT_PHNUM = 5; // Number of program headers 1067 constexpr Elf_Word AT_PAGESZ = 6; // System page size 1068 constexpr Elf_Word AT_BASE = 7; // Base address of interpreter 1069 constexpr Elf_Word AT_FLAGS = 8; // Flags 1070 constexpr Elf_Word AT_ENTRY = 9; // Entry point of program 1071 constexpr Elf_Word AT_NOTELF = 10; // Program is not ELF 1072 constexpr Elf_Word AT_UID = 11; // Real uid 1073 constexpr Elf_Word AT_EUID = 12; // Effective uid 1074 constexpr Elf_Word AT_GID = 13; // Real gid 1075 constexpr Elf_Word AT_EGID = 14; // Effective gid 1076 constexpr Elf_Word AT_CLKTCK = 17; // Frequency of times() 1077 constexpr Elf_Word AT_PLATFORM = 15; // String identifying platform. 1078 constexpr Elf_Word AT_HWCAP = 16; // Hints about processor capabilities. 1079 constexpr Elf_Word AT_FPUCW = 18; // Used FPU control word. 1080 constexpr Elf_Word AT_DCACHEBSIZE = 19; // Data cache block size. 1081 constexpr Elf_Word AT_ICACHEBSIZE = 20; // Instruction cache block size. 1082 constexpr Elf_Word AT_UCACHEBSIZE = 21; // Unified cache block size. 1083 constexpr Elf_Word AT_IGNOREPPC = 22; // Entry should be ignored. 1084 constexpr Elf_Word AT_SECURE = 23; // Boolean, was exec setuid-like? 1085 constexpr Elf_Word AT_BASE_PLATFORM = 24; // String identifying real platforms. 1086 constexpr Elf_Word AT_RANDOM = 25; // Address of 16 random bytes. 1087 constexpr Elf_Word AT_HWCAP2 = 26; // More hints about processor capabilities. 1088 constexpr Elf_Word AT_EXECFN = 31; // Filename of executable. 1089 constexpr Elf_Word AT_SYSINFO = 32; // EP to the system call in the vDSO. 1090 constexpr Elf_Word AT_SYSINFO_EHDR = 33; // Start of the ELF header of the vDSO. 1091 constexpr Elf_Word AT_L1I_CACHESHAPE = 34; 1092 constexpr Elf_Word AT_L1D_CACHESHAPE = 35; 1093 constexpr Elf_Word AT_L2_CACHESHAPE = 36; 1094 constexpr Elf_Word AT_L3_CACHESHAPE = 37; 1095 constexpr Elf_Word AT_L1I_CACHESIZE = 40; 1096 constexpr Elf_Word AT_L1I_CACHEGEOMETRY = 41; 1097 constexpr Elf_Word AT_L1D_CACHESIZE = 42; 1098 constexpr Elf_Word AT_L1D_CACHEGEOMETRY = 43; 1099 constexpr Elf_Word AT_L2_CACHESIZE = 44; 1100 constexpr Elf_Word AT_L2_CACHEGEOMETRY = 45; 1101 constexpr Elf_Word AT_L3_CACHESIZE = 46; 1102 1103 // ELF file header 1104 struct Elf32_Ehdr 1105 { 1106 unsigned char e_ident[EI_NIDENT]; 1107 Elf_Half e_type; 1108 Elf_Half e_machine; 1109 Elf_Word e_version; 1110 Elf32_Addr e_entry; 1111 Elf32_Off e_phoff; 1112 Elf32_Off e_shoff; 1113 Elf_Word e_flags; 1114 Elf_Half e_ehsize; 1115 Elf_Half e_phentsize; 1116 Elf_Half e_phnum; 1117 Elf_Half e_shentsize; 1118 Elf_Half e_shnum; 1119 Elf_Half e_shstrndx; 1120 }; 1121 1122 struct Elf64_Ehdr 1123 { 1124 unsigned char e_ident[EI_NIDENT]; 1125 Elf_Half e_type; 1126 Elf_Half e_machine; 1127 Elf_Word e_version; 1128 Elf64_Addr e_entry; 1129 Elf64_Off e_phoff; 1130 Elf64_Off e_shoff; 1131 Elf_Word e_flags; 1132 Elf_Half e_ehsize; 1133 Elf_Half e_phentsize; 1134 Elf_Half e_phnum; 1135 Elf_Half e_shentsize; 1136 Elf_Half e_shnum; 1137 Elf_Half e_shstrndx; 1138 }; 1139 1140 // Section header 1141 struct Elf32_Shdr 1142 { 1143 Elf_Word sh_name; 1144 Elf_Word sh_type; 1145 Elf_Word sh_flags; 1146 Elf32_Addr sh_addr; 1147 Elf32_Off sh_offset; 1148 Elf_Word sh_size; 1149 Elf_Word sh_link; 1150 Elf_Word sh_info; 1151 Elf_Word sh_addralign; 1152 Elf_Word sh_entsize; 1153 }; 1154 1155 struct Elf64_Shdr 1156 { 1157 Elf_Word sh_name; 1158 Elf_Word sh_type; 1159 Elf_Xword sh_flags; 1160 Elf64_Addr sh_addr; 1161 Elf64_Off sh_offset; 1162 Elf_Xword sh_size; 1163 Elf_Word sh_link; 1164 Elf_Word sh_info; 1165 Elf_Xword sh_addralign; 1166 Elf_Xword sh_entsize; 1167 }; 1168 1169 // Segment header 1170 struct Elf32_Phdr 1171 { 1172 Elf_Word p_type; 1173 Elf32_Off p_offset; 1174 Elf32_Addr p_vaddr; 1175 Elf32_Addr p_paddr; 1176 Elf_Word p_filesz; 1177 Elf_Word p_memsz; 1178 Elf_Word p_flags; 1179 Elf_Word p_align; 1180 }; 1181 1182 struct Elf64_Phdr 1183 { 1184 Elf_Word p_type; 1185 Elf_Word p_flags; 1186 Elf64_Off p_offset; 1187 Elf64_Addr p_vaddr; 1188 Elf64_Addr p_paddr; 1189 Elf_Xword p_filesz; 1190 Elf_Xword p_memsz; 1191 Elf_Xword p_align; 1192 }; 1193 1194 // Symbol table entry 1195 struct Elf32_Sym 1196 { 1197 Elf_Word st_name; 1198 Elf32_Addr st_value; 1199 Elf_Word st_size; 1200 unsigned char st_info; 1201 unsigned char st_other; 1202 Elf_Half st_shndx; 1203 }; 1204 1205 struct Elf64_Sym 1206 { 1207 Elf_Word st_name; 1208 unsigned char st_info; 1209 unsigned char st_other; 1210 Elf_Half st_shndx; 1211 Elf64_Addr st_value; 1212 Elf_Xword st_size; 1213 }; 1214 1215 #define ELF_ST_BIND( i ) ( ( i ) >> 4 ) 1216 #define ELF_ST_TYPE( i ) ( (i)&0xf ) 1217 #define ELF_ST_INFO( b, t ) ( ( ( b ) << 4 ) + ( (t)&0xf ) ) 1218 1219 #define ELF_ST_VISIBILITY( o ) ( (o)&0x3 ) 1220 1221 // Relocation entries 1222 struct Elf32_Rel 1223 { 1224 Elf32_Addr r_offset; 1225 Elf_Word r_info; 1226 }; 1227 1228 struct Elf32_Rela 1229 { 1230 Elf32_Addr r_offset; 1231 Elf_Word r_info; 1232 Elf_Sword r_addend; 1233 }; 1234 1235 struct Elf64_Rel 1236 { 1237 Elf64_Addr r_offset; 1238 Elf_Xword r_info; 1239 }; 1240 1241 struct Elf64_Rela 1242 { 1243 Elf64_Addr r_offset; 1244 Elf_Xword r_info; 1245 Elf_Sxword r_addend; 1246 }; 1247 1248 #define ELF32_R_SYM( i ) ( ( i ) >> 8 ) 1249 #define ELF32_R_TYPE( i ) ( (unsigned char)( i ) ) 1250 #define ELF32_R_INFO( s, t ) ( ( ( s ) << 8 ) + (unsigned char)( t ) ) 1251 1252 #define ELF64_R_SYM( i ) ( ( i ) >> 32 ) 1253 #define ELF64_R_TYPE( i ) ( (i)&0xffffffffL ) 1254 #define ELF64_R_INFO( s, t ) \ 1255 ( ( ( (int64_t)( s ) ) << 32 ) + ( (t)&0xffffffffL ) ) 1256 1257 // Dynamic structure 1258 struct Elf32_Dyn 1259 { 1260 Elf_Sword d_tag; 1261 union { 1262 Elf_Word d_val; 1263 Elf32_Addr d_ptr; 1264 } d_un; 1265 }; 1266 1267 struct Elf64_Dyn 1268 { 1269 Elf_Sxword d_tag; 1270 union { 1271 Elf_Xword d_val; 1272 Elf64_Addr d_ptr; 1273 } d_un; 1274 }; 1275 1276 struct Elfxx_Verneed 1277 { 1278 Elf_Half vn_version; 1279 Elf_Half vn_cnt; 1280 Elf_Word vn_file; 1281 Elf_Word vn_aux; 1282 Elf_Word vn_next; 1283 }; 1284 1285 struct Elfxx_Vernaux 1286 { 1287 Elf_Word vna_hash; 1288 Elf_Half vna_flags; 1289 Elf_Half vna_other; 1290 Elf_Word vna_name; 1291 Elf_Word vna_next; 1292 }; 1293 1294 // ELF auxiliary vectors, they are usually run-time information 1295 // being passed to program when the kernel is loading it. 1296 // This is now required, 1297 // because in order to initialize the stack cookie 1298 // to protect against buffer overflows, 1299 // most of libc ask us to have a valid pointer for the AT_RANDOM entry. 1300 // glibc for example crashes if you don't. 1301 // https://sourceware.org/git/?p=glibc.git;a=blob;f=csu/libc-start.c;h=543560f36c33b07a1fbe1b7e4578374fe8007b1f;hb=HEAD#l308 1302 // This is also useful to be able to reconstruct at run-time 1303 // the ELF headers, if ELF headers were erased after loading. 1304 // Although this library is targeted to be parsing files only, 1305 // I assume auxiliary vectors could be also used to get 1306 // more information about the ELF binary at run-time in future. 1307 // The main purpose is also for ELF injectors. 1308 struct Elf32_auxv 1309 { 1310 uint32_t a_type; // Entry type 1311 1312 union { 1313 uint32_t a_val; // Integer value, usually a pointer 1314 } a_un; 1315 }; 1316 1317 struct Elf64_auxv 1318 { 1319 uint64_t a_type; // Entry type 1320 1321 union { 1322 uint64_t a_val; // Integer value, usually a pointer 1323 } a_un; 1324 }; 1325 1326 struct Elf32_Chdr 1327 { 1328 Elf32_Word ch_type; // The compression algorithm used 1329 Elf32_Word ch_size; //The size, in bytes, of the uncompressed section data 1330 Elf32_Word 1331 ch_addralign; // The address alignment of the uncompressed section data 1332 }; 1333 1334 struct Elf64_Chdr 1335 { 1336 Elf64_Word ch_type; //The compression algorithm used 1337 Elf64_Word ch_reserved; // Reserved 1338 Elf_Xword ch_size; //The size, in bytes, of the uncompressed section data 1339 Elf_Xword 1340 ch_addralign; //The address alignment of the uncompressed section data 1341 }; 1342 1343 #ifdef __cplusplus 1344 } // namespace ELFIO 1345 #endif 1346 1347 #endif // ELFTYPES_H 1348