1 /* $NetBSD: elf.h,v 1.3 2014/01/03 16:40:58 dsl Exp $ */ 2 @@ 3 4 /*- 5 * Copyright (c) 1994 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Christos Zoulas. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef _STAND_E32BOOT_ELF_H_ 34 #define _STAND_E32BOOT_ELF_H_ 35 36 /* 37 * The current ELF ABI specification is available at: 38 * http://www.sco.com/developers/gabi/ 39 * 40 * Current header definitions are in: 41 * http://www.sco.com/developers/gabi/latest/ch4.eheader.html 42 */ 43 44 typedef unsigned char uint8_t; 45 typedef unsigned short int uint16_t; 46 typedef unsigned int uint32_t; 47 typedef unsigned long long int uint64_t; 48 typedef signed char int8_t; 49 typedef int int32_t; 50 typedef long long int int64_t; 51 52 53 typedef uint8_t Elf_Byte; 54 55 typedef uint32_t Elf32_Addr; 56 #define ELF32_FSZ_ADDR 4 57 typedef uint32_t Elf32_Off; 58 typedef int32_t Elf32_SOff; 59 #define ELF32_FSZ_OFF 4 60 typedef int32_t Elf32_Sword; 61 #define ELF32_FSZ_SWORD 4 62 typedef uint32_t Elf32_Word; 63 #define ELF32_FSZ_WORD 4 64 typedef uint16_t Elf32_Half; 65 #define ELF32_FSZ_HALF 2 66 typedef uint64_t Elf32_Lword; 67 #define ELF32_FSZ_LWORD 8 68 69 typedef uint64_t Elf64_Addr; 70 #define ELF64_FSZ_ADDR 8 71 typedef uint64_t Elf64_Off; 72 typedef int64_t Elf64_SOff; 73 #define ELF64_FSZ_OFF 8 74 75 typedef int32_t Elf64_Sword; 76 #define ELF64_FSZ_SWORD 4 77 typedef uint32_t Elf64_Word; 78 #define ELF64_FSZ_WORD 4 79 80 typedef int64_t Elf64_Sxword; 81 #define ELF64_FSZ_SXWORD 8 82 typedef uint64_t Elf64_Xword; 83 #define ELF64_FSZ_XWORD 8 84 typedef uint64_t Elf64_Lword; 85 #define ELF64_FSZ_LWORD 8 86 typedef uint16_t Elf64_Half; 87 #define ELF64_FSZ_HALF 2 88 89 /* 90 * ELF Header 91 */ 92 #define ELF_NIDENT 16 93 94 typedef struct { 95 unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ 96 Elf32_Half e_type; /* file type */ 97 Elf32_Half e_machine; /* machine type */ 98 Elf32_Word e_version; /* version number */ 99 Elf32_Addr e_entry; /* entry point */ 100 Elf32_Off e_phoff; /* Program hdr offset */ 101 Elf32_Off e_shoff; /* Section hdr offset */ 102 Elf32_Word e_flags; /* Processor flags */ 103 Elf32_Half e_ehsize; /* sizeof ehdr */ 104 Elf32_Half e_phentsize; /* Program header entry size */ 105 Elf32_Half e_phnum; /* Number of program headers */ 106 Elf32_Half e_shentsize; /* Section header entry size */ 107 Elf32_Half e_shnum; /* Number of section headers */ 108 Elf32_Half e_shstrndx; /* String table index */ 109 } Elf32_Ehdr; 110 111 typedef struct { 112 unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ 113 Elf64_Half e_type; /* file type */ 114 Elf64_Half e_machine; /* machine type */ 115 Elf64_Word e_version; /* version number */ 116 Elf64_Addr e_entry; /* entry point */ 117 Elf64_Off e_phoff; /* Program hdr offset */ 118 Elf64_Off e_shoff; /* Section hdr offset */ 119 Elf64_Word e_flags; /* Processor flags */ 120 Elf64_Half e_ehsize; /* sizeof ehdr */ 121 Elf64_Half e_phentsize; /* Program header entry size */ 122 Elf64_Half e_phnum; /* Number of program headers */ 123 Elf64_Half e_shentsize; /* Section header entry size */ 124 Elf64_Half e_shnum; /* Number of section headers */ 125 Elf64_Half e_shstrndx; /* String table index */ 126 } Elf64_Ehdr; 127 128 /* e_ident offsets */ 129 #define EI_MAG0 0 /* '\177' */ 130 #define EI_MAG1 1 /* 'E' */ 131 #define EI_MAG2 2 /* 'L' */ 132 #define EI_MAG3 3 /* 'F' */ 133 #define EI_CLASS 4 /* File class */ 134 #define EI_DATA 5 /* Data encoding */ 135 #define EI_VERSION 6 /* File version */ 136 #define EI_OSABI 7 /* Operating system/ABI identification */ 137 #define EI_ABIVERSION 8 /* ABI version */ 138 #define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/ 139 #define EI_NIDENT 16 /* First non-ident header byte */ 140 141 /* e_ident[EI_MAG0,EI_MAG3] */ 142 #define ELFMAG0 0x7f 143 #define ELFMAG1 'E' 144 #define ELFMAG2 'L' 145 #define ELFMAG3 'F' 146 #define ELFMAG "\177ELF" 147 #define SELFMAG 4 148 149 /* e_ident[EI_CLASS] */ 150 #define ELFCLASSNONE 0 /* Invalid class */ 151 #define ELFCLASS32 1 /* 32-bit objects */ 152 #define ELFCLASS64 2 /* 64-bit objects */ 153 #define ELFCLASSNUM 3 154 155 /* e_ident[EI_DATA] */ 156 #define ELFDATANONE 0 /* Invalid data encoding */ 157 #define ELFDATA2LSB 1 /* 2's complement values, LSB first */ 158 #define ELFDATA2MSB 2 /* 2's complement values, MSB first */ 159 160 /* e_ident[EI_VERSION] */ 161 #define EV_NONE 0 /* Invalid version */ 162 #define EV_CURRENT 1 /* Current version */ 163 #define EV_NUM 2 164 165 /* e_ident[EI_OSABI] */ 166 #define ELFOSABI_SYSV 0 /* UNIX System V ABI */ 167 #define ELFOSABI_HPUX 1 /* HP-UX operating system */ 168 #define ELFOSABI_NETBSD 2 /* NetBSD */ 169 #define ELFOSABI_LINUX 3 /* GNU/Linux */ 170 #define ELFOSABI_HURD 4 /* GNU/Hurd */ 171 #define ELFOSABI_86OPEN 5 /* 86Open */ 172 #define ELFOSABI_SOLARIS 6 /* Solaris */ 173 #define ELFOSABI_MONTEREY 7 /* Monterey */ 174 #define ELFOSABI_IRIX 8 /* IRIX */ 175 #define ELFOSABI_FREEBSD 9 /* FreeBSD */ 176 #define ELFOSABI_TRU64 10 /* TRU64 UNIX */ 177 #define ELFOSABI_MODESTO 11 /* Novell Modesto */ 178 #define ELFOSABI_OPENBSD 12 /* OpenBSD */ 179 #define ELFOSABI_OPENVMS 13 /* OpenVMS */ 180 #define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ 181 #define ELFOSABI_AROS 15 /* Amiga Research OS */ 182 /* Unofficial OSABIs follow */ 183 #define ELFOSABI_ARM 97 /* ARM */ 184 #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ 185 186 #define ELFOSABI_NONE ELFOSABI_SYSV 187 #define ELFOSABI_AIX ELFOSABI_MONTEREY 188 189 /* e_type */ 190 #define ET_NONE 0 /* No file type */ 191 #define ET_REL 1 /* Relocatable file */ 192 #define ET_EXEC 2 /* Executable file */ 193 #define ET_DYN 3 /* Shared object file */ 194 #define ET_CORE 4 /* Core file */ 195 #define ET_NUM 5 196 197 #define ET_LOOS 0xfe00 /* Operating system specific range */ 198 #define ET_HIOS 0xfeff 199 #define ET_LOPROC 0xff00 /* Processor-specific range */ 200 #define ET_HIPROC 0xffff 201 202 /* e_machine */ 203 #define EM_NONE 0 /* No machine */ 204 #define EM_M32 1 /* AT&T WE 32100 */ 205 #define EM_SPARC 2 /* SPARC */ 206 #define EM_386 3 /* Intel 80386 */ 207 #define EM_68K 4 /* Motorola 68000 */ 208 #define EM_88K 5 /* Motorola 88000 */ 209 #define EM_486 6 /* Intel 80486 */ 210 #define EM_860 7 /* Intel 80860 */ 211 #define EM_MIPS 8 /* MIPS I Architecture */ 212 #define EM_S370 9 /* Amdahl UTS on System/370 */ 213 #define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */ 214 /* 11-14 - Reserved */ 215 #define EM_RS6000 11 /* IBM RS/6000 XXX reserved */ 216 #define EM_PARISC 15 /* Hewlett-Packard PA-RISC */ 217 #define EM_NCUBE 16 /* NCube XXX reserved */ 218 #define EM_VPP500 17 /* Fujitsu VPP500 */ 219 #define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ 220 #define EM_960 19 /* Intel 80960 */ 221 #define EM_PPC 20 /* PowerPC */ 222 #define EM_PPC64 21 /* 64-bit PowerPC */ 223 /* 22-35 - Reserved */ 224 #define EM_S390 22 /* System/390 XXX reserved */ 225 #define EM_V800 36 /* NEC V800 */ 226 #define EM_FR20 37 /* Fujitsu FR20 */ 227 #define EM_RH32 38 /* TRW RH-32 */ 228 #define EM_RCE 39 /* Motorola RCE */ 229 #define EM_ARM 40 /* Advanced RISC Machines ARM */ 230 #define EM_ALPHA 41 /* DIGITAL Alpha */ 231 #define EM_SH 42 /* Hitachi Super-H */ 232 #define EM_SPARCV9 43 /* SPARC Version 9 */ 233 #define EM_TRICORE 44 /* Siemens Tricore */ 234 #define EM_ARC 45 /* Argonaut RISC Core */ 235 #define EM_H8_300 46 /* Hitachi H8/300 */ 236 #define EM_H8_300H 47 /* Hitachi H8/300H */ 237 #define EM_H8S 48 /* Hitachi H8S */ 238 #define EM_H8_500 49 /* Hitachi H8/500 */ 239 #define EM_IA_64 50 /* Intel Merced Processor */ 240 #define EM_MIPS_X 51 /* Stanford MIPS-X */ 241 #define EM_COLDFIRE 52 /* Motorola Coldfire */ 242 #define EM_68HC12 53 /* Motorola MC68HC12 */ 243 #define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */ 244 #define EM_PCP 55 /* Siemens PCP */ 245 #define EM_NCPU 56 /* Sony nCPU embedded RISC processor */ 246 #define EM_NDR1 57 /* Denso NDR1 microprocessor */ 247 #define EM_STARCORE 58 /* Motorola Star*Core processor */ 248 #define EM_ME16 59 /* Toyota ME16 processor */ 249 #define EM_ST100 60 /* STMicroelectronics ST100 processor */ 250 #define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded family processor */ 251 #define EM_X86_64 62 /* AMD x86-64 architecture */ 252 #define EM_PDSP 63 /* Sony DSP Processor */ 253 #define EM_PDP10 64 /* Digital Equipment Corp. PDP-10 */ 254 #define EM_PDP11 65 /* Digital Equipment Corp. PDP-11 */ 255 #define EM_FX66 66 /* Siemens FX66 microcontroller */ 256 #define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 bit microcontroller */ 257 #define EM_ST7 68 /* STMicroelectronics ST7 8-bit microcontroller */ 258 #define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */ 259 #define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */ 260 #define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */ 261 #define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */ 262 #define EM_SVX 73 /* Silicon Graphics SVx */ 263 #define EM_ST19 74 /* STMicroelectronics ST19 8-bit CPU */ 264 #define EM_VAX 75 /* Digital VAX */ 265 #define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ 266 #define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded CPU */ 267 #define EM_FIREPATH 78 /* Element 14 64-bit DSP processor */ 268 #define EM_ZSP 79 /* LSI Logic's 16-bit DSP processor */ 269 #define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ 270 #define EM_HUANY 81 /* Harvard's machine-independent format */ 271 #define EM_PRISM 82 /* SiTera Prism */ 272 #define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ 273 #define EM_FR30 84 /* Fujitsu FR30 */ 274 #define EM_D10V 85 /* Mitsubishi D10V */ 275 #define EM_D30V 86 /* Mitsubishi D30V */ 276 #define EM_V850 87 /* NEC v850 */ 277 #define EM_M32R 88 /* Mitsubishi M32R */ 278 #define EM_MN10300 89 /* Matsushita MN10300 */ 279 #define EM_MN10200 90 /* Matsushita MN10200 */ 280 #define EM_PJ 91 /* picoJava */ 281 #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ 282 #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ 283 #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ 284 #define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */ 285 #define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Processor */ 286 #define EM_NS32K 97 /* National Semiconductor 32000 series */ 287 #define EM_TPC 98 /* Tenor Network TPC processor */ 288 #define EM_SNP1K 99 /* Trebia SNP 1000 processor */ 289 #define EM_ST200 100 /* STMicroelectronics ST200 microcontroller */ 290 #define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */ 291 #define EM_MAX 102 /* MAX processor */ 292 #define EM_CR 103 /* National Semiconductor CompactRISC micorprocessor */ 293 #define EM_F2MC16 104 /* Fujitsu F2MC16 */ 294 #define EM_MSP430 105 /* Texas Instruments MSP430 */ 295 #define EM_BLACKFIN 106 /* Analog Devices Blackfin DSP */ 296 #define EM_SE_C33 107 /* Seiko Epson S1C33 family */ 297 #define EM_SEP 108 /* Sharp embedded microprocessor */ 298 #define EM_ARCA 109 /* Arca RISC microprocessor */ 299 #define EM_UNICORE 110 /* UNICORE from PKU-Unity Ltd. and MPRC Peking University */ 300 301 /* Unofficial machine types follow */ 302 #define EM_AVR32 6317 /* used by NetBSD/avr32 */ 303 #define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */ 304 #define EM_NUM 36903 305 306 /* 307 * Program Header 308 */ 309 typedef struct { 310 Elf32_Word p_type; /* entry type */ 311 Elf32_Off p_offset; /* offset */ 312 Elf32_Addr p_vaddr; /* virtual address */ 313 Elf32_Addr p_paddr; /* physical address */ 314 Elf32_Word p_filesz; /* file size */ 315 Elf32_Word p_memsz; /* memory size */ 316 Elf32_Word p_flags; /* flags */ 317 Elf32_Word p_align; /* memory & file alignment */ 318 } Elf32_Phdr; 319 320 typedef struct { 321 Elf64_Word p_type; /* entry type */ 322 Elf64_Word p_flags; /* flags */ 323 Elf64_Off p_offset; /* offset */ 324 Elf64_Addr p_vaddr; /* virtual address */ 325 Elf64_Addr p_paddr; /* physical address */ 326 Elf64_Xword p_filesz; /* file size */ 327 Elf64_Xword p_memsz; /* memory size */ 328 Elf64_Xword p_align; /* memory & file alignment */ 329 } Elf64_Phdr; 330 331 /* p_type */ 332 #define PT_NULL 0 /* Program header table entry unused */ 333 #define PT_LOAD 1 /* Loadable program segment */ 334 #define PT_DYNAMIC 2 /* Dynamic linking information */ 335 #define PT_INTERP 3 /* Program interpreter */ 336 #define PT_NOTE 4 /* Auxiliary information */ 337 #define PT_SHLIB 5 /* Reserved, unspecified semantics */ 338 #define PT_PHDR 6 /* Entry for header table itself */ 339 #define PT_TLS 7 /* TLS initialisation image */ 340 #define PT_NUM 8 341 342 #define PT_LOOS 0x60000000 /* OS-specific range */ 343 344 /* GNU-specific */ 345 #define PT_GNU_EH_FRAME 0x6474e550 /* EH frame segment */ 346 #define PT_GNU_STACK 0x6474e551 /* Indicate executable stack */ 347 #define PT_GNU_RELRO 0x6474e552 /* Make read-only after relocation */ 348 349 #define PT_HIOS 0x6fffffff 350 #define PT_LOPROC 0x70000000 /* Processor-specific range */ 351 #define PT_HIPROC 0x7fffffff 352 353 #define PT_MIPS_REGINFO 0x70000000 354 355 /* p_flags */ 356 #define PF_R 0x4 /* Segment is readable */ 357 #define PF_W 0x2 /* Segment is writable */ 358 #define PF_X 0x1 /* Segment is executable */ 359 360 #define PF_MASKOS 0x0ff00000 /* Operating system specific values */ 361 #define PF_MASKPROC 0xf0000000 /* Processor-specific values */ 362 363 /* Extended program header index. */ 364 #define PN_XNUM 0xffff 365 366 /* 367 * Section Headers 368 */ 369 typedef struct { 370 Elf32_Word sh_name; /* section name (.shstrtab index) */ 371 Elf32_Word sh_type; /* section type */ 372 Elf32_Word sh_flags; /* section flags */ 373 Elf32_Addr sh_addr; /* virtual address */ 374 Elf32_Off sh_offset; /* file offset */ 375 Elf32_Word sh_size; /* section size */ 376 Elf32_Word sh_link; /* link to another */ 377 Elf32_Word sh_info; /* misc info */ 378 Elf32_Word sh_addralign; /* memory alignment */ 379 Elf32_Word sh_entsize; /* table entry size */ 380 } Elf32_Shdr; 381 382 typedef struct { 383 Elf64_Word sh_name; /* section name (.shstrtab index) */ 384 Elf64_Word sh_type; /* section type */ 385 Elf64_Xword sh_flags; /* section flags */ 386 Elf64_Addr sh_addr; /* virtual address */ 387 Elf64_Off sh_offset; /* file offset */ 388 Elf64_Xword sh_size; /* section size */ 389 Elf64_Word sh_link; /* link to another */ 390 Elf64_Word sh_info; /* misc info */ 391 Elf64_Xword sh_addralign; /* memory alignment */ 392 Elf64_Xword sh_entsize; /* table entry size */ 393 } Elf64_Shdr; 394 395 /* sh_type */ 396 #define SHT_NULL 0 /* Section header table entry unused */ 397 #define SHT_PROGBITS 1 /* Program information */ 398 #define SHT_SYMTAB 2 /* Symbol table */ 399 #define SHT_STRTAB 3 /* String table */ 400 #define SHT_RELA 4 /* Relocation information w/ addend */ 401 #define SHT_HASH 5 /* Symbol hash table */ 402 #define SHT_DYNAMIC 6 /* Dynamic linking information */ 403 #define SHT_NOTE 7 /* Auxiliary information */ 404 #define SHT_NOBITS 8 /* No space allocated in file image */ 405 #define SHT_REL 9 /* Relocation information w/o addend */ 406 #define SHT_SHLIB 10 /* Reserved, unspecified semantics */ 407 #define SHT_DYNSYM 11 /* Symbol table for dynamic linker */ 408 #define SHT_INIT_ARRAY 14 /* Initialization function pointers */ 409 #define SHT_FINI_ARRAY 15 /* Termination function pointers */ 410 #define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs */ 411 #define SHT_GROUP 17 /* Section group */ 412 #define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX) */ 413 #define SHT_NUM 19 414 415 #define SHT_LOOS 0x60000000 /* Operating system specific range */ 416 #define SHT_GNU_HASH 0x6ffffff6 /* GNU style symbol hash table */ 417 #define SHT_SUNW_move 0x6ffffffa 418 #define SHT_SUNW_syminfo 0x6ffffffc 419 #define SHT_SUNW_verdef 0x6ffffffd /* Versions defined by file */ 420 #define SHT_GNU_verdef SHT_SUNW_verdef 421 #define SHT_SUNW_verneed 0x6ffffffe /* Versions needed by file */ 422 #define SHT_GNU_verneed SHT_SUNW_verneed 423 #define SHT_SUNW_versym 0x6fffffff /* Symbol versions */ 424 #define SHT_GNU_versym SHT_SUNW_versym 425 #define SHT_HIOS 0x6fffffff 426 #define SHT_LOPROC 0x70000000 /* Processor-specific range */ 427 #define SHT_AMD64_UNWIND 0x70000001 /* unwind information */ 428 #define SHT_HIPROC 0x7fffffff 429 #define SHT_LOUSER 0x80000000 /* Application-specific range */ 430 #define SHT_HIUSER 0xffffffff 431 432 /* sh_flags */ 433 #define SHF_WRITE 0x00000001 /* Contains writable data */ 434 #define SHF_ALLOC 0x00000002 /* Occupies memory */ 435 #define SHF_EXECINSTR 0x00000004 /* Contains executable insns */ 436 #define SHF_MERGE 0x00000010 /* Might be merged */ 437 #define SHF_STRINGS 0x00000020 /* Contains nul terminated strings */ 438 #define SHF_INFO_LINK 0x00000040 /* "sh_info" contains SHT index */ 439 #define SHF_LINK_ORDER 0x00000080 /* Preserve order after combining */ 440 #define SHF_OS_NONCONFORMING 0x00000100 /* OS specific handling required */ 441 #define SHF_GROUP 0x00000200 /* Is member of a group */ 442 #define SHF_TLS 0x00000400 /* Holds thread-local data */ 443 #define SHF_MASKOS 0x0ff00000 /* Operating system specific values */ 444 #define SHF_MASKPROC 0xf0000000 /* Processor-specific values */ 445 #define SHF_ORDERED 0x40000000 /* Ordering requirement (Solaris) */ 446 #define SHF_EXCLUDE 0x80000000 /* Excluded unless unles ref/alloc 447 (Solaris).*/ 448 /* 449 * Symbol Table 450 */ 451 typedef struct { 452 Elf32_Word st_name; /* Symbol name (.strtab index) */ 453 Elf32_Word st_value; /* value of symbol */ 454 Elf32_Word st_size; /* size of symbol */ 455 Elf_Byte st_info; /* type / binding attrs */ 456 Elf_Byte st_other; /* unused */ 457 Elf32_Half st_shndx; /* section index of symbol */ 458 } Elf32_Sym; 459 460 typedef struct { 461 Elf64_Word st_name; /* Symbol name (.strtab index) */ 462 Elf_Byte st_info; /* type / binding attrs */ 463 Elf_Byte st_other; /* unused */ 464 Elf64_Half st_shndx; /* section index of symbol */ 465 Elf64_Addr st_value; /* value of symbol */ 466 Elf64_Xword st_size; /* size of symbol */ 467 } Elf64_Sym; 468 469 /* Symbol Table index of the undefined symbol */ 470 #define ELF_SYM_UNDEFINED 0 471 472 #define STN_UNDEF 0 /* undefined index */ 473 474 /* st_info: Symbol Bindings */ 475 #define STB_LOCAL 0 /* local symbol */ 476 #define STB_GLOBAL 1 /* global symbol */ 477 #define STB_WEAK 2 /* weakly defined global symbol */ 478 #define STB_NUM 3 479 480 #define STB_LOOS 10 /* Operating system specific range */ 481 #define STB_HIOS 12 482 #define STB_LOPROC 13 /* Processor-specific range */ 483 #define STB_HIPROC 15 484 485 /* st_info: Symbol Types */ 486 #define STT_NOTYPE 0 /* Type not specified */ 487 #define STT_OBJECT 1 /* Associated with a data object */ 488 #define STT_FUNC 2 /* Associated with a function */ 489 #define STT_SECTION 3 /* Associated with a section */ 490 #define STT_FILE 4 /* Associated with a file name */ 491 #define STT_COMMON 5 /* Uninitialised common block */ 492 #define STT_TLS 6 /* Thread local data object */ 493 #define STT_NUM 7 494 495 #define STT_LOOS 10 /* Operating system specific range */ 496 #define STT_HIOS 12 497 #define STT_LOPROC 13 /* Processor-specific range */ 498 #define STT_HIPROC 15 499 500 /* st_other: Visibility Types */ 501 #define STV_DEFAULT 0 /* use binding type */ 502 #define STV_INTERNAL 1 /* not referenced from outside */ 503 #define STV_HIDDEN 2 /* not visible, may be used via ptr */ 504 #define STV_PROTECTED 3 /* visible, not preemptible */ 505 #define STV_EXPORTED 4 506 #define STV_SINGLETON 5 507 #define STV_ELIMINATE 6 508 509 /* st_info/st_other utility macros */ 510 #define ELF_ST_BIND(info) ((uint32_t)(info) >> 4) 511 #define ELF_ST_TYPE(info) ((uint32_t)(info) & 0xf) 512 #define ELF_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | \ 513 ((type) & 0xf))) 514 #define ELF_ST_VISIBILITY(other) ((uint32_t)(other) & 3) 515 516 /* 517 * Special section indexes 518 */ 519 #define SHN_UNDEF 0 /* Undefined section */ 520 521 #define SHN_LORESERVE 0xff00 /* Reserved range */ 522 #define SHN_ABS 0xfff1 /* Absolute symbols */ 523 #define SHN_COMMON 0xfff2 /* Common symbols */ 524 #define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere */ 525 #define SHN_HIRESERVE 0xffff 526 527 #define SHN_LOPROC 0xff00 /* Processor-specific range */ 528 #define SHN_HIPROC 0xff1f 529 #define SHN_LOOS 0xff20 /* Operating system specific range */ 530 #define SHN_HIOS 0xff3f 531 532 #define SHN_MIPS_ACOMMON 0xff00 533 #define SHN_MIPS_TEXT 0xff01 534 #define SHN_MIPS_DATA 0xff02 535 #define SHN_MIPS_SCOMMON 0xff03 536 537 /* 538 * Relocation Entries 539 */ 540 typedef struct { 541 Elf32_Word r_offset; /* where to do it */ 542 Elf32_Word r_info; /* index & type of relocation */ 543 } Elf32_Rel; 544 545 typedef struct { 546 Elf32_Word r_offset; /* where to do it */ 547 Elf32_Word r_info; /* index & type of relocation */ 548 Elf32_Sword r_addend; /* adjustment value */ 549 } Elf32_Rela; 550 551 /* r_info utility macros */ 552 #define ELF32_R_SYM(info) ((info) >> 8) 553 #define ELF32_R_TYPE(info) ((info) & 0xff) 554 #define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) 555 556 typedef struct { 557 Elf64_Addr r_offset; /* where to do it */ 558 Elf64_Xword r_info; /* index & type of relocation */ 559 } Elf64_Rel; 560 561 typedef struct { 562 Elf64_Addr r_offset; /* where to do it */ 563 Elf64_Xword r_info; /* index & type of relocation */ 564 Elf64_Sxword r_addend; /* adjustment value */ 565 } Elf64_Rela; 566 567 /* r_info utility macros */ 568 #define ELF64_R_SYM(info) ((info) >> 32) 569 #define ELF64_R_TYPE(info) ((info) & 0xffffffff) 570 #define ELF64_R_INFO(sym,type) (((sym) << 32) + (type)) 571 572 /* 573 * Move entries 574 */ 575 typedef struct { 576 Elf32_Lword m_value; /* symbol value */ 577 Elf32_Word m_info; /* size + index */ 578 Elf32_Word m_poffset; /* symbol offset */ 579 Elf32_Half m_repeat; /* repeat count */ 580 Elf32_Half m_stride; /* stride info */ 581 } Elf32_Move; 582 583 #define ELF32_M_SYM(info) ((info) >> 8) 584 #define ELF32_M_SIZE(info) ((info) & 0xff) 585 #define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) 586 587 typedef struct { 588 Elf64_Lword m_value; /* symbol value */ 589 Elf64_Xword m_info; /* size + index */ 590 Elf64_Xword m_poffset; /* symbol offset */ 591 Elf64_Word m_repeat; /* repeat count */ 592 Elf64_Word m_stride; /* stride info */ 593 } Elf64_Move; 594 595 #define ELF64_M_SYM(info) ((info) >> 8) 596 #define ELF64_M_SIZE(info) ((info) & 0xff) 597 #define ELF64_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) 598 599 /* 600 * Hardware/software capabilities entry 601 */ 602 typedef struct { 603 Elf32_Word c_tag; /* entry tag value */ 604 union { 605 Elf32_Addr c_ptr; 606 Elf32_Word c_val; 607 } c_un; 608 } Elf32_Cap; 609 610 typedef struct { 611 Elf64_Xword c_tag; /* entry tag value */ 612 union { 613 Elf64_Addr c_ptr; 614 Elf64_Xword c_val; 615 } c_un; 616 } Elf64_Cap; 617 618 /* 619 * Dynamic Section structure array 620 */ 621 typedef struct { 622 Elf32_Word d_tag; /* entry tag value */ 623 union { 624 Elf32_Addr d_ptr; 625 Elf32_Word d_val; 626 } d_un; 627 } Elf32_Dyn; 628 629 typedef struct { 630 Elf64_Xword d_tag; /* entry tag value */ 631 union { 632 Elf64_Addr d_ptr; 633 Elf64_Xword d_val; 634 } d_un; 635 } Elf64_Dyn; 636 637 /* d_tag */ 638 #define DT_NULL 0 /* Marks end of dynamic array */ 639 #define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */ 640 #define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */ 641 #define DT_PLTGOT 3 /* Address of PLT and/or GOT */ 642 #define DT_HASH 4 /* Address of symbol hash table */ 643 #define DT_STRTAB 5 /* Address of string table */ 644 #define DT_SYMTAB 6 /* Address of symbol table */ 645 #define DT_RELA 7 /* Address of Rela relocation table */ 646 #define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */ 647 #define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */ 648 #define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */ 649 #define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */ 650 #define DT_INIT 12 /* Address of initialization function */ 651 #define DT_FINI 13 /* Address of termination function */ 652 #define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */ 653 #define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */ 654 #define DT_SYMBOLIC 16 /* Start symbol search within local object */ 655 #define DT_REL 17 /* Address of Rel relocation table */ 656 #define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */ 657 #define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */ 658 #define DT_PLTREL 20 /* Type of PLT relocation entries */ 659 #define DT_DEBUG 21 /* Used for debugging; unspecified */ 660 #define DT_TEXTREL 22 /* Relocations might modify non-writable seg */ 661 #define DT_JMPREL 23 /* Address of relocations associated with PLT */ 662 #define DT_BIND_NOW 24 /* Process all relocations at load-time */ 663 #define DT_INIT_ARRAY 25 /* Address of initialization function array */ 664 #define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */ 665 #define DT_INIT_ARRAYSZ 27 /* Address of termination function array */ 666 #define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/ 667 #define DT_NUM 29 668 669 #define DT_LOOS 0x60000000 /* Operating system specific range */ 670 #define DT_VERSYM 0x6ffffff0 /* Symbol versions */ 671 #define DT_FLAGS_1 0x6ffffffb /* ELF dynamic flags */ 672 #define DT_VERDEF 0x6ffffffc /* Versions defined by file */ 673 #define DT_VERDEFNUM 0x6ffffffd /* Number of versions defined by file */ 674 #define DT_VERNEED 0x6ffffffe /* Versions needed by file */ 675 #define DT_VERNEEDNUM 0x6fffffff /* Number of versions needed by file */ 676 #define DT_HIOS 0x6fffffff 677 #define DT_LOPROC 0x70000000 /* Processor-specific range */ 678 #define DT_HIPROC 0x7fffffff 679 680 /* Flag values for DT_FLAGS_1 (incomplete) */ 681 #define DF_1_BIND_NOW 0x00000001 /* Same as DF_BIND_NOW */ 682 #define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */ 683 #define DF_1_INITFIRST 0x00000020 /* Object's init/fini take priority */ 684 #define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */ 685 686 /* 687 * Auxiliary Vectors 688 */ 689 typedef struct { 690 Elf32_Word a_type; /* 32-bit id */ 691 Elf32_Word a_v; /* 32-bit id */ 692 } Aux32Info; 693 694 typedef struct { 695 Elf64_Word a_type; /* 32-bit id */ 696 Elf64_Xword a_v; /* 64-bit id */ 697 } Aux64Info; 698 699 /* a_type */ 700 #define AT_NULL 0 /* Marks end of array */ 701 #define AT_IGNORE 1 /* No meaning, a_un is undefined */ 702 #define AT_EXECFD 2 /* Open file descriptor of object file */ 703 #define AT_PHDR 3 /* &phdr[0] */ 704 #define AT_PHENT 4 /* sizeof(phdr[0]) */ 705 #define AT_PHNUM 5 /* # phdr entries */ 706 #define AT_PAGESZ 6 /* PAGESIZE */ 707 #define AT_BASE 7 /* Interpreter base addr */ 708 #define AT_FLAGS 8 /* Processor flags */ 709 #define AT_ENTRY 9 /* Entry address of executable */ 710 #define AT_DCACHEBSIZE 10 /* Data cache block size */ 711 #define AT_ICACHEBSIZE 11 /* Instruction cache block size */ 712 #define AT_UCACHEBSIZE 12 /* Unified cache block size */ 713 #define AT_STACKBASE 13 /* Base address of the main thread */ 714 715 /* Vendor specific */ 716 #define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */ 717 718 #define AT_EUID 2000 /* euid (solaris compatible numbers) */ 719 #define AT_RUID 2001 /* ruid (solaris compatible numbers) */ 720 #define AT_EGID 2002 /* egid (solaris compatible numbers) */ 721 #define AT_RGID 2003 /* rgid (solaris compatible numbers) */ 722 723 /* Solaris kernel specific */ 724 #define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */ 725 #define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */ 726 #define AT_SUN_LDNAME 2006 /* dynamic linker's name */ 727 #define AT_SUN_LPGSIZE 2007 /* large pagesize */ 728 729 /* Other information */ 730 #define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */ 731 #define AT_SUN_HWCAP 2009 /* process hardware capabilities */ 732 #define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */ 733 #define AT_SUN_CPU 2011 /* CPU name */ 734 /* ibcs2 emulation band aid */ 735 #define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */ 736 #define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */ 737 /* Executable's fully resolved name */ 738 #define AT_SUN_EXECNAME 2014 739 740 /* 741 * Note Headers 742 */ 743 typedef struct { 744 Elf32_Word n_namesz; 745 Elf32_Word n_descsz; 746 Elf32_Word n_type; 747 } Elf32_Nhdr; 748 749 typedef struct { 750 Elf64_Word n_namesz; 751 Elf64_Word n_descsz; 752 Elf64_Word n_type; 753 } Elf64_Nhdr; 754 755 #define ELF_NOTE_GNU_NAMESZ 4 756 #define ELF_NOTE_GNU_NAME "GNU\0" 757 758 /* 759 * GNU-specific note type: ABI tag 760 * name: GNU\0 761 * namesz: 4 762 * desc: 763 * word[0]: OS tag 764 * word[1]: major version 765 * word[2]: minor version 766 * word[3]: teeny version 767 * descsz: 16 768 */ 769 /* GNU-specific note name and description sizes */ 770 #define ELF_NOTE_TYPE_ABI_TAG 1 771 #define ELF_NOTE_ABI_NAME ELF_NOTE_GNU_NAME 772 #define ELF_NOTE_ABI_NAMESZ ELF_NOTE_GNU_NAMESZ 773 #define ELF_NOTE_ABI_DESCSZ 16 774 /* GNU-specific OS/version value stuff */ 775 #define ELF_NOTE_ABI_OS_LINUX 0 776 #define ELF_NOTE_ABI_OS_HURD 1 777 #define ELF_NOTE_ABI_OS_SOLARIS 2 778 #define ELF_NOTE_ABI_OS_KFREEBSD 3 779 #define ELF_NOTE_ABI_OS_KNETBSD 4 780 781 /* 782 * GNU-specific note type: Hardware capabilities 783 * name: GNU\0 784 * namesz: 4 785 * desc: 786 * word[0]: Number of entries 787 * word[1]: Bitmask of enabled entries 788 * Followed by a byte id, and a NUL terminated string per entry 789 * descsz: variable 790 */ 791 #define ELF_NOTE_TYPE_GNU_HWCAP 2 792 793 /* 794 * GNU-specific note type: Build ID generated by ld 795 * name: GNU\0 796 * desc: 797 * word[0..4] SHA1 [default] 798 * or 799 * word[0..3] md5 or uuid 800 * descsz: 16 or 20 801 */ 802 #define ELF_NOTE_TYPE_GNU_BUILD_ID 3 803 804 /* SuSE-specific note type: ABI 805 * name: SuSE\0 806 * namesz: 5 807 * desc: 808 * half[0] = MMmm 809 * 810 * M = product major version 811 * m = product minor version 812 * descsz: 2 813 */ 814 #define ELF_NOTE_TYPE_SUSE_TAG 1 815 /* SuSE-specific note name and description sizes */ 816 #define ELF_NOTE_SUSE_NAMESZ 5 817 #define ELF_NOTE_SUSE_DESCSZ 2 818 /* SuSE-specific note name */ 819 #define ELF_NOTE_SUSE_NAME "SuSE\0" 820 821 /* SuSE-specific note type: version 822 * name: SuSE\0\0\0\0 823 * namesz: 8 824 * desc: 825 * word[0] = VVTTMMmm 826 * 827 * V = version of following data 828 * T = product type: [box, sles, nld, whatever] 829 * M = product major version 830 * m = product minor version 831 * descsz: 8 832 */ 833 #define ELF_NOTE_TYPE_SUSE_VERSION_TAG 0x45537553 /* SuSE in LE */ 834 /* SuSE-specific note name and description sizes */ 835 #define ELF_NOTE_SUSE_VERSION_NAMESZ 8 836 #define ELF_NOTE_SUSE_VERSION_DESCSZ 8 837 /* SuSE-specific note name */ 838 #define ELF_NOTE_SUSE_VERSION_NAME "SuSE\0\0\0\0" 839 840 /* NetBSD-specific note type: Emulation name. 841 * name: NetBSD\0\0 842 * namesz: 8 843 * desc: 844 * word[0]: MMmmrrpp00 845 * 846 * M = major version 847 * m = minor version 848 * r = release ["",A-Z,Z[A-Z] but numeric] 849 * p = patchlevel 850 * descsz: 4 851 */ 852 #define ELF_NOTE_TYPE_NETBSD_TAG 1 853 /* NetBSD-specific note name and description sizes */ 854 #define ELF_NOTE_NETBSD_NAMESZ 7 855 #define ELF_NOTE_NETBSD_DESCSZ 4 856 /* NetBSD-specific note name */ 857 #define ELF_NOTE_NETBSD_NAME "NetBSD\0\0" 858 859 /* NetBSD-specific note type: Checksum. 860 * There should be 1 NOTE per PT_LOAD section. 861 * name: ??? 862 * namesz: ??? 863 * desc: 864 * a tuple of <phnum>(16),<chk-type>(16),<chk-value>. 865 * descsz: ??? 866 */ 867 #define ELF_NOTE_TYPE_CHECKSUM_TAG 2 868 #define ELF_NOTE_CHECKSUM_CRC32 1 869 #define ELF_NOTE_CHECKSUM_MD5 2 870 #define ELF_NOTE_CHECKSUM_SHA1 3 871 #define ELF_NOTE_CHECKSUM_SHA256 4 872 873 /* 874 * NetBSD-specific note type: PaX. 875 * There should be 1 NOTE per executable. 876 * name: PaX\0 877 * namesz: 4 878 * desc: 879 * word[0]: capability bitmask 880 * descsz: 4 881 */ 882 #define ELF_NOTE_TYPE_PAX_TAG 3 883 #define ELF_NOTE_PAX_MPROTECT 0x01 /* Force enable Mprotect */ 884 #define ELF_NOTE_PAX_NOMPROTECT 0x02 /* Force disable Mprotect */ 885 #define ELF_NOTE_PAX_GUARD 0x04 /* Force enable Segvguard */ 886 #define ELF_NOTE_PAX_NOGUARD 0x08 /* Force disable Servguard */ 887 #define ELF_NOTE_PAX_ASLR 0x10 /* Force enable ASLR */ 888 #define ELF_NOTE_PAX_NOASLR 0x20 /* Force disable ASLR */ 889 #define ELF_NOTE_PAX_NAMESZ 4 890 #define ELF_NOTE_PAX_NAME "PaX\0" 891 #define ELF_NOTE_PAX_DESCSZ 4 892 893 /* 894 * NetBSD-specific core file information. 895 * 896 * NetBSD ELF core files use notes to provide information about 897 * the process's state. The note name is "NetBSD-CORE" for 898 * information that is global to the process, and "NetBSD-CORE@nn", 899 * where "nn" is the lwpid of the LWP that the information belongs 900 * to (such as register state). 901 * 902 * We use the following note identifiers: 903 * 904 * ELF_NOTE_NETBSD_CORE_PROCINFO 905 * Note is a "netbsd_elfcore_procinfo" structure. 906 * 907 * We also use ptrace(2) request numbers (the ones that exist in 908 * machine-dependent space) to identify register info notes. The 909 * info in such notes is in the same format that ptrace(2) would 910 * export that information. 911 * 912 * Please try to keep the members of this structure nicely aligned, 913 * and if you add elements, add them to the end and bump the version. 914 */ 915 916 #define ELF_NOTE_NETBSD_CORE_NAME "NetBSD-CORE" 917 918 #define ELF_NOTE_NETBSD_CORE_PROCINFO 1 919 920 #define NETBSD_ELFCORE_PROCINFO_VERSION 1 921 922 struct netbsd_elfcore_procinfo { 923 /* Version 1 fields start here. */ 924 uint32_t cpi_version; /* our version */ 925 uint32_t cpi_cpisize; /* sizeof(this struct) */ 926 uint32_t cpi_signo; /* killing signal */ 927 uint32_t cpi_sigcode; /* signal code */ 928 uint32_t cpi_sigpend[4]; /* pending signals */ 929 uint32_t cpi_sigmask[4]; /* blocked signals */ 930 uint32_t cpi_sigignore[4]; /* ignored signals */ 931 uint32_t cpi_sigcatch[4]; /* caught signals */ 932 int32_t cpi_pid; /* process ID */ 933 int32_t cpi_ppid; /* parent process ID */ 934 int32_t cpi_pgrp; /* process group ID */ 935 int32_t cpi_sid; /* session ID */ 936 uint32_t cpi_ruid; /* real user ID */ 937 uint32_t cpi_euid; /* effective user ID */ 938 uint32_t cpi_svuid; /* saved user ID */ 939 uint32_t cpi_rgid; /* real group ID */ 940 uint32_t cpi_egid; /* effective group ID */ 941 uint32_t cpi_svgid; /* saved group ID */ 942 uint32_t cpi_nlwps; /* number of LWPs */ 943 int8_t cpi_name[32]; /* copy of p->p_comm */ 944 /* Add version 2 fields below here. */ 945 int32_t cpi_siglwp; /* LWP target of killing signal */ 946 }; 947 948 #if !defined(ELFSIZE) && defined(ARCH_ELFSIZE) 949 #define ELFSIZE ARCH_ELFSIZE 950 #endif 951 952 #if defined(ELFSIZE) 953 #define CONCAT(x,y) __CONCAT(x,y) 954 #define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x))) 955 #define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y)))) 956 #define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE)) 957 #define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x))) 958 #endif 959 960 #if defined(ELFSIZE) && (ELFSIZE == 32) 961 #define Elf_Ehdr Elf32_Ehdr 962 #define Elf_Phdr Elf32_Phdr 963 #define Elf_Shdr Elf32_Shdr 964 #define Elf_Sym Elf32_Sym 965 #define Elf_Rel Elf32_Rel 966 #define Elf_Rela Elf32_Rela 967 #define Elf_Dyn Elf32_Dyn 968 #define Elf_Word Elf32_Word 969 #define Elf_Sword Elf32_Sword 970 #define Elf_Half Elf32_Half 971 #define Elf_Addr Elf32_Addr 972 #define Elf_Off Elf32_Off 973 #define Elf_SOff Elf32_SOff 974 #define Elf_Nhdr Elf32_Nhdr 975 #define Elf_Verdef Elf32_Verdef 976 #define Elf_Verdaux Elf32_Verdaux 977 #define Elf_Verneed Elf32_Verneed 978 #define Elf_Vernaux Elf32_Vernaux 979 #define Elf_Versym Elf32_Versym 980 981 #define ELF_R_SYM ELF32_R_SYM 982 #define ELF_R_TYPE ELF32_R_TYPE 983 #define ELFCLASS ELFCLASS32 984 985 #define AuxInfo Aux32Info 986 #elif defined(ELFSIZE) && (ELFSIZE == 64) 987 #define Elf_Ehdr Elf64_Ehdr 988 #define Elf_Phdr Elf64_Phdr 989 #define Elf_Shdr Elf64_Shdr 990 #define Elf_Sym Elf64_Sym 991 #define Elf_Rel Elf64_Rel 992 #define Elf_Rela Elf64_Rela 993 #define Elf_Dyn Elf64_Dyn 994 #define Elf_Word Elf64_Word 995 #define Elf_Sword Elf64_Sword 996 #define Elf_Half Elf64_Half 997 #define Elf_Addr Elf64_Addr 998 #define Elf_Off Elf64_Off 999 #define Elf_SOff Elf64_SOff 1000 #define Elf_Nhdr Elf64_Nhdr 1001 #define Elf_Verdef Elf64_Verdef 1002 #define Elf_Verdaux Elf64_Verdaux 1003 #define Elf_Verneed Elf64_Verneed 1004 #define Elf_Vernaux Elf64_Vernaux 1005 #define Elf_Versym Elf64_Versym 1006 1007 #define ELF_R_SYM ELF64_R_SYM 1008 #define ELF_R_TYPE ELF64_R_TYPE 1009 #define ELFCLASS ELFCLASS64 1010 1011 #define AuxInfo Aux64Info 1012 #endif 1013 1014 #ifndef Elf_Symindx 1015 #define Elf_Symindx uint32_t 1016 #endif 1017 1018 #define ELF32_ST_BIND(info) ELF_ST_BIND(info) 1019 #define ELF32_ST_TYPE(info) ELF_ST_TYPE(info) 1020 #define ELF32_ST_INFO(bind,type) ELF_ST_INFO(bind,type) 1021 #define ELF32_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) 1022 1023 #define ELF64_ST_BIND(info) ELF_ST_BIND(info) 1024 #define ELF64_ST_TYPE(info) ELF_ST_TYPE(info) 1025 #define ELF64_ST_INFO(bind,type) ELF_ST_INFO(bind,type) 1026 #define ELF64_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) 1027 1028 typedef struct { 1029 Elf32_Half si_boundto; /* direct bindings - symbol bound to */ 1030 Elf32_Half si_flags; /* per symbol flags */ 1031 } Elf32_Syminfo; 1032 1033 typedef struct { 1034 Elf64_Word si_boundto; /* direct bindings - symbol bound to */ 1035 Elf64_Word si_flags; /* per symbol flags */ 1036 } Elf64_Syminfo; 1037 1038 #define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association 1039 to object containing definition */ 1040 #define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */ 1041 #define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ 1042 #define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be 1043 lazily-loaded */ 1044 #define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to 1045 object containing definition */ 1046 #define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference 1047 directly bind to this symbol */ 1048 #define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ 1049 #define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */ 1050 1051 #define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ 1052 #define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ 1053 #define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ 1054 #define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ 1055 #define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ 1056 1057 #define SYMINFO_NONE 0 /* Syminfo version */ 1058 #define SYMINFO_CURRENT 1 1059 #define SYMINFO_NUM 2 1060 1061 /* 1062 * These constants are used for Elf32_Verdef struct's version number. 1063 */ 1064 #define VER_DEF_NONE 0 1065 #define VER_DEF_CURRENT 1 1066 1067 /* 1068 * These constants are used for Elf32_Verdef struct's vd_ndx. 1069 */ 1070 #define VER_DEF_IDX(x) VER_NDX(x) 1071 1072 /* 1073 * These constants are used for Elf32_Verdef struct's vd_flags. 1074 */ 1075 #define VER_FLG_BASE 0x1 1076 #define VER_FLG_WEAK 0x2 1077 1078 /* 1079 * These are used in an Elf32_Versym field. 1080 */ 1081 #define VER_NDX_LOCAL 0 1082 #define VER_NDX_GLOBAL 1 1083 #define VER_NDX_GIVEN 2 1084 1085 /* 1086 * These constants are used for Elf32_Verneed struct's version number. 1087 */ 1088 #define VER_NEED_NONE 0 1089 #define VER_NEED_CURRENT 1 1090 1091 /* 1092 * These constants are used for Elf32_Vernaux struct's vna_other. 1093 */ 1094 #define VER_NEED_HIDDEN VER_NDX_HIDDEN 1095 #define VER_NEED_IDX(x) VER_NDX(x) 1096 1097 /* index */ 1098 #define VER_NDX_HIDDEN 0x8000 1099 #define VER_NDX(x) ((x) & ~VER_NDX_HIDDEN) 1100 1101 /* 1102 * GNU Extension hidding symbol 1103 */ 1104 #define VERSYM_HIDDEN 0x8000 1105 #define VERSYM_VERSION 0x7fff 1106 1107 #define ELF_VER_CHR '@' 1108 1109 /* 1110 * These are current size independent. 1111 */ 1112 1113 typedef struct { 1114 Elf32_Half vd_version; /* version number of structure */ 1115 Elf32_Half vd_flags; /* flags (VER_FLG_*) */ 1116 Elf32_Half vd_ndx; /* version index */ 1117 Elf32_Half vd_cnt; /* number of verdaux entries */ 1118 Elf32_Word vd_hash; /* hash of name */ 1119 Elf32_Word vd_aux; /* offset to verdaux entries */ 1120 Elf32_Word vd_next; /* offset to next verdef */ 1121 } Elf32_Verdef; 1122 typedef Elf32_Verdef Elf64_Verdef; 1123 1124 typedef struct { 1125 Elf32_Word vda_name; /* string table offset of name */ 1126 Elf32_Word vda_next; /* offset to verdaux */ 1127 } Elf32_Verdaux; 1128 typedef Elf32_Verdaux Elf64_Verdaux; 1129 1130 typedef struct { 1131 Elf32_Half vn_version; /* version number of structure */ 1132 Elf32_Half vn_cnt; /* number of vernaux entries */ 1133 Elf32_Word vn_file; /* string table offset of library name*/ 1134 Elf32_Word vn_aux; /* offset to vernaux entries */ 1135 Elf32_Word vn_next; /* offset to next verneed */ 1136 } Elf32_Verneed; 1137 typedef Elf32_Verneed Elf64_Verneed; 1138 1139 typedef struct { 1140 Elf32_Word vna_hash; /* Hash of dependency name */ 1141 Elf32_Half vna_flags; /* flags (VER_FLG_*) */ 1142 Elf32_Half vna_other; /* unused */ 1143 Elf32_Word vna_name; /* string table offset to version name*/ 1144 Elf32_Word vna_next; /* offset to next vernaux */ 1145 } Elf32_Vernaux; 1146 typedef Elf32_Vernaux Elf64_Vernaux; 1147 1148 typedef struct { 1149 Elf32_Half vs_vers; 1150 } Elf32_Versym; 1151 typedef Elf32_Versym Elf64_Versym; 1152 1153 #endif /* !_STAND_E32BOOT_ELF_H_ */ 1154