17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5c13de8f6Sab196087 * Common Development and Distribution License (the "License"). 6c13de8f6Sab196087 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 2234bdffbfSGarrett D'Amore * Copyright 2012 DEY Storage Systems, Inc. All rights reserved. 23*f971a346SBryan Cantrill * Copyright (c) 2013, Joyent, Inc. All rights reserved. 2434bdffbfSGarrett D'Amore */ 2534bdffbfSGarrett D'Amore /* 2669112eddSAli Bahrami * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 277c478bd9Sstevel@tonic-gate * Use is subject to license terms. 287c478bd9Sstevel@tonic-gate */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 317c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifndef _SYS_ELF_H 357c478bd9Sstevel@tonic-gate #define _SYS_ELF_H 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <sys/elftypes.h> 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef __cplusplus 407c478bd9Sstevel@tonic-gate extern "C" { 417c478bd9Sstevel@tonic-gate #endif 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #define ELF32_FSZ_ADDR 4 447c478bd9Sstevel@tonic-gate #define ELF32_FSZ_HALF 2 457c478bd9Sstevel@tonic-gate #define ELF32_FSZ_OFF 4 467c478bd9Sstevel@tonic-gate #define ELF32_FSZ_SWORD 4 477c478bd9Sstevel@tonic-gate #define ELF32_FSZ_WORD 4 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define ELF64_FSZ_ADDR 8 507c478bd9Sstevel@tonic-gate #define ELF64_FSZ_HALF 2 517c478bd9Sstevel@tonic-gate #define ELF64_FSZ_OFF 8 527c478bd9Sstevel@tonic-gate #define ELF64_FSZ_SWORD 4 537c478bd9Sstevel@tonic-gate #define ELF64_FSZ_WORD 4 547c478bd9Sstevel@tonic-gate #define ELF64_FSZ_SXWORD 8 557c478bd9Sstevel@tonic-gate #define ELF64_FSZ_XWORD 8 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* 587c478bd9Sstevel@tonic-gate * "Enumerations" below use ...NUM as the number of 597c478bd9Sstevel@tonic-gate * values in the list. It should be 1 greater than the 607c478bd9Sstevel@tonic-gate * highest "real" value. 617c478bd9Sstevel@tonic-gate */ 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate /* 647c478bd9Sstevel@tonic-gate * ELF header 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate #define EI_NIDENT 16 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate typedef struct { 707c478bd9Sstevel@tonic-gate unsigned char e_ident[EI_NIDENT]; /* ident bytes */ 717c478bd9Sstevel@tonic-gate Elf32_Half e_type; /* file type */ 727c478bd9Sstevel@tonic-gate Elf32_Half e_machine; /* target machine */ 737c478bd9Sstevel@tonic-gate Elf32_Word e_version; /* file version */ 747c478bd9Sstevel@tonic-gate Elf32_Addr e_entry; /* start address */ 757c478bd9Sstevel@tonic-gate Elf32_Off e_phoff; /* phdr file offset */ 767c478bd9Sstevel@tonic-gate Elf32_Off e_shoff; /* shdr file offset */ 777c478bd9Sstevel@tonic-gate Elf32_Word e_flags; /* file flags */ 787c478bd9Sstevel@tonic-gate Elf32_Half e_ehsize; /* sizeof ehdr */ 797c478bd9Sstevel@tonic-gate Elf32_Half e_phentsize; /* sizeof phdr */ 807c478bd9Sstevel@tonic-gate Elf32_Half e_phnum; /* number phdrs */ 817c478bd9Sstevel@tonic-gate Elf32_Half e_shentsize; /* sizeof shdr */ 827c478bd9Sstevel@tonic-gate Elf32_Half e_shnum; /* number shdrs */ 837c478bd9Sstevel@tonic-gate Elf32_Half e_shstrndx; /* shdr string index */ 847c478bd9Sstevel@tonic-gate } Elf32_Ehdr; 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE) 877c478bd9Sstevel@tonic-gate typedef struct { 887c478bd9Sstevel@tonic-gate unsigned char e_ident[EI_NIDENT]; /* ident bytes */ 897c478bd9Sstevel@tonic-gate Elf64_Half e_type; /* file type */ 907c478bd9Sstevel@tonic-gate Elf64_Half e_machine; /* target machine */ 917c478bd9Sstevel@tonic-gate Elf64_Word e_version; /* file version */ 927c478bd9Sstevel@tonic-gate Elf64_Addr e_entry; /* start address */ 937c478bd9Sstevel@tonic-gate Elf64_Off e_phoff; /* phdr file offset */ 947c478bd9Sstevel@tonic-gate Elf64_Off e_shoff; /* shdr file offset */ 957c478bd9Sstevel@tonic-gate Elf64_Word e_flags; /* file flags */ 967c478bd9Sstevel@tonic-gate Elf64_Half e_ehsize; /* sizeof ehdr */ 977c478bd9Sstevel@tonic-gate Elf64_Half e_phentsize; /* sizeof phdr */ 987c478bd9Sstevel@tonic-gate Elf64_Half e_phnum; /* number phdrs */ 997c478bd9Sstevel@tonic-gate Elf64_Half e_shentsize; /* sizeof shdr */ 1007c478bd9Sstevel@tonic-gate Elf64_Half e_shnum; /* number shdrs */ 1017c478bd9Sstevel@tonic-gate Elf64_Half e_shstrndx; /* shdr string index */ 1027c478bd9Sstevel@tonic-gate } Elf64_Ehdr; 1037c478bd9Sstevel@tonic-gate #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate #define EI_MAG0 0 /* e_ident[] indexes */ 1077c478bd9Sstevel@tonic-gate #define EI_MAG1 1 1087c478bd9Sstevel@tonic-gate #define EI_MAG2 2 1097c478bd9Sstevel@tonic-gate #define EI_MAG3 3 1107c478bd9Sstevel@tonic-gate #define EI_CLASS 4 /* File class */ 1117c478bd9Sstevel@tonic-gate #define EI_DATA 5 /* Data encoding */ 1127c478bd9Sstevel@tonic-gate #define EI_VERSION 6 /* File version */ 1137c478bd9Sstevel@tonic-gate #define EI_OSABI 7 /* Operating system/ABI identification */ 1147c478bd9Sstevel@tonic-gate #define EI_ABIVERSION 8 /* ABI version */ 1157c478bd9Sstevel@tonic-gate #define EI_PAD 9 /* Start of padding bytes */ 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate #define ELFMAG0 0x7f /* EI_MAG */ 1187c478bd9Sstevel@tonic-gate #define ELFMAG1 'E' 1197c478bd9Sstevel@tonic-gate #define ELFMAG2 'L' 1207c478bd9Sstevel@tonic-gate #define ELFMAG3 'F' 1217c478bd9Sstevel@tonic-gate #define ELFMAG "\177ELF" 1227c478bd9Sstevel@tonic-gate #define SELFMAG 4 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate #define ELFCLASSNONE 0 /* EI_CLASS */ 1257c478bd9Sstevel@tonic-gate #define ELFCLASS32 1 1267c478bd9Sstevel@tonic-gate #define ELFCLASS64 2 1277c478bd9Sstevel@tonic-gate #define ELFCLASSNUM 3 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate #define ELFDATANONE 0 /* EI_DATA */ 1307c478bd9Sstevel@tonic-gate #define ELFDATA2LSB 1 1317c478bd9Sstevel@tonic-gate #define ELFDATA2MSB 2 1327c478bd9Sstevel@tonic-gate #define ELFDATANUM 3 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate #define ET_NONE 0 /* e_type */ 1357c478bd9Sstevel@tonic-gate #define ET_REL 1 1367c478bd9Sstevel@tonic-gate #define ET_EXEC 2 1377c478bd9Sstevel@tonic-gate #define ET_DYN 3 1387c478bd9Sstevel@tonic-gate #define ET_CORE 4 1397c478bd9Sstevel@tonic-gate #define ET_NUM 5 1407c478bd9Sstevel@tonic-gate #define ET_LOOS 0xfe00 /* OS specific range */ 1417c478bd9Sstevel@tonic-gate #define ET_LOSUNW 0xfeff 1427c478bd9Sstevel@tonic-gate #define ET_SUNWPSEUDO 0xfeff 1437c478bd9Sstevel@tonic-gate #define ET_HISUNW 0xfeff 1447c478bd9Sstevel@tonic-gate #define ET_HIOS 0xfeff 1457c478bd9Sstevel@tonic-gate #define ET_LOPROC 0xff00 /* processor specific range */ 1467c478bd9Sstevel@tonic-gate #define ET_HIPROC 0xffff 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate #define ET_LOPROC 0xff00 /* processor specific range */ 1497c478bd9Sstevel@tonic-gate #define ET_HIPROC 0xffff 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate #define EM_NONE 0 /* e_machine */ 1527c478bd9Sstevel@tonic-gate #define EM_M32 1 /* AT&T WE 32100 */ 1537c478bd9Sstevel@tonic-gate #define EM_SPARC 2 /* Sun SPARC */ 1547c478bd9Sstevel@tonic-gate #define EM_386 3 /* Intel 80386 */ 1557c478bd9Sstevel@tonic-gate #define EM_68K 4 /* Motorola 68000 */ 1567c478bd9Sstevel@tonic-gate #define EM_88K 5 /* Motorola 88000 */ 1577c478bd9Sstevel@tonic-gate #define EM_486 6 /* Intel 80486 */ 1587c478bd9Sstevel@tonic-gate #define EM_860 7 /* Intel i860 */ 1597c478bd9Sstevel@tonic-gate #define EM_MIPS 8 /* MIPS RS3000 Big-Endian */ 1607c478bd9Sstevel@tonic-gate #define EM_S370 9 /* IBM System/370 Processor */ 1617c478bd9Sstevel@tonic-gate #define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-Endian */ 1627c478bd9Sstevel@tonic-gate #define EM_RS6000 11 /* RS6000 */ 1637c478bd9Sstevel@tonic-gate #define EM_UNKNOWN12 12 1647c478bd9Sstevel@tonic-gate #define EM_UNKNOWN13 13 1657c478bd9Sstevel@tonic-gate #define EM_UNKNOWN14 14 1667c478bd9Sstevel@tonic-gate #define EM_PA_RISC 15 /* PA-RISC */ 1671638af81Sab196087 #define EM_PARISC EM_PA_RISC /* Alias: GNU compatibility */ 1687c478bd9Sstevel@tonic-gate #define EM_nCUBE 16 /* nCUBE */ 1697c478bd9Sstevel@tonic-gate #define EM_VPP500 17 /* Fujitsu VPP500 */ 1707c478bd9Sstevel@tonic-gate #define EM_SPARC32PLUS 18 /* Sun SPARC 32+ */ 1717c478bd9Sstevel@tonic-gate #define EM_960 19 /* Intel 80960 */ 1727c478bd9Sstevel@tonic-gate #define EM_PPC 20 /* PowerPC */ 1737c478bd9Sstevel@tonic-gate #define EM_PPC64 21 /* 64-bit PowerPC */ 1741638af81Sab196087 #define EM_S390 22 /* IBM System/390 Processor */ 1751638af81Sab196087 #define EM_UNKNOWN22 EM_S390 /* Alias: Older published name */ 1767c478bd9Sstevel@tonic-gate #define EM_UNKNOWN23 23 1777c478bd9Sstevel@tonic-gate #define EM_UNKNOWN24 24 1787c478bd9Sstevel@tonic-gate #define EM_UNKNOWN25 25 1797c478bd9Sstevel@tonic-gate #define EM_UNKNOWN26 26 1807c478bd9Sstevel@tonic-gate #define EM_UNKNOWN27 27 1817c478bd9Sstevel@tonic-gate #define EM_UNKNOWN28 28 1827c478bd9Sstevel@tonic-gate #define EM_UNKNOWN29 29 1837c478bd9Sstevel@tonic-gate #define EM_UNKNOWN30 30 1847c478bd9Sstevel@tonic-gate #define EM_UNKNOWN31 31 1857c478bd9Sstevel@tonic-gate #define EM_UNKNOWN32 32 1867c478bd9Sstevel@tonic-gate #define EM_UNKNOWN33 33 1877c478bd9Sstevel@tonic-gate #define EM_UNKNOWN34 34 1887c478bd9Sstevel@tonic-gate #define EM_UNKNOWN35 35 1897c478bd9Sstevel@tonic-gate #define EM_V800 36 /* NEX V800 */ 1907c478bd9Sstevel@tonic-gate #define EM_FR20 37 /* Fujitsu FR20 */ 1917c478bd9Sstevel@tonic-gate #define EM_RH32 38 /* TRW RH-32 */ 1927c478bd9Sstevel@tonic-gate #define EM_RCE 39 /* Motorola RCE */ 1937c478bd9Sstevel@tonic-gate #define EM_ARM 40 /* Advanced RISC Marchines ARM */ 1947c478bd9Sstevel@tonic-gate #define EM_ALPHA 41 /* Digital Alpha */ 1957c478bd9Sstevel@tonic-gate #define EM_SH 42 /* Hitachi SH */ 1967c478bd9Sstevel@tonic-gate #define EM_SPARCV9 43 /* Sun SPARC V9 (64-bit) */ 1977c478bd9Sstevel@tonic-gate #define EM_TRICORE 44 /* Siemens Tricore embedded processor */ 1987c478bd9Sstevel@tonic-gate #define EM_ARC 45 /* Argonaut RISC Core, */ 1997c478bd9Sstevel@tonic-gate /* Argonaut Technologies Inc. */ 2007c478bd9Sstevel@tonic-gate #define EM_H8_300 46 /* Hitachi H8/300 */ 2017c478bd9Sstevel@tonic-gate #define EM_H8_300H 47 /* Hitachi H8/300H */ 2027c478bd9Sstevel@tonic-gate #define EM_H8S 48 /* Hitachi H8S */ 2037c478bd9Sstevel@tonic-gate #define EM_H8_500 49 /* Hitachi H8/500 */ 2047c478bd9Sstevel@tonic-gate #define EM_IA_64 50 /* Intel IA64 */ 2057c478bd9Sstevel@tonic-gate #define EM_MIPS_X 51 /* Stanford MIPS-X */ 2067c478bd9Sstevel@tonic-gate #define EM_COLDFIRE 52 /* Motorola ColdFire */ 2077c478bd9Sstevel@tonic-gate #define EM_68HC12 53 /* Motorola M68HC12 */ 2087c478bd9Sstevel@tonic-gate #define EM_MMA 54 /* Fujitsu MMA Mulimedia Accelerator */ 2097c478bd9Sstevel@tonic-gate #define EM_PCP 55 /* Siemens PCP */ 2107c478bd9Sstevel@tonic-gate #define EM_NCPU 56 /* Sony nCPU embedded RISC processor */ 2117c478bd9Sstevel@tonic-gate #define EM_NDR1 57 /* Denso NDR1 microprocessor */ 2127c478bd9Sstevel@tonic-gate #define EM_STARCORE 58 /* Motorola Star*Core processor */ 2137c478bd9Sstevel@tonic-gate #define EM_ME16 59 /* Toyota ME16 processor */ 2147c478bd9Sstevel@tonic-gate #define EM_ST100 60 /* STMicroelectronics ST100 processor */ 2157c478bd9Sstevel@tonic-gate #define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ */ 2167c478bd9Sstevel@tonic-gate /* embedded processor family */ 2177c478bd9Sstevel@tonic-gate #define EM_AMD64 62 /* AMDs x86-64 architecture */ 2187c478bd9Sstevel@tonic-gate #define EM_X86_64 EM_AMD64 /* (compatibility) */ 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate #define EM_PDSP 63 /* Sony DSP Processor */ 2217c478bd9Sstevel@tonic-gate #define EM_UNKNOWN64 64 2227c478bd9Sstevel@tonic-gate #define EM_UNKNOWN65 65 2237c478bd9Sstevel@tonic-gate #define EM_FX66 66 /* Siemens FX66 microcontroller */ 2247c478bd9Sstevel@tonic-gate #define EM_ST9PLUS 67 /* STMicroelectronics ST9+8/16 bit */ 2257c478bd9Sstevel@tonic-gate /* microcontroller */ 2267c478bd9Sstevel@tonic-gate #define EM_ST7 68 /* STMicroelectronics ST7 8-bit */ 2277c478bd9Sstevel@tonic-gate /* microcontroller */ 2287c478bd9Sstevel@tonic-gate #define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */ 2297c478bd9Sstevel@tonic-gate #define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */ 2307c478bd9Sstevel@tonic-gate #define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */ 2317c478bd9Sstevel@tonic-gate #define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */ 2327c478bd9Sstevel@tonic-gate #define EM_SVX 73 /* Silicon Graphics SVx */ 2337c478bd9Sstevel@tonic-gate #define EM_ST19 74 /* STMicroelectronics ST19 8-bit */ 2347c478bd9Sstevel@tonic-gate /* microcontroller */ 2357c478bd9Sstevel@tonic-gate #define EM_VAX 75 /* Digital VAX */ 2367c478bd9Sstevel@tonic-gate #define EM_CRIS 76 /* Axis Communications 32-bit */ 2377c478bd9Sstevel@tonic-gate /* embedded processor */ 2387c478bd9Sstevel@tonic-gate #define EM_JAVELIN 77 /* Infineon Technologies 32-bit */ 2397c478bd9Sstevel@tonic-gate /* embedded processor */ 2407c478bd9Sstevel@tonic-gate #define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ 2417c478bd9Sstevel@tonic-gate #define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ 2427c478bd9Sstevel@tonic-gate #define EM_MMIX 80 /* Donald Knuth's educational */ 2437c478bd9Sstevel@tonic-gate /* 64-bit processor */ 2447c478bd9Sstevel@tonic-gate #define EM_HUANY 81 /* Harvard University */ 2457c478bd9Sstevel@tonic-gate /* machine-independent */ 2467c478bd9Sstevel@tonic-gate /* object files */ 2477c478bd9Sstevel@tonic-gate #define EM_PRISM 82 /* SiTera Prism */ 2487c478bd9Sstevel@tonic-gate #define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ 2497c478bd9Sstevel@tonic-gate #define EM_FR30 84 /* Fujitsu FR30 */ 2507c478bd9Sstevel@tonic-gate #define EM_D10V 85 /* Mitsubishi D10V */ 2517c478bd9Sstevel@tonic-gate #define EM_D30V 86 /* Mitsubishi D30V */ 2527c478bd9Sstevel@tonic-gate #define EM_V850 87 /* NEC v850 */ 2537c478bd9Sstevel@tonic-gate #define EM_M32R 88 /* Mitsubishi M32R */ 2547c478bd9Sstevel@tonic-gate #define EM_MN10300 89 /* Matsushita MN10300 */ 2557c478bd9Sstevel@tonic-gate #define EM_MN10200 90 /* Matsushita MN10200 */ 2567c478bd9Sstevel@tonic-gate #define EM_PJ 91 /* picoJava */ 2577c478bd9Sstevel@tonic-gate #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ 2587c478bd9Sstevel@tonic-gate #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ 2597c478bd9Sstevel@tonic-gate #define EM_XTENSA 94 /* Tensilica Xtensa architecture */ 2607c478bd9Sstevel@tonic-gate #define EM_NUM 95 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate #define EV_NONE 0 /* e_version, EI_VERSION */ 2637c478bd9Sstevel@tonic-gate #define EV_CURRENT 1 2647c478bd9Sstevel@tonic-gate #define EV_NUM 2 2657c478bd9Sstevel@tonic-gate 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate #define ELFOSABI_NONE 0 /* No extensions or unspecified */ 2681638af81Sab196087 #define ELFOSABI_SYSV ELFOSABI_NONE 2697c478bd9Sstevel@tonic-gate #define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */ 2707c478bd9Sstevel@tonic-gate #define ELFOSABI_NETBSD 2 /* NetBSD */ 2717c478bd9Sstevel@tonic-gate #define ELFOSABI_LINUX 3 /* Linux */ 2727c478bd9Sstevel@tonic-gate #define ELFOSABI_UNKNOWN4 4 2737c478bd9Sstevel@tonic-gate #define ELFOSABI_UNKNOWN5 5 2747c478bd9Sstevel@tonic-gate #define ELFOSABI_SOLARIS 6 /* Sun Solaris */ 2757c478bd9Sstevel@tonic-gate #define ELFOSABI_AIX 7 /* AIX */ 2767c478bd9Sstevel@tonic-gate #define ELFOSABI_IRIX 8 /* IRIX */ 2777c478bd9Sstevel@tonic-gate #define ELFOSABI_FREEBSD 9 /* FreeBSD */ 2787c478bd9Sstevel@tonic-gate #define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX */ 2797c478bd9Sstevel@tonic-gate #define ELFOSABI_MODESTO 11 /* Novell Modesto */ 2807c478bd9Sstevel@tonic-gate #define ELFOSABI_OPENBSD 12 /* Open BSD */ 2811638af81Sab196087 #define ELFOSABI_OPENVMS 13 /* Open VMS */ 2821638af81Sab196087 #define ELFOSABI_NSK 14 /* Hewlett-Packard Non-Stop Kernel */ 2831638af81Sab196087 #define ELFOSABI_AROS 15 /* Amiga Research OS */ 2841638af81Sab196087 #define ELFOSABI_ARM 97 /* ARM */ 2851638af81Sab196087 #define ELFOSABI_STANDALONE 255 /* standalone (embedded) application */ 2867c478bd9Sstevel@tonic-gate 2874f680cc6SAli Bahrami #define EAV_SUNW_NONE 0 /* EI_ABIVERSION */ 2884f680cc6SAli Bahrami #define EAV_SUNW_CURRENT 1 2894f680cc6SAli Bahrami #define EAV_SUNW_NUM 2 2904f680cc6SAli Bahrami 2914f680cc6SAli Bahrami 2927c478bd9Sstevel@tonic-gate /* 2937c478bd9Sstevel@tonic-gate * Program header 2947c478bd9Sstevel@tonic-gate */ 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate typedef struct { 2977c478bd9Sstevel@tonic-gate Elf32_Word p_type; /* entry type */ 2987c478bd9Sstevel@tonic-gate Elf32_Off p_offset; /* file offset */ 2997c478bd9Sstevel@tonic-gate Elf32_Addr p_vaddr; /* virtual address */ 3007c478bd9Sstevel@tonic-gate Elf32_Addr p_paddr; /* physical address */ 3017c478bd9Sstevel@tonic-gate Elf32_Word p_filesz; /* file size */ 3027c478bd9Sstevel@tonic-gate Elf32_Word p_memsz; /* memory size */ 3037c478bd9Sstevel@tonic-gate Elf32_Word p_flags; /* entry flags */ 3047c478bd9Sstevel@tonic-gate Elf32_Word p_align; /* memory/file alignment */ 3057c478bd9Sstevel@tonic-gate } Elf32_Phdr; 3067c478bd9Sstevel@tonic-gate 3077c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE) 3087c478bd9Sstevel@tonic-gate typedef struct { 3097c478bd9Sstevel@tonic-gate Elf64_Word p_type; /* entry type */ 3107c478bd9Sstevel@tonic-gate Elf64_Word p_flags; /* entry flags */ 3117c478bd9Sstevel@tonic-gate Elf64_Off p_offset; /* file offset */ 3127c478bd9Sstevel@tonic-gate Elf64_Addr p_vaddr; /* virtual address */ 3137c478bd9Sstevel@tonic-gate Elf64_Addr p_paddr; /* physical address */ 3147c478bd9Sstevel@tonic-gate Elf64_Xword p_filesz; /* file size */ 3157c478bd9Sstevel@tonic-gate Elf64_Xword p_memsz; /* memory size */ 3167c478bd9Sstevel@tonic-gate Elf64_Xword p_align; /* memory/file alignment */ 3177c478bd9Sstevel@tonic-gate } Elf64_Phdr; 3187c478bd9Sstevel@tonic-gate #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate #define PT_NULL 0 /* p_type */ 3227c478bd9Sstevel@tonic-gate #define PT_LOAD 1 3237c478bd9Sstevel@tonic-gate #define PT_DYNAMIC 2 3247c478bd9Sstevel@tonic-gate #define PT_INTERP 3 3257c478bd9Sstevel@tonic-gate #define PT_NOTE 4 3267c478bd9Sstevel@tonic-gate #define PT_SHLIB 5 3277c478bd9Sstevel@tonic-gate #define PT_PHDR 6 3287c478bd9Sstevel@tonic-gate #define PT_TLS 7 3297c478bd9Sstevel@tonic-gate #define PT_NUM 8 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate #define PT_LOOS 0x60000000 /* OS specific range */ 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate /* 3347e16fca0SAli Bahrami * PT_SUNW_UNWIND and PT_SUNW_EH_FRAME perform the same function, 3357e16fca0SAli Bahrami * providing access to the .eh_frame_hdr section of the object. 3367e16fca0SAli Bahrami * PT_SUNW_UNWIND is the original value, while PT_SUNW_EH_FRAME is 3377e16fca0SAli Bahrami * required by the amd64 psABI. The Solaris link-editor (ld) tags output 3387e16fca0SAli Bahrami * objects with PT_SUNW_UNWIND, but the Solaris runtime linker (ld.so.1) 3397e16fca0SAli Bahrami * will accept and use either value. 3407c478bd9Sstevel@tonic-gate */ 3417e16fca0SAli Bahrami #define PT_SUNW_UNWIND 0x6464e550 3427e16fca0SAli Bahrami #define PT_SUNW_EH_FRAME 0x6474e550 3437e16fca0SAli Bahrami #define PT_GNU_EH_FRAME PT_SUNW_EH_FRAME 3447c478bd9Sstevel@tonic-gate 3457e16fca0SAli Bahrami /* 3467e16fca0SAli Bahrami * Linux specific program headers not currently used by Solaris 3477e16fca0SAli Bahrami */ 3487e16fca0SAli Bahrami #define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */ 3497e16fca0SAli Bahrami #define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */ 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate #define PT_LOSUNW 0x6ffffffa 35235450702SAli Bahrami #define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment (unused) */ 3537c478bd9Sstevel@tonic-gate #define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */ 3547c478bd9Sstevel@tonic-gate #define PT_SUNWDTRACE 0x6ffffffc /* private */ 3557c478bd9Sstevel@tonic-gate #define PT_SUNWCAP 0x6ffffffd /* hard/soft capabilities segment */ 3567c478bd9Sstevel@tonic-gate #define PT_HISUNW 0x6fffffff 3577c478bd9Sstevel@tonic-gate #define PT_HIOS 0x6fffffff 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate #define PT_LOPROC 0x70000000 /* processor specific range */ 3607c478bd9Sstevel@tonic-gate #define PT_HIPROC 0x7fffffff 3617c478bd9Sstevel@tonic-gate 3627c478bd9Sstevel@tonic-gate #define PF_R 0x4 /* p_flags */ 3637c478bd9Sstevel@tonic-gate #define PF_W 0x2 3647c478bd9Sstevel@tonic-gate #define PF_X 0x1 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate #define PF_MASKOS 0x0ff00000 /* OS specific values */ 3677c478bd9Sstevel@tonic-gate #define PF_MASKPROC 0xf0000000 /* processor specific values */ 3687c478bd9Sstevel@tonic-gate 3697c478bd9Sstevel@tonic-gate #define PF_SUNW_FAILURE 0x00100000 /* mapping absent due to failure */ 370*f971a346SBryan Cantrill #define PF_SUNW_KILLED 0x00200000 /* signal received during dump */ 371*f971a346SBryan Cantrill #define PF_SUNW_SIGINFO 0x00400000 /* segment has killing sig's siginfo */ 3727c478bd9Sstevel@tonic-gate 37330da1432Sahl #define PN_XNUM 0xffff /* extended program header index */ 37430da1432Sahl 3757c478bd9Sstevel@tonic-gate /* 3767c478bd9Sstevel@tonic-gate * Section header 3777c478bd9Sstevel@tonic-gate */ 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate typedef struct { 3807c478bd9Sstevel@tonic-gate Elf32_Word sh_name; /* section name */ 3817c478bd9Sstevel@tonic-gate Elf32_Word sh_type; /* SHT_... */ 3827c478bd9Sstevel@tonic-gate Elf32_Word sh_flags; /* SHF_... */ 3837c478bd9Sstevel@tonic-gate Elf32_Addr sh_addr; /* virtual address */ 3847c478bd9Sstevel@tonic-gate Elf32_Off sh_offset; /* file offset */ 3857c478bd9Sstevel@tonic-gate Elf32_Word sh_size; /* section size */ 3867c478bd9Sstevel@tonic-gate Elf32_Word sh_link; /* misc info */ 3877c478bd9Sstevel@tonic-gate Elf32_Word sh_info; /* misc info */ 3887c478bd9Sstevel@tonic-gate Elf32_Word sh_addralign; /* memory alignment */ 3897c478bd9Sstevel@tonic-gate Elf32_Word sh_entsize; /* entry size if table */ 3907c478bd9Sstevel@tonic-gate } Elf32_Shdr; 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE) 3937c478bd9Sstevel@tonic-gate typedef struct { 3947c478bd9Sstevel@tonic-gate Elf64_Word sh_name; /* section name */ 3957c478bd9Sstevel@tonic-gate Elf64_Word sh_type; /* SHT_... */ 3967c478bd9Sstevel@tonic-gate Elf64_Xword sh_flags; /* SHF_... */ 3977c478bd9Sstevel@tonic-gate Elf64_Addr sh_addr; /* virtual address */ 3987c478bd9Sstevel@tonic-gate Elf64_Off sh_offset; /* file offset */ 3997c478bd9Sstevel@tonic-gate Elf64_Xword sh_size; /* section size */ 4007c478bd9Sstevel@tonic-gate Elf64_Word sh_link; /* misc info */ 4017c478bd9Sstevel@tonic-gate Elf64_Word sh_info; /* misc info */ 4027c478bd9Sstevel@tonic-gate Elf64_Xword sh_addralign; /* memory alignment */ 4037c478bd9Sstevel@tonic-gate Elf64_Xword sh_entsize; /* entry size if table */ 4047c478bd9Sstevel@tonic-gate } Elf64_Shdr; 4057c478bd9Sstevel@tonic-gate #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ 4067c478bd9Sstevel@tonic-gate 4077c478bd9Sstevel@tonic-gate #define SHT_NULL 0 /* sh_type */ 4087c478bd9Sstevel@tonic-gate #define SHT_PROGBITS 1 4097c478bd9Sstevel@tonic-gate #define SHT_SYMTAB 2 4107c478bd9Sstevel@tonic-gate #define SHT_STRTAB 3 4117c478bd9Sstevel@tonic-gate #define SHT_RELA 4 4127c478bd9Sstevel@tonic-gate #define SHT_HASH 5 4137c478bd9Sstevel@tonic-gate #define SHT_DYNAMIC 6 4147c478bd9Sstevel@tonic-gate #define SHT_NOTE 7 4157c478bd9Sstevel@tonic-gate #define SHT_NOBITS 8 4167c478bd9Sstevel@tonic-gate #define SHT_REL 9 4177c478bd9Sstevel@tonic-gate #define SHT_SHLIB 10 4187c478bd9Sstevel@tonic-gate #define SHT_DYNSYM 11 4197c478bd9Sstevel@tonic-gate #define SHT_UNKNOWN12 12 4207c478bd9Sstevel@tonic-gate #define SHT_UNKNOWN13 13 4217c478bd9Sstevel@tonic-gate #define SHT_INIT_ARRAY 14 4227c478bd9Sstevel@tonic-gate #define SHT_FINI_ARRAY 15 4237c478bd9Sstevel@tonic-gate #define SHT_PREINIT_ARRAY 16 4247c478bd9Sstevel@tonic-gate #define SHT_GROUP 17 4257c478bd9Sstevel@tonic-gate #define SHT_SYMTAB_SHNDX 18 4267c478bd9Sstevel@tonic-gate #define SHT_NUM 19 4277c478bd9Sstevel@tonic-gate 4281638af81Sab196087 /* Solaris ABI specific values */ 4297c478bd9Sstevel@tonic-gate #define SHT_LOOS 0x60000000 /* OS specific range */ 43008278a5eSRod Evans #define SHT_LOSUNW 0x6fffffef 43108278a5eSRod Evans #define SHT_SUNW_capchain 0x6fffffef 43208278a5eSRod Evans #define SHT_SUNW_capinfo 0x6ffffff0 433d579eb63Sab196087 #define SHT_SUNW_symsort 0x6ffffff1 434d579eb63Sab196087 #define SHT_SUNW_tlssort 0x6ffffff2 4359039eeafSab196087 #define SHT_SUNW_LDYNSYM 0x6ffffff3 4367c478bd9Sstevel@tonic-gate #define SHT_SUNW_dof 0x6ffffff4 4377c478bd9Sstevel@tonic-gate #define SHT_SUNW_cap 0x6ffffff5 4387c478bd9Sstevel@tonic-gate #define SHT_SUNW_SIGNATURE 0x6ffffff6 4397c478bd9Sstevel@tonic-gate #define SHT_SUNW_ANNOTATE 0x6ffffff7 4407c478bd9Sstevel@tonic-gate #define SHT_SUNW_DEBUGSTR 0x6ffffff8 4417c478bd9Sstevel@tonic-gate #define SHT_SUNW_DEBUG 0x6ffffff9 4427c478bd9Sstevel@tonic-gate #define SHT_SUNW_move 0x6ffffffa 4437c478bd9Sstevel@tonic-gate #define SHT_SUNW_COMDAT 0x6ffffffb 4447c478bd9Sstevel@tonic-gate #define SHT_SUNW_syminfo 0x6ffffffc 4457c478bd9Sstevel@tonic-gate #define SHT_SUNW_verdef 0x6ffffffd 4467e16fca0SAli Bahrami #define SHT_GNU_verdef SHT_SUNW_verdef 4477c478bd9Sstevel@tonic-gate #define SHT_SUNW_verneed 0x6ffffffe 4487e16fca0SAli Bahrami #define SHT_GNU_verneed SHT_SUNW_verneed 4497c478bd9Sstevel@tonic-gate #define SHT_SUNW_versym 0x6fffffff 4507e16fca0SAli Bahrami #define SHT_GNU_versym SHT_SUNW_versym 4517c478bd9Sstevel@tonic-gate #define SHT_HISUNW 0x6fffffff 4527c478bd9Sstevel@tonic-gate #define SHT_HIOS 0x6fffffff 4537c478bd9Sstevel@tonic-gate 4547e16fca0SAli Bahrami /* 4557e16fca0SAli Bahrami * GNU/Linux OSABI specific values with different meanings than under Solaris. 4567e16fca0SAli Bahrami * Due to the overlap in assigned values with the Solaris OSABI, correct 4577e16fca0SAli Bahrami * interpretation of these values requires knowledge of the OSABI used by 4587e16fca0SAli Bahrami * the object. 4597e16fca0SAli Bahrami */ 4607e16fca0SAli Bahrami #define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes */ 4617e16fca0SAli Bahrami #define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table */ 4627e16fca0SAli Bahrami #define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ 4637e16fca0SAli Bahrami #define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content */ 4641638af81Sab196087 4657c478bd9Sstevel@tonic-gate #define SHT_LOPROC 0x70000000 /* processor specific range */ 4667c478bd9Sstevel@tonic-gate #define SHT_HIPROC 0x7fffffff 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate #define SHT_LOUSER 0x80000000 4697c478bd9Sstevel@tonic-gate #define SHT_HIUSER 0xffffffff 4707c478bd9Sstevel@tonic-gate 4717c478bd9Sstevel@tonic-gate #define SHF_WRITE 0x01 /* sh_flags */ 4727c478bd9Sstevel@tonic-gate #define SHF_ALLOC 0x02 4737c478bd9Sstevel@tonic-gate #define SHF_EXECINSTR 0x04 4747c478bd9Sstevel@tonic-gate #define SHF_MERGE 0x10 4757c478bd9Sstevel@tonic-gate #define SHF_STRINGS 0x20 4767c478bd9Sstevel@tonic-gate #define SHF_INFO_LINK 0x40 4777c478bd9Sstevel@tonic-gate #define SHF_LINK_ORDER 0x80 4787c478bd9Sstevel@tonic-gate #define SHF_OS_NONCONFORMING 0x100 4797c478bd9Sstevel@tonic-gate #define SHF_GROUP 0x200 4807c478bd9Sstevel@tonic-gate #define SHF_TLS 0x400 4817c478bd9Sstevel@tonic-gate 4827c478bd9Sstevel@tonic-gate #define SHF_MASKOS 0x0ff00000 /* OS specific values */ 4837c478bd9Sstevel@tonic-gate 4847c478bd9Sstevel@tonic-gate 4857c478bd9Sstevel@tonic-gate #define SHF_MASKPROC 0xf0000000 /* processor specific values */ 4867c478bd9Sstevel@tonic-gate 4877c478bd9Sstevel@tonic-gate #define SHN_UNDEF 0 /* special section numbers */ 4887c478bd9Sstevel@tonic-gate #define SHN_LORESERVE 0xff00 4897c478bd9Sstevel@tonic-gate #define SHN_LOPROC 0xff00 /* processor specific range */ 4907c478bd9Sstevel@tonic-gate #define SHN_HIPROC 0xff1f 4917c478bd9Sstevel@tonic-gate #define SHN_LOOS 0xff20 /* OS specific range */ 4927c478bd9Sstevel@tonic-gate #define SHN_LOSUNW 0xff3f 4937c478bd9Sstevel@tonic-gate #define SHN_SUNW_IGNORE 0xff3f 4947c478bd9Sstevel@tonic-gate #define SHN_HISUNW 0xff3f 4957c478bd9Sstevel@tonic-gate #define SHN_HIOS 0xff3f 4967c478bd9Sstevel@tonic-gate #define SHN_ABS 0xfff1 4977c478bd9Sstevel@tonic-gate #define SHN_COMMON 0xfff2 4987c478bd9Sstevel@tonic-gate #define SHN_XINDEX 0xffff /* extended sect index */ 4997c478bd9Sstevel@tonic-gate #define SHN_HIRESERVE 0xffff 5007c478bd9Sstevel@tonic-gate 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate 5037c478bd9Sstevel@tonic-gate /* 5047c478bd9Sstevel@tonic-gate * Symbol table 5057c478bd9Sstevel@tonic-gate */ 5067c478bd9Sstevel@tonic-gate 5077c478bd9Sstevel@tonic-gate typedef struct { 5087c478bd9Sstevel@tonic-gate Elf32_Word st_name; 5097c478bd9Sstevel@tonic-gate Elf32_Addr st_value; 5107c478bd9Sstevel@tonic-gate Elf32_Word st_size; 5117c478bd9Sstevel@tonic-gate unsigned char st_info; /* bind, type: ELF_32_ST_... */ 5127c478bd9Sstevel@tonic-gate unsigned char st_other; 5137c478bd9Sstevel@tonic-gate Elf32_Half st_shndx; /* SHN_... */ 5147c478bd9Sstevel@tonic-gate } Elf32_Sym; 5157c478bd9Sstevel@tonic-gate 5167c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE) 5177c478bd9Sstevel@tonic-gate typedef struct { 5187c478bd9Sstevel@tonic-gate Elf64_Word st_name; 5197c478bd9Sstevel@tonic-gate unsigned char st_info; /* bind, type: ELF_64_ST_... */ 5207c478bd9Sstevel@tonic-gate unsigned char st_other; 5217c478bd9Sstevel@tonic-gate Elf64_Half st_shndx; /* SHN_... */ 5227c478bd9Sstevel@tonic-gate Elf64_Addr st_value; 5237c478bd9Sstevel@tonic-gate Elf64_Xword st_size; 5247c478bd9Sstevel@tonic-gate } Elf64_Sym; 5257c478bd9Sstevel@tonic-gate #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ 5267c478bd9Sstevel@tonic-gate 5277c478bd9Sstevel@tonic-gate #define STN_UNDEF 0 5287c478bd9Sstevel@tonic-gate 5297c478bd9Sstevel@tonic-gate /* 53008278a5eSRod Evans * Macros to compose and decompose values for S.st_info 5317c478bd9Sstevel@tonic-gate * 5327c478bd9Sstevel@tonic-gate * bind = ELF32_ST_BIND(S.st_info) 5337c478bd9Sstevel@tonic-gate * type = ELF32_ST_TYPE(S.st_info) 5347c478bd9Sstevel@tonic-gate * S.st_info = ELF32_ST_INFO(bind, type) 5357c478bd9Sstevel@tonic-gate */ 5367c478bd9Sstevel@tonic-gate 5377c478bd9Sstevel@tonic-gate #define ELF32_ST_BIND(info) ((info) >> 4) 5387c478bd9Sstevel@tonic-gate #define ELF32_ST_TYPE(info) ((info) & 0xf) 5397c478bd9Sstevel@tonic-gate #define ELF32_ST_INFO(bind, type) (((bind)<<4)+((type)&0xf)) 5407c478bd9Sstevel@tonic-gate 5417c478bd9Sstevel@tonic-gate #define ELF64_ST_BIND(info) ((info) >> 4) 5427c478bd9Sstevel@tonic-gate #define ELF64_ST_TYPE(info) ((info) & 0xf) 5437c478bd9Sstevel@tonic-gate #define ELF64_ST_INFO(bind, type) (((bind)<<4)+((type)&0xf)) 5447c478bd9Sstevel@tonic-gate 5457c478bd9Sstevel@tonic-gate 5467c478bd9Sstevel@tonic-gate #define STB_LOCAL 0 /* BIND */ 5477c478bd9Sstevel@tonic-gate #define STB_GLOBAL 1 5487c478bd9Sstevel@tonic-gate #define STB_WEAK 2 5497c478bd9Sstevel@tonic-gate #define STB_NUM 3 5507c478bd9Sstevel@tonic-gate 5517c478bd9Sstevel@tonic-gate #define STB_LOPROC 13 /* processor specific range */ 5527c478bd9Sstevel@tonic-gate #define STB_HIPROC 15 5537c478bd9Sstevel@tonic-gate 5547e16fca0SAli Bahrami #define STT_NOTYPE 0 /* symbol type is unspecified */ 5557e16fca0SAli Bahrami #define STT_OBJECT 1 /* data object */ 5567e16fca0SAli Bahrami #define STT_FUNC 2 /* code object */ 5577e16fca0SAli Bahrami #define STT_SECTION 3 /* symbol identifies an ELF section */ 5587e16fca0SAli Bahrami #define STT_FILE 4 /* symbol's name is file name */ 5597e16fca0SAli Bahrami #define STT_COMMON 5 /* common data object */ 5607e16fca0SAli Bahrami #define STT_TLS 6 /* thread-local data object */ 56162b628a6SAli Bahrami #define STT_NUM 7 /* # defined types in generic range */ 5627e16fca0SAli Bahrami #define STT_LOOS 10 /* OS specific range */ 5637e16fca0SAli Bahrami #define STT_HIOS 12 5647c478bd9Sstevel@tonic-gate #define STT_LOPROC 13 /* processor specific range */ 5657c478bd9Sstevel@tonic-gate #define STT_HIPROC 15 5667c478bd9Sstevel@tonic-gate 5677c478bd9Sstevel@tonic-gate /* 56808278a5eSRod Evans * Macros to decompose values for S.st_other 5697c478bd9Sstevel@tonic-gate * 5707c478bd9Sstevel@tonic-gate * visibility = ELF32_ST_VISIBILITY(S.st_other) 5717c478bd9Sstevel@tonic-gate */ 57260758829Srie #define ELF32_ST_VISIBILITY(other) ((other)&0x7) 57360758829Srie #define ELF64_ST_VISIBILITY(other) ((other)&0x7) 5747c478bd9Sstevel@tonic-gate 5757c478bd9Sstevel@tonic-gate #define STV_DEFAULT 0 5767c478bd9Sstevel@tonic-gate #define STV_INTERNAL 1 5777c478bd9Sstevel@tonic-gate #define STV_HIDDEN 2 5787c478bd9Sstevel@tonic-gate #define STV_PROTECTED 3 57960758829Srie #define STV_EXPORTED 4 58060758829Srie #define STV_SINGLETON 5 58160758829Srie #define STV_ELIMINATE 6 5827c478bd9Sstevel@tonic-gate 58360758829Srie #define STV_NUM 7 5847c478bd9Sstevel@tonic-gate 5857c478bd9Sstevel@tonic-gate /* 5867c478bd9Sstevel@tonic-gate * Relocation 5877c478bd9Sstevel@tonic-gate */ 5887c478bd9Sstevel@tonic-gate 5897c478bd9Sstevel@tonic-gate typedef struct { 5907c478bd9Sstevel@tonic-gate Elf32_Addr r_offset; 5917c478bd9Sstevel@tonic-gate Elf32_Word r_info; /* sym, type: ELF32_R_... */ 5927c478bd9Sstevel@tonic-gate } Elf32_Rel; 5937c478bd9Sstevel@tonic-gate 5947c478bd9Sstevel@tonic-gate typedef struct { 5957c478bd9Sstevel@tonic-gate Elf32_Addr r_offset; 5967c478bd9Sstevel@tonic-gate Elf32_Word r_info; /* sym, type: ELF32_R_... */ 5977c478bd9Sstevel@tonic-gate Elf32_Sword r_addend; 5987c478bd9Sstevel@tonic-gate } Elf32_Rela; 5997c478bd9Sstevel@tonic-gate 6007c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE) 6017c478bd9Sstevel@tonic-gate typedef struct { 6027c478bd9Sstevel@tonic-gate Elf64_Addr r_offset; 6037c478bd9Sstevel@tonic-gate Elf64_Xword r_info; /* sym, type: ELF64_R_... */ 6047c478bd9Sstevel@tonic-gate } Elf64_Rel; 6057c478bd9Sstevel@tonic-gate 6067c478bd9Sstevel@tonic-gate typedef struct { 6077c478bd9Sstevel@tonic-gate Elf64_Addr r_offset; 6087c478bd9Sstevel@tonic-gate Elf64_Xword r_info; /* sym, type: ELF64_R_... */ 6097c478bd9Sstevel@tonic-gate Elf64_Sxword r_addend; 6107c478bd9Sstevel@tonic-gate } Elf64_Rela; 6117c478bd9Sstevel@tonic-gate #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ 6127c478bd9Sstevel@tonic-gate 6137c478bd9Sstevel@tonic-gate 6147c478bd9Sstevel@tonic-gate /* 61508278a5eSRod Evans * Macros to compose and decompose values for Rel.r_info, Rela.f_info 6167c478bd9Sstevel@tonic-gate * 6177c478bd9Sstevel@tonic-gate * sym = ELF32_R_SYM(R.r_info) 6187c478bd9Sstevel@tonic-gate * type = ELF32_R_TYPE(R.r_info) 6197c478bd9Sstevel@tonic-gate * R.r_info = ELF32_R_INFO(sym, type) 6207c478bd9Sstevel@tonic-gate */ 6217c478bd9Sstevel@tonic-gate 6227c478bd9Sstevel@tonic-gate #define ELF32_R_SYM(info) ((info)>>8) 6237c478bd9Sstevel@tonic-gate #define ELF32_R_TYPE(info) ((unsigned char)(info)) 6247c478bd9Sstevel@tonic-gate #define ELF32_R_INFO(sym, type) (((sym)<<8)+(unsigned char)(type)) 6257c478bd9Sstevel@tonic-gate 6267c478bd9Sstevel@tonic-gate #define ELF64_R_SYM(info) ((info)>>32) 6277c478bd9Sstevel@tonic-gate #define ELF64_R_TYPE(info) ((Elf64_Word)(info)) 6287c478bd9Sstevel@tonic-gate #define ELF64_R_INFO(sym, type) (((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(type)) 6297c478bd9Sstevel@tonic-gate 6307c478bd9Sstevel@tonic-gate 6317c478bd9Sstevel@tonic-gate /* 6327c478bd9Sstevel@tonic-gate * The r_info field is composed of two 32-bit components: the symbol 6337c478bd9Sstevel@tonic-gate * table index and the relocation type. The relocation type for SPARC V9 6347c478bd9Sstevel@tonic-gate * is further decomposed into an 8-bit type identifier and a 24-bit type 6357c478bd9Sstevel@tonic-gate * dependent data field. For the existing Elf32 relocation types, 6367c478bd9Sstevel@tonic-gate * that data field is zero. 6377c478bd9Sstevel@tonic-gate */ 6387c478bd9Sstevel@tonic-gate #define ELF64_R_TYPE_DATA(info) (((Elf64_Xword)(info)<<32)>>40) 6397c478bd9Sstevel@tonic-gate #define ELF64_R_TYPE_ID(info) (((Elf64_Xword)(info)<<56)>>56) 6407c478bd9Sstevel@tonic-gate #define ELF64_R_TYPE_INFO(data, type) \ 6417c478bd9Sstevel@tonic-gate (((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type)) 6427c478bd9Sstevel@tonic-gate 6437c478bd9Sstevel@tonic-gate 6447c478bd9Sstevel@tonic-gate /* 6457c478bd9Sstevel@tonic-gate * Section Group Flags (SHT_GROUP) 6467c478bd9Sstevel@tonic-gate */ 6477c478bd9Sstevel@tonic-gate #define GRP_COMDAT 0x01 6487c478bd9Sstevel@tonic-gate 6497c478bd9Sstevel@tonic-gate 6507c478bd9Sstevel@tonic-gate /* 6517c478bd9Sstevel@tonic-gate * Note entry header 6527c478bd9Sstevel@tonic-gate */ 6537c478bd9Sstevel@tonic-gate 6547c478bd9Sstevel@tonic-gate typedef struct { 6557c478bd9Sstevel@tonic-gate Elf32_Word n_namesz; /* length of note's name */ 6567c478bd9Sstevel@tonic-gate Elf32_Word n_descsz; /* length of note's "desc" */ 6577c478bd9Sstevel@tonic-gate Elf32_Word n_type; /* type of note */ 6587c478bd9Sstevel@tonic-gate } Elf32_Nhdr; 6597c478bd9Sstevel@tonic-gate 6607c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE) 6617c478bd9Sstevel@tonic-gate typedef struct { 6627c478bd9Sstevel@tonic-gate Elf64_Word n_namesz; /* length of note's name */ 6637c478bd9Sstevel@tonic-gate Elf64_Word n_descsz; /* length of note's "desc" */ 6647c478bd9Sstevel@tonic-gate Elf64_Word n_type; /* type of note */ 6657c478bd9Sstevel@tonic-gate } Elf64_Nhdr; 6667c478bd9Sstevel@tonic-gate #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ 6677c478bd9Sstevel@tonic-gate 6687c478bd9Sstevel@tonic-gate /* 6697c478bd9Sstevel@tonic-gate * Move entry 6707c478bd9Sstevel@tonic-gate */ 6717c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE) 6727c478bd9Sstevel@tonic-gate typedef struct { 6737c478bd9Sstevel@tonic-gate Elf32_Lword m_value; /* symbol value */ 6747c478bd9Sstevel@tonic-gate Elf32_Word m_info; /* size + index */ 6757c478bd9Sstevel@tonic-gate Elf32_Word m_poffset; /* symbol offset */ 6767c478bd9Sstevel@tonic-gate Elf32_Half m_repeat; /* repeat count */ 6777c478bd9Sstevel@tonic-gate Elf32_Half m_stride; /* stride info */ 6787c478bd9Sstevel@tonic-gate } Elf32_Move; 6797c478bd9Sstevel@tonic-gate 6807c478bd9Sstevel@tonic-gate /* 68108278a5eSRod Evans * Macros to compose and decompose values for Move.r_info 6827c478bd9Sstevel@tonic-gate * 6837c478bd9Sstevel@tonic-gate * sym = ELF32_M_SYM(M.m_info) 6847c478bd9Sstevel@tonic-gate * size = ELF32_M_SIZE(M.m_info) 6857c478bd9Sstevel@tonic-gate * M.m_info = ELF32_M_INFO(sym, size) 6867c478bd9Sstevel@tonic-gate */ 6877c478bd9Sstevel@tonic-gate #define ELF32_M_SYM(info) ((info)>>8) 6887c478bd9Sstevel@tonic-gate #define ELF32_M_SIZE(info) ((unsigned char)(info)) 6897c478bd9Sstevel@tonic-gate #define ELF32_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size)) 6907c478bd9Sstevel@tonic-gate 6917c478bd9Sstevel@tonic-gate typedef struct { 6927c478bd9Sstevel@tonic-gate Elf64_Lword m_value; /* symbol value */ 6937c478bd9Sstevel@tonic-gate Elf64_Xword m_info; /* size + index */ 6947c478bd9Sstevel@tonic-gate Elf64_Xword m_poffset; /* symbol offset */ 6957c478bd9Sstevel@tonic-gate Elf64_Half m_repeat; /* repeat count */ 6967c478bd9Sstevel@tonic-gate Elf64_Half m_stride; /* stride info */ 6977c478bd9Sstevel@tonic-gate } Elf64_Move; 6987c478bd9Sstevel@tonic-gate #define ELF64_M_SYM(info) ((info)>>8) 6997c478bd9Sstevel@tonic-gate #define ELF64_M_SIZE(info) ((unsigned char)(info)) 7007c478bd9Sstevel@tonic-gate #define ELF64_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size)) 7017c478bd9Sstevel@tonic-gate 7027c478bd9Sstevel@tonic-gate #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ 7037c478bd9Sstevel@tonic-gate 7047c478bd9Sstevel@tonic-gate 7057c478bd9Sstevel@tonic-gate /* 70608278a5eSRod Evans * Capabilities entry, Capabilities info and Capabilities chain. 7077c478bd9Sstevel@tonic-gate */ 7087c478bd9Sstevel@tonic-gate #ifndef _ASM 7097c478bd9Sstevel@tonic-gate typedef struct { 7107c478bd9Sstevel@tonic-gate Elf32_Word c_tag; /* how to interpret value */ 7117c478bd9Sstevel@tonic-gate union { 7127c478bd9Sstevel@tonic-gate Elf32_Word c_val; 7137c478bd9Sstevel@tonic-gate Elf32_Addr c_ptr; 7147c478bd9Sstevel@tonic-gate } c_un; 7157c478bd9Sstevel@tonic-gate } Elf32_Cap; 7167c478bd9Sstevel@tonic-gate 71708278a5eSRod Evans typedef Elf32_Word Elf32_Capinfo; 71808278a5eSRod Evans typedef Elf32_Word Elf32_Capchain; 71908278a5eSRod Evans 72008278a5eSRod Evans /* 72108278a5eSRod Evans * Macros to compose and decompose values for capabilities info. 72208278a5eSRod Evans * 72308278a5eSRod Evans * sym = ELF32_C_SYM(info) 72408278a5eSRod Evans * grp = ELF32_C_GROUP(info) 72508278a5eSRod Evans * info = ELF32_C_INFO(sym, grp) 72608278a5eSRod Evans */ 72708278a5eSRod Evans #define ELF32_C_SYM(info) ((info)>>8) 72808278a5eSRod Evans #define ELF32_C_GROUP(info) ((unsigned char)(info)) 72908278a5eSRod Evans #define ELF32_C_INFO(sym, grp) (((sym)<<8)+(unsigned char)(grp)) 73008278a5eSRod Evans 73108278a5eSRod Evans 7327c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE) 7337c478bd9Sstevel@tonic-gate typedef struct { 7347c478bd9Sstevel@tonic-gate Elf64_Xword c_tag; /* how to interpret value */ 7357c478bd9Sstevel@tonic-gate union { 7367c478bd9Sstevel@tonic-gate Elf64_Xword c_val; 7377c478bd9Sstevel@tonic-gate Elf64_Addr c_ptr; 7387c478bd9Sstevel@tonic-gate } c_un; 7397c478bd9Sstevel@tonic-gate } Elf64_Cap; 74008278a5eSRod Evans 74108278a5eSRod Evans typedef Elf64_Xword Elf64_Capinfo; 74208278a5eSRod Evans typedef Elf64_Word Elf64_Capchain; 74308278a5eSRod Evans 74408278a5eSRod Evans /* 74508278a5eSRod Evans * Macros to compose and decompose values for capabilities info. 74608278a5eSRod Evans * 74708278a5eSRod Evans * sym = ELF64_C_SYM(info) 74808278a5eSRod Evans * grp = ELF64_C_GROUP(info) 74908278a5eSRod Evans * info = ELF64_C_INFO(sym, grp) 75008278a5eSRod Evans */ 75108278a5eSRod Evans #define ELF64_C_SYM(info) ((info)>>32) 75208278a5eSRod Evans #define ELF64_C_GROUP(info) ((Elf64_Word)(info)) 75308278a5eSRod Evans #define ELF64_C_INFO(sym, grp) (((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(grp)) 75408278a5eSRod Evans 7557c478bd9Sstevel@tonic-gate #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */ 7567c478bd9Sstevel@tonic-gate #endif 7577c478bd9Sstevel@tonic-gate 75808278a5eSRod Evans /* 75908278a5eSRod Evans * Version numbers for SHT_SUNW_capinfo and SHT_SUNW_capchain. 76008278a5eSRod Evans */ 76108278a5eSRod Evans #define CAPINFO_NONE 0 76208278a5eSRod Evans #define CAPINFO_CURRENT 1 76308278a5eSRod Evans #define CAPINFO_NUM 2 76408278a5eSRod Evans 76508278a5eSRod Evans #define CAPCHAIN_NONE 0 76608278a5eSRod Evans #define CAPCHAIN_CURRENT 1 76708278a5eSRod Evans #define CAPCHAIN_NUM 2 76808278a5eSRod Evans 76908278a5eSRod Evans /* 77008278a5eSRod Evans * A SHT_SUNW_capinfo table mirrors a symbol table. A capabilities symbol has 77108278a5eSRod Evans * a SHT_SUNW_capinfo table entry that provides an index into the associated 77208278a5eSRod Evans * SHT_SUNW_cap capabilities group, and the symbol index of the associated lead 77308278a5eSRod Evans * symbol. A capabilities symbol is a local symbol. A global lead capabilities 77408278a5eSRod Evans * symbol is tagged with a group CAPINFO_SUNW_GLOB. 77508278a5eSRod Evans */ 77608278a5eSRod Evans #define CAPINFO_SUNW_GLOB 0xff 77708278a5eSRod Evans 77808278a5eSRod Evans /* 77908278a5eSRod Evans * Capabilities values. 78008278a5eSRod Evans */ 7817c478bd9Sstevel@tonic-gate #define CA_SUNW_NULL 0 7827c478bd9Sstevel@tonic-gate #define CA_SUNW_HW_1 1 /* first hardware capabilities entry */ 7837c478bd9Sstevel@tonic-gate #define CA_SUNW_SF_1 2 /* first software capabilities entry */ 78469112eddSAli Bahrami #define CA_SUNW_HW_2 3 /* second hardware capabilities entry */ 78508278a5eSRod Evans #define CA_SUNW_PLAT 4 /* platform capability entry */ 78608278a5eSRod Evans #define CA_SUNW_MACH 5 /* machine capability entry */ 78708278a5eSRod Evans #define CA_SUNW_ID 6 /* capability identifier */ 78808278a5eSRod Evans #define CA_SUNW_NUM 7 7897c478bd9Sstevel@tonic-gate 7907c478bd9Sstevel@tonic-gate /* 7917c478bd9Sstevel@tonic-gate * Define software capabilities (CA_SUNW_SF_1 values). Note, hardware 7927c478bd9Sstevel@tonic-gate * capabilities (CA_SUNW_HW_1 values) are taken directly from sys/auxv_$MACH.h. 7937c478bd9Sstevel@tonic-gate */ 794bebb829dSRod Evans #define SF1_SUNW_FPKNWN 0x001 /* frame pointer usage is known */ 795bebb829dSRod Evans #define SF1_SUNW_FPUSED 0x002 /* frame pointer is in use */ 796bebb829dSRod Evans #define SF1_SUNW_ADDR32 0x004 /* 32-bit address space requirement */ 797bebb829dSRod Evans #define SF1_SUNW_MASK 0x007 /* known software capabilities mask */ 7987c478bd9Sstevel@tonic-gate 7997c478bd9Sstevel@tonic-gate /* 8007c478bd9Sstevel@tonic-gate * Known values for note entry types (e_type == ET_CORE) 8017c478bd9Sstevel@tonic-gate */ 8027c478bd9Sstevel@tonic-gate #define NT_PRSTATUS 1 /* prstatus_t <sys/old_procfs.h> */ 8037c478bd9Sstevel@tonic-gate #define NT_PRFPREG 2 /* prfpregset_t <sys/old_procfs.h> */ 8047c478bd9Sstevel@tonic-gate #define NT_PRPSINFO 3 /* prpsinfo_t <sys/old_procfs.h> */ 8057c478bd9Sstevel@tonic-gate #define NT_PRXREG 4 /* prxregset_t <sys/procfs.h> */ 8067c478bd9Sstevel@tonic-gate #define NT_PLATFORM 5 /* string from sysinfo(SI_PLATFORM) */ 8077c478bd9Sstevel@tonic-gate #define NT_AUXV 6 /* auxv_t array <sys/auxv.h> */ 8087c478bd9Sstevel@tonic-gate #define NT_GWINDOWS 7 /* gwindows_t SPARC only */ 8097c478bd9Sstevel@tonic-gate #define NT_ASRS 8 /* asrset_t SPARC V9 only */ 8107c478bd9Sstevel@tonic-gate #define NT_LDT 9 /* ssd array <sys/sysi86.h> IA32 only */ 8117c478bd9Sstevel@tonic-gate #define NT_PSTATUS 10 /* pstatus_t <sys/procfs.h> */ 8127c478bd9Sstevel@tonic-gate #define NT_PSINFO 13 /* psinfo_t <sys/procfs.h> */ 8137c478bd9Sstevel@tonic-gate #define NT_PRCRED 14 /* prcred_t <sys/procfs.h> */ 8147c478bd9Sstevel@tonic-gate #define NT_UTSNAME 15 /* struct utsname <sys/utsname.h> */ 8157c478bd9Sstevel@tonic-gate #define NT_LWPSTATUS 16 /* lwpstatus_t <sys/procfs.h> */ 8167c478bd9Sstevel@tonic-gate #define NT_LWPSINFO 17 /* lwpsinfo_t <sys/procfs.h> */ 8177c478bd9Sstevel@tonic-gate #define NT_PRPRIV 18 /* prpriv_t <sys/procfs.h> */ 8187c478bd9Sstevel@tonic-gate #define NT_PRPRIVINFO 19 /* priv_impl_info_t <sys/priv.h> */ 8197c478bd9Sstevel@tonic-gate #define NT_CONTENT 20 /* core_content_t <sys/corectl.h> */ 8207c478bd9Sstevel@tonic-gate #define NT_ZONENAME 21 /* string from getzonenamebyid(3C) */ 82134bdffbfSGarrett D'Amore #define NT_FDINFO 22 /* open fd info */ 822*f971a346SBryan Cantrill #define NT_SPYMASTER 23 /* psinfo_t for agent LWP spymaster */ 823*f971a346SBryan Cantrill #define NT_NUM 23 824c6c9aed4Sab196087 8257c478bd9Sstevel@tonic-gate 8267c478bd9Sstevel@tonic-gate #ifdef _KERNEL 8277c478bd9Sstevel@tonic-gate /* 8287c478bd9Sstevel@tonic-gate * The following routine checks the processor-specific 8297c478bd9Sstevel@tonic-gate * fields of an ELF header. 8307c478bd9Sstevel@tonic-gate */ 8317c478bd9Sstevel@tonic-gate int elfheadcheck(unsigned char, Elf32_Half, Elf32_Word); 8327c478bd9Sstevel@tonic-gate #endif 8337c478bd9Sstevel@tonic-gate 8347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 8357c478bd9Sstevel@tonic-gate } 8367c478bd9Sstevel@tonic-gate #endif 8377c478bd9Sstevel@tonic-gate 8387c478bd9Sstevel@tonic-gate #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_SPARC) 8397c478bd9Sstevel@tonic-gate #include <sys/elf_SPARC.h> 8407c478bd9Sstevel@tonic-gate #endif 8417c478bd9Sstevel@tonic-gate 8427c478bd9Sstevel@tonic-gate #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_386) 8437c478bd9Sstevel@tonic-gate #include <sys/elf_386.h> 8447c478bd9Sstevel@tonic-gate #endif 8457c478bd9Sstevel@tonic-gate 8467c478bd9Sstevel@tonic-gate #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_AMD64) 8477c478bd9Sstevel@tonic-gate #include <sys/elf_amd64.h> 8487c478bd9Sstevel@tonic-gate #endif 8497c478bd9Sstevel@tonic-gate 8507c478bd9Sstevel@tonic-gate #endif /* _SYS_ELF_H */ 851