github.com/FenixAra/go@v0.0.0-20170127160404-96ea0918e670/src/debug/elf/elf.go (about) 1 /* 2 * ELF constants and data structures 3 * 4 * Derived from: 5 * $FreeBSD: src/sys/sys/elf32.h,v 1.8.14.1 2005/12/30 22:13:58 marcel Exp $ 6 * $FreeBSD: src/sys/sys/elf64.h,v 1.10.14.1 2005/12/30 22:13:58 marcel Exp $ 7 * $FreeBSD: src/sys/sys/elf_common.h,v 1.15.8.1 2005/12/30 22:13:58 marcel Exp $ 8 * $FreeBSD: src/sys/alpha/include/elf.h,v 1.14 2003/09/25 01:10:22 peter Exp $ 9 * $FreeBSD: src/sys/amd64/include/elf.h,v 1.18 2004/08/03 08:21:48 dfr Exp $ 10 * $FreeBSD: src/sys/arm/include/elf.h,v 1.5.2.1 2006/06/30 21:42:52 cognet Exp $ 11 * $FreeBSD: src/sys/i386/include/elf.h,v 1.16 2004/08/02 19:12:17 dfr Exp $ 12 * $FreeBSD: src/sys/powerpc/include/elf.h,v 1.7 2004/11/02 09:47:01 ssouhlal Exp $ 13 * $FreeBSD: src/sys/sparc64/include/elf.h,v 1.12 2003/09/25 01:10:26 peter Exp $ 14 * "ELF for the ARMĀ® 64-bit Architecture (AArch64)" (ARM IHI 0056B) 15 * 16 * Copyright (c) 1996-1998 John D. Polstra. All rights reserved. 17 * Copyright (c) 2001 David E. O'Brien 18 * Portions Copyright 2009 The Go Authors. All rights reserved. 19 * 20 * Redistribution and use in source and binary forms, with or without 21 * modification, are permitted provided that the following conditions 22 * are met: 23 * 1. Redistributions of source code must retain the above copyright 24 * notice, this list of conditions and the following disclaimer. 25 * 2. Redistributions in binary form must reproduce the above copyright 26 * notice, this list of conditions and the following disclaimer in the 27 * documentation and/or other materials provided with the distribution. 28 * 29 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 */ 41 42 package elf 43 44 import "strconv" 45 46 /* 47 * Constants 48 */ 49 50 // Indexes into the Header.Ident array. 51 const ( 52 EI_CLASS = 4 /* Class of machine. */ 53 EI_DATA = 5 /* Data format. */ 54 EI_VERSION = 6 /* ELF format version. */ 55 EI_OSABI = 7 /* Operating system / ABI identification */ 56 EI_ABIVERSION = 8 /* ABI version */ 57 EI_PAD = 9 /* Start of padding (per SVR4 ABI). */ 58 EI_NIDENT = 16 /* Size of e_ident array. */ 59 ) 60 61 // Initial magic number for ELF files. 62 const ELFMAG = "\177ELF" 63 64 // Version is found in Header.Ident[EI_VERSION] and Header.Version. 65 type Version byte 66 67 const ( 68 EV_NONE Version = 0 69 EV_CURRENT Version = 1 70 ) 71 72 var versionStrings = []intName{ 73 {0, "EV_NONE"}, 74 {1, "EV_CURRENT"}, 75 } 76 77 func (i Version) String() string { return stringName(uint32(i), versionStrings, false) } 78 func (i Version) GoString() string { return stringName(uint32(i), versionStrings, true) } 79 80 // Class is found in Header.Ident[EI_CLASS] and Header.Class. 81 type Class byte 82 83 const ( 84 ELFCLASSNONE Class = 0 /* Unknown class. */ 85 ELFCLASS32 Class = 1 /* 32-bit architecture. */ 86 ELFCLASS64 Class = 2 /* 64-bit architecture. */ 87 ) 88 89 var classStrings = []intName{ 90 {0, "ELFCLASSNONE"}, 91 {1, "ELFCLASS32"}, 92 {2, "ELFCLASS64"}, 93 } 94 95 func (i Class) String() string { return stringName(uint32(i), classStrings, false) } 96 func (i Class) GoString() string { return stringName(uint32(i), classStrings, true) } 97 98 // Data is found in Header.Ident[EI_DATA] and Header.Data. 99 type Data byte 100 101 const ( 102 ELFDATANONE Data = 0 /* Unknown data format. */ 103 ELFDATA2LSB Data = 1 /* 2's complement little-endian. */ 104 ELFDATA2MSB Data = 2 /* 2's complement big-endian. */ 105 ) 106 107 var dataStrings = []intName{ 108 {0, "ELFDATANONE"}, 109 {1, "ELFDATA2LSB"}, 110 {2, "ELFDATA2MSB"}, 111 } 112 113 func (i Data) String() string { return stringName(uint32(i), dataStrings, false) } 114 func (i Data) GoString() string { return stringName(uint32(i), dataStrings, true) } 115 116 // OSABI is found in Header.Ident[EI_OSABI] and Header.OSABI. 117 type OSABI byte 118 119 const ( 120 ELFOSABI_NONE OSABI = 0 /* UNIX System V ABI */ 121 ELFOSABI_HPUX OSABI = 1 /* HP-UX operating system */ 122 ELFOSABI_NETBSD OSABI = 2 /* NetBSD */ 123 ELFOSABI_LINUX OSABI = 3 /* GNU/Linux */ 124 ELFOSABI_HURD OSABI = 4 /* GNU/Hurd */ 125 ELFOSABI_86OPEN OSABI = 5 /* 86Open common IA32 ABI */ 126 ELFOSABI_SOLARIS OSABI = 6 /* Solaris */ 127 ELFOSABI_AIX OSABI = 7 /* AIX */ 128 ELFOSABI_IRIX OSABI = 8 /* IRIX */ 129 ELFOSABI_FREEBSD OSABI = 9 /* FreeBSD */ 130 ELFOSABI_TRU64 OSABI = 10 /* TRU64 UNIX */ 131 ELFOSABI_MODESTO OSABI = 11 /* Novell Modesto */ 132 ELFOSABI_OPENBSD OSABI = 12 /* OpenBSD */ 133 ELFOSABI_OPENVMS OSABI = 13 /* Open VMS */ 134 ELFOSABI_NSK OSABI = 14 /* HP Non-Stop Kernel */ 135 ELFOSABI_ARM OSABI = 97 /* ARM */ 136 ELFOSABI_STANDALONE OSABI = 255 /* Standalone (embedded) application */ 137 ) 138 139 var osabiStrings = []intName{ 140 {0, "ELFOSABI_NONE"}, 141 {1, "ELFOSABI_HPUX"}, 142 {2, "ELFOSABI_NETBSD"}, 143 {3, "ELFOSABI_LINUX"}, 144 {4, "ELFOSABI_HURD"}, 145 {5, "ELFOSABI_86OPEN"}, 146 {6, "ELFOSABI_SOLARIS"}, 147 {7, "ELFOSABI_AIX"}, 148 {8, "ELFOSABI_IRIX"}, 149 {9, "ELFOSABI_FREEBSD"}, 150 {10, "ELFOSABI_TRU64"}, 151 {11, "ELFOSABI_MODESTO"}, 152 {12, "ELFOSABI_OPENBSD"}, 153 {13, "ELFOSABI_OPENVMS"}, 154 {14, "ELFOSABI_NSK"}, 155 {97, "ELFOSABI_ARM"}, 156 {255, "ELFOSABI_STANDALONE"}, 157 } 158 159 func (i OSABI) String() string { return stringName(uint32(i), osabiStrings, false) } 160 func (i OSABI) GoString() string { return stringName(uint32(i), osabiStrings, true) } 161 162 // Type is found in Header.Type. 163 type Type uint16 164 165 const ( 166 ET_NONE Type = 0 /* Unknown type. */ 167 ET_REL Type = 1 /* Relocatable. */ 168 ET_EXEC Type = 2 /* Executable. */ 169 ET_DYN Type = 3 /* Shared object. */ 170 ET_CORE Type = 4 /* Core file. */ 171 ET_LOOS Type = 0xfe00 /* First operating system specific. */ 172 ET_HIOS Type = 0xfeff /* Last operating system-specific. */ 173 ET_LOPROC Type = 0xff00 /* First processor-specific. */ 174 ET_HIPROC Type = 0xffff /* Last processor-specific. */ 175 ) 176 177 var typeStrings = []intName{ 178 {0, "ET_NONE"}, 179 {1, "ET_REL"}, 180 {2, "ET_EXEC"}, 181 {3, "ET_DYN"}, 182 {4, "ET_CORE"}, 183 {0xfe00, "ET_LOOS"}, 184 {0xfeff, "ET_HIOS"}, 185 {0xff00, "ET_LOPROC"}, 186 {0xffff, "ET_HIPROC"}, 187 } 188 189 func (i Type) String() string { return stringName(uint32(i), typeStrings, false) } 190 func (i Type) GoString() string { return stringName(uint32(i), typeStrings, true) } 191 192 // Machine is found in Header.Machine. 193 type Machine uint16 194 195 const ( 196 EM_NONE Machine = 0 /* Unknown machine. */ 197 EM_M32 Machine = 1 /* AT&T WE32100. */ 198 EM_SPARC Machine = 2 /* Sun SPARC. */ 199 EM_386 Machine = 3 /* Intel i386. */ 200 EM_68K Machine = 4 /* Motorola 68000. */ 201 EM_88K Machine = 5 /* Motorola 88000. */ 202 EM_860 Machine = 7 /* Intel i860. */ 203 EM_MIPS Machine = 8 /* MIPS R3000 Big-Endian only. */ 204 EM_S370 Machine = 9 /* IBM System/370. */ 205 EM_MIPS_RS3_LE Machine = 10 /* MIPS R3000 Little-Endian. */ 206 EM_PARISC Machine = 15 /* HP PA-RISC. */ 207 EM_VPP500 Machine = 17 /* Fujitsu VPP500. */ 208 EM_SPARC32PLUS Machine = 18 /* SPARC v8plus. */ 209 EM_960 Machine = 19 /* Intel 80960. */ 210 EM_PPC Machine = 20 /* PowerPC 32-bit. */ 211 EM_PPC64 Machine = 21 /* PowerPC 64-bit. */ 212 EM_S390 Machine = 22 /* IBM System/390. */ 213 EM_V800 Machine = 36 /* NEC V800. */ 214 EM_FR20 Machine = 37 /* Fujitsu FR20. */ 215 EM_RH32 Machine = 38 /* TRW RH-32. */ 216 EM_RCE Machine = 39 /* Motorola RCE. */ 217 EM_ARM Machine = 40 /* ARM. */ 218 EM_SH Machine = 42 /* Hitachi SH. */ 219 EM_SPARCV9 Machine = 43 /* SPARC v9 64-bit. */ 220 EM_TRICORE Machine = 44 /* Siemens TriCore embedded processor. */ 221 EM_ARC Machine = 45 /* Argonaut RISC Core. */ 222 EM_H8_300 Machine = 46 /* Hitachi H8/300. */ 223 EM_H8_300H Machine = 47 /* Hitachi H8/300H. */ 224 EM_H8S Machine = 48 /* Hitachi H8S. */ 225 EM_H8_500 Machine = 49 /* Hitachi H8/500. */ 226 EM_IA_64 Machine = 50 /* Intel IA-64 Processor. */ 227 EM_MIPS_X Machine = 51 /* Stanford MIPS-X. */ 228 EM_COLDFIRE Machine = 52 /* Motorola ColdFire. */ 229 EM_68HC12 Machine = 53 /* Motorola M68HC12. */ 230 EM_MMA Machine = 54 /* Fujitsu MMA. */ 231 EM_PCP Machine = 55 /* Siemens PCP. */ 232 EM_NCPU Machine = 56 /* Sony nCPU. */ 233 EM_NDR1 Machine = 57 /* Denso NDR1 microprocessor. */ 234 EM_STARCORE Machine = 58 /* Motorola Star*Core processor. */ 235 EM_ME16 Machine = 59 /* Toyota ME16 processor. */ 236 EM_ST100 Machine = 60 /* STMicroelectronics ST100 processor. */ 237 EM_TINYJ Machine = 61 /* Advanced Logic Corp. TinyJ processor. */ 238 EM_X86_64 Machine = 62 /* Advanced Micro Devices x86-64 */ 239 EM_AARCH64 Machine = 183 /* ARM 64-bit Architecture (AArch64) */ 240 241 /* Non-standard or deprecated. */ 242 EM_486 Machine = 6 /* Intel i486. */ 243 EM_MIPS_RS4_BE Machine = 10 /* MIPS R4000 Big-Endian */ 244 EM_ALPHA_STD Machine = 41 /* Digital Alpha (standard value). */ 245 EM_ALPHA Machine = 0x9026 /* Alpha (written in the absence of an ABI) */ 246 ) 247 248 var machineStrings = []intName{ 249 {0, "EM_NONE"}, 250 {1, "EM_M32"}, 251 {2, "EM_SPARC"}, 252 {3, "EM_386"}, 253 {4, "EM_68K"}, 254 {5, "EM_88K"}, 255 {7, "EM_860"}, 256 {8, "EM_MIPS"}, 257 {9, "EM_S370"}, 258 {10, "EM_MIPS_RS3_LE"}, 259 {15, "EM_PARISC"}, 260 {17, "EM_VPP500"}, 261 {18, "EM_SPARC32PLUS"}, 262 {19, "EM_960"}, 263 {20, "EM_PPC"}, 264 {21, "EM_PPC64"}, 265 {22, "EM_S390"}, 266 {36, "EM_V800"}, 267 {37, "EM_FR20"}, 268 {38, "EM_RH32"}, 269 {39, "EM_RCE"}, 270 {40, "EM_ARM"}, 271 {42, "EM_SH"}, 272 {43, "EM_SPARCV9"}, 273 {44, "EM_TRICORE"}, 274 {45, "EM_ARC"}, 275 {46, "EM_H8_300"}, 276 {47, "EM_H8_300H"}, 277 {48, "EM_H8S"}, 278 {49, "EM_H8_500"}, 279 {50, "EM_IA_64"}, 280 {51, "EM_MIPS_X"}, 281 {52, "EM_COLDFIRE"}, 282 {53, "EM_68HC12"}, 283 {54, "EM_MMA"}, 284 {55, "EM_PCP"}, 285 {56, "EM_NCPU"}, 286 {57, "EM_NDR1"}, 287 {58, "EM_STARCORE"}, 288 {59, "EM_ME16"}, 289 {60, "EM_ST100"}, 290 {61, "EM_TINYJ"}, 291 {62, "EM_X86_64"}, 292 293 /* Non-standard or deprecated. */ 294 {6, "EM_486"}, 295 {10, "EM_MIPS_RS4_BE"}, 296 {41, "EM_ALPHA_STD"}, 297 {0x9026, "EM_ALPHA"}, 298 } 299 300 func (i Machine) String() string { return stringName(uint32(i), machineStrings, false) } 301 func (i Machine) GoString() string { return stringName(uint32(i), machineStrings, true) } 302 303 // Special section indices. 304 type SectionIndex int 305 306 const ( 307 SHN_UNDEF SectionIndex = 0 /* Undefined, missing, irrelevant. */ 308 SHN_LORESERVE SectionIndex = 0xff00 /* First of reserved range. */ 309 SHN_LOPROC SectionIndex = 0xff00 /* First processor-specific. */ 310 SHN_HIPROC SectionIndex = 0xff1f /* Last processor-specific. */ 311 SHN_LOOS SectionIndex = 0xff20 /* First operating system-specific. */ 312 SHN_HIOS SectionIndex = 0xff3f /* Last operating system-specific. */ 313 SHN_ABS SectionIndex = 0xfff1 /* Absolute values. */ 314 SHN_COMMON SectionIndex = 0xfff2 /* Common data. */ 315 SHN_XINDEX SectionIndex = 0xffff /* Escape; index stored elsewhere. */ 316 SHN_HIRESERVE SectionIndex = 0xffff /* Last of reserved range. */ 317 ) 318 319 var shnStrings = []intName{ 320 {0, "SHN_UNDEF"}, 321 {0xff00, "SHN_LOPROC"}, 322 {0xff20, "SHN_LOOS"}, 323 {0xfff1, "SHN_ABS"}, 324 {0xfff2, "SHN_COMMON"}, 325 {0xffff, "SHN_XINDEX"}, 326 } 327 328 func (i SectionIndex) String() string { return stringName(uint32(i), shnStrings, false) } 329 func (i SectionIndex) GoString() string { return stringName(uint32(i), shnStrings, true) } 330 331 // Section type. 332 type SectionType uint32 333 334 const ( 335 SHT_NULL SectionType = 0 /* inactive */ 336 SHT_PROGBITS SectionType = 1 /* program defined information */ 337 SHT_SYMTAB SectionType = 2 /* symbol table section */ 338 SHT_STRTAB SectionType = 3 /* string table section */ 339 SHT_RELA SectionType = 4 /* relocation section with addends */ 340 SHT_HASH SectionType = 5 /* symbol hash table section */ 341 SHT_DYNAMIC SectionType = 6 /* dynamic section */ 342 SHT_NOTE SectionType = 7 /* note section */ 343 SHT_NOBITS SectionType = 8 /* no space section */ 344 SHT_REL SectionType = 9 /* relocation section - no addends */ 345 SHT_SHLIB SectionType = 10 /* reserved - purpose unknown */ 346 SHT_DYNSYM SectionType = 11 /* dynamic symbol table section */ 347 SHT_INIT_ARRAY SectionType = 14 /* Initialization function pointers. */ 348 SHT_FINI_ARRAY SectionType = 15 /* Termination function pointers. */ 349 SHT_PREINIT_ARRAY SectionType = 16 /* Pre-initialization function ptrs. */ 350 SHT_GROUP SectionType = 17 /* Section group. */ 351 SHT_SYMTAB_SHNDX SectionType = 18 /* Section indexes (see SHN_XINDEX). */ 352 SHT_LOOS SectionType = 0x60000000 /* First of OS specific semantics */ 353 SHT_GNU_ATTRIBUTES SectionType = 0x6ffffff5 /* GNU object attributes */ 354 SHT_GNU_HASH SectionType = 0x6ffffff6 /* GNU hash table */ 355 SHT_GNU_LIBLIST SectionType = 0x6ffffff7 /* GNU prelink library list */ 356 SHT_GNU_VERDEF SectionType = 0x6ffffffd /* GNU version definition section */ 357 SHT_GNU_VERNEED SectionType = 0x6ffffffe /* GNU version needs section */ 358 SHT_GNU_VERSYM SectionType = 0x6fffffff /* GNU version symbol table */ 359 SHT_HIOS SectionType = 0x6fffffff /* Last of OS specific semantics */ 360 SHT_LOPROC SectionType = 0x70000000 /* reserved range for processor */ 361 SHT_HIPROC SectionType = 0x7fffffff /* specific section header types */ 362 SHT_LOUSER SectionType = 0x80000000 /* reserved range for application */ 363 SHT_HIUSER SectionType = 0xffffffff /* specific indexes */ 364 ) 365 366 var shtStrings = []intName{ 367 {0, "SHT_NULL"}, 368 {1, "SHT_PROGBITS"}, 369 {2, "SHT_SYMTAB"}, 370 {3, "SHT_STRTAB"}, 371 {4, "SHT_RELA"}, 372 {5, "SHT_HASH"}, 373 {6, "SHT_DYNAMIC"}, 374 {7, "SHT_NOTE"}, 375 {8, "SHT_NOBITS"}, 376 {9, "SHT_REL"}, 377 {10, "SHT_SHLIB"}, 378 {11, "SHT_DYNSYM"}, 379 {14, "SHT_INIT_ARRAY"}, 380 {15, "SHT_FINI_ARRAY"}, 381 {16, "SHT_PREINIT_ARRAY"}, 382 {17, "SHT_GROUP"}, 383 {18, "SHT_SYMTAB_SHNDX"}, 384 {0x60000000, "SHT_LOOS"}, 385 {0x6ffffff5, "SHT_GNU_ATTRIBUTES"}, 386 {0x6ffffff6, "SHT_GNU_HASH"}, 387 {0x6ffffff7, "SHT_GNU_LIBLIST"}, 388 {0x6ffffffd, "SHT_GNU_VERDEF"}, 389 {0x6ffffffe, "SHT_GNU_VERNEED"}, 390 {0x6fffffff, "SHT_GNU_VERSYM"}, 391 {0x70000000, "SHT_LOPROC"}, 392 {0x7fffffff, "SHT_HIPROC"}, 393 {0x80000000, "SHT_LOUSER"}, 394 {0xffffffff, "SHT_HIUSER"}, 395 } 396 397 func (i SectionType) String() string { return stringName(uint32(i), shtStrings, false) } 398 func (i SectionType) GoString() string { return stringName(uint32(i), shtStrings, true) } 399 400 // Section flags. 401 type SectionFlag uint32 402 403 const ( 404 SHF_WRITE SectionFlag = 0x1 /* Section contains writable data. */ 405 SHF_ALLOC SectionFlag = 0x2 /* Section occupies memory. */ 406 SHF_EXECINSTR SectionFlag = 0x4 /* Section contains instructions. */ 407 SHF_MERGE SectionFlag = 0x10 /* Section may be merged. */ 408 SHF_STRINGS SectionFlag = 0x20 /* Section contains strings. */ 409 SHF_INFO_LINK SectionFlag = 0x40 /* sh_info holds section index. */ 410 SHF_LINK_ORDER SectionFlag = 0x80 /* Special ordering requirements. */ 411 SHF_OS_NONCONFORMING SectionFlag = 0x100 /* OS-specific processing required. */ 412 SHF_GROUP SectionFlag = 0x200 /* Member of section group. */ 413 SHF_TLS SectionFlag = 0x400 /* Section contains TLS data. */ 414 SHF_COMPRESSED SectionFlag = 0x800 /* Section is compressed. */ 415 SHF_MASKOS SectionFlag = 0x0ff00000 /* OS-specific semantics. */ 416 SHF_MASKPROC SectionFlag = 0xf0000000 /* Processor-specific semantics. */ 417 ) 418 419 var shfStrings = []intName{ 420 {0x1, "SHF_WRITE"}, 421 {0x2, "SHF_ALLOC"}, 422 {0x4, "SHF_EXECINSTR"}, 423 {0x10, "SHF_MERGE"}, 424 {0x20, "SHF_STRINGS"}, 425 {0x40, "SHF_INFO_LINK"}, 426 {0x80, "SHF_LINK_ORDER"}, 427 {0x100, "SHF_OS_NONCONFORMING"}, 428 {0x200, "SHF_GROUP"}, 429 {0x400, "SHF_TLS"}, 430 {0x800, "SHF_COMPRESSED"}, 431 } 432 433 func (i SectionFlag) String() string { return flagName(uint32(i), shfStrings, false) } 434 func (i SectionFlag) GoString() string { return flagName(uint32(i), shfStrings, true) } 435 436 // Section compression type. 437 type CompressionType int 438 439 const ( 440 COMPRESS_ZLIB CompressionType = 1 /* ZLIB compression. */ 441 COMPRESS_LOOS CompressionType = 0x60000000 /* First OS-specific. */ 442 COMPRESS_HIOS CompressionType = 0x6fffffff /* Last OS-specific. */ 443 COMPRESS_LOPROC CompressionType = 0x70000000 /* First processor-specific type. */ 444 COMPRESS_HIPROC CompressionType = 0x7fffffff /* Last processor-specific type. */ 445 ) 446 447 var compressionStrings = []intName{ 448 {0, "COMPRESS_ZLIB"}, 449 {0x60000000, "COMPRESS_LOOS"}, 450 {0x6fffffff, "COMPRESS_HIOS"}, 451 {0x70000000, "COMPRESS_LOPROC"}, 452 {0x7fffffff, "COMPRESS_HIPROC"}, 453 } 454 455 func (i CompressionType) String() string { return stringName(uint32(i), compressionStrings, false) } 456 func (i CompressionType) GoString() string { return stringName(uint32(i), compressionStrings, true) } 457 458 // Prog.Type 459 type ProgType int 460 461 const ( 462 PT_NULL ProgType = 0 /* Unused entry. */ 463 PT_LOAD ProgType = 1 /* Loadable segment. */ 464 PT_DYNAMIC ProgType = 2 /* Dynamic linking information segment. */ 465 PT_INTERP ProgType = 3 /* Pathname of interpreter. */ 466 PT_NOTE ProgType = 4 /* Auxiliary information. */ 467 PT_SHLIB ProgType = 5 /* Reserved (not used). */ 468 PT_PHDR ProgType = 6 /* Location of program header itself. */ 469 PT_TLS ProgType = 7 /* Thread local storage segment */ 470 PT_LOOS ProgType = 0x60000000 /* First OS-specific. */ 471 PT_HIOS ProgType = 0x6fffffff /* Last OS-specific. */ 472 PT_LOPROC ProgType = 0x70000000 /* First processor-specific type. */ 473 PT_HIPROC ProgType = 0x7fffffff /* Last processor-specific type. */ 474 ) 475 476 var ptStrings = []intName{ 477 {0, "PT_NULL"}, 478 {1, "PT_LOAD"}, 479 {2, "PT_DYNAMIC"}, 480 {3, "PT_INTERP"}, 481 {4, "PT_NOTE"}, 482 {5, "PT_SHLIB"}, 483 {6, "PT_PHDR"}, 484 {7, "PT_TLS"}, 485 {0x60000000, "PT_LOOS"}, 486 {0x6fffffff, "PT_HIOS"}, 487 {0x70000000, "PT_LOPROC"}, 488 {0x7fffffff, "PT_HIPROC"}, 489 } 490 491 func (i ProgType) String() string { return stringName(uint32(i), ptStrings, false) } 492 func (i ProgType) GoString() string { return stringName(uint32(i), ptStrings, true) } 493 494 // Prog.Flag 495 type ProgFlag uint32 496 497 const ( 498 PF_X ProgFlag = 0x1 /* Executable. */ 499 PF_W ProgFlag = 0x2 /* Writable. */ 500 PF_R ProgFlag = 0x4 /* Readable. */ 501 PF_MASKOS ProgFlag = 0x0ff00000 /* Operating system-specific. */ 502 PF_MASKPROC ProgFlag = 0xf0000000 /* Processor-specific. */ 503 ) 504 505 var pfStrings = []intName{ 506 {0x1, "PF_X"}, 507 {0x2, "PF_W"}, 508 {0x4, "PF_R"}, 509 } 510 511 func (i ProgFlag) String() string { return flagName(uint32(i), pfStrings, false) } 512 func (i ProgFlag) GoString() string { return flagName(uint32(i), pfStrings, true) } 513 514 // Dyn.Tag 515 type DynTag int 516 517 const ( 518 DT_NULL DynTag = 0 /* Terminating entry. */ 519 DT_NEEDED DynTag = 1 /* String table offset of a needed shared library. */ 520 DT_PLTRELSZ DynTag = 2 /* Total size in bytes of PLT relocations. */ 521 DT_PLTGOT DynTag = 3 /* Processor-dependent address. */ 522 DT_HASH DynTag = 4 /* Address of symbol hash table. */ 523 DT_STRTAB DynTag = 5 /* Address of string table. */ 524 DT_SYMTAB DynTag = 6 /* Address of symbol table. */ 525 DT_RELA DynTag = 7 /* Address of ElfNN_Rela relocations. */ 526 DT_RELASZ DynTag = 8 /* Total size of ElfNN_Rela relocations. */ 527 DT_RELAENT DynTag = 9 /* Size of each ElfNN_Rela relocation entry. */ 528 DT_STRSZ DynTag = 10 /* Size of string table. */ 529 DT_SYMENT DynTag = 11 /* Size of each symbol table entry. */ 530 DT_INIT DynTag = 12 /* Address of initialization function. */ 531 DT_FINI DynTag = 13 /* Address of finalization function. */ 532 DT_SONAME DynTag = 14 /* String table offset of shared object name. */ 533 DT_RPATH DynTag = 15 /* String table offset of library path. [sup] */ 534 DT_SYMBOLIC DynTag = 16 /* Indicates "symbolic" linking. [sup] */ 535 DT_REL DynTag = 17 /* Address of ElfNN_Rel relocations. */ 536 DT_RELSZ DynTag = 18 /* Total size of ElfNN_Rel relocations. */ 537 DT_RELENT DynTag = 19 /* Size of each ElfNN_Rel relocation. */ 538 DT_PLTREL DynTag = 20 /* Type of relocation used for PLT. */ 539 DT_DEBUG DynTag = 21 /* Reserved (not used). */ 540 DT_TEXTREL DynTag = 22 /* Indicates there may be relocations in non-writable segments. [sup] */ 541 DT_JMPREL DynTag = 23 /* Address of PLT relocations. */ 542 DT_BIND_NOW DynTag = 24 /* [sup] */ 543 DT_INIT_ARRAY DynTag = 25 /* Address of the array of pointers to initialization functions */ 544 DT_FINI_ARRAY DynTag = 26 /* Address of the array of pointers to termination functions */ 545 DT_INIT_ARRAYSZ DynTag = 27 /* Size in bytes of the array of initialization functions. */ 546 DT_FINI_ARRAYSZ DynTag = 28 /* Size in bytes of the array of termination functions. */ 547 DT_RUNPATH DynTag = 29 /* String table offset of a null-terminated library search path string. */ 548 DT_FLAGS DynTag = 30 /* Object specific flag values. */ 549 DT_ENCODING DynTag = 32 /* Values greater than or equal to DT_ENCODING 550 and less than DT_LOOS follow the rules for 551 the interpretation of the d_un union 552 as follows: even == 'd_ptr', even == 'd_val' 553 or none */ 554 DT_PREINIT_ARRAY DynTag = 32 /* Address of the array of pointers to pre-initialization functions. */ 555 DT_PREINIT_ARRAYSZ DynTag = 33 /* Size in bytes of the array of pre-initialization functions. */ 556 DT_LOOS DynTag = 0x6000000d /* First OS-specific */ 557 DT_HIOS DynTag = 0x6ffff000 /* Last OS-specific */ 558 DT_VERSYM DynTag = 0x6ffffff0 559 DT_VERNEED DynTag = 0x6ffffffe 560 DT_VERNEEDNUM DynTag = 0x6fffffff 561 DT_LOPROC DynTag = 0x70000000 /* First processor-specific type. */ 562 DT_HIPROC DynTag = 0x7fffffff /* Last processor-specific type. */ 563 ) 564 565 var dtStrings = []intName{ 566 {0, "DT_NULL"}, 567 {1, "DT_NEEDED"}, 568 {2, "DT_PLTRELSZ"}, 569 {3, "DT_PLTGOT"}, 570 {4, "DT_HASH"}, 571 {5, "DT_STRTAB"}, 572 {6, "DT_SYMTAB"}, 573 {7, "DT_RELA"}, 574 {8, "DT_RELASZ"}, 575 {9, "DT_RELAENT"}, 576 {10, "DT_STRSZ"}, 577 {11, "DT_SYMENT"}, 578 {12, "DT_INIT"}, 579 {13, "DT_FINI"}, 580 {14, "DT_SONAME"}, 581 {15, "DT_RPATH"}, 582 {16, "DT_SYMBOLIC"}, 583 {17, "DT_REL"}, 584 {18, "DT_RELSZ"}, 585 {19, "DT_RELENT"}, 586 {20, "DT_PLTREL"}, 587 {21, "DT_DEBUG"}, 588 {22, "DT_TEXTREL"}, 589 {23, "DT_JMPREL"}, 590 {24, "DT_BIND_NOW"}, 591 {25, "DT_INIT_ARRAY"}, 592 {26, "DT_FINI_ARRAY"}, 593 {27, "DT_INIT_ARRAYSZ"}, 594 {28, "DT_FINI_ARRAYSZ"}, 595 {29, "DT_RUNPATH"}, 596 {30, "DT_FLAGS"}, 597 {32, "DT_ENCODING"}, 598 {32, "DT_PREINIT_ARRAY"}, 599 {33, "DT_PREINIT_ARRAYSZ"}, 600 {0x6000000d, "DT_LOOS"}, 601 {0x6ffff000, "DT_HIOS"}, 602 {0x6ffffff0, "DT_VERSYM"}, 603 {0x6ffffffe, "DT_VERNEED"}, 604 {0x6fffffff, "DT_VERNEEDNUM"}, 605 {0x70000000, "DT_LOPROC"}, 606 {0x7fffffff, "DT_HIPROC"}, 607 } 608 609 func (i DynTag) String() string { return stringName(uint32(i), dtStrings, false) } 610 func (i DynTag) GoString() string { return stringName(uint32(i), dtStrings, true) } 611 612 // DT_FLAGS values. 613 type DynFlag int 614 615 const ( 616 DF_ORIGIN DynFlag = 0x0001 /* Indicates that the object being loaded may 617 make reference to the 618 $ORIGIN substitution string */ 619 DF_SYMBOLIC DynFlag = 0x0002 /* Indicates "symbolic" linking. */ 620 DF_TEXTREL DynFlag = 0x0004 /* Indicates there may be relocations in non-writable segments. */ 621 DF_BIND_NOW DynFlag = 0x0008 /* Indicates that the dynamic linker should 622 process all relocations for the object 623 containing this entry before transferring 624 control to the program. */ 625 DF_STATIC_TLS DynFlag = 0x0010 /* Indicates that the shared object or 626 executable contains code using a static 627 thread-local storage scheme. */ 628 ) 629 630 var dflagStrings = []intName{ 631 {0x0001, "DF_ORIGIN"}, 632 {0x0002, "DF_SYMBOLIC"}, 633 {0x0004, "DF_TEXTREL"}, 634 {0x0008, "DF_BIND_NOW"}, 635 {0x0010, "DF_STATIC_TLS"}, 636 } 637 638 func (i DynFlag) String() string { return flagName(uint32(i), dflagStrings, false) } 639 func (i DynFlag) GoString() string { return flagName(uint32(i), dflagStrings, true) } 640 641 // NType values; used in core files. 642 type NType int 643 644 const ( 645 NT_PRSTATUS NType = 1 /* Process status. */ 646 NT_FPREGSET NType = 2 /* Floating point registers. */ 647 NT_PRPSINFO NType = 3 /* Process state info. */ 648 ) 649 650 var ntypeStrings = []intName{ 651 {1, "NT_PRSTATUS"}, 652 {2, "NT_FPREGSET"}, 653 {3, "NT_PRPSINFO"}, 654 } 655 656 func (i NType) String() string { return stringName(uint32(i), ntypeStrings, false) } 657 func (i NType) GoString() string { return stringName(uint32(i), ntypeStrings, true) } 658 659 /* Symbol Binding - ELFNN_ST_BIND - st_info */ 660 type SymBind int 661 662 const ( 663 STB_LOCAL SymBind = 0 /* Local symbol */ 664 STB_GLOBAL SymBind = 1 /* Global symbol */ 665 STB_WEAK SymBind = 2 /* like global - lower precedence */ 666 STB_LOOS SymBind = 10 /* Reserved range for operating system */ 667 STB_HIOS SymBind = 12 /* specific semantics. */ 668 STB_LOPROC SymBind = 13 /* reserved range for processor */ 669 STB_HIPROC SymBind = 15 /* specific semantics. */ 670 ) 671 672 var stbStrings = []intName{ 673 {0, "STB_LOCAL"}, 674 {1, "STB_GLOBAL"}, 675 {2, "STB_WEAK"}, 676 {10, "STB_LOOS"}, 677 {12, "STB_HIOS"}, 678 {13, "STB_LOPROC"}, 679 {15, "STB_HIPROC"}, 680 } 681 682 func (i SymBind) String() string { return stringName(uint32(i), stbStrings, false) } 683 func (i SymBind) GoString() string { return stringName(uint32(i), stbStrings, true) } 684 685 /* Symbol type - ELFNN_ST_TYPE - st_info */ 686 type SymType int 687 688 const ( 689 STT_NOTYPE SymType = 0 /* Unspecified type. */ 690 STT_OBJECT SymType = 1 /* Data object. */ 691 STT_FUNC SymType = 2 /* Function. */ 692 STT_SECTION SymType = 3 /* Section. */ 693 STT_FILE SymType = 4 /* Source file. */ 694 STT_COMMON SymType = 5 /* Uninitialized common block. */ 695 STT_TLS SymType = 6 /* TLS object. */ 696 STT_LOOS SymType = 10 /* Reserved range for operating system */ 697 STT_HIOS SymType = 12 /* specific semantics. */ 698 STT_LOPROC SymType = 13 /* reserved range for processor */ 699 STT_HIPROC SymType = 15 /* specific semantics. */ 700 ) 701 702 var sttStrings = []intName{ 703 {0, "STT_NOTYPE"}, 704 {1, "STT_OBJECT"}, 705 {2, "STT_FUNC"}, 706 {3, "STT_SECTION"}, 707 {4, "STT_FILE"}, 708 {5, "STT_COMMON"}, 709 {6, "STT_TLS"}, 710 {10, "STT_LOOS"}, 711 {12, "STT_HIOS"}, 712 {13, "STT_LOPROC"}, 713 {15, "STT_HIPROC"}, 714 } 715 716 func (i SymType) String() string { return stringName(uint32(i), sttStrings, false) } 717 func (i SymType) GoString() string { return stringName(uint32(i), sttStrings, true) } 718 719 /* Symbol visibility - ELFNN_ST_VISIBILITY - st_other */ 720 type SymVis int 721 722 const ( 723 STV_DEFAULT SymVis = 0x0 /* Default visibility (see binding). */ 724 STV_INTERNAL SymVis = 0x1 /* Special meaning in relocatable objects. */ 725 STV_HIDDEN SymVis = 0x2 /* Not visible. */ 726 STV_PROTECTED SymVis = 0x3 /* Visible but not preemptible. */ 727 ) 728 729 var stvStrings = []intName{ 730 {0x0, "STV_DEFAULT"}, 731 {0x1, "STV_INTERNAL"}, 732 {0x2, "STV_HIDDEN"}, 733 {0x3, "STV_PROTECTED"}, 734 } 735 736 func (i SymVis) String() string { return stringName(uint32(i), stvStrings, false) } 737 func (i SymVis) GoString() string { return stringName(uint32(i), stvStrings, true) } 738 739 /* 740 * Relocation types. 741 */ 742 743 // Relocation types for x86-64. 744 type R_X86_64 int 745 746 const ( 747 R_X86_64_NONE R_X86_64 = 0 /* No relocation. */ 748 R_X86_64_64 R_X86_64 = 1 /* Add 64 bit symbol value. */ 749 R_X86_64_PC32 R_X86_64 = 2 /* PC-relative 32 bit signed sym value. */ 750 R_X86_64_GOT32 R_X86_64 = 3 /* PC-relative 32 bit GOT offset. */ 751 R_X86_64_PLT32 R_X86_64 = 4 /* PC-relative 32 bit PLT offset. */ 752 R_X86_64_COPY R_X86_64 = 5 /* Copy data from shared object. */ 753 R_X86_64_GLOB_DAT R_X86_64 = 6 /* Set GOT entry to data address. */ 754 R_X86_64_JMP_SLOT R_X86_64 = 7 /* Set GOT entry to code address. */ 755 R_X86_64_RELATIVE R_X86_64 = 8 /* Add load address of shared object. */ 756 R_X86_64_GOTPCREL R_X86_64 = 9 /* Add 32 bit signed pcrel offset to GOT. */ 757 R_X86_64_32 R_X86_64 = 10 /* Add 32 bit zero extended symbol value */ 758 R_X86_64_32S R_X86_64 = 11 /* Add 32 bit sign extended symbol value */ 759 R_X86_64_16 R_X86_64 = 12 /* Add 16 bit zero extended symbol value */ 760 R_X86_64_PC16 R_X86_64 = 13 /* Add 16 bit signed extended pc relative symbol value */ 761 R_X86_64_8 R_X86_64 = 14 /* Add 8 bit zero extended symbol value */ 762 R_X86_64_PC8 R_X86_64 = 15 /* Add 8 bit signed extended pc relative symbol value */ 763 R_X86_64_DTPMOD64 R_X86_64 = 16 /* ID of module containing symbol */ 764 R_X86_64_DTPOFF64 R_X86_64 = 17 /* Offset in TLS block */ 765 R_X86_64_TPOFF64 R_X86_64 = 18 /* Offset in static TLS block */ 766 R_X86_64_TLSGD R_X86_64 = 19 /* PC relative offset to GD GOT entry */ 767 R_X86_64_TLSLD R_X86_64 = 20 /* PC relative offset to LD GOT entry */ 768 R_X86_64_DTPOFF32 R_X86_64 = 21 /* Offset in TLS block */ 769 R_X86_64_GOTTPOFF R_X86_64 = 22 /* PC relative offset to IE GOT entry */ 770 R_X86_64_TPOFF32 R_X86_64 = 23 /* Offset in static TLS block */ 771 ) 772 773 var rx86_64Strings = []intName{ 774 {0, "R_X86_64_NONE"}, 775 {1, "R_X86_64_64"}, 776 {2, "R_X86_64_PC32"}, 777 {3, "R_X86_64_GOT32"}, 778 {4, "R_X86_64_PLT32"}, 779 {5, "R_X86_64_COPY"}, 780 {6, "R_X86_64_GLOB_DAT"}, 781 {7, "R_X86_64_JMP_SLOT"}, 782 {8, "R_X86_64_RELATIVE"}, 783 {9, "R_X86_64_GOTPCREL"}, 784 {10, "R_X86_64_32"}, 785 {11, "R_X86_64_32S"}, 786 {12, "R_X86_64_16"}, 787 {13, "R_X86_64_PC16"}, 788 {14, "R_X86_64_8"}, 789 {15, "R_X86_64_PC8"}, 790 {16, "R_X86_64_DTPMOD64"}, 791 {17, "R_X86_64_DTPOFF64"}, 792 {18, "R_X86_64_TPOFF64"}, 793 {19, "R_X86_64_TLSGD"}, 794 {20, "R_X86_64_TLSLD"}, 795 {21, "R_X86_64_DTPOFF32"}, 796 {22, "R_X86_64_GOTTPOFF"}, 797 {23, "R_X86_64_TPOFF32"}, 798 } 799 800 func (i R_X86_64) String() string { return stringName(uint32(i), rx86_64Strings, false) } 801 func (i R_X86_64) GoString() string { return stringName(uint32(i), rx86_64Strings, true) } 802 803 // Relocation types for AArch64 (aka arm64) 804 type R_AARCH64 int 805 806 const ( 807 R_AARCH64_NONE R_AARCH64 = 0 808 R_AARCH64_P32_ABS32 R_AARCH64 = 1 809 R_AARCH64_P32_ABS16 R_AARCH64 = 2 810 R_AARCH64_P32_PREL32 R_AARCH64 = 3 811 R_AARCH64_P32_PREL16 R_AARCH64 = 4 812 R_AARCH64_P32_MOVW_UABS_G0 R_AARCH64 = 5 813 R_AARCH64_P32_MOVW_UABS_G0_NC R_AARCH64 = 6 814 R_AARCH64_P32_MOVW_UABS_G1 R_AARCH64 = 7 815 R_AARCH64_P32_MOVW_SABS_G0 R_AARCH64 = 8 816 R_AARCH64_P32_LD_PREL_LO19 R_AARCH64 = 9 817 R_AARCH64_P32_ADR_PREL_LO21 R_AARCH64 = 10 818 R_AARCH64_P32_ADR_PREL_PG_HI21 R_AARCH64 = 11 819 R_AARCH64_P32_ADD_ABS_LO12_NC R_AARCH64 = 12 820 R_AARCH64_P32_LDST8_ABS_LO12_NC R_AARCH64 = 13 821 R_AARCH64_P32_LDST16_ABS_LO12_NC R_AARCH64 = 14 822 R_AARCH64_P32_LDST32_ABS_LO12_NC R_AARCH64 = 15 823 R_AARCH64_P32_LDST64_ABS_LO12_NC R_AARCH64 = 16 824 R_AARCH64_P32_LDST128_ABS_LO12_NC R_AARCH64 = 17 825 R_AARCH64_P32_TSTBR14 R_AARCH64 = 18 826 R_AARCH64_P32_CONDBR19 R_AARCH64 = 19 827 R_AARCH64_P32_JUMP26 R_AARCH64 = 20 828 R_AARCH64_P32_CALL26 R_AARCH64 = 21 829 R_AARCH64_P32_GOT_LD_PREL19 R_AARCH64 = 25 830 R_AARCH64_P32_ADR_GOT_PAGE R_AARCH64 = 26 831 R_AARCH64_P32_LD32_GOT_LO12_NC R_AARCH64 = 27 832 R_AARCH64_P32_TLSGD_ADR_PAGE21 R_AARCH64 = 81 833 R_AARCH64_P32_TLSGD_ADD_LO12_NC R_AARCH64 = 82 834 R_AARCH64_P32_TLSIE_ADR_GOTTPREL_PAGE21 R_AARCH64 = 103 835 R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC R_AARCH64 = 104 836 R_AARCH64_P32_TLSIE_LD_GOTTPREL_PREL19 R_AARCH64 = 105 837 R_AARCH64_P32_TLSLE_MOVW_TPREL_G1 R_AARCH64 = 106 838 R_AARCH64_P32_TLSLE_MOVW_TPREL_G0 R_AARCH64 = 107 839 R_AARCH64_P32_TLSLE_MOVW_TPREL_G0_NC R_AARCH64 = 108 840 R_AARCH64_P32_TLSLE_ADD_TPREL_HI12 R_AARCH64 = 109 841 R_AARCH64_P32_TLSLE_ADD_TPREL_LO12 R_AARCH64 = 110 842 R_AARCH64_P32_TLSLE_ADD_TPREL_LO12_NC R_AARCH64 = 111 843 R_AARCH64_P32_TLSDESC_LD_PREL19 R_AARCH64 = 122 844 R_AARCH64_P32_TLSDESC_ADR_PREL21 R_AARCH64 = 123 845 R_AARCH64_P32_TLSDESC_ADR_PAGE21 R_AARCH64 = 124 846 R_AARCH64_P32_TLSDESC_LD32_LO12_NC R_AARCH64 = 125 847 R_AARCH64_P32_TLSDESC_ADD_LO12_NC R_AARCH64 = 126 848 R_AARCH64_P32_TLSDESC_CALL R_AARCH64 = 127 849 R_AARCH64_P32_COPY R_AARCH64 = 180 850 R_AARCH64_P32_GLOB_DAT R_AARCH64 = 181 851 R_AARCH64_P32_JUMP_SLOT R_AARCH64 = 182 852 R_AARCH64_P32_RELATIVE R_AARCH64 = 183 853 R_AARCH64_P32_TLS_DTPMOD R_AARCH64 = 184 854 R_AARCH64_P32_TLS_DTPREL R_AARCH64 = 185 855 R_AARCH64_P32_TLS_TPREL R_AARCH64 = 186 856 R_AARCH64_P32_TLSDESC R_AARCH64 = 187 857 R_AARCH64_P32_IRELATIVE R_AARCH64 = 188 858 R_AARCH64_NULL R_AARCH64 = 256 859 R_AARCH64_ABS64 R_AARCH64 = 257 860 R_AARCH64_ABS32 R_AARCH64 = 258 861 R_AARCH64_ABS16 R_AARCH64 = 259 862 R_AARCH64_PREL64 R_AARCH64 = 260 863 R_AARCH64_PREL32 R_AARCH64 = 261 864 R_AARCH64_PREL16 R_AARCH64 = 262 865 R_AARCH64_MOVW_UABS_G0 R_AARCH64 = 263 866 R_AARCH64_MOVW_UABS_G0_NC R_AARCH64 = 264 867 R_AARCH64_MOVW_UABS_G1 R_AARCH64 = 265 868 R_AARCH64_MOVW_UABS_G1_NC R_AARCH64 = 266 869 R_AARCH64_MOVW_UABS_G2 R_AARCH64 = 267 870 R_AARCH64_MOVW_UABS_G2_NC R_AARCH64 = 268 871 R_AARCH64_MOVW_UABS_G3 R_AARCH64 = 269 872 R_AARCH64_MOVW_SABS_G0 R_AARCH64 = 270 873 R_AARCH64_MOVW_SABS_G1 R_AARCH64 = 271 874 R_AARCH64_MOVW_SABS_G2 R_AARCH64 = 272 875 R_AARCH64_LD_PREL_LO19 R_AARCH64 = 273 876 R_AARCH64_ADR_PREL_LO21 R_AARCH64 = 274 877 R_AARCH64_ADR_PREL_PG_HI21 R_AARCH64 = 275 878 R_AARCH64_ADR_PREL_PG_HI21_NC R_AARCH64 = 276 879 R_AARCH64_ADD_ABS_LO12_NC R_AARCH64 = 277 880 R_AARCH64_LDST8_ABS_LO12_NC R_AARCH64 = 278 881 R_AARCH64_TSTBR14 R_AARCH64 = 279 882 R_AARCH64_CONDBR19 R_AARCH64 = 280 883 R_AARCH64_JUMP26 R_AARCH64 = 282 884 R_AARCH64_CALL26 R_AARCH64 = 283 885 R_AARCH64_LDST16_ABS_LO12_NC R_AARCH64 = 284 886 R_AARCH64_LDST32_ABS_LO12_NC R_AARCH64 = 285 887 R_AARCH64_LDST64_ABS_LO12_NC R_AARCH64 = 286 888 R_AARCH64_LDST128_ABS_LO12_NC R_AARCH64 = 299 889 R_AARCH64_GOT_LD_PREL19 R_AARCH64 = 309 890 R_AARCH64_ADR_GOT_PAGE R_AARCH64 = 311 891 R_AARCH64_LD64_GOT_LO12_NC R_AARCH64 = 312 892 R_AARCH64_TLSGD_ADR_PAGE21 R_AARCH64 = 513 893 R_AARCH64_TLSGD_ADD_LO12_NC R_AARCH64 = 514 894 R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 R_AARCH64 = 539 895 R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC R_AARCH64 = 540 896 R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 R_AARCH64 = 541 897 R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC R_AARCH64 = 542 898 R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 R_AARCH64 = 543 899 R_AARCH64_TLSLE_MOVW_TPREL_G2 R_AARCH64 = 544 900 R_AARCH64_TLSLE_MOVW_TPREL_G1 R_AARCH64 = 545 901 R_AARCH64_TLSLE_MOVW_TPREL_G1_NC R_AARCH64 = 546 902 R_AARCH64_TLSLE_MOVW_TPREL_G0 R_AARCH64 = 547 903 R_AARCH64_TLSLE_MOVW_TPREL_G0_NC R_AARCH64 = 548 904 R_AARCH64_TLSLE_ADD_TPREL_HI12 R_AARCH64 = 549 905 R_AARCH64_TLSLE_ADD_TPREL_LO12 R_AARCH64 = 550 906 R_AARCH64_TLSLE_ADD_TPREL_LO12_NC R_AARCH64 = 551 907 R_AARCH64_TLSDESC_LD_PREL19 R_AARCH64 = 560 908 R_AARCH64_TLSDESC_ADR_PREL21 R_AARCH64 = 561 909 R_AARCH64_TLSDESC_ADR_PAGE21 R_AARCH64 = 562 910 R_AARCH64_TLSDESC_LD64_LO12_NC R_AARCH64 = 563 911 R_AARCH64_TLSDESC_ADD_LO12_NC R_AARCH64 = 564 912 R_AARCH64_TLSDESC_OFF_G1 R_AARCH64 = 565 913 R_AARCH64_TLSDESC_OFF_G0_NC R_AARCH64 = 566 914 R_AARCH64_TLSDESC_LDR R_AARCH64 = 567 915 R_AARCH64_TLSDESC_ADD R_AARCH64 = 568 916 R_AARCH64_TLSDESC_CALL R_AARCH64 = 569 917 R_AARCH64_COPY R_AARCH64 = 1024 918 R_AARCH64_GLOB_DAT R_AARCH64 = 1025 919 R_AARCH64_JUMP_SLOT R_AARCH64 = 1026 920 R_AARCH64_RELATIVE R_AARCH64 = 1027 921 R_AARCH64_TLS_DTPMOD64 R_AARCH64 = 1028 922 R_AARCH64_TLS_DTPREL64 R_AARCH64 = 1029 923 R_AARCH64_TLS_TPREL64 R_AARCH64 = 1030 924 R_AARCH64_TLSDESC R_AARCH64 = 1031 925 R_AARCH64_IRELATIVE R_AARCH64 = 1032 926 ) 927 928 var raarch64Strings = []intName{ 929 {0, "R_AARCH64_NONE"}, 930 {1, "R_AARCH64_P32_ABS32"}, 931 {2, "R_AARCH64_P32_ABS16"}, 932 {3, "R_AARCH64_P32_PREL32"}, 933 {4, "R_AARCH64_P32_PREL16"}, 934 {5, "R_AARCH64_P32_MOVW_UABS_G0"}, 935 {6, "R_AARCH64_P32_MOVW_UABS_G0_NC"}, 936 {7, "R_AARCH64_P32_MOVW_UABS_G1"}, 937 {8, "R_AARCH64_P32_MOVW_SABS_G0"}, 938 {9, "R_AARCH64_P32_LD_PREL_LO19"}, 939 {10, "R_AARCH64_P32_ADR_PREL_LO21"}, 940 {11, "R_AARCH64_P32_ADR_PREL_PG_HI21"}, 941 {12, "R_AARCH64_P32_ADD_ABS_LO12_NC"}, 942 {13, "R_AARCH64_P32_LDST8_ABS_LO12_NC"}, 943 {14, "R_AARCH64_P32_LDST16_ABS_LO12_NC"}, 944 {15, "R_AARCH64_P32_LDST32_ABS_LO12_NC"}, 945 {16, "R_AARCH64_P32_LDST64_ABS_LO12_NC"}, 946 {17, "R_AARCH64_P32_LDST128_ABS_LO12_NC"}, 947 {18, "R_AARCH64_P32_TSTBR14"}, 948 {19, "R_AARCH64_P32_CONDBR19"}, 949 {20, "R_AARCH64_P32_JUMP26"}, 950 {21, "R_AARCH64_P32_CALL26"}, 951 {25, "R_AARCH64_P32_GOT_LD_PREL19"}, 952 {26, "R_AARCH64_P32_ADR_GOT_PAGE"}, 953 {27, "R_AARCH64_P32_LD32_GOT_LO12_NC"}, 954 {81, "R_AARCH64_P32_TLSGD_ADR_PAGE21"}, 955 {82, "R_AARCH64_P32_TLSGD_ADD_LO12_NC"}, 956 {103, "R_AARCH64_P32_TLSIE_ADR_GOTTPREL_PAGE21"}, 957 {104, "R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC"}, 958 {105, "R_AARCH64_P32_TLSIE_LD_GOTTPREL_PREL19"}, 959 {106, "R_AARCH64_P32_TLSLE_MOVW_TPREL_G1"}, 960 {107, "R_AARCH64_P32_TLSLE_MOVW_TPREL_G0"}, 961 {108, "R_AARCH64_P32_TLSLE_MOVW_TPREL_G0_NC"}, 962 {109, "R_AARCH64_P32_TLSLE_ADD_TPREL_HI12"}, 963 {110, "R_AARCH64_P32_TLSLE_ADD_TPREL_LO12"}, 964 {111, "R_AARCH64_P32_TLSLE_ADD_TPREL_LO12_NC"}, 965 {122, "R_AARCH64_P32_TLSDESC_LD_PREL19"}, 966 {123, "R_AARCH64_P32_TLSDESC_ADR_PREL21"}, 967 {124, "R_AARCH64_P32_TLSDESC_ADR_PAGE21"}, 968 {125, "R_AARCH64_P32_TLSDESC_LD32_LO12_NC"}, 969 {126, "R_AARCH64_P32_TLSDESC_ADD_LO12_NC"}, 970 {127, "R_AARCH64_P32_TLSDESC_CALL"}, 971 {180, "R_AARCH64_P32_COPY"}, 972 {181, "R_AARCH64_P32_GLOB_DAT"}, 973 {182, "R_AARCH64_P32_JUMP_SLOT"}, 974 {183, "R_AARCH64_P32_RELATIVE"}, 975 {184, "R_AARCH64_P32_TLS_DTPMOD"}, 976 {185, "R_AARCH64_P32_TLS_DTPREL"}, 977 {186, "R_AARCH64_P32_TLS_TPREL"}, 978 {187, "R_AARCH64_P32_TLSDESC"}, 979 {188, "R_AARCH64_P32_IRELATIVE"}, 980 {256, "R_AARCH64_NULL"}, 981 {257, "R_AARCH64_ABS64"}, 982 {258, "R_AARCH64_ABS32"}, 983 {259, "R_AARCH64_ABS16"}, 984 {260, "R_AARCH64_PREL64"}, 985 {261, "R_AARCH64_PREL32"}, 986 {262, "R_AARCH64_PREL16"}, 987 {263, "R_AARCH64_MOVW_UABS_G0"}, 988 {264, "R_AARCH64_MOVW_UABS_G0_NC"}, 989 {265, "R_AARCH64_MOVW_UABS_G1"}, 990 {266, "R_AARCH64_MOVW_UABS_G1_NC"}, 991 {267, "R_AARCH64_MOVW_UABS_G2"}, 992 {268, "R_AARCH64_MOVW_UABS_G2_NC"}, 993 {269, "R_AARCH64_MOVW_UABS_G3"}, 994 {270, "R_AARCH64_MOVW_SABS_G0"}, 995 {271, "R_AARCH64_MOVW_SABS_G1"}, 996 {272, "R_AARCH64_MOVW_SABS_G2"}, 997 {273, "R_AARCH64_LD_PREL_LO19"}, 998 {274, "R_AARCH64_ADR_PREL_LO21"}, 999 {275, "R_AARCH64_ADR_PREL_PG_HI21"}, 1000 {276, "R_AARCH64_ADR_PREL_PG_HI21_NC"}, 1001 {277, "R_AARCH64_ADD_ABS_LO12_NC"}, 1002 {278, "R_AARCH64_LDST8_ABS_LO12_NC"}, 1003 {279, "R_AARCH64_TSTBR14"}, 1004 {280, "R_AARCH64_CONDBR19"}, 1005 {282, "R_AARCH64_JUMP26"}, 1006 {283, "R_AARCH64_CALL26"}, 1007 {284, "R_AARCH64_LDST16_ABS_LO12_NC"}, 1008 {285, "R_AARCH64_LDST32_ABS_LO12_NC"}, 1009 {286, "R_AARCH64_LDST64_ABS_LO12_NC"}, 1010 {299, "R_AARCH64_LDST128_ABS_LO12_NC"}, 1011 {309, "R_AARCH64_GOT_LD_PREL19"}, 1012 {311, "R_AARCH64_ADR_GOT_PAGE"}, 1013 {312, "R_AARCH64_LD64_GOT_LO12_NC"}, 1014 {513, "R_AARCH64_TLSGD_ADR_PAGE21"}, 1015 {514, "R_AARCH64_TLSGD_ADD_LO12_NC"}, 1016 {539, "R_AARCH64_TLSIE_MOVW_GOTTPREL_G1"}, 1017 {540, "R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC"}, 1018 {541, "R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21"}, 1019 {542, "R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC"}, 1020 {543, "R_AARCH64_TLSIE_LD_GOTTPREL_PREL19"}, 1021 {544, "R_AARCH64_TLSLE_MOVW_TPREL_G2"}, 1022 {545, "R_AARCH64_TLSLE_MOVW_TPREL_G1"}, 1023 {546, "R_AARCH64_TLSLE_MOVW_TPREL_G1_NC"}, 1024 {547, "R_AARCH64_TLSLE_MOVW_TPREL_G0"}, 1025 {548, "R_AARCH64_TLSLE_MOVW_TPREL_G0_NC"}, 1026 {549, "R_AARCH64_TLSLE_ADD_TPREL_HI12"}, 1027 {550, "R_AARCH64_TLSLE_ADD_TPREL_LO12"}, 1028 {551, "R_AARCH64_TLSLE_ADD_TPREL_LO12_NC"}, 1029 {560, "R_AARCH64_TLSDESC_LD_PREL19"}, 1030 {561, "R_AARCH64_TLSDESC_ADR_PREL21"}, 1031 {562, "R_AARCH64_TLSDESC_ADR_PAGE21"}, 1032 {563, "R_AARCH64_TLSDESC_LD64_LO12_NC"}, 1033 {564, "R_AARCH64_TLSDESC_ADD_LO12_NC"}, 1034 {565, "R_AARCH64_TLSDESC_OFF_G1"}, 1035 {566, "R_AARCH64_TLSDESC_OFF_G0_NC"}, 1036 {567, "R_AARCH64_TLSDESC_LDR"}, 1037 {568, "R_AARCH64_TLSDESC_ADD"}, 1038 {569, "R_AARCH64_TLSDESC_CALL"}, 1039 {1024, "R_AARCH64_COPY"}, 1040 {1025, "R_AARCH64_GLOB_DAT"}, 1041 {1026, "R_AARCH64_JUMP_SLOT"}, 1042 {1027, "R_AARCH64_RELATIVE"}, 1043 {1028, "R_AARCH64_TLS_DTPMOD64"}, 1044 {1029, "R_AARCH64_TLS_DTPREL64"}, 1045 {1030, "R_AARCH64_TLS_TPREL64"}, 1046 {1031, "R_AARCH64_TLSDESC"}, 1047 {1032, "R_AARCH64_IRELATIVE"}, 1048 } 1049 1050 func (i R_AARCH64) String() string { return stringName(uint32(i), raarch64Strings, false) } 1051 func (i R_AARCH64) GoString() string { return stringName(uint32(i), raarch64Strings, true) } 1052 1053 // Relocation types for Alpha. 1054 type R_ALPHA int 1055 1056 const ( 1057 R_ALPHA_NONE R_ALPHA = 0 /* No reloc */ 1058 R_ALPHA_REFLONG R_ALPHA = 1 /* Direct 32 bit */ 1059 R_ALPHA_REFQUAD R_ALPHA = 2 /* Direct 64 bit */ 1060 R_ALPHA_GPREL32 R_ALPHA = 3 /* GP relative 32 bit */ 1061 R_ALPHA_LITERAL R_ALPHA = 4 /* GP relative 16 bit w/optimization */ 1062 R_ALPHA_LITUSE R_ALPHA = 5 /* Optimization hint for LITERAL */ 1063 R_ALPHA_GPDISP R_ALPHA = 6 /* Add displacement to GP */ 1064 R_ALPHA_BRADDR R_ALPHA = 7 /* PC+4 relative 23 bit shifted */ 1065 R_ALPHA_HINT R_ALPHA = 8 /* PC+4 relative 16 bit shifted */ 1066 R_ALPHA_SREL16 R_ALPHA = 9 /* PC relative 16 bit */ 1067 R_ALPHA_SREL32 R_ALPHA = 10 /* PC relative 32 bit */ 1068 R_ALPHA_SREL64 R_ALPHA = 11 /* PC relative 64 bit */ 1069 R_ALPHA_OP_PUSH R_ALPHA = 12 /* OP stack push */ 1070 R_ALPHA_OP_STORE R_ALPHA = 13 /* OP stack pop and store */ 1071 R_ALPHA_OP_PSUB R_ALPHA = 14 /* OP stack subtract */ 1072 R_ALPHA_OP_PRSHIFT R_ALPHA = 15 /* OP stack right shift */ 1073 R_ALPHA_GPVALUE R_ALPHA = 16 1074 R_ALPHA_GPRELHIGH R_ALPHA = 17 1075 R_ALPHA_GPRELLOW R_ALPHA = 18 1076 R_ALPHA_IMMED_GP_16 R_ALPHA = 19 1077 R_ALPHA_IMMED_GP_HI32 R_ALPHA = 20 1078 R_ALPHA_IMMED_SCN_HI32 R_ALPHA = 21 1079 R_ALPHA_IMMED_BR_HI32 R_ALPHA = 22 1080 R_ALPHA_IMMED_LO32 R_ALPHA = 23 1081 R_ALPHA_COPY R_ALPHA = 24 /* Copy symbol at runtime */ 1082 R_ALPHA_GLOB_DAT R_ALPHA = 25 /* Create GOT entry */ 1083 R_ALPHA_JMP_SLOT R_ALPHA = 26 /* Create PLT entry */ 1084 R_ALPHA_RELATIVE R_ALPHA = 27 /* Adjust by program base */ 1085 ) 1086 1087 var ralphaStrings = []intName{ 1088 {0, "R_ALPHA_NONE"}, 1089 {1, "R_ALPHA_REFLONG"}, 1090 {2, "R_ALPHA_REFQUAD"}, 1091 {3, "R_ALPHA_GPREL32"}, 1092 {4, "R_ALPHA_LITERAL"}, 1093 {5, "R_ALPHA_LITUSE"}, 1094 {6, "R_ALPHA_GPDISP"}, 1095 {7, "R_ALPHA_BRADDR"}, 1096 {8, "R_ALPHA_HINT"}, 1097 {9, "R_ALPHA_SREL16"}, 1098 {10, "R_ALPHA_SREL32"}, 1099 {11, "R_ALPHA_SREL64"}, 1100 {12, "R_ALPHA_OP_PUSH"}, 1101 {13, "R_ALPHA_OP_STORE"}, 1102 {14, "R_ALPHA_OP_PSUB"}, 1103 {15, "R_ALPHA_OP_PRSHIFT"}, 1104 {16, "R_ALPHA_GPVALUE"}, 1105 {17, "R_ALPHA_GPRELHIGH"}, 1106 {18, "R_ALPHA_GPRELLOW"}, 1107 {19, "R_ALPHA_IMMED_GP_16"}, 1108 {20, "R_ALPHA_IMMED_GP_HI32"}, 1109 {21, "R_ALPHA_IMMED_SCN_HI32"}, 1110 {22, "R_ALPHA_IMMED_BR_HI32"}, 1111 {23, "R_ALPHA_IMMED_LO32"}, 1112 {24, "R_ALPHA_COPY"}, 1113 {25, "R_ALPHA_GLOB_DAT"}, 1114 {26, "R_ALPHA_JMP_SLOT"}, 1115 {27, "R_ALPHA_RELATIVE"}, 1116 } 1117 1118 func (i R_ALPHA) String() string { return stringName(uint32(i), ralphaStrings, false) } 1119 func (i R_ALPHA) GoString() string { return stringName(uint32(i), ralphaStrings, true) } 1120 1121 // Relocation types for ARM. 1122 type R_ARM int 1123 1124 const ( 1125 R_ARM_NONE R_ARM = 0 /* No relocation. */ 1126 R_ARM_PC24 R_ARM = 1 1127 R_ARM_ABS32 R_ARM = 2 1128 R_ARM_REL32 R_ARM = 3 1129 R_ARM_PC13 R_ARM = 4 1130 R_ARM_ABS16 R_ARM = 5 1131 R_ARM_ABS12 R_ARM = 6 1132 R_ARM_THM_ABS5 R_ARM = 7 1133 R_ARM_ABS8 R_ARM = 8 1134 R_ARM_SBREL32 R_ARM = 9 1135 R_ARM_THM_PC22 R_ARM = 10 1136 R_ARM_THM_PC8 R_ARM = 11 1137 R_ARM_AMP_VCALL9 R_ARM = 12 1138 R_ARM_SWI24 R_ARM = 13 1139 R_ARM_THM_SWI8 R_ARM = 14 1140 R_ARM_XPC25 R_ARM = 15 1141 R_ARM_THM_XPC22 R_ARM = 16 1142 R_ARM_COPY R_ARM = 20 /* Copy data from shared object. */ 1143 R_ARM_GLOB_DAT R_ARM = 21 /* Set GOT entry to data address. */ 1144 R_ARM_JUMP_SLOT R_ARM = 22 /* Set GOT entry to code address. */ 1145 R_ARM_RELATIVE R_ARM = 23 /* Add load address of shared object. */ 1146 R_ARM_GOTOFF R_ARM = 24 /* Add GOT-relative symbol address. */ 1147 R_ARM_GOTPC R_ARM = 25 /* Add PC-relative GOT table address. */ 1148 R_ARM_GOT32 R_ARM = 26 /* Add PC-relative GOT offset. */ 1149 R_ARM_PLT32 R_ARM = 27 /* Add PC-relative PLT offset. */ 1150 R_ARM_GNU_VTENTRY R_ARM = 100 1151 R_ARM_GNU_VTINHERIT R_ARM = 101 1152 R_ARM_RSBREL32 R_ARM = 250 1153 R_ARM_THM_RPC22 R_ARM = 251 1154 R_ARM_RREL32 R_ARM = 252 1155 R_ARM_RABS32 R_ARM = 253 1156 R_ARM_RPC24 R_ARM = 254 1157 R_ARM_RBASE R_ARM = 255 1158 ) 1159 1160 var rarmStrings = []intName{ 1161 {0, "R_ARM_NONE"}, 1162 {1, "R_ARM_PC24"}, 1163 {2, "R_ARM_ABS32"}, 1164 {3, "R_ARM_REL32"}, 1165 {4, "R_ARM_PC13"}, 1166 {5, "R_ARM_ABS16"}, 1167 {6, "R_ARM_ABS12"}, 1168 {7, "R_ARM_THM_ABS5"}, 1169 {8, "R_ARM_ABS8"}, 1170 {9, "R_ARM_SBREL32"}, 1171 {10, "R_ARM_THM_PC22"}, 1172 {11, "R_ARM_THM_PC8"}, 1173 {12, "R_ARM_AMP_VCALL9"}, 1174 {13, "R_ARM_SWI24"}, 1175 {14, "R_ARM_THM_SWI8"}, 1176 {15, "R_ARM_XPC25"}, 1177 {16, "R_ARM_THM_XPC22"}, 1178 {20, "R_ARM_COPY"}, 1179 {21, "R_ARM_GLOB_DAT"}, 1180 {22, "R_ARM_JUMP_SLOT"}, 1181 {23, "R_ARM_RELATIVE"}, 1182 {24, "R_ARM_GOTOFF"}, 1183 {25, "R_ARM_GOTPC"}, 1184 {26, "R_ARM_GOT32"}, 1185 {27, "R_ARM_PLT32"}, 1186 {100, "R_ARM_GNU_VTENTRY"}, 1187 {101, "R_ARM_GNU_VTINHERIT"}, 1188 {250, "R_ARM_RSBREL32"}, 1189 {251, "R_ARM_THM_RPC22"}, 1190 {252, "R_ARM_RREL32"}, 1191 {253, "R_ARM_RABS32"}, 1192 {254, "R_ARM_RPC24"}, 1193 {255, "R_ARM_RBASE"}, 1194 } 1195 1196 func (i R_ARM) String() string { return stringName(uint32(i), rarmStrings, false) } 1197 func (i R_ARM) GoString() string { return stringName(uint32(i), rarmStrings, true) } 1198 1199 // Relocation types for 386. 1200 type R_386 int 1201 1202 const ( 1203 R_386_NONE R_386 = 0 /* No relocation. */ 1204 R_386_32 R_386 = 1 /* Add symbol value. */ 1205 R_386_PC32 R_386 = 2 /* Add PC-relative symbol value. */ 1206 R_386_GOT32 R_386 = 3 /* Add PC-relative GOT offset. */ 1207 R_386_PLT32 R_386 = 4 /* Add PC-relative PLT offset. */ 1208 R_386_COPY R_386 = 5 /* Copy data from shared object. */ 1209 R_386_GLOB_DAT R_386 = 6 /* Set GOT entry to data address. */ 1210 R_386_JMP_SLOT R_386 = 7 /* Set GOT entry to code address. */ 1211 R_386_RELATIVE R_386 = 8 /* Add load address of shared object. */ 1212 R_386_GOTOFF R_386 = 9 /* Add GOT-relative symbol address. */ 1213 R_386_GOTPC R_386 = 10 /* Add PC-relative GOT table address. */ 1214 R_386_TLS_TPOFF R_386 = 14 /* Negative offset in static TLS block */ 1215 R_386_TLS_IE R_386 = 15 /* Absolute address of GOT for -ve static TLS */ 1216 R_386_TLS_GOTIE R_386 = 16 /* GOT entry for negative static TLS block */ 1217 R_386_TLS_LE R_386 = 17 /* Negative offset relative to static TLS */ 1218 R_386_TLS_GD R_386 = 18 /* 32 bit offset to GOT (index,off) pair */ 1219 R_386_TLS_LDM R_386 = 19 /* 32 bit offset to GOT (index,zero) pair */ 1220 R_386_TLS_GD_32 R_386 = 24 /* 32 bit offset to GOT (index,off) pair */ 1221 R_386_TLS_GD_PUSH R_386 = 25 /* pushl instruction for Sun ABI GD sequence */ 1222 R_386_TLS_GD_CALL R_386 = 26 /* call instruction for Sun ABI GD sequence */ 1223 R_386_TLS_GD_POP R_386 = 27 /* popl instruction for Sun ABI GD sequence */ 1224 R_386_TLS_LDM_32 R_386 = 28 /* 32 bit offset to GOT (index,zero) pair */ 1225 R_386_TLS_LDM_PUSH R_386 = 29 /* pushl instruction for Sun ABI LD sequence */ 1226 R_386_TLS_LDM_CALL R_386 = 30 /* call instruction for Sun ABI LD sequence */ 1227 R_386_TLS_LDM_POP R_386 = 31 /* popl instruction for Sun ABI LD sequence */ 1228 R_386_TLS_LDO_32 R_386 = 32 /* 32 bit offset from start of TLS block */ 1229 R_386_TLS_IE_32 R_386 = 33 /* 32 bit offset to GOT static TLS offset entry */ 1230 R_386_TLS_LE_32 R_386 = 34 /* 32 bit offset within static TLS block */ 1231 R_386_TLS_DTPMOD32 R_386 = 35 /* GOT entry containing TLS index */ 1232 R_386_TLS_DTPOFF32 R_386 = 36 /* GOT entry containing TLS offset */ 1233 R_386_TLS_TPOFF32 R_386 = 37 /* GOT entry of -ve static TLS offset */ 1234 ) 1235 1236 var r386Strings = []intName{ 1237 {0, "R_386_NONE"}, 1238 {1, "R_386_32"}, 1239 {2, "R_386_PC32"}, 1240 {3, "R_386_GOT32"}, 1241 {4, "R_386_PLT32"}, 1242 {5, "R_386_COPY"}, 1243 {6, "R_386_GLOB_DAT"}, 1244 {7, "R_386_JMP_SLOT"}, 1245 {8, "R_386_RELATIVE"}, 1246 {9, "R_386_GOTOFF"}, 1247 {10, "R_386_GOTPC"}, 1248 {14, "R_386_TLS_TPOFF"}, 1249 {15, "R_386_TLS_IE"}, 1250 {16, "R_386_TLS_GOTIE"}, 1251 {17, "R_386_TLS_LE"}, 1252 {18, "R_386_TLS_GD"}, 1253 {19, "R_386_TLS_LDM"}, 1254 {24, "R_386_TLS_GD_32"}, 1255 {25, "R_386_TLS_GD_PUSH"}, 1256 {26, "R_386_TLS_GD_CALL"}, 1257 {27, "R_386_TLS_GD_POP"}, 1258 {28, "R_386_TLS_LDM_32"}, 1259 {29, "R_386_TLS_LDM_PUSH"}, 1260 {30, "R_386_TLS_LDM_CALL"}, 1261 {31, "R_386_TLS_LDM_POP"}, 1262 {32, "R_386_TLS_LDO_32"}, 1263 {33, "R_386_TLS_IE_32"}, 1264 {34, "R_386_TLS_LE_32"}, 1265 {35, "R_386_TLS_DTPMOD32"}, 1266 {36, "R_386_TLS_DTPOFF32"}, 1267 {37, "R_386_TLS_TPOFF32"}, 1268 } 1269 1270 func (i R_386) String() string { return stringName(uint32(i), r386Strings, false) } 1271 func (i R_386) GoString() string { return stringName(uint32(i), r386Strings, true) } 1272 1273 // Relocation types for MIPS. 1274 type R_MIPS int 1275 1276 const ( 1277 R_MIPS_NONE R_MIPS = 0 1278 R_MIPS_16 R_MIPS = 1 1279 R_MIPS_32 R_MIPS = 2 1280 R_MIPS_REL32 R_MIPS = 3 1281 R_MIPS_26 R_MIPS = 4 1282 R_MIPS_HI16 R_MIPS = 5 /* high 16 bits of symbol value */ 1283 R_MIPS_LO16 R_MIPS = 6 /* low 16 bits of symbol value */ 1284 R_MIPS_GPREL16 R_MIPS = 7 /* GP-relative reference */ 1285 R_MIPS_LITERAL R_MIPS = 8 /* Reference to literal section */ 1286 R_MIPS_GOT16 R_MIPS = 9 /* Reference to global offset table */ 1287 R_MIPS_PC16 R_MIPS = 10 /* 16 bit PC relative reference */ 1288 R_MIPS_CALL16 R_MIPS = 11 /* 16 bit call through glbl offset tbl */ 1289 R_MIPS_GPREL32 R_MIPS = 12 1290 R_MIPS_SHIFT5 R_MIPS = 16 1291 R_MIPS_SHIFT6 R_MIPS = 17 1292 R_MIPS_64 R_MIPS = 18 1293 R_MIPS_GOT_DISP R_MIPS = 19 1294 R_MIPS_GOT_PAGE R_MIPS = 20 1295 R_MIPS_GOT_OFST R_MIPS = 21 1296 R_MIPS_GOT_HI16 R_MIPS = 22 1297 R_MIPS_GOT_LO16 R_MIPS = 23 1298 R_MIPS_SUB R_MIPS = 24 1299 R_MIPS_INSERT_A R_MIPS = 25 1300 R_MIPS_INSERT_B R_MIPS = 26 1301 R_MIPS_DELETE R_MIPS = 27 1302 R_MIPS_HIGHER R_MIPS = 28 1303 R_MIPS_HIGHEST R_MIPS = 29 1304 R_MIPS_CALL_HI16 R_MIPS = 30 1305 R_MIPS_CALL_LO16 R_MIPS = 31 1306 R_MIPS_SCN_DISP R_MIPS = 32 1307 R_MIPS_REL16 R_MIPS = 33 1308 R_MIPS_ADD_IMMEDIATE R_MIPS = 34 1309 R_MIPS_PJUMP R_MIPS = 35 1310 R_MIPS_RELGOT R_MIPS = 36 1311 R_MIPS_JALR R_MIPS = 37 1312 1313 R_MIPS_TLS_DTPMOD32 R_MIPS = 38 /* Module number 32 bit */ 1314 R_MIPS_TLS_DTPREL32 R_MIPS = 39 /* Module-relative offset 32 bit */ 1315 R_MIPS_TLS_DTPMOD64 R_MIPS = 40 /* Module number 64 bit */ 1316 R_MIPS_TLS_DTPREL64 R_MIPS = 41 /* Module-relative offset 64 bit */ 1317 R_MIPS_TLS_GD R_MIPS = 42 /* 16 bit GOT offset for GD */ 1318 R_MIPS_TLS_LDM R_MIPS = 43 /* 16 bit GOT offset for LDM */ 1319 R_MIPS_TLS_DTPREL_HI16 R_MIPS = 44 /* Module-relative offset, high 16 bits */ 1320 R_MIPS_TLS_DTPREL_LO16 R_MIPS = 45 /* Module-relative offset, low 16 bits */ 1321 R_MIPS_TLS_GOTTPREL R_MIPS = 46 /* 16 bit GOT offset for IE */ 1322 R_MIPS_TLS_TPREL32 R_MIPS = 47 /* TP-relative offset, 32 bit */ 1323 R_MIPS_TLS_TPREL64 R_MIPS = 48 /* TP-relative offset, 64 bit */ 1324 R_MIPS_TLS_TPREL_HI16 R_MIPS = 49 /* TP-relative offset, high 16 bits */ 1325 R_MIPS_TLS_TPREL_LO16 R_MIPS = 50 /* TP-relative offset, low 16 bits */ 1326 ) 1327 1328 var rmipsStrings = []intName{ 1329 {0, "R_MIPS_NONE"}, 1330 {1, "R_MIPS_16"}, 1331 {2, "R_MIPS_32"}, 1332 {3, "R_MIPS_REL32"}, 1333 {4, "R_MIPS_26"}, 1334 {5, "R_MIPS_HI16"}, 1335 {6, "R_MIPS_LO16"}, 1336 {7, "R_MIPS_GPREL16"}, 1337 {8, "R_MIPS_LITERAL"}, 1338 {9, "R_MIPS_GOT16"}, 1339 {10, "R_MIPS_PC16"}, 1340 {11, "R_MIPS_CALL16"}, 1341 {12, "R_MIPS_GPREL32"}, 1342 {16, "R_MIPS_SHIFT5"}, 1343 {17, "R_MIPS_SHIFT6"}, 1344 {18, "R_MIPS_64"}, 1345 {19, "R_MIPS_GOT_DISP"}, 1346 {20, "R_MIPS_GOT_PAGE"}, 1347 {21, "R_MIPS_GOT_OFST"}, 1348 {22, "R_MIPS_GOT_HI16"}, 1349 {23, "R_MIPS_GOT_LO16"}, 1350 {24, "R_MIPS_SUB"}, 1351 {25, "R_MIPS_INSERT_A"}, 1352 {26, "R_MIPS_INSERT_B"}, 1353 {27, "R_MIPS_DELETE"}, 1354 {28, "R_MIPS_HIGHER"}, 1355 {29, "R_MIPS_HIGHEST"}, 1356 {30, "R_MIPS_CALL_HI16"}, 1357 {31, "R_MIPS_CALL_LO16"}, 1358 {32, "R_MIPS_SCN_DISP"}, 1359 {33, "R_MIPS_REL16"}, 1360 {34, "R_MIPS_ADD_IMMEDIATE"}, 1361 {35, "R_MIPS_PJUMP"}, 1362 {36, "R_MIPS_RELGOT"}, 1363 {37, "R_MIPS_JALR"}, 1364 {38, "R_MIPS_TLS_DTPMOD32"}, 1365 {39, "R_MIPS_TLS_DTPREL32"}, 1366 {40, "R_MIPS_TLS_DTPMOD64"}, 1367 {41, "R_MIPS_TLS_DTPREL64"}, 1368 {42, "R_MIPS_TLS_GD"}, 1369 {43, "R_MIPS_TLS_LDM"}, 1370 {44, "R_MIPS_TLS_DTPREL_HI16"}, 1371 {45, "R_MIPS_TLS_DTPREL_LO16"}, 1372 {46, "R_MIPS_TLS_GOTTPREL"}, 1373 {47, "R_MIPS_TLS_TPREL32"}, 1374 {48, "R_MIPS_TLS_TPREL64"}, 1375 {49, "R_MIPS_TLS_TPREL_HI16"}, 1376 {50, "R_MIPS_TLS_TPREL_LO16"}, 1377 } 1378 1379 func (i R_MIPS) String() string { return stringName(uint32(i), rmipsStrings, false) } 1380 func (i R_MIPS) GoString() string { return stringName(uint32(i), rmipsStrings, true) } 1381 1382 // Relocation types for PowerPC. 1383 type R_PPC int 1384 1385 const ( 1386 R_PPC_NONE R_PPC = 0 /* No relocation. */ 1387 R_PPC_ADDR32 R_PPC = 1 1388 R_PPC_ADDR24 R_PPC = 2 1389 R_PPC_ADDR16 R_PPC = 3 1390 R_PPC_ADDR16_LO R_PPC = 4 1391 R_PPC_ADDR16_HI R_PPC = 5 1392 R_PPC_ADDR16_HA R_PPC = 6 1393 R_PPC_ADDR14 R_PPC = 7 1394 R_PPC_ADDR14_BRTAKEN R_PPC = 8 1395 R_PPC_ADDR14_BRNTAKEN R_PPC = 9 1396 R_PPC_REL24 R_PPC = 10 1397 R_PPC_REL14 R_PPC = 11 1398 R_PPC_REL14_BRTAKEN R_PPC = 12 1399 R_PPC_REL14_BRNTAKEN R_PPC = 13 1400 R_PPC_GOT16 R_PPC = 14 1401 R_PPC_GOT16_LO R_PPC = 15 1402 R_PPC_GOT16_HI R_PPC = 16 1403 R_PPC_GOT16_HA R_PPC = 17 1404 R_PPC_PLTREL24 R_PPC = 18 1405 R_PPC_COPY R_PPC = 19 1406 R_PPC_GLOB_DAT R_PPC = 20 1407 R_PPC_JMP_SLOT R_PPC = 21 1408 R_PPC_RELATIVE R_PPC = 22 1409 R_PPC_LOCAL24PC R_PPC = 23 1410 R_PPC_UADDR32 R_PPC = 24 1411 R_PPC_UADDR16 R_PPC = 25 1412 R_PPC_REL32 R_PPC = 26 1413 R_PPC_PLT32 R_PPC = 27 1414 R_PPC_PLTREL32 R_PPC = 28 1415 R_PPC_PLT16_LO R_PPC = 29 1416 R_PPC_PLT16_HI R_PPC = 30 1417 R_PPC_PLT16_HA R_PPC = 31 1418 R_PPC_SDAREL16 R_PPC = 32 1419 R_PPC_SECTOFF R_PPC = 33 1420 R_PPC_SECTOFF_LO R_PPC = 34 1421 R_PPC_SECTOFF_HI R_PPC = 35 1422 R_PPC_SECTOFF_HA R_PPC = 36 1423 R_PPC_TLS R_PPC = 67 1424 R_PPC_DTPMOD32 R_PPC = 68 1425 R_PPC_TPREL16 R_PPC = 69 1426 R_PPC_TPREL16_LO R_PPC = 70 1427 R_PPC_TPREL16_HI R_PPC = 71 1428 R_PPC_TPREL16_HA R_PPC = 72 1429 R_PPC_TPREL32 R_PPC = 73 1430 R_PPC_DTPREL16 R_PPC = 74 1431 R_PPC_DTPREL16_LO R_PPC = 75 1432 R_PPC_DTPREL16_HI R_PPC = 76 1433 R_PPC_DTPREL16_HA R_PPC = 77 1434 R_PPC_DTPREL32 R_PPC = 78 1435 R_PPC_GOT_TLSGD16 R_PPC = 79 1436 R_PPC_GOT_TLSGD16_LO R_PPC = 80 1437 R_PPC_GOT_TLSGD16_HI R_PPC = 81 1438 R_PPC_GOT_TLSGD16_HA R_PPC = 82 1439 R_PPC_GOT_TLSLD16 R_PPC = 83 1440 R_PPC_GOT_TLSLD16_LO R_PPC = 84 1441 R_PPC_GOT_TLSLD16_HI R_PPC = 85 1442 R_PPC_GOT_TLSLD16_HA R_PPC = 86 1443 R_PPC_GOT_TPREL16 R_PPC = 87 1444 R_PPC_GOT_TPREL16_LO R_PPC = 88 1445 R_PPC_GOT_TPREL16_HI R_PPC = 89 1446 R_PPC_GOT_TPREL16_HA R_PPC = 90 1447 R_PPC_EMB_NADDR32 R_PPC = 101 1448 R_PPC_EMB_NADDR16 R_PPC = 102 1449 R_PPC_EMB_NADDR16_LO R_PPC = 103 1450 R_PPC_EMB_NADDR16_HI R_PPC = 104 1451 R_PPC_EMB_NADDR16_HA R_PPC = 105 1452 R_PPC_EMB_SDAI16 R_PPC = 106 1453 R_PPC_EMB_SDA2I16 R_PPC = 107 1454 R_PPC_EMB_SDA2REL R_PPC = 108 1455 R_PPC_EMB_SDA21 R_PPC = 109 1456 R_PPC_EMB_MRKREF R_PPC = 110 1457 R_PPC_EMB_RELSEC16 R_PPC = 111 1458 R_PPC_EMB_RELST_LO R_PPC = 112 1459 R_PPC_EMB_RELST_HI R_PPC = 113 1460 R_PPC_EMB_RELST_HA R_PPC = 114 1461 R_PPC_EMB_BIT_FLD R_PPC = 115 1462 R_PPC_EMB_RELSDA R_PPC = 116 1463 ) 1464 1465 var rppcStrings = []intName{ 1466 {0, "R_PPC_NONE"}, 1467 {1, "R_PPC_ADDR32"}, 1468 {2, "R_PPC_ADDR24"}, 1469 {3, "R_PPC_ADDR16"}, 1470 {4, "R_PPC_ADDR16_LO"}, 1471 {5, "R_PPC_ADDR16_HI"}, 1472 {6, "R_PPC_ADDR16_HA"}, 1473 {7, "R_PPC_ADDR14"}, 1474 {8, "R_PPC_ADDR14_BRTAKEN"}, 1475 {9, "R_PPC_ADDR14_BRNTAKEN"}, 1476 {10, "R_PPC_REL24"}, 1477 {11, "R_PPC_REL14"}, 1478 {12, "R_PPC_REL14_BRTAKEN"}, 1479 {13, "R_PPC_REL14_BRNTAKEN"}, 1480 {14, "R_PPC_GOT16"}, 1481 {15, "R_PPC_GOT16_LO"}, 1482 {16, "R_PPC_GOT16_HI"}, 1483 {17, "R_PPC_GOT16_HA"}, 1484 {18, "R_PPC_PLTREL24"}, 1485 {19, "R_PPC_COPY"}, 1486 {20, "R_PPC_GLOB_DAT"}, 1487 {21, "R_PPC_JMP_SLOT"}, 1488 {22, "R_PPC_RELATIVE"}, 1489 {23, "R_PPC_LOCAL24PC"}, 1490 {24, "R_PPC_UADDR32"}, 1491 {25, "R_PPC_UADDR16"}, 1492 {26, "R_PPC_REL32"}, 1493 {27, "R_PPC_PLT32"}, 1494 {28, "R_PPC_PLTREL32"}, 1495 {29, "R_PPC_PLT16_LO"}, 1496 {30, "R_PPC_PLT16_HI"}, 1497 {31, "R_PPC_PLT16_HA"}, 1498 {32, "R_PPC_SDAREL16"}, 1499 {33, "R_PPC_SECTOFF"}, 1500 {34, "R_PPC_SECTOFF_LO"}, 1501 {35, "R_PPC_SECTOFF_HI"}, 1502 {36, "R_PPC_SECTOFF_HA"}, 1503 1504 {67, "R_PPC_TLS"}, 1505 {68, "R_PPC_DTPMOD32"}, 1506 {69, "R_PPC_TPREL16"}, 1507 {70, "R_PPC_TPREL16_LO"}, 1508 {71, "R_PPC_TPREL16_HI"}, 1509 {72, "R_PPC_TPREL16_HA"}, 1510 {73, "R_PPC_TPREL32"}, 1511 {74, "R_PPC_DTPREL16"}, 1512 {75, "R_PPC_DTPREL16_LO"}, 1513 {76, "R_PPC_DTPREL16_HI"}, 1514 {77, "R_PPC_DTPREL16_HA"}, 1515 {78, "R_PPC_DTPREL32"}, 1516 {79, "R_PPC_GOT_TLSGD16"}, 1517 {80, "R_PPC_GOT_TLSGD16_LO"}, 1518 {81, "R_PPC_GOT_TLSGD16_HI"}, 1519 {82, "R_PPC_GOT_TLSGD16_HA"}, 1520 {83, "R_PPC_GOT_TLSLD16"}, 1521 {84, "R_PPC_GOT_TLSLD16_LO"}, 1522 {85, "R_PPC_GOT_TLSLD16_HI"}, 1523 {86, "R_PPC_GOT_TLSLD16_HA"}, 1524 {87, "R_PPC_GOT_TPREL16"}, 1525 {88, "R_PPC_GOT_TPREL16_LO"}, 1526 {89, "R_PPC_GOT_TPREL16_HI"}, 1527 {90, "R_PPC_GOT_TPREL16_HA"}, 1528 1529 {101, "R_PPC_EMB_NADDR32"}, 1530 {102, "R_PPC_EMB_NADDR16"}, 1531 {103, "R_PPC_EMB_NADDR16_LO"}, 1532 {104, "R_PPC_EMB_NADDR16_HI"}, 1533 {105, "R_PPC_EMB_NADDR16_HA"}, 1534 {106, "R_PPC_EMB_SDAI16"}, 1535 {107, "R_PPC_EMB_SDA2I16"}, 1536 {108, "R_PPC_EMB_SDA2REL"}, 1537 {109, "R_PPC_EMB_SDA21"}, 1538 {110, "R_PPC_EMB_MRKREF"}, 1539 {111, "R_PPC_EMB_RELSEC16"}, 1540 {112, "R_PPC_EMB_RELST_LO"}, 1541 {113, "R_PPC_EMB_RELST_HI"}, 1542 {114, "R_PPC_EMB_RELST_HA"}, 1543 {115, "R_PPC_EMB_BIT_FLD"}, 1544 {116, "R_PPC_EMB_RELSDA"}, 1545 } 1546 1547 func (i R_PPC) String() string { return stringName(uint32(i), rppcStrings, false) } 1548 func (i R_PPC) GoString() string { return stringName(uint32(i), rppcStrings, true) } 1549 1550 // Relocation types for 64-bit PowerPC or Power Architecture processors. 1551 type R_PPC64 int 1552 1553 const ( 1554 R_PPC64_NONE R_PPC64 = 0 1555 R_PPC64_ADDR32 R_PPC64 = 1 1556 R_PPC64_ADDR24 R_PPC64 = 2 1557 R_PPC64_ADDR16 R_PPC64 = 3 1558 R_PPC64_ADDR16_LO R_PPC64 = 4 1559 R_PPC64_ADDR16_HI R_PPC64 = 5 1560 R_PPC64_ADDR16_HA R_PPC64 = 6 1561 R_PPC64_ADDR14 R_PPC64 = 7 1562 R_PPC64_ADDR14_BRTAKEN R_PPC64 = 8 1563 R_PPC64_ADDR14_BRNTAKEN R_PPC64 = 9 1564 R_PPC64_REL24 R_PPC64 = 10 1565 R_PPC64_REL14 R_PPC64 = 11 1566 R_PPC64_REL14_BRTAKEN R_PPC64 = 12 1567 R_PPC64_REL14_BRNTAKEN R_PPC64 = 13 1568 R_PPC64_GOT16 R_PPC64 = 14 1569 R_PPC64_GOT16_LO R_PPC64 = 15 1570 R_PPC64_GOT16_HI R_PPC64 = 16 1571 R_PPC64_GOT16_HA R_PPC64 = 17 1572 R_PPC64_JMP_SLOT R_PPC64 = 21 1573 R_PPC64_REL32 R_PPC64 = 26 1574 R_PPC64_ADDR64 R_PPC64 = 38 1575 R_PPC64_ADDR16_HIGHER R_PPC64 = 39 1576 R_PPC64_ADDR16_HIGHERA R_PPC64 = 40 1577 R_PPC64_ADDR16_HIGHEST R_PPC64 = 41 1578 R_PPC64_ADDR16_HIGHESTA R_PPC64 = 42 1579 R_PPC64_REL64 R_PPC64 = 44 1580 R_PPC64_TOC16 R_PPC64 = 47 1581 R_PPC64_TOC16_LO R_PPC64 = 48 1582 R_PPC64_TOC16_HI R_PPC64 = 49 1583 R_PPC64_TOC16_HA R_PPC64 = 50 1584 R_PPC64_TOC R_PPC64 = 51 1585 R_PPC64_ADDR16_DS R_PPC64 = 56 1586 R_PPC64_ADDR16_LO_DS R_PPC64 = 57 1587 R_PPC64_GOT16_DS R_PPC64 = 58 1588 R_PPC64_GOT16_LO_DS R_PPC64 = 59 1589 R_PPC64_TOC16_DS R_PPC64 = 63 1590 R_PPC64_TOC16_LO_DS R_PPC64 = 64 1591 R_PPC64_TLS R_PPC64 = 67 1592 R_PPC64_DTPMOD64 R_PPC64 = 68 1593 R_PPC64_TPREL16 R_PPC64 = 69 1594 R_PPC64_TPREL16_LO R_PPC64 = 70 1595 R_PPC64_TPREL16_HI R_PPC64 = 71 1596 R_PPC64_TPREL16_HA R_PPC64 = 72 1597 R_PPC64_TPREL64 R_PPC64 = 73 1598 R_PPC64_DTPREL16 R_PPC64 = 74 1599 R_PPC64_DTPREL16_LO R_PPC64 = 75 1600 R_PPC64_DTPREL16_HI R_PPC64 = 76 1601 R_PPC64_DTPREL16_HA R_PPC64 = 77 1602 R_PPC64_DTPREL64 R_PPC64 = 78 1603 R_PPC64_GOT_TLSGD16 R_PPC64 = 79 1604 R_PPC64_GOT_TLSGD16_LO R_PPC64 = 80 1605 R_PPC64_GOT_TLSGD16_HI R_PPC64 = 81 1606 R_PPC64_GOT_TLSGD16_HA R_PPC64 = 82 1607 R_PPC64_GOT_TLSLD16 R_PPC64 = 83 1608 R_PPC64_GOT_TLSLD16_LO R_PPC64 = 84 1609 R_PPC64_GOT_TLSLD16_HI R_PPC64 = 85 1610 R_PPC64_GOT_TLSLD16_HA R_PPC64 = 86 1611 R_PPC64_GOT_TPREL16_DS R_PPC64 = 87 1612 R_PPC64_GOT_TPREL16_LO_DS R_PPC64 = 88 1613 R_PPC64_GOT_TPREL16_HI R_PPC64 = 89 1614 R_PPC64_GOT_TPREL16_HA R_PPC64 = 90 1615 R_PPC64_GOT_DTPREL16_DS R_PPC64 = 91 1616 R_PPC64_GOT_DTPREL16_LO_DS R_PPC64 = 92 1617 R_PPC64_GOT_DTPREL16_HI R_PPC64 = 93 1618 R_PPC64_GOT_DTPREL16_HA R_PPC64 = 94 1619 R_PPC64_TPREL16_DS R_PPC64 = 95 1620 R_PPC64_TPREL16_LO_DS R_PPC64 = 96 1621 R_PPC64_TPREL16_HIGHER R_PPC64 = 97 1622 R_PPC64_TPREL16_HIGHERA R_PPC64 = 98 1623 R_PPC64_TPREL16_HIGHEST R_PPC64 = 99 1624 R_PPC64_TPREL16_HIGHESTA R_PPC64 = 100 1625 R_PPC64_DTPREL16_DS R_PPC64 = 101 1626 R_PPC64_DTPREL16_LO_DS R_PPC64 = 102 1627 R_PPC64_DTPREL16_HIGHER R_PPC64 = 103 1628 R_PPC64_DTPREL16_HIGHERA R_PPC64 = 104 1629 R_PPC64_DTPREL16_HIGHEST R_PPC64 = 105 1630 R_PPC64_DTPREL16_HIGHESTA R_PPC64 = 106 1631 R_PPC64_TLSGD R_PPC64 = 107 1632 R_PPC64_TLSLD R_PPC64 = 108 1633 R_PPC64_REL16 R_PPC64 = 249 1634 R_PPC64_REL16_LO R_PPC64 = 250 1635 R_PPC64_REL16_HI R_PPC64 = 251 1636 R_PPC64_REL16_HA R_PPC64 = 252 1637 ) 1638 1639 var rppc64Strings = []intName{ 1640 {0, "R_PPC64_NONE"}, 1641 {1, "R_PPC64_ADDR32"}, 1642 {2, "R_PPC64_ADDR24"}, 1643 {3, "R_PPC64_ADDR16"}, 1644 {4, "R_PPC64_ADDR16_LO"}, 1645 {5, "R_PPC64_ADDR16_HI"}, 1646 {6, "R_PPC64_ADDR16_HA"}, 1647 {7, "R_PPC64_ADDR14"}, 1648 {8, "R_PPC64_ADDR14_BRTAKEN"}, 1649 {9, "R_PPC64_ADDR14_BRNTAKEN"}, 1650 {10, "R_PPC64_REL24"}, 1651 {11, "R_PPC64_REL14"}, 1652 {12, "R_PPC64_REL14_BRTAKEN"}, 1653 {13, "R_PPC64_REL14_BRNTAKEN"}, 1654 {14, "R_PPC64_GOT16"}, 1655 {15, "R_PPC64_GOT16_LO"}, 1656 {16, "R_PPC64_GOT16_HI"}, 1657 {17, "R_PPC64_GOT16_HA"}, 1658 {21, "R_PPC64_JMP_SLOT"}, 1659 {26, "R_PPC64_REL32"}, 1660 {38, "R_PPC64_ADDR64"}, 1661 {39, "R_PPC64_ADDR16_HIGHER"}, 1662 {40, "R_PPC64_ADDR16_HIGHERA"}, 1663 {41, "R_PPC64_ADDR16_HIGHEST"}, 1664 {42, "R_PPC64_ADDR16_HIGHESTA"}, 1665 {44, "R_PPC64_REL64"}, 1666 {47, "R_PPC64_TOC16"}, 1667 {48, "R_PPC64_TOC16_LO"}, 1668 {49, "R_PPC64_TOC16_HI"}, 1669 {50, "R_PPC64_TOC16_HA"}, 1670 {51, "R_PPC64_TOC"}, 1671 {56, "R_PPC64_ADDR16_DS"}, 1672 {57, "R_PPC64_ADDR16_LO_DS"}, 1673 {58, "R_PPC64_GOT16_DS"}, 1674 {59, "R_PPC64_GOT16_LO_DS"}, 1675 {63, "R_PPC64_TOC16_DS"}, 1676 {64, "R_PPC64_TOC16_LO_DS"}, 1677 {67, "R_PPC64_TLS"}, 1678 {68, "R_PPC64_DTPMOD64"}, 1679 {69, "R_PPC64_TPREL16"}, 1680 {70, "R_PPC64_TPREL16_LO"}, 1681 {71, "R_PPC64_TPREL16_HI"}, 1682 {72, "R_PPC64_TPREL16_HA"}, 1683 {73, "R_PPC64_TPREL64"}, 1684 {74, "R_PPC64_DTPREL16"}, 1685 {75, "R_PPC64_DTPREL16_LO"}, 1686 {76, "R_PPC64_DTPREL16_HI"}, 1687 {77, "R_PPC64_DTPREL16_HA"}, 1688 {78, "R_PPC64_DTPREL64"}, 1689 {79, "R_PPC64_GOT_TLSGD16"}, 1690 {80, "R_PPC64_GOT_TLSGD16_LO"}, 1691 {81, "R_PPC64_GOT_TLSGD16_HI"}, 1692 {82, "R_PPC64_GOT_TLSGD16_HA"}, 1693 {83, "R_PPC64_GOT_TLSLD16"}, 1694 {84, "R_PPC64_GOT_TLSLD16_LO"}, 1695 {85, "R_PPC64_GOT_TLSLD16_HI"}, 1696 {86, "R_PPC64_GOT_TLSLD16_HA"}, 1697 {87, "R_PPC64_GOT_TPREL16_DS"}, 1698 {88, "R_PPC64_GOT_TPREL16_LO_DS"}, 1699 {89, "R_PPC64_GOT_TPREL16_HI"}, 1700 {90, "R_PPC64_GOT_TPREL16_HA"}, 1701 {91, "R_PPC64_GOT_DTPREL16_DS"}, 1702 {92, "R_PPC64_GOT_DTPREL16_LO_DS"}, 1703 {93, "R_PPC64_GOT_DTPREL16_HI"}, 1704 {94, "R_PPC64_GOT_DTPREL16_HA"}, 1705 {95, "R_PPC64_TPREL16_DS"}, 1706 {96, "R_PPC64_TPREL16_LO_DS"}, 1707 {97, "R_PPC64_TPREL16_HIGHER"}, 1708 {98, "R_PPC64_TPREL16_HIGHERA"}, 1709 {99, "R_PPC64_TPREL16_HIGHEST"}, 1710 {100, "R_PPC64_TPREL16_HIGHESTA"}, 1711 {101, "R_PPC64_DTPREL16_DS"}, 1712 {102, "R_PPC64_DTPREL16_LO_DS"}, 1713 {103, "R_PPC64_DTPREL16_HIGHER"}, 1714 {104, "R_PPC64_DTPREL16_HIGHERA"}, 1715 {105, "R_PPC64_DTPREL16_HIGHEST"}, 1716 {106, "R_PPC64_DTPREL16_HIGHESTA"}, 1717 {107, "R_PPC64_TLSGD"}, 1718 {108, "R_PPC64_TLSLD"}, 1719 {249, "R_PPC64_REL16"}, 1720 {250, "R_PPC64_REL16_LO"}, 1721 {251, "R_PPC64_REL16_HI"}, 1722 {252, "R_PPC64_REL16_HA"}, 1723 } 1724 1725 func (i R_PPC64) String() string { return stringName(uint32(i), rppc64Strings, false) } 1726 func (i R_PPC64) GoString() string { return stringName(uint32(i), rppc64Strings, true) } 1727 1728 // Relocation types for s390x processors. 1729 type R_390 int 1730 1731 const ( 1732 R_390_NONE R_390 = 0 1733 R_390_8 R_390 = 1 1734 R_390_12 R_390 = 2 1735 R_390_16 R_390 = 3 1736 R_390_32 R_390 = 4 1737 R_390_PC32 R_390 = 5 1738 R_390_GOT12 R_390 = 6 1739 R_390_GOT32 R_390 = 7 1740 R_390_PLT32 R_390 = 8 1741 R_390_COPY R_390 = 9 1742 R_390_GLOB_DAT R_390 = 10 1743 R_390_JMP_SLOT R_390 = 11 1744 R_390_RELATIVE R_390 = 12 1745 R_390_GOTOFF R_390 = 13 1746 R_390_GOTPC R_390 = 14 1747 R_390_GOT16 R_390 = 15 1748 R_390_PC16 R_390 = 16 1749 R_390_PC16DBL R_390 = 17 1750 R_390_PLT16DBL R_390 = 18 1751 R_390_PC32DBL R_390 = 19 1752 R_390_PLT32DBL R_390 = 20 1753 R_390_GOTPCDBL R_390 = 21 1754 R_390_64 R_390 = 22 1755 R_390_PC64 R_390 = 23 1756 R_390_GOT64 R_390 = 24 1757 R_390_PLT64 R_390 = 25 1758 R_390_GOTENT R_390 = 26 1759 R_390_GOTOFF16 R_390 = 27 1760 R_390_GOTOFF64 R_390 = 28 1761 R_390_GOTPLT12 R_390 = 29 1762 R_390_GOTPLT16 R_390 = 30 1763 R_390_GOTPLT32 R_390 = 31 1764 R_390_GOTPLT64 R_390 = 32 1765 R_390_GOTPLTENT R_390 = 33 1766 R_390_GOTPLTOFF16 R_390 = 34 1767 R_390_GOTPLTOFF32 R_390 = 35 1768 R_390_GOTPLTOFF64 R_390 = 36 1769 R_390_TLS_LOAD R_390 = 37 1770 R_390_TLS_GDCALL R_390 = 38 1771 R_390_TLS_LDCALL R_390 = 39 1772 R_390_TLS_GD32 R_390 = 40 1773 R_390_TLS_GD64 R_390 = 41 1774 R_390_TLS_GOTIE12 R_390 = 42 1775 R_390_TLS_GOTIE32 R_390 = 43 1776 R_390_TLS_GOTIE64 R_390 = 44 1777 R_390_TLS_LDM32 R_390 = 45 1778 R_390_TLS_LDM64 R_390 = 46 1779 R_390_TLS_IE32 R_390 = 47 1780 R_390_TLS_IE64 R_390 = 48 1781 R_390_TLS_IEENT R_390 = 49 1782 R_390_TLS_LE32 R_390 = 50 1783 R_390_TLS_LE64 R_390 = 51 1784 R_390_TLS_LDO32 R_390 = 52 1785 R_390_TLS_LDO64 R_390 = 53 1786 R_390_TLS_DTPMOD R_390 = 54 1787 R_390_TLS_DTPOFF R_390 = 55 1788 R_390_TLS_TPOFF R_390 = 56 1789 R_390_20 R_390 = 57 1790 R_390_GOT20 R_390 = 58 1791 R_390_GOTPLT20 R_390 = 59 1792 R_390_TLS_GOTIE20 R_390 = 60 1793 ) 1794 1795 var r390Strings = []intName{ 1796 {0, "R_390_NONE"}, 1797 {1, "R_390_8"}, 1798 {2, "R_390_12"}, 1799 {3, "R_390_16"}, 1800 {4, "R_390_32"}, 1801 {5, "R_390_PC32"}, 1802 {6, "R_390_GOT12"}, 1803 {7, "R_390_GOT32"}, 1804 {8, "R_390_PLT32"}, 1805 {9, "R_390_COPY"}, 1806 {10, "R_390_GLOB_DAT"}, 1807 {11, "R_390_JMP_SLOT"}, 1808 {12, "R_390_RELATIVE"}, 1809 {13, "R_390_GOTOFF"}, 1810 {14, "R_390_GOTPC"}, 1811 {15, "R_390_GOT16"}, 1812 {16, "R_390_PC16"}, 1813 {17, "R_390_PC16DBL"}, 1814 {18, "R_390_PLT16DBL"}, 1815 {19, "R_390_PC32DBL"}, 1816 {20, "R_390_PLT32DBL"}, 1817 {21, "R_390_GOTPCDBL"}, 1818 {22, "R_390_64"}, 1819 {23, "R_390_PC64"}, 1820 {24, "R_390_GOT64"}, 1821 {25, "R_390_PLT64"}, 1822 {26, "R_390_GOTENT"}, 1823 {27, "R_390_GOTOFF16"}, 1824 {28, "R_390_GOTOFF64"}, 1825 {29, "R_390_GOTPLT12"}, 1826 {30, "R_390_GOTPLT16"}, 1827 {31, "R_390_GOTPLT32"}, 1828 {32, "R_390_GOTPLT64"}, 1829 {33, "R_390_GOTPLTENT"}, 1830 {34, "R_390_GOTPLTOFF16"}, 1831 {35, "R_390_GOTPLTOFF32"}, 1832 {36, "R_390_GOTPLTOFF64"}, 1833 {37, "R_390_TLS_LOAD"}, 1834 {38, "R_390_TLS_GDCALL"}, 1835 {39, "R_390_TLS_LDCALL"}, 1836 {40, "R_390_TLS_GD32"}, 1837 {41, "R_390_TLS_GD64"}, 1838 {42, "R_390_TLS_GOTIE12"}, 1839 {43, "R_390_TLS_GOTIE32"}, 1840 {44, "R_390_TLS_GOTIE64"}, 1841 {45, "R_390_TLS_LDM32"}, 1842 {46, "R_390_TLS_LDM64"}, 1843 {47, "R_390_TLS_IE32"}, 1844 {48, "R_390_TLS_IE64"}, 1845 {49, "R_390_TLS_IEENT"}, 1846 {50, "R_390_TLS_LE32"}, 1847 {51, "R_390_TLS_LE64"}, 1848 {52, "R_390_TLS_LDO32"}, 1849 {53, "R_390_TLS_LDO64"}, 1850 {54, "R_390_TLS_DTPMOD"}, 1851 {55, "R_390_TLS_DTPOFF"}, 1852 {56, "R_390_TLS_TPOFF"}, 1853 {57, "R_390_20"}, 1854 {58, "R_390_GOT20"}, 1855 {59, "R_390_GOTPLT20"}, 1856 {60, "R_390_TLS_GOTIE20"}, 1857 } 1858 1859 func (i R_390) String() string { return stringName(uint32(i), r390Strings, false) } 1860 func (i R_390) GoString() string { return stringName(uint32(i), r390Strings, true) } 1861 1862 // Relocation types for SPARC. 1863 type R_SPARC int 1864 1865 const ( 1866 R_SPARC_NONE R_SPARC = 0 1867 R_SPARC_8 R_SPARC = 1 1868 R_SPARC_16 R_SPARC = 2 1869 R_SPARC_32 R_SPARC = 3 1870 R_SPARC_DISP8 R_SPARC = 4 1871 R_SPARC_DISP16 R_SPARC = 5 1872 R_SPARC_DISP32 R_SPARC = 6 1873 R_SPARC_WDISP30 R_SPARC = 7 1874 R_SPARC_WDISP22 R_SPARC = 8 1875 R_SPARC_HI22 R_SPARC = 9 1876 R_SPARC_22 R_SPARC = 10 1877 R_SPARC_13 R_SPARC = 11 1878 R_SPARC_LO10 R_SPARC = 12 1879 R_SPARC_GOT10 R_SPARC = 13 1880 R_SPARC_GOT13 R_SPARC = 14 1881 R_SPARC_GOT22 R_SPARC = 15 1882 R_SPARC_PC10 R_SPARC = 16 1883 R_SPARC_PC22 R_SPARC = 17 1884 R_SPARC_WPLT30 R_SPARC = 18 1885 R_SPARC_COPY R_SPARC = 19 1886 R_SPARC_GLOB_DAT R_SPARC = 20 1887 R_SPARC_JMP_SLOT R_SPARC = 21 1888 R_SPARC_RELATIVE R_SPARC = 22 1889 R_SPARC_UA32 R_SPARC = 23 1890 R_SPARC_PLT32 R_SPARC = 24 1891 R_SPARC_HIPLT22 R_SPARC = 25 1892 R_SPARC_LOPLT10 R_SPARC = 26 1893 R_SPARC_PCPLT32 R_SPARC = 27 1894 R_SPARC_PCPLT22 R_SPARC = 28 1895 R_SPARC_PCPLT10 R_SPARC = 29 1896 R_SPARC_10 R_SPARC = 30 1897 R_SPARC_11 R_SPARC = 31 1898 R_SPARC_64 R_SPARC = 32 1899 R_SPARC_OLO10 R_SPARC = 33 1900 R_SPARC_HH22 R_SPARC = 34 1901 R_SPARC_HM10 R_SPARC = 35 1902 R_SPARC_LM22 R_SPARC = 36 1903 R_SPARC_PC_HH22 R_SPARC = 37 1904 R_SPARC_PC_HM10 R_SPARC = 38 1905 R_SPARC_PC_LM22 R_SPARC = 39 1906 R_SPARC_WDISP16 R_SPARC = 40 1907 R_SPARC_WDISP19 R_SPARC = 41 1908 R_SPARC_GLOB_JMP R_SPARC = 42 1909 R_SPARC_7 R_SPARC = 43 1910 R_SPARC_5 R_SPARC = 44 1911 R_SPARC_6 R_SPARC = 45 1912 R_SPARC_DISP64 R_SPARC = 46 1913 R_SPARC_PLT64 R_SPARC = 47 1914 R_SPARC_HIX22 R_SPARC = 48 1915 R_SPARC_LOX10 R_SPARC = 49 1916 R_SPARC_H44 R_SPARC = 50 1917 R_SPARC_M44 R_SPARC = 51 1918 R_SPARC_L44 R_SPARC = 52 1919 R_SPARC_REGISTER R_SPARC = 53 1920 R_SPARC_UA64 R_SPARC = 54 1921 R_SPARC_UA16 R_SPARC = 55 1922 ) 1923 1924 var rsparcStrings = []intName{ 1925 {0, "R_SPARC_NONE"}, 1926 {1, "R_SPARC_8"}, 1927 {2, "R_SPARC_16"}, 1928 {3, "R_SPARC_32"}, 1929 {4, "R_SPARC_DISP8"}, 1930 {5, "R_SPARC_DISP16"}, 1931 {6, "R_SPARC_DISP32"}, 1932 {7, "R_SPARC_WDISP30"}, 1933 {8, "R_SPARC_WDISP22"}, 1934 {9, "R_SPARC_HI22"}, 1935 {10, "R_SPARC_22"}, 1936 {11, "R_SPARC_13"}, 1937 {12, "R_SPARC_LO10"}, 1938 {13, "R_SPARC_GOT10"}, 1939 {14, "R_SPARC_GOT13"}, 1940 {15, "R_SPARC_GOT22"}, 1941 {16, "R_SPARC_PC10"}, 1942 {17, "R_SPARC_PC22"}, 1943 {18, "R_SPARC_WPLT30"}, 1944 {19, "R_SPARC_COPY"}, 1945 {20, "R_SPARC_GLOB_DAT"}, 1946 {21, "R_SPARC_JMP_SLOT"}, 1947 {22, "R_SPARC_RELATIVE"}, 1948 {23, "R_SPARC_UA32"}, 1949 {24, "R_SPARC_PLT32"}, 1950 {25, "R_SPARC_HIPLT22"}, 1951 {26, "R_SPARC_LOPLT10"}, 1952 {27, "R_SPARC_PCPLT32"}, 1953 {28, "R_SPARC_PCPLT22"}, 1954 {29, "R_SPARC_PCPLT10"}, 1955 {30, "R_SPARC_10"}, 1956 {31, "R_SPARC_11"}, 1957 {32, "R_SPARC_64"}, 1958 {33, "R_SPARC_OLO10"}, 1959 {34, "R_SPARC_HH22"}, 1960 {35, "R_SPARC_HM10"}, 1961 {36, "R_SPARC_LM22"}, 1962 {37, "R_SPARC_PC_HH22"}, 1963 {38, "R_SPARC_PC_HM10"}, 1964 {39, "R_SPARC_PC_LM22"}, 1965 {40, "R_SPARC_WDISP16"}, 1966 {41, "R_SPARC_WDISP19"}, 1967 {42, "R_SPARC_GLOB_JMP"}, 1968 {43, "R_SPARC_7"}, 1969 {44, "R_SPARC_5"}, 1970 {45, "R_SPARC_6"}, 1971 {46, "R_SPARC_DISP64"}, 1972 {47, "R_SPARC_PLT64"}, 1973 {48, "R_SPARC_HIX22"}, 1974 {49, "R_SPARC_LOX10"}, 1975 {50, "R_SPARC_H44"}, 1976 {51, "R_SPARC_M44"}, 1977 {52, "R_SPARC_L44"}, 1978 {53, "R_SPARC_REGISTER"}, 1979 {54, "R_SPARC_UA64"}, 1980 {55, "R_SPARC_UA16"}, 1981 } 1982 1983 func (i R_SPARC) String() string { return stringName(uint32(i), rsparcStrings, false) } 1984 func (i R_SPARC) GoString() string { return stringName(uint32(i), rsparcStrings, true) } 1985 1986 // Magic number for the elf trampoline, chosen wisely to be an immediate value. 1987 const ARM_MAGIC_TRAMP_NUMBER = 0x5c000003 1988 1989 // ELF32 File header. 1990 type Header32 struct { 1991 Ident [EI_NIDENT]byte /* File identification. */ 1992 Type uint16 /* File type. */ 1993 Machine uint16 /* Machine architecture. */ 1994 Version uint32 /* ELF format version. */ 1995 Entry uint32 /* Entry point. */ 1996 Phoff uint32 /* Program header file offset. */ 1997 Shoff uint32 /* Section header file offset. */ 1998 Flags uint32 /* Architecture-specific flags. */ 1999 Ehsize uint16 /* Size of ELF header in bytes. */ 2000 Phentsize uint16 /* Size of program header entry. */ 2001 Phnum uint16 /* Number of program header entries. */ 2002 Shentsize uint16 /* Size of section header entry. */ 2003 Shnum uint16 /* Number of section header entries. */ 2004 Shstrndx uint16 /* Section name strings section. */ 2005 } 2006 2007 // ELF32 Section header. 2008 type Section32 struct { 2009 Name uint32 /* Section name (index into the section header string table). */ 2010 Type uint32 /* Section type. */ 2011 Flags uint32 /* Section flags. */ 2012 Addr uint32 /* Address in memory image. */ 2013 Off uint32 /* Offset in file. */ 2014 Size uint32 /* Size in bytes. */ 2015 Link uint32 /* Index of a related section. */ 2016 Info uint32 /* Depends on section type. */ 2017 Addralign uint32 /* Alignment in bytes. */ 2018 Entsize uint32 /* Size of each entry in section. */ 2019 } 2020 2021 // ELF32 Program header. 2022 type Prog32 struct { 2023 Type uint32 /* Entry type. */ 2024 Off uint32 /* File offset of contents. */ 2025 Vaddr uint32 /* Virtual address in memory image. */ 2026 Paddr uint32 /* Physical address (not used). */ 2027 Filesz uint32 /* Size of contents in file. */ 2028 Memsz uint32 /* Size of contents in memory. */ 2029 Flags uint32 /* Access permission flags. */ 2030 Align uint32 /* Alignment in memory and file. */ 2031 } 2032 2033 // ELF32 Dynamic structure. The ".dynamic" section contains an array of them. 2034 type Dyn32 struct { 2035 Tag int32 /* Entry type. */ 2036 Val uint32 /* Integer/Address value. */ 2037 } 2038 2039 // ELF32 Compression header. 2040 type Chdr32 struct { 2041 Type uint32 2042 Size uint32 2043 Addralign uint32 2044 } 2045 2046 /* 2047 * Relocation entries. 2048 */ 2049 2050 // ELF32 Relocations that don't need an addend field. 2051 type Rel32 struct { 2052 Off uint32 /* Location to be relocated. */ 2053 Info uint32 /* Relocation type and symbol index. */ 2054 } 2055 2056 // ELF32 Relocations that need an addend field. 2057 type Rela32 struct { 2058 Off uint32 /* Location to be relocated. */ 2059 Info uint32 /* Relocation type and symbol index. */ 2060 Addend int32 /* Addend. */ 2061 } 2062 2063 func R_SYM32(info uint32) uint32 { return info >> 8 } 2064 func R_TYPE32(info uint32) uint32 { return info & 0xff } 2065 func R_INFO32(sym, typ uint32) uint32 { return sym<<8 | typ } 2066 2067 // ELF32 Symbol. 2068 type Sym32 struct { 2069 Name uint32 2070 Value uint32 2071 Size uint32 2072 Info uint8 2073 Other uint8 2074 Shndx uint16 2075 } 2076 2077 const Sym32Size = 16 2078 2079 func ST_BIND(info uint8) SymBind { return SymBind(info >> 4) } 2080 func ST_TYPE(info uint8) SymType { return SymType(info & 0xF) } 2081 func ST_INFO(bind SymBind, typ SymType) uint8 { 2082 return uint8(bind)<<4 | uint8(typ)&0xf 2083 } 2084 func ST_VISIBILITY(other uint8) SymVis { return SymVis(other & 3) } 2085 2086 /* 2087 * ELF64 2088 */ 2089 2090 // ELF64 file header. 2091 type Header64 struct { 2092 Ident [EI_NIDENT]byte /* File identification. */ 2093 Type uint16 /* File type. */ 2094 Machine uint16 /* Machine architecture. */ 2095 Version uint32 /* ELF format version. */ 2096 Entry uint64 /* Entry point. */ 2097 Phoff uint64 /* Program header file offset. */ 2098 Shoff uint64 /* Section header file offset. */ 2099 Flags uint32 /* Architecture-specific flags. */ 2100 Ehsize uint16 /* Size of ELF header in bytes. */ 2101 Phentsize uint16 /* Size of program header entry. */ 2102 Phnum uint16 /* Number of program header entries. */ 2103 Shentsize uint16 /* Size of section header entry. */ 2104 Shnum uint16 /* Number of section header entries. */ 2105 Shstrndx uint16 /* Section name strings section. */ 2106 } 2107 2108 // ELF64 Section header. 2109 type Section64 struct { 2110 Name uint32 /* Section name (index into the section header string table). */ 2111 Type uint32 /* Section type. */ 2112 Flags uint64 /* Section flags. */ 2113 Addr uint64 /* Address in memory image. */ 2114 Off uint64 /* Offset in file. */ 2115 Size uint64 /* Size in bytes. */ 2116 Link uint32 /* Index of a related section. */ 2117 Info uint32 /* Depends on section type. */ 2118 Addralign uint64 /* Alignment in bytes. */ 2119 Entsize uint64 /* Size of each entry in section. */ 2120 } 2121 2122 // ELF64 Program header. 2123 type Prog64 struct { 2124 Type uint32 /* Entry type. */ 2125 Flags uint32 /* Access permission flags. */ 2126 Off uint64 /* File offset of contents. */ 2127 Vaddr uint64 /* Virtual address in memory image. */ 2128 Paddr uint64 /* Physical address (not used). */ 2129 Filesz uint64 /* Size of contents in file. */ 2130 Memsz uint64 /* Size of contents in memory. */ 2131 Align uint64 /* Alignment in memory and file. */ 2132 } 2133 2134 // ELF64 Dynamic structure. The ".dynamic" section contains an array of them. 2135 type Dyn64 struct { 2136 Tag int64 /* Entry type. */ 2137 Val uint64 /* Integer/address value */ 2138 } 2139 2140 // ELF64 Compression header. 2141 type Chdr64 struct { 2142 Type uint32 2143 _ uint32 /* Reserved. */ 2144 Size uint64 2145 Addralign uint64 2146 } 2147 2148 /* 2149 * Relocation entries. 2150 */ 2151 2152 /* ELF64 relocations that don't need an addend field. */ 2153 type Rel64 struct { 2154 Off uint64 /* Location to be relocated. */ 2155 Info uint64 /* Relocation type and symbol index. */ 2156 } 2157 2158 /* ELF64 relocations that need an addend field. */ 2159 type Rela64 struct { 2160 Off uint64 /* Location to be relocated. */ 2161 Info uint64 /* Relocation type and symbol index. */ 2162 Addend int64 /* Addend. */ 2163 } 2164 2165 func R_SYM64(info uint64) uint32 { return uint32(info >> 32) } 2166 func R_TYPE64(info uint64) uint32 { return uint32(info) } 2167 func R_INFO(sym, typ uint32) uint64 { return uint64(sym)<<32 | uint64(typ) } 2168 2169 // ELF64 symbol table entries. 2170 type Sym64 struct { 2171 Name uint32 /* String table index of name. */ 2172 Info uint8 /* Type and binding information. */ 2173 Other uint8 /* Reserved (not used). */ 2174 Shndx uint16 /* Section index of symbol. */ 2175 Value uint64 /* Symbol value. */ 2176 Size uint64 /* Size of associated object. */ 2177 } 2178 2179 const Sym64Size = 24 2180 2181 type intName struct { 2182 i uint32 2183 s string 2184 } 2185 2186 func stringName(i uint32, names []intName, goSyntax bool) string { 2187 for _, n := range names { 2188 if n.i == i { 2189 if goSyntax { 2190 return "elf." + n.s 2191 } 2192 return n.s 2193 } 2194 } 2195 2196 // second pass - look for smaller to add with. 2197 // assume sorted already 2198 for j := len(names) - 1; j >= 0; j-- { 2199 n := names[j] 2200 if n.i < i { 2201 s := n.s 2202 if goSyntax { 2203 s = "elf." + s 2204 } 2205 return s + "+" + strconv.FormatUint(uint64(i-n.i), 10) 2206 } 2207 } 2208 2209 return strconv.FormatUint(uint64(i), 10) 2210 } 2211 2212 func flagName(i uint32, names []intName, goSyntax bool) string { 2213 s := "" 2214 for _, n := range names { 2215 if n.i&i == n.i { 2216 if len(s) > 0 { 2217 s += "+" 2218 } 2219 if goSyntax { 2220 s += "elf." 2221 } 2222 s += n.s 2223 i -= n.i 2224 } 2225 } 2226 if len(s) == 0 { 2227 return "0x" + strconv.FormatUint(uint64(i), 16) 2228 } 2229 if i != 0 { 2230 s += "+0x" + strconv.FormatUint(uint64(i), 16) 2231 } 2232 return s 2233 }