github.com/primecitizens/pcz/std@v0.2.1/encoding/binfmt/elf/elf.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Copyright 2009 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 package elf 9 10 // Indexes into the Header.Ident array. 11 const ( 12 EI_CLASS = 4 /* Class of machine. */ 13 EI_DATA = 5 /* Data format. */ 14 EI_VERSION = 6 /* ELF format version. */ 15 EI_OSABI = 7 /* Operating system / ABI identification */ 16 EI_ABIVERSION = 8 /* ABI version */ 17 EI_PAD = 9 /* Start of padding (per SVR4 ABI). */ 18 EI_NIDENT = 16 /* Size of e_ident array. */ 19 ) 20 21 // Initial magic number for ELF files. 22 const ELFMAG = "\177ELF" 23 24 // Version is found in Header.Ident[EI_VERSION] and Header.Version. 25 type Version byte 26 27 const ( 28 EV_NONE Version = 0 29 EV_CURRENT Version = 1 30 ) 31 32 // Class is found in Header.Ident[EI_CLASS] and Header.Class. 33 type Class byte 34 35 const ( 36 ELFCLASSNONE Class = 0 /* Unknown class. */ 37 ELFCLASS32 Class = 1 /* 32-bit architecture. */ 38 ELFCLASS64 Class = 2 /* 64-bit architecture. */ 39 ) 40 41 // Data is found in Header.Ident[EI_DATA] and Header.Data. 42 type Data byte 43 44 const ( 45 ELFDATANONE Data = 0 /* Unknown data format. */ 46 ELFDATA2LSB Data = 1 /* 2's complement little-endian. */ 47 ELFDATA2MSB Data = 2 /* 2's complement big-endian. */ 48 ) 49 50 // OSABI is found in Header.Ident[EI_OSABI] and Header.OSABI. 51 type OSABI byte 52 53 const ( 54 ELFOSABI_NONE OSABI = 0 /* UNIX System V ABI */ 55 ELFOSABI_HPUX OSABI = 1 /* HP-UX operating system */ 56 ELFOSABI_NETBSD OSABI = 2 /* NetBSD */ 57 ELFOSABI_LINUX OSABI = 3 /* Linux */ 58 ELFOSABI_HURD OSABI = 4 /* Hurd */ 59 ELFOSABI_86OPEN OSABI = 5 /* 86Open common IA32 ABI */ 60 ELFOSABI_SOLARIS OSABI = 6 /* Solaris */ 61 ELFOSABI_AIX OSABI = 7 /* AIX */ 62 ELFOSABI_IRIX OSABI = 8 /* IRIX */ 63 ELFOSABI_FREEBSD OSABI = 9 /* FreeBSD */ 64 ELFOSABI_TRU64 OSABI = 10 /* TRU64 UNIX */ 65 ELFOSABI_MODESTO OSABI = 11 /* Novell Modesto */ 66 ELFOSABI_OPENBSD OSABI = 12 /* OpenBSD */ 67 ELFOSABI_OPENVMS OSABI = 13 /* Open VMS */ 68 ELFOSABI_NSK OSABI = 14 /* HP Non-Stop Kernel */ 69 ELFOSABI_AROS OSABI = 15 /* Amiga Research OS */ 70 ELFOSABI_FENIXOS OSABI = 16 /* The FenixOS highly scalable multi-core OS */ 71 ELFOSABI_CLOUDABI OSABI = 17 /* Nuxi CloudABI */ 72 ELFOSABI_ARM OSABI = 97 /* ARM */ 73 ELFOSABI_STANDALONE OSABI = 255 /* Standalone (embedded) application */ 74 ) 75 76 // Type is found in Header.Type. 77 type Type uint16 78 79 const ( 80 ET_NONE Type = 0 /* Unknown type. */ 81 ET_REL Type = 1 /* Relocatable. */ 82 ET_EXEC Type = 2 /* Executable. */ 83 ET_DYN Type = 3 /* Shared object. */ 84 ET_CORE Type = 4 /* Core file. */ 85 ET_LOOS Type = 0xfe00 /* First operating system specific. */ 86 ET_HIOS Type = 0xfeff /* Last operating system-specific. */ 87 ET_LOPROC Type = 0xff00 /* First processor-specific. */ 88 ET_HIPROC Type = 0xffff /* Last processor-specific. */ 89 ) 90 91 // Machine is found in Header.Machine. 92 type Machine uint16 93 94 const ( 95 EM_NONE Machine = 0 /* Unknown machine. */ 96 EM_M32 Machine = 1 /* AT&T WE32100. */ 97 EM_SPARC Machine = 2 /* Sun SPARC. */ 98 EM_386 Machine = 3 /* Intel i386. */ 99 EM_68K Machine = 4 /* Motorola 68000. */ 100 EM_88K Machine = 5 /* Motorola 88000. */ 101 EM_860 Machine = 7 /* Intel i860. */ 102 EM_MIPS Machine = 8 /* MIPS R3000 Big-Endian only. */ 103 EM_S370 Machine = 9 /* IBM System/370. */ 104 EM_MIPS_RS3_LE Machine = 10 /* MIPS R3000 Little-Endian. */ 105 EM_PARISC Machine = 15 /* HP PA-RISC. */ 106 EM_VPP500 Machine = 17 /* Fujitsu VPP500. */ 107 EM_SPARC32PLUS Machine = 18 /* SPARC v8plus. */ 108 EM_960 Machine = 19 /* Intel 80960. */ 109 EM_PPC Machine = 20 /* PowerPC 32-bit. */ 110 EM_PPC64 Machine = 21 /* PowerPC 64-bit. */ 111 EM_S390 Machine = 22 /* IBM System/390. */ 112 EM_V800 Machine = 36 /* NEC V800. */ 113 EM_FR20 Machine = 37 /* Fujitsu FR20. */ 114 EM_RH32 Machine = 38 /* TRW RH-32. */ 115 EM_RCE Machine = 39 /* Motorola RCE. */ 116 EM_ARM Machine = 40 /* ARM. */ 117 EM_SH Machine = 42 /* Hitachi SH. */ 118 EM_SPARCV9 Machine = 43 /* SPARC v9 64-bit. */ 119 EM_TRICORE Machine = 44 /* Siemens TriCore embedded processor. */ 120 EM_ARC Machine = 45 /* Argonaut RISC Core. */ 121 EM_H8_300 Machine = 46 /* Hitachi H8/300. */ 122 EM_H8_300H Machine = 47 /* Hitachi H8/300H. */ 123 EM_H8S Machine = 48 /* Hitachi H8S. */ 124 EM_H8_500 Machine = 49 /* Hitachi H8/500. */ 125 EM_IA_64 Machine = 50 /* Intel IA-64 Processor. */ 126 EM_MIPS_X Machine = 51 /* Stanford MIPS-X. */ 127 EM_COLDFIRE Machine = 52 /* Motorola ColdFire. */ 128 EM_68HC12 Machine = 53 /* Motorola M68HC12. */ 129 EM_MMA Machine = 54 /* Fujitsu MMA. */ 130 EM_PCP Machine = 55 /* Siemens PCP. */ 131 EM_NCPU Machine = 56 /* Sony nCPU. */ 132 EM_NDR1 Machine = 57 /* Denso NDR1 microprocessor. */ 133 EM_STARCORE Machine = 58 /* Motorola Star*Core processor. */ 134 EM_ME16 Machine = 59 /* Toyota ME16 processor. */ 135 EM_ST100 Machine = 60 /* STMicroelectronics ST100 processor. */ 136 EM_TINYJ Machine = 61 /* Advanced Logic Corp. TinyJ processor. */ 137 EM_X86_64 Machine = 62 /* Advanced Micro Devices x86-64 */ 138 EM_PDSP Machine = 63 /* Sony DSP Processor */ 139 EM_PDP10 Machine = 64 /* Digital Equipment Corp. PDP-10 */ 140 EM_PDP11 Machine = 65 /* Digital Equipment Corp. PDP-11 */ 141 EM_FX66 Machine = 66 /* Siemens FX66 microcontroller */ 142 EM_ST9PLUS Machine = 67 /* STMicroelectronics ST9+ 8/16 bit microcontroller */ 143 EM_ST7 Machine = 68 /* STMicroelectronics ST7 8-bit microcontroller */ 144 EM_68HC16 Machine = 69 /* Motorola MC68HC16 Microcontroller */ 145 EM_68HC11 Machine = 70 /* Motorola MC68HC11 Microcontroller */ 146 EM_68HC08 Machine = 71 /* Motorola MC68HC08 Microcontroller */ 147 EM_68HC05 Machine = 72 /* Motorola MC68HC05 Microcontroller */ 148 EM_SVX Machine = 73 /* Silicon Graphics SVx */ 149 EM_ST19 Machine = 74 /* STMicroelectronics ST19 8-bit microcontroller */ 150 EM_VAX Machine = 75 /* Digital VAX */ 151 EM_CRIS Machine = 76 /* Axis Communications 32-bit embedded processor */ 152 EM_JAVELIN Machine = 77 /* Infineon Technologies 32-bit embedded processor */ 153 EM_FIREPATH Machine = 78 /* Element 14 64-bit DSP Processor */ 154 EM_ZSP Machine = 79 /* LSI Logic 16-bit DSP Processor */ 155 EM_MMIX Machine = 80 /* Donald Knuth's educational 64-bit processor */ 156 EM_HUANY Machine = 81 /* Harvard University machine-independent object files */ 157 EM_PRISM Machine = 82 /* SiTera Prism */ 158 EM_AVR Machine = 83 /* Atmel AVR 8-bit microcontroller */ 159 EM_FR30 Machine = 84 /* Fujitsu FR30 */ 160 EM_D10V Machine = 85 /* Mitsubishi D10V */ 161 EM_D30V Machine = 86 /* Mitsubishi D30V */ 162 EM_V850 Machine = 87 /* NEC v850 */ 163 EM_M32R Machine = 88 /* Mitsubishi M32R */ 164 EM_MN10300 Machine = 89 /* Matsushita MN10300 */ 165 EM_MN10200 Machine = 90 /* Matsushita MN10200 */ 166 EM_PJ Machine = 91 /* picoJava */ 167 EM_OPENRISC Machine = 92 /* OpenRISC 32-bit embedded processor */ 168 EM_ARC_COMPACT Machine = 93 /* ARC International ARCompact processor (old spelling/synonym: EM_ARC_A5) */ 169 EM_XTENSA Machine = 94 /* Tensilica Xtensa Architecture */ 170 EM_VIDEOCORE Machine = 95 /* Alphamosaic VideoCore processor */ 171 EM_TMM_GPP Machine = 96 /* Thompson Multimedia General Purpose Processor */ 172 EM_NS32K Machine = 97 /* National Semiconductor 32000 series */ 173 EM_TPC Machine = 98 /* Tenor Network TPC processor */ 174 EM_SNP1K Machine = 99 /* Trebia SNP 1000 processor */ 175 EM_ST200 Machine = 100 /* STMicroelectronics (www.st.com) ST200 microcontroller */ 176 EM_IP2K Machine = 101 /* Ubicom IP2xxx microcontroller family */ 177 EM_MAX Machine = 102 /* MAX Processor */ 178 EM_CR Machine = 103 /* National Semiconductor CompactRISC microprocessor */ 179 EM_F2MC16 Machine = 104 /* Fujitsu F2MC16 */ 180 EM_MSP430 Machine = 105 /* Texas Instruments embedded microcontroller msp430 */ 181 EM_BLACKFIN Machine = 106 /* Analog Devices Blackfin (DSP) processor */ 182 EM_SE_C33 Machine = 107 /* S1C33 Family of Seiko Epson processors */ 183 EM_SEP Machine = 108 /* Sharp embedded microprocessor */ 184 EM_ARCA Machine = 109 /* Arca RISC Microprocessor */ 185 EM_UNICORE Machine = 110 /* Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University */ 186 EM_EXCESS Machine = 111 /* eXcess: 16/32/64-bit configurable embedded CPU */ 187 EM_DXP Machine = 112 /* Icera Semiconductor Inc. Deep Execution Processor */ 188 EM_ALTERA_NIOS2 Machine = 113 /* Altera Nios II soft-core processor */ 189 EM_CRX Machine = 114 /* National Semiconductor CompactRISC CRX microprocessor */ 190 EM_XGATE Machine = 115 /* Motorola XGATE embedded processor */ 191 EM_C166 Machine = 116 /* Infineon C16x/XC16x processor */ 192 EM_M16C Machine = 117 /* Renesas M16C series microprocessors */ 193 EM_DSPIC30F Machine = 118 /* Microchip Technology dsPIC30F Digital Signal Controller */ 194 EM_CE Machine = 119 /* Freescale Communication Engine RISC core */ 195 EM_M32C Machine = 120 /* Renesas M32C series microprocessors */ 196 EM_TSK3000 Machine = 131 /* Altium TSK3000 core */ 197 EM_RS08 Machine = 132 /* Freescale RS08 embedded processor */ 198 EM_SHARC Machine = 133 /* Analog Devices SHARC family of 32-bit DSP processors */ 199 EM_ECOG2 Machine = 134 /* Cyan Technology eCOG2 microprocessor */ 200 EM_SCORE7 Machine = 135 /* Sunplus S+core7 RISC processor */ 201 EM_DSP24 Machine = 136 /* New Japan Radio (NJR) 24-bit DSP Processor */ 202 EM_VIDEOCORE3 Machine = 137 /* Broadcom VideoCore III processor */ 203 EM_LATTICEMICO32 Machine = 138 /* RISC processor for Lattice FPGA architecture */ 204 EM_SE_C17 Machine = 139 /* Seiko Epson C17 family */ 205 EM_TI_C6000 Machine = 140 /* The Texas Instruments TMS320C6000 DSP family */ 206 EM_TI_C2000 Machine = 141 /* The Texas Instruments TMS320C2000 DSP family */ 207 EM_TI_C5500 Machine = 142 /* The Texas Instruments TMS320C55x DSP family */ 208 EM_TI_ARP32 Machine = 143 /* Texas Instruments Application Specific RISC Processor, 32bit fetch */ 209 EM_TI_PRU Machine = 144 /* Texas Instruments Programmable Realtime Unit */ 210 EM_MMDSP_PLUS Machine = 160 /* STMicroelectronics 64bit VLIW Data Signal Processor */ 211 EM_CYPRESS_M8C Machine = 161 /* Cypress M8C microprocessor */ 212 EM_R32C Machine = 162 /* Renesas R32C series microprocessors */ 213 EM_TRIMEDIA Machine = 163 /* NXP Semiconductors TriMedia architecture family */ 214 EM_QDSP6 Machine = 164 /* QUALCOMM DSP6 Processor */ 215 EM_8051 Machine = 165 /* Intel 8051 and variants */ 216 EM_STXP7X Machine = 166 /* STMicroelectronics STxP7x family of configurable and extensible RISC processors */ 217 EM_NDS32 Machine = 167 /* Andes Technology compact code size embedded RISC processor family */ 218 EM_ECOG1 Machine = 168 /* Cyan Technology eCOG1X family */ 219 EM_ECOG1X Machine = 168 /* Cyan Technology eCOG1X family */ 220 EM_MAXQ30 Machine = 169 /* Dallas Semiconductor MAXQ30 Core Micro-controllers */ 221 EM_XIMO16 Machine = 170 /* New Japan Radio (NJR) 16-bit DSP Processor */ 222 EM_MANIK Machine = 171 /* M2000 Reconfigurable RISC Microprocessor */ 223 EM_CRAYNV2 Machine = 172 /* Cray Inc. NV2 vector architecture */ 224 EM_RX Machine = 173 /* Renesas RX family */ 225 EM_METAG Machine = 174 /* Imagination Technologies META processor architecture */ 226 EM_MCST_ELBRUS Machine = 175 /* MCST Elbrus general purpose hardware architecture */ 227 EM_ECOG16 Machine = 176 /* Cyan Technology eCOG16 family */ 228 EM_CR16 Machine = 177 /* National Semiconductor CompactRISC CR16 16-bit microprocessor */ 229 EM_ETPU Machine = 178 /* Freescale Extended Time Processing Unit */ 230 EM_SLE9X Machine = 179 /* Infineon Technologies SLE9X core */ 231 EM_L10M Machine = 180 /* Intel L10M */ 232 EM_K10M Machine = 181 /* Intel K10M */ 233 EM_AARCH64 Machine = 183 /* ARM 64-bit Architecture (AArch64) */ 234 EM_AVR32 Machine = 185 /* Atmel Corporation 32-bit microprocessor family */ 235 EM_STM8 Machine = 186 /* STMicroeletronics STM8 8-bit microcontroller */ 236 EM_TILE64 Machine = 187 /* Tilera TILE64 multicore architecture family */ 237 EM_TILEPRO Machine = 188 /* Tilera TILEPro multicore architecture family */ 238 EM_MICROBLAZE Machine = 189 /* Xilinx MicroBlaze 32-bit RISC soft processor core */ 239 EM_CUDA Machine = 190 /* NVIDIA CUDA architecture */ 240 EM_TILEGX Machine = 191 /* Tilera TILE-Gx multicore architecture family */ 241 EM_CLOUDSHIELD Machine = 192 /* CloudShield architecture family */ 242 EM_COREA_1ST Machine = 193 /* KIPO-KAIST Core-A 1st generation processor family */ 243 EM_COREA_2ND Machine = 194 /* KIPO-KAIST Core-A 2nd generation processor family */ 244 EM_ARC_COMPACT2 Machine = 195 /* Synopsys ARCompact V2 */ 245 EM_OPEN8 Machine = 196 /* Open8 8-bit RISC soft processor core */ 246 EM_RL78 Machine = 197 /* Renesas RL78 family */ 247 EM_VIDEOCORE5 Machine = 198 /* Broadcom VideoCore V processor */ 248 EM_78KOR Machine = 199 /* Renesas 78KOR family */ 249 EM_56800EX Machine = 200 /* Freescale 56800EX Digital Signal Controller (DSC) */ 250 EM_BA1 Machine = 201 /* Beyond BA1 CPU architecture */ 251 EM_BA2 Machine = 202 /* Beyond BA2 CPU architecture */ 252 EM_XCORE Machine = 203 /* XMOS xCORE processor family */ 253 EM_MCHP_PIC Machine = 204 /* Microchip 8-bit PIC(r) family */ 254 EM_INTEL205 Machine = 205 /* Reserved by Intel */ 255 EM_INTEL206 Machine = 206 /* Reserved by Intel */ 256 EM_INTEL207 Machine = 207 /* Reserved by Intel */ 257 EM_INTEL208 Machine = 208 /* Reserved by Intel */ 258 EM_INTEL209 Machine = 209 /* Reserved by Intel */ 259 EM_KM32 Machine = 210 /* KM211 KM32 32-bit processor */ 260 EM_KMX32 Machine = 211 /* KM211 KMX32 32-bit processor */ 261 EM_KMX16 Machine = 212 /* KM211 KMX16 16-bit processor */ 262 EM_KMX8 Machine = 213 /* KM211 KMX8 8-bit processor */ 263 EM_KVARC Machine = 214 /* KM211 KVARC processor */ 264 EM_CDP Machine = 215 /* Paneve CDP architecture family */ 265 EM_COGE Machine = 216 /* Cognitive Smart Memory Processor */ 266 EM_COOL Machine = 217 /* Bluechip Systems CoolEngine */ 267 EM_NORC Machine = 218 /* Nanoradio Optimized RISC */ 268 EM_CSR_KALIMBA Machine = 219 /* CSR Kalimba architecture family */ 269 EM_Z80 Machine = 220 /* Zilog Z80 */ 270 EM_VISIUM Machine = 221 /* Controls and Data Services VISIUMcore processor */ 271 EM_FT32 Machine = 222 /* FTDI Chip FT32 high performance 32-bit RISC architecture */ 272 EM_MOXIE Machine = 223 /* Moxie processor family */ 273 EM_AMDGPU Machine = 224 /* AMD GPU architecture */ 274 EM_RISCV Machine = 243 /* RISC-V */ 275 EM_LANAI Machine = 244 /* Lanai 32-bit processor */ 276 EM_BPF Machine = 247 /* Linux BPF – in-kernel virtual machine */ 277 278 /* Non-standard or deprecated. */ 279 EM_486 Machine = 6 /* Intel i486. */ 280 EM_MIPS_RS4_BE Machine = 10 /* MIPS R4000 Big-Endian */ 281 EM_ALPHA_STD Machine = 41 /* Digital Alpha (standard value). */ 282 EM_ALPHA Machine = 0x9026 /* Alpha (written in the absence of an ABI) */ 283 ) 284 285 // Special section indices. 286 type SectionIndex int 287 288 const ( 289 SHN_UNDEF SectionIndex = 0 /* Undefined, missing, irrelevant. */ 290 SHN_LORESERVE SectionIndex = 0xff00 /* First of reserved range. */ 291 SHN_LOPROC SectionIndex = 0xff00 /* First processor-specific. */ 292 SHN_HIPROC SectionIndex = 0xff1f /* Last processor-specific. */ 293 SHN_LOOS SectionIndex = 0xff20 /* First operating system-specific. */ 294 SHN_HIOS SectionIndex = 0xff3f /* Last operating system-specific. */ 295 SHN_ABS SectionIndex = 0xfff1 /* Absolute values. */ 296 SHN_COMMON SectionIndex = 0xfff2 /* Common data. */ 297 SHN_XINDEX SectionIndex = 0xffff /* Escape; index stored elsewhere. */ 298 SHN_HIRESERVE SectionIndex = 0xffff /* Last of reserved range. */ 299 ) 300 301 // Section type. 302 type SectionType uint32 303 304 const ( 305 SHT_NULL SectionType = 0 /* inactive */ 306 SHT_PROGBITS SectionType = 1 /* program defined information */ 307 SHT_SYMTAB SectionType = 2 /* symbol table section */ 308 SHT_STRTAB SectionType = 3 /* string table section */ 309 SHT_RELA SectionType = 4 /* relocation section with addends */ 310 SHT_HASH SectionType = 5 /* symbol hash table section */ 311 SHT_DYNAMIC SectionType = 6 /* dynamic section */ 312 SHT_NOTE SectionType = 7 /* note section */ 313 SHT_NOBITS SectionType = 8 /* no space section */ 314 SHT_REL SectionType = 9 /* relocation section - no addends */ 315 SHT_SHLIB SectionType = 10 /* reserved - purpose unknown */ 316 SHT_DYNSYM SectionType = 11 /* dynamic symbol table section */ 317 SHT_INIT_ARRAY SectionType = 14 /* Initialization function pointers. */ 318 SHT_FINI_ARRAY SectionType = 15 /* Termination function pointers. */ 319 SHT_PREINIT_ARRAY SectionType = 16 /* Pre-initialization function ptrs. */ 320 SHT_GROUP SectionType = 17 /* Section group. */ 321 SHT_SYMTAB_SHNDX SectionType = 18 /* Section indexes (see SHN_XINDEX). */ 322 SHT_LOOS SectionType = 0x60000000 /* First of OS specific semantics */ 323 SHT_GNU_ATTRIBUTES SectionType = 0x6ffffff5 /* GNU object attributes */ 324 SHT_GNU_HASH SectionType = 0x6ffffff6 /* GNU hash table */ 325 SHT_GNU_LIBLIST SectionType = 0x6ffffff7 /* GNU prelink library list */ 326 SHT_GNU_VERDEF SectionType = 0x6ffffffd /* GNU version definition section */ 327 SHT_GNU_VERNEED SectionType = 0x6ffffffe /* GNU version needs section */ 328 SHT_GNU_VERSYM SectionType = 0x6fffffff /* GNU version symbol table */ 329 SHT_HIOS SectionType = 0x6fffffff /* Last of OS specific semantics */ 330 SHT_LOPROC SectionType = 0x70000000 /* reserved range for processor */ 331 SHT_MIPS_ABIFLAGS SectionType = 0x7000002a /* .MIPS.abiflags */ 332 SHT_HIPROC SectionType = 0x7fffffff /* specific section header types */ 333 SHT_LOUSER SectionType = 0x80000000 /* reserved range for application */ 334 SHT_HIUSER SectionType = 0xffffffff /* specific indexes */ 335 ) 336 337 // Section flags. 338 type SectionFlag uint32 339 340 const ( 341 SHF_WRITE SectionFlag = 0x1 /* Section contains writable data. */ 342 SHF_ALLOC SectionFlag = 0x2 /* Section occupies memory. */ 343 SHF_EXECINSTR SectionFlag = 0x4 /* Section contains instructions. */ 344 SHF_MERGE SectionFlag = 0x10 /* Section may be merged. */ 345 SHF_STRINGS SectionFlag = 0x20 /* Section contains strings. */ 346 SHF_INFO_LINK SectionFlag = 0x40 /* sh_info holds section index. */ 347 SHF_LINK_ORDER SectionFlag = 0x80 /* Special ordering requirements. */ 348 SHF_OS_NONCONFORMING SectionFlag = 0x100 /* OS-specific processing required. */ 349 SHF_GROUP SectionFlag = 0x200 /* Member of section group. */ 350 SHF_TLS SectionFlag = 0x400 /* Section contains TLS data. */ 351 SHF_COMPRESSED SectionFlag = 0x800 /* Section is compressed. */ 352 SHF_MASKOS SectionFlag = 0x0ff00000 /* OS-specific semantics. */ 353 SHF_MASKPROC SectionFlag = 0xf0000000 /* Processor-specific semantics. */ 354 ) 355 356 // Section compression type. 357 type CompressionType int 358 359 const ( 360 COMPRESS_ZLIB CompressionType = 1 /* ZLIB compression. */ 361 COMPRESS_ZSTD CompressionType = 2 /* ZSTD compression. */ 362 COMPRESS_LOOS CompressionType = 0x60000000 /* First OS-specific. */ 363 COMPRESS_HIOS CompressionType = 0x6fffffff /* Last OS-specific. */ 364 COMPRESS_LOPROC CompressionType = 0x70000000 /* First processor-specific type. */ 365 COMPRESS_HIPROC CompressionType = 0x7fffffff /* Last processor-specific type. */ 366 ) 367 368 // Prog.Type 369 type ProgType int 370 371 const ( 372 PT_NULL ProgType = 0 /* Unused entry. */ 373 PT_LOAD ProgType = 1 /* Loadable segment. */ 374 PT_DYNAMIC ProgType = 2 /* Dynamic linking information segment. */ 375 PT_INTERP ProgType = 3 /* Pathname of interpreter. */ 376 PT_NOTE ProgType = 4 /* Auxiliary information. */ 377 PT_SHLIB ProgType = 5 /* Reserved (not used). */ 378 PT_PHDR ProgType = 6 /* Location of program header itself. */ 379 PT_TLS ProgType = 7 /* Thread local storage segment */ 380 381 PT_LOOS ProgType = 0x60000000 /* First OS-specific. */ 382 383 PT_GNU_EH_FRAME ProgType = 0x6474e550 /* Frame unwind information */ 384 PT_GNU_STACK ProgType = 0x6474e551 /* Stack flags */ 385 PT_GNU_RELRO ProgType = 0x6474e552 /* Read only after relocs */ 386 PT_GNU_PROPERTY ProgType = 0x6474e553 /* GNU property */ 387 PT_GNU_MBIND_LO ProgType = 0x6474e555 /* Mbind segments start */ 388 PT_GNU_MBIND_HI ProgType = 0x6474f554 /* Mbind segments finish */ 389 390 PT_PAX_FLAGS ProgType = 0x65041580 /* PAX flags */ 391 392 PT_OPENBSD_RANDOMIZE ProgType = 0x65a3dbe6 /* Random data */ 393 PT_OPENBSD_WXNEEDED ProgType = 0x65a3dbe7 /* W^X violations */ 394 PT_OPENBSD_BOOTDATA ProgType = 0x65a41be6 /* Boot arguments */ 395 396 PT_SUNW_EH_FRAME ProgType = 0x6474e550 /* Frame unwind information */ 397 PT_SUNWSTACK ProgType = 0x6ffffffb /* Stack segment */ 398 399 PT_HIOS ProgType = 0x6fffffff /* Last OS-specific. */ 400 401 PT_LOPROC ProgType = 0x70000000 /* First processor-specific type. */ 402 403 PT_ARM_ARCHEXT ProgType = 0x70000000 /* Architecture compatibility */ 404 PT_ARM_EXIDX ProgType = 0x70000001 /* Exception unwind tables */ 405 406 PT_AARCH64_ARCHEXT ProgType = 0x70000000 /* Architecture compatibility */ 407 PT_AARCH64_UNWIND ProgType = 0x70000001 /* Exception unwind tables */ 408 409 PT_MIPS_REGINFO ProgType = 0x70000000 /* Register usage */ 410 PT_MIPS_RTPROC ProgType = 0x70000001 /* Runtime procedures */ 411 PT_MIPS_OPTIONS ProgType = 0x70000002 /* Options */ 412 PT_MIPS_ABIFLAGS ProgType = 0x70000003 /* ABI flags */ 413 414 PT_S390_PGSTE ProgType = 0x70000000 /* 4k page table size */ 415 416 PT_HIPROC ProgType = 0x7fffffff /* Last processor-specific type. */ 417 ) 418 419 // Prog.Flag 420 type ProgFlag uint32 421 422 const ( 423 PF_X ProgFlag = 0x1 /* Executable. */ 424 PF_W ProgFlag = 0x2 /* Writable. */ 425 PF_R ProgFlag = 0x4 /* Readable. */ 426 PF_MASKOS ProgFlag = 0x0ff00000 /* Operating system-specific. */ 427 PF_MASKPROC ProgFlag = 0xf0000000 /* Processor-specific. */ 428 ) 429 430 // Dyn.Tag 431 type DynTag int 432 433 const ( 434 DT_NULL DynTag = 0 /* Terminating entry. */ 435 DT_NEEDED DynTag = 1 /* String table offset of a needed shared library. */ 436 DT_PLTRELSZ DynTag = 2 /* Total size in bytes of PLT relocations. */ 437 DT_PLTGOT DynTag = 3 /* Processor-dependent address. */ 438 DT_HASH DynTag = 4 /* Address of symbol hash table. */ 439 DT_STRTAB DynTag = 5 /* Address of string table. */ 440 DT_SYMTAB DynTag = 6 /* Address of symbol table. */ 441 DT_RELA DynTag = 7 /* Address of ElfNN_Rela relocations. */ 442 DT_RELASZ DynTag = 8 /* Total size of ElfNN_Rela relocations. */ 443 DT_RELAENT DynTag = 9 /* Size of each ElfNN_Rela relocation entry. */ 444 DT_STRSZ DynTag = 10 /* Size of string table. */ 445 DT_SYMENT DynTag = 11 /* Size of each symbol table entry. */ 446 DT_INIT DynTag = 12 /* Address of initialization function. */ 447 DT_FINI DynTag = 13 /* Address of finalization function. */ 448 DT_SONAME DynTag = 14 /* String table offset of shared object name. */ 449 DT_RPATH DynTag = 15 /* String table offset of library path. [sup] */ 450 DT_SYMBOLIC DynTag = 16 /* Indicates "symbolic" linking. [sup] */ 451 DT_REL DynTag = 17 /* Address of ElfNN_Rel relocations. */ 452 DT_RELSZ DynTag = 18 /* Total size of ElfNN_Rel relocations. */ 453 DT_RELENT DynTag = 19 /* Size of each ElfNN_Rel relocation. */ 454 DT_PLTREL DynTag = 20 /* Type of relocation used for PLT. */ 455 DT_DEBUG DynTag = 21 /* Reserved (not used). */ 456 DT_TEXTREL DynTag = 22 /* Indicates there may be relocations in non-writable segments. [sup] */ 457 DT_JMPREL DynTag = 23 /* Address of PLT relocations. */ 458 DT_BIND_NOW DynTag = 24 /* [sup] */ 459 DT_INIT_ARRAY DynTag = 25 /* Address of the array of pointers to initialization functions */ 460 DT_FINI_ARRAY DynTag = 26 /* Address of the array of pointers to termination functions */ 461 DT_INIT_ARRAYSZ DynTag = 27 /* Size in bytes of the array of initialization functions. */ 462 DT_FINI_ARRAYSZ DynTag = 28 /* Size in bytes of the array of termination functions. */ 463 DT_RUNPATH DynTag = 29 /* String table offset of a null-terminated library search path string. */ 464 DT_FLAGS DynTag = 30 /* Object specific flag values. */ 465 DT_ENCODING DynTag = 32 /* Values greater than or equal to DT_ENCODING 466 and less than DT_LOOS follow the rules for 467 the interpretation of the d_un union 468 as follows: even == 'd_ptr', even == 'd_val' 469 or none */ 470 DT_PREINIT_ARRAY DynTag = 32 /* Address of the array of pointers to pre-initialization functions. */ 471 DT_PREINIT_ARRAYSZ DynTag = 33 /* Size in bytes of the array of pre-initialization functions. */ 472 DT_SYMTAB_SHNDX DynTag = 34 /* Address of SHT_SYMTAB_SHNDX section. */ 473 474 DT_LOOS DynTag = 0x6000000d /* First OS-specific */ 475 DT_HIOS DynTag = 0x6ffff000 /* Last OS-specific */ 476 477 DT_VALRNGLO DynTag = 0x6ffffd00 478 DT_GNU_PRELINKED DynTag = 0x6ffffdf5 479 DT_GNU_CONFLICTSZ DynTag = 0x6ffffdf6 480 DT_GNU_LIBLISTSZ DynTag = 0x6ffffdf7 481 DT_CHECKSUM DynTag = 0x6ffffdf8 482 DT_PLTPADSZ DynTag = 0x6ffffdf9 483 DT_MOVEENT DynTag = 0x6ffffdfa 484 DT_MOVESZ DynTag = 0x6ffffdfb 485 DT_FEATURE DynTag = 0x6ffffdfc 486 DT_POSFLAG_1 DynTag = 0x6ffffdfd 487 DT_SYMINSZ DynTag = 0x6ffffdfe 488 DT_SYMINENT DynTag = 0x6ffffdff 489 DT_VALRNGHI DynTag = 0x6ffffdff 490 491 DT_ADDRRNGLO DynTag = 0x6ffffe00 492 DT_GNU_HASH DynTag = 0x6ffffef5 493 DT_TLSDESC_PLT DynTag = 0x6ffffef6 494 DT_TLSDESC_GOT DynTag = 0x6ffffef7 495 DT_GNU_CONFLICT DynTag = 0x6ffffef8 496 DT_GNU_LIBLIST DynTag = 0x6ffffef9 497 DT_CONFIG DynTag = 0x6ffffefa 498 DT_DEPAUDIT DynTag = 0x6ffffefb 499 DT_AUDIT DynTag = 0x6ffffefc 500 DT_PLTPAD DynTag = 0x6ffffefd 501 DT_MOVETAB DynTag = 0x6ffffefe 502 DT_SYMINFO DynTag = 0x6ffffeff 503 DT_ADDRRNGHI DynTag = 0x6ffffeff 504 505 DT_VERSYM DynTag = 0x6ffffff0 506 DT_RELACOUNT DynTag = 0x6ffffff9 507 DT_RELCOUNT DynTag = 0x6ffffffa 508 DT_FLAGS_1 DynTag = 0x6ffffffb 509 DT_VERDEF DynTag = 0x6ffffffc 510 DT_VERDEFNUM DynTag = 0x6ffffffd 511 DT_VERNEED DynTag = 0x6ffffffe 512 DT_VERNEEDNUM DynTag = 0x6fffffff 513 514 DT_LOPROC DynTag = 0x70000000 /* First processor-specific type. */ 515 516 DT_MIPS_RLD_VERSION DynTag = 0x70000001 517 DT_MIPS_TIME_STAMP DynTag = 0x70000002 518 DT_MIPS_ICHECKSUM DynTag = 0x70000003 519 DT_MIPS_IVERSION DynTag = 0x70000004 520 DT_MIPS_FLAGS DynTag = 0x70000005 521 DT_MIPS_BASE_ADDRESS DynTag = 0x70000006 522 DT_MIPS_MSYM DynTag = 0x70000007 523 DT_MIPS_CONFLICT DynTag = 0x70000008 524 DT_MIPS_LIBLIST DynTag = 0x70000009 525 DT_MIPS_LOCAL_GOTNO DynTag = 0x7000000a 526 DT_MIPS_CONFLICTNO DynTag = 0x7000000b 527 DT_MIPS_LIBLISTNO DynTag = 0x70000010 528 DT_MIPS_SYMTABNO DynTag = 0x70000011 529 DT_MIPS_UNREFEXTNO DynTag = 0x70000012 530 DT_MIPS_GOTSYM DynTag = 0x70000013 531 DT_MIPS_HIPAGENO DynTag = 0x70000014 532 DT_MIPS_RLD_MAP DynTag = 0x70000016 533 DT_MIPS_DELTA_CLASS DynTag = 0x70000017 534 DT_MIPS_DELTA_CLASS_NO DynTag = 0x70000018 535 DT_MIPS_DELTA_INSTANCE DynTag = 0x70000019 536 DT_MIPS_DELTA_INSTANCE_NO DynTag = 0x7000001a 537 DT_MIPS_DELTA_RELOC DynTag = 0x7000001b 538 DT_MIPS_DELTA_RELOC_NO DynTag = 0x7000001c 539 DT_MIPS_DELTA_SYM DynTag = 0x7000001d 540 DT_MIPS_DELTA_SYM_NO DynTag = 0x7000001e 541 DT_MIPS_DELTA_CLASSSYM DynTag = 0x70000020 542 DT_MIPS_DELTA_CLASSSYM_NO DynTag = 0x70000021 543 DT_MIPS_CXX_FLAGS DynTag = 0x70000022 544 DT_MIPS_PIXIE_INIT DynTag = 0x70000023 545 DT_MIPS_SYMBOL_LIB DynTag = 0x70000024 546 DT_MIPS_LOCALPAGE_GOTIDX DynTag = 0x70000025 547 DT_MIPS_LOCAL_GOTIDX DynTag = 0x70000026 548 DT_MIPS_HIDDEN_GOTIDX DynTag = 0x70000027 549 DT_MIPS_PROTECTED_GOTIDX DynTag = 0x70000028 550 DT_MIPS_OPTIONS DynTag = 0x70000029 551 DT_MIPS_INTERFACE DynTag = 0x7000002a 552 DT_MIPS_DYNSTR_ALIGN DynTag = 0x7000002b 553 DT_MIPS_INTERFACE_SIZE DynTag = 0x7000002c 554 DT_MIPS_RLD_TEXT_RESOLVE_ADDR DynTag = 0x7000002d 555 DT_MIPS_PERF_SUFFIX DynTag = 0x7000002e 556 DT_MIPS_COMPACT_SIZE DynTag = 0x7000002f 557 DT_MIPS_GP_VALUE DynTag = 0x70000030 558 DT_MIPS_AUX_DYNAMIC DynTag = 0x70000031 559 DT_MIPS_PLTGOT DynTag = 0x70000032 560 DT_MIPS_RWPLT DynTag = 0x70000034 561 DT_MIPS_RLD_MAP_REL DynTag = 0x70000035 562 563 DT_PPC_GOT DynTag = 0x70000000 564 DT_PPC_OPT DynTag = 0x70000001 565 566 DT_PPC64_GLINK DynTag = 0x70000000 567 DT_PPC64_OPD DynTag = 0x70000001 568 DT_PPC64_OPDSZ DynTag = 0x70000002 569 DT_PPC64_OPT DynTag = 0x70000003 570 571 DT_SPARC_REGISTER DynTag = 0x70000001 572 573 DT_AUXILIARY DynTag = 0x7ffffffd 574 DT_USED DynTag = 0x7ffffffe 575 DT_FILTER DynTag = 0x7fffffff 576 577 DT_HIPROC DynTag = 0x7fffffff /* Last processor-specific type. */ 578 ) 579 580 // DT_FLAGS values. 581 type DynFlag int 582 583 const ( 584 DF_ORIGIN DynFlag = 0x0001 /* Indicates that the object being loaded may 585 make reference to the 586 $ORIGIN substitution string */ 587 DF_SYMBOLIC DynFlag = 0x0002 /* Indicates "symbolic" linking. */ 588 DF_TEXTREL DynFlag = 0x0004 /* Indicates there may be relocations in non-writable segments. */ 589 DF_BIND_NOW DynFlag = 0x0008 /* Indicates that the dynamic linker should 590 process all relocations for the object 591 containing this entry before transferring 592 control to the program. */ 593 DF_STATIC_TLS DynFlag = 0x0010 /* Indicates that the shared object or 594 executable contains code using a static 595 thread-local storage scheme. */ 596 ) 597 598 // DT_FLAGS_1 values. 599 type DynFlag1 uint32 600 601 const ( 602 // Indicates that all relocations for this object must be processed before 603 // returning control to the program. 604 DF_1_NOW DynFlag1 = 0x00000001 605 // Unused. 606 DF_1_GLOBAL DynFlag1 = 0x00000002 607 // Indicates that the object is a member of a group. 608 DF_1_GROUP DynFlag1 = 0x00000004 609 // Indicates that the object cannot be deleted from a process. 610 DF_1_NODELETE DynFlag1 = 0x00000008 611 // Meaningful only for filters. Indicates that all associated filtees be 612 // processed immediately. 613 DF_1_LOADFLTR DynFlag1 = 0x00000010 614 // Indicates that this object's initialization section be run before any other 615 // objects loaded. 616 DF_1_INITFIRST DynFlag1 = 0x00000020 617 // Indicates that the object cannot be added to a running process with dlopen. 618 DF_1_NOOPEN DynFlag1 = 0x00000040 619 // Indicates the object requires $ORIGIN processing. 620 DF_1_ORIGIN DynFlag1 = 0x00000080 621 // Indicates that the object should use direct binding information. 622 DF_1_DIRECT DynFlag1 = 0x00000100 623 // Unused. 624 DF_1_TRANS DynFlag1 = 0x00000200 625 // Indicates that the objects symbol table is to interpose before all symbols 626 // except the primary load object, which is typically the executable. 627 DF_1_INTERPOSE DynFlag1 = 0x00000400 628 // Indicates that the search for dependencies of this object ignores any 629 // default library search paths. 630 DF_1_NODEFLIB DynFlag1 = 0x00000800 631 // Indicates that this object is not dumped by dldump. Candidates are objects 632 // with no relocations that might get included when generating alternative 633 // objects using. 634 DF_1_NODUMP DynFlag1 = 0x00001000 635 // Identifies this object as a configuration alternative object generated by 636 // crle. Triggers the runtime linker to search for a configuration file $ORIGIN/ld.config.app-name. 637 DF_1_CONFALT DynFlag1 = 0x00002000 638 // Meaningful only for filtees. Terminates a filters search for any 639 // further filtees. 640 DF_1_ENDFILTEE DynFlag1 = 0x00004000 641 // Indicates that this object has displacement relocations applied. 642 DF_1_DISPRELDNE DynFlag1 = 0x00008000 643 // Indicates that this object has displacement relocations pending. 644 DF_1_DISPRELPND DynFlag1 = 0x00010000 645 // Indicates that this object contains symbols that cannot be directly 646 // bound to. 647 DF_1_NODIRECT DynFlag1 = 0x00020000 648 // Reserved for internal use by the kernel runtime-linker. 649 DF_1_IGNMULDEF DynFlag1 = 0x00040000 650 // Reserved for internal use by the kernel runtime-linker. 651 DF_1_NOKSYMS DynFlag1 = 0x00080000 652 // Reserved for internal use by the kernel runtime-linker. 653 DF_1_NOHDR DynFlag1 = 0x00100000 654 // Indicates that this object has been edited or has been modified since the 655 // objects original construction by the link-editor. 656 DF_1_EDITED DynFlag1 = 0x00200000 657 // Reserved for internal use by the kernel runtime-linker. 658 DF_1_NORELOC DynFlag1 = 0x00400000 659 // Indicates that the object contains individual symbols that should interpose 660 // before all symbols except the primary load object, which is typically the 661 // executable. 662 DF_1_SYMINTPOSE DynFlag1 = 0x00800000 663 // Indicates that the executable requires global auditing. 664 DF_1_GLOBAUDIT DynFlag1 = 0x01000000 665 // Indicates that the object defines, or makes reference to singleton symbols. 666 DF_1_SINGLETON DynFlag1 = 0x02000000 667 // Indicates that the object is a stub. 668 DF_1_STUB DynFlag1 = 0x04000000 669 // Indicates that the object is a position-independent executable. 670 DF_1_PIE DynFlag1 = 0x08000000 671 // Indicates that the object is a kernel module. 672 DF_1_KMOD DynFlag1 = 0x10000000 673 // Indicates that the object is a weak standard filter. 674 DF_1_WEAKFILTER DynFlag1 = 0x20000000 675 // Unused. 676 DF_1_NOCOMMON DynFlag1 = 0x40000000 677 ) 678 679 // NType values; used in core files. 680 type NType int 681 682 const ( 683 NT_PRSTATUS NType = 1 /* Process status. */ 684 NT_FPREGSET NType = 2 /* Floating point registers. */ 685 NT_PRPSINFO NType = 3 /* Process state info. */ 686 ) 687 688 /* Symbol Binding - ELFNN_ST_BIND - st_info */ 689 type SymBind int 690 691 const ( 692 STB_LOCAL SymBind = 0 /* Local symbol */ 693 STB_GLOBAL SymBind = 1 /* Global symbol */ 694 STB_WEAK SymBind = 2 /* like global - lower precedence */ 695 STB_LOOS SymBind = 10 /* Reserved range for operating system */ 696 STB_HIOS SymBind = 12 /* specific semantics. */ 697 STB_LOPROC SymBind = 13 /* reserved range for processor */ 698 STB_HIPROC SymBind = 15 /* specific semantics. */ 699 ) 700 701 /* Symbol type - ELFNN_ST_TYPE - st_info */ 702 type SymType int 703 704 const ( 705 STT_NOTYPE SymType = 0 /* Unspecified type. */ 706 STT_OBJECT SymType = 1 /* Data object. */ 707 STT_FUNC SymType = 2 /* Function. */ 708 STT_SECTION SymType = 3 /* Section. */ 709 STT_FILE SymType = 4 /* Source file. */ 710 STT_COMMON SymType = 5 /* Uninitialized common block. */ 711 STT_TLS SymType = 6 /* TLS object. */ 712 STT_LOOS SymType = 10 /* Reserved range for operating system */ 713 STT_HIOS SymType = 12 /* specific semantics. */ 714 STT_LOPROC SymType = 13 /* reserved range for processor */ 715 STT_HIPROC SymType = 15 /* specific semantics. */ 716 ) 717 718 /* Symbol visibility - ELFNN_ST_VISIBILITY - st_other */ 719 type SymVis int 720 721 const ( 722 STV_DEFAULT SymVis = 0x0 /* Default visibility (see binding). */ 723 STV_INTERNAL SymVis = 0x1 /* Special meaning in relocatable objects. */ 724 STV_HIDDEN SymVis = 0x2 /* Not visible. */ 725 STV_PROTECTED SymVis = 0x3 /* Visible but not preemptible. */ 726 ) 727 728 // Magic number for the elf trampoline, chosen wisely to be an immediate value. 729 const ARM_MAGIC_TRAMP_NUMBER = 0x5c000003