pkg: ship usr/lib/security/amd64/*.so links
[unleashed.git] / include / sys / elf.h
blob53b62031c62d5aefb1c24225e5788d78992ef0f5
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
23 * Copyright (c) 2018, Joyent, Inc.
26 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
30 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
31 /* All Rights Reserved */
34 #ifndef _SYS_ELF_H
35 #define _SYS_ELF_H
37 #include <sys/elftypes.h>
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
43 #define ELF32_FSZ_ADDR 4
44 #define ELF32_FSZ_HALF 2
45 #define ELF32_FSZ_OFF 4
46 #define ELF32_FSZ_SWORD 4
47 #define ELF32_FSZ_WORD 4
49 #define ELF64_FSZ_ADDR 8
50 #define ELF64_FSZ_HALF 2
51 #define ELF64_FSZ_OFF 8
52 #define ELF64_FSZ_SWORD 4
53 #define ELF64_FSZ_WORD 4
54 #define ELF64_FSZ_SXWORD 8
55 #define ELF64_FSZ_XWORD 8
58 * "Enumerations" below use ...NUM as the number of
59 * values in the list. It should be 1 greater than the
60 * highest "real" value.
64 * ELF header
67 #define EI_NIDENT 16
69 typedef struct {
70 unsigned char e_ident[EI_NIDENT]; /* ident bytes */
71 Elf32_Half e_type; /* file type */
72 Elf32_Half e_machine; /* target machine */
73 Elf32_Word e_version; /* file version */
74 Elf32_Addr e_entry; /* start address */
75 Elf32_Off e_phoff; /* phdr file offset */
76 Elf32_Off e_shoff; /* shdr file offset */
77 Elf32_Word e_flags; /* file flags */
78 Elf32_Half e_ehsize; /* sizeof ehdr */
79 Elf32_Half e_phentsize; /* sizeof phdr */
80 Elf32_Half e_phnum; /* number phdrs */
81 Elf32_Half e_shentsize; /* sizeof shdr */
82 Elf32_Half e_shnum; /* number shdrs */
83 Elf32_Half e_shstrndx; /* shdr string index */
84 } Elf32_Ehdr;
86 typedef struct {
87 unsigned char e_ident[EI_NIDENT]; /* ident bytes */
88 Elf64_Half e_type; /* file type */
89 Elf64_Half e_machine; /* target machine */
90 Elf64_Word e_version; /* file version */
91 Elf64_Addr e_entry; /* start address */
92 Elf64_Off e_phoff; /* phdr file offset */
93 Elf64_Off e_shoff; /* shdr file offset */
94 Elf64_Word e_flags; /* file flags */
95 Elf64_Half e_ehsize; /* sizeof ehdr */
96 Elf64_Half e_phentsize; /* sizeof phdr */
97 Elf64_Half e_phnum; /* number phdrs */
98 Elf64_Half e_shentsize; /* sizeof shdr */
99 Elf64_Half e_shnum; /* number shdrs */
100 Elf64_Half e_shstrndx; /* shdr string index */
101 } Elf64_Ehdr;
103 #define EI_MAG0 0 /* e_ident[] indexes */
104 #define EI_MAG1 1
105 #define EI_MAG2 2
106 #define EI_MAG3 3
107 #define EI_CLASS 4 /* File class */
108 #define EI_DATA 5 /* Data encoding */
109 #define EI_VERSION 6 /* File version */
110 #define EI_OSABI 7 /* Operating system/ABI identification */
111 #define EI_ABIVERSION 8 /* ABI version */
112 #define EI_PAD 9 /* Start of padding bytes */
114 #define ELFMAG0 0x7f /* EI_MAG */
115 #define ELFMAG1 'E'
116 #define ELFMAG2 'L'
117 #define ELFMAG3 'F'
118 #define ELFMAG "\177ELF"
119 #define SELFMAG 4
121 #define ELFCLASSNONE 0 /* EI_CLASS */
122 #define ELFCLASS32 1
123 #define ELFCLASS64 2
124 #define ELFCLASSNUM 3
126 #define ELFDATANONE 0 /* EI_DATA */
127 #define ELFDATA2LSB 1
128 #define ELFDATA2MSB 2
129 #define ELFDATANUM 3
131 #define ET_NONE 0 /* e_type */
132 #define ET_REL 1
133 #define ET_EXEC 2
134 #define ET_DYN 3
135 #define ET_CORE 4
136 #define ET_NUM 5
137 #define ET_LOOS 0xfe00 /* OS specific range */
138 #define ET_LOSUNW 0xfeff
139 #define ET_SUNWPSEUDO 0xfeff
140 #define ET_HISUNW 0xfeff
141 #define ET_HIOS 0xfeff
142 #define ET_LOPROC 0xff00 /* processor specific range */
143 #define ET_HIPROC 0xffff
145 #define ET_LOPROC 0xff00 /* processor specific range */
146 #define ET_HIPROC 0xffff
148 #define EM_NONE 0 /* e_machine */
149 #define EM_M32 1 /* AT&T WE 32100 */
150 #define EM_SPARC 2 /* Sun SPARC */
151 #define EM_386 3 /* Intel 80386 */
152 #define EM_68K 4 /* Motorola 68000 */
153 #define EM_88K 5 /* Motorola 88000 */
154 #define EM_486 6 /* Intel 80486 */
155 #define EM_860 7 /* Intel i860 */
156 #define EM_MIPS 8 /* MIPS RS3000 Big-Endian */
157 #define EM_S370 9 /* IBM System/370 Processor */
158 #define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-Endian */
159 #define EM_RS6000 11 /* RS6000 */
160 #define EM_UNKNOWN12 12
161 #define EM_UNKNOWN13 13
162 #define EM_UNKNOWN14 14
163 #define EM_PA_RISC 15 /* PA-RISC */
164 #define EM_PARISC EM_PA_RISC /* Alias: GNU compatibility */
165 #define EM_nCUBE 16 /* nCUBE */
166 #define EM_VPP500 17 /* Fujitsu VPP500 */
167 #define EM_SPARC32PLUS 18 /* Sun SPARC 32+ */
168 #define EM_960 19 /* Intel 80960 */
169 #define EM_PPC 20 /* PowerPC */
170 #define EM_PPC64 21 /* 64-bit PowerPC */
171 #define EM_S390 22 /* IBM System/390 Processor */
172 #define EM_UNKNOWN22 EM_S390 /* Alias: Older published name */
173 #define EM_UNKNOWN23 23
174 #define EM_UNKNOWN24 24
175 #define EM_UNKNOWN25 25
176 #define EM_UNKNOWN26 26
177 #define EM_UNKNOWN27 27
178 #define EM_UNKNOWN28 28
179 #define EM_UNKNOWN29 29
180 #define EM_UNKNOWN30 30
181 #define EM_UNKNOWN31 31
182 #define EM_UNKNOWN32 32
183 #define EM_UNKNOWN33 33
184 #define EM_UNKNOWN34 34
185 #define EM_UNKNOWN35 35
186 #define EM_V800 36 /* NEX V800 */
187 #define EM_FR20 37 /* Fujitsu FR20 */
188 #define EM_RH32 38 /* TRW RH-32 */
189 #define EM_RCE 39 /* Motorola RCE */
190 #define EM_ARM 40 /* Advanced RISC Marchines ARM */
191 #define EM_ALPHA 41 /* Digital Alpha */
192 #define EM_SH 42 /* Hitachi SH */
193 #define EM_SPARCV9 43 /* Sun SPARC V9 (64-bit) */
194 #define EM_TRICORE 44 /* Siemens Tricore embedded processor */
195 #define EM_ARC 45 /* Argonaut RISC Core, */
196 /* Argonaut Technologies Inc. */
197 #define EM_H8_300 46 /* Hitachi H8/300 */
198 #define EM_H8_300H 47 /* Hitachi H8/300H */
199 #define EM_H8S 48 /* Hitachi H8S */
200 #define EM_H8_500 49 /* Hitachi H8/500 */
201 #define EM_IA_64 50 /* Intel IA64 */
202 #define EM_MIPS_X 51 /* Stanford MIPS-X */
203 #define EM_COLDFIRE 52 /* Motorola ColdFire */
204 #define EM_68HC12 53 /* Motorola M68HC12 */
205 #define EM_MMA 54 /* Fujitsu MMA Mulimedia Accelerator */
206 #define EM_PCP 55 /* Siemens PCP */
207 #define EM_NCPU 56 /* Sony nCPU embedded RISC processor */
208 #define EM_NDR1 57 /* Denso NDR1 microprocessor */
209 #define EM_STARCORE 58 /* Motorola Star*Core processor */
210 #define EM_ME16 59 /* Toyota ME16 processor */
211 #define EM_ST100 60 /* STMicroelectronics ST100 processor */
212 #define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ */
213 /* embedded processor family */
214 #define EM_AMD64 62 /* AMDs x86-64 architecture */
215 #define EM_X86_64 EM_AMD64 /* (compatibility) */
217 #define EM_PDSP 63 /* Sony DSP Processor */
218 #define EM_UNKNOWN64 64
219 #define EM_UNKNOWN65 65
220 #define EM_FX66 66 /* Siemens FX66 microcontroller */
221 #define EM_ST9PLUS 67 /* STMicroelectronics ST9+8/16 bit */
222 /* microcontroller */
223 #define EM_ST7 68 /* STMicroelectronics ST7 8-bit */
224 /* microcontroller */
225 #define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */
226 #define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */
227 #define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */
228 #define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */
229 #define EM_SVX 73 /* Silicon Graphics SVx */
230 #define EM_ST19 74 /* STMicroelectronics ST19 8-bit */
231 /* microcontroller */
232 #define EM_VAX 75 /* Digital VAX */
233 #define EM_CRIS 76 /* Axis Communications 32-bit */
234 /* embedded processor */
235 #define EM_JAVELIN 77 /* Infineon Technologies 32-bit */
236 /* embedded processor */
237 #define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
238 #define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
239 #define EM_MMIX 80 /* Donald Knuth's educational */
240 /* 64-bit processor */
241 #define EM_HUANY 81 /* Harvard University */
242 /* machine-independent */
243 /* object files */
244 #define EM_PRISM 82 /* SiTera Prism */
245 #define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
246 #define EM_FR30 84 /* Fujitsu FR30 */
247 #define EM_D10V 85 /* Mitsubishi D10V */
248 #define EM_D30V 86 /* Mitsubishi D30V */
249 #define EM_V850 87 /* NEC v850 */
250 #define EM_M32R 88 /* Mitsubishi M32R */
251 #define EM_MN10300 89 /* Matsushita MN10300 */
252 #define EM_MN10200 90 /* Matsushita MN10200 */
253 #define EM_PJ 91 /* picoJava */
254 #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
255 #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
256 #define EM_XTENSA 94 /* Tensilica Xtensa architecture */
258 #define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */
259 #define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose */
260 /* Processor */
261 #define EM_NS32K 97 /* National Semiconductor 32000 series */
262 #define EM_TPC 98 /* Tenor Network TPC processor */
263 #define EM_SNP1K 99 /* Trebia SNP 1000 processor */
264 #define EM_ST200 100 /* STMicroelectronics (www.st.com) ST200 */
265 /* microcontroller */
266 #define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */
267 #define EM_MAX 102 /* MAX Processor */
268 #define EM_CR 103 /* National Semiconductor CompactRISC */
269 /* microprocessor */
270 #define EM_F2MC16 104 /* Fujitsu F2MC16 */
271 #define EM_MSP430 105 /* Texas Instruments embedded microcontroller */
272 /* msp430 */
273 #define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor */
274 #define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors */
275 #define EM_SEP 108 /* Sharp embedded microprocessor */
276 #define EM_ARCA 109 /* Arca RISC Microprocessor */
277 #define EM_UNICORE 110 /* Microprocessor series from PKU-Unity Ltd. */
278 /* and MPRC of Peking University */
279 #define EM_EXCESS 111 /* eXcess: 16/32/64-bit configurable embedded */
280 /* CPU */
281 #define EM_DXP 112 /* Icera Semiconductor Inc. Deep Execution */
282 /* Processor */
283 #define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */
284 #define EM_CRX 114 /* National Semiconductor CompactRISC CRX */
285 /* microprocessor */
286 #define EM_XGATE 115 /* Motorola XGATE embedded processor */
287 #define EM_C166 116 /* Infineon C16x/XC16x processor */
288 #define EM_M16C 117 /* Renesas M16C series microprocessors */
289 #define EM_DSPIC30F 118 /* Microchip Technology dsPIC30F Digital */
290 /* Signal Controller */
291 #define EM_CE 119 /* Freescale Communication Engine RISC core */
292 #define EM_M32C 120 /* Renesas M32C series microprocessors */
294 #define EM_TSK3000 131 /* Altium TSK3000 core */
295 #define EM_RS08 132 /* Freescale RS08 embedded processor */
296 #define EM_SHARC 133 /* Analog Devices SHARC family of 32-bit DSP */
297 /* processors */
298 #define EM_ECOG2 134 /* Cyan Technology eCOG2 microprocessor */
299 #define EM_SCORE7 135 /* Sunplus S+core7 RISC processor */
300 #define EM_DSP24 136 /* New Japan Radio (NJR) 24-bit DSP Processor */
301 #define EM_VIDEOCORE3 137 /* Broadcom VideoCore III processor */
302 #define EM_LATTICEMICO32 138 /* RISC processor for Lattice FPGA */
303 /* architecture */
304 #define EM_SE_C17 139 /* Seiko Epson C17 family */
305 #define EM_TI_C6000 140 /* The Texas Instruments TMS320C6000 DSP */
306 /* family */
307 #define EM_TI_C2000 141 /* The Texas Instruments TMS320C2000 DSP */
308 /* family */
309 #define EM_TI_C5500 142 /* The Texas Instruments TMS320C55x DSP */
310 /* family */
311 #define EM_TI_ARP32 143 /* Texas Instruments Application Specific */
312 /* RISC Processor, 32bit fetch */
313 #define EM_TI_PRU 144 /* Texas Instruments Programmable Realtime */
314 /* Unit */
316 #define EM_MMDSP_PLUS 160 /* STMicroelectronics 64bit VLIW Data Signal */
317 /* Processor */
318 #define EM_CYPRESS_M8C 161 /* Cypress M8C microprocessor */
319 #define EM_R32C 162 /* Renesas R32C series microprocessors */
320 #define EM_TRIMEDIA 163 /* NXP Semiconductors TriMedia architecture */
321 /* family */
322 #define EM_QDSP6 164 /* QUALCOMM DSP6 Processor */
323 #define EM_8051 165 /* Intel 8051 and variants */
324 #define EM_STXP7X 166 /* STMicroelectronics STxP7x family of */
325 /* configurable and extensible RISC */
326 /* processors */
327 #define EM_NDS32 167 /* Andes Technology compact code size */
328 /* embedded RISC processor family */
329 #define EM_ECOG1 168 /* Cyan Technology eCOG1X family */
330 #define EM_ECOG1X EM_EC0G1X /* Cyan Technology eCOG1X family */
331 #define EM_MAXQ30 169 /* Dallas Semiconductor MAXQ30 Core */
332 /* Micro-controllers */
333 #define EM_XIMO16 170 /* New Japan Radio (NJR) 16-bit DSP Processor */
334 #define EM_MANIK 171 /* M2000 Reconfigurable RISC Microprocessor */
335 #define EM_CRAYNV2 172 /* Cray Inc. NV2 vector architecture */
336 #define EM_RX 173 /* Renesas RX family */
337 #define EM_METAG 174 /* Imagination Technologies META processor */
338 /* architecture */
339 #define EM_MCST_ELBRUS 175 /* MCST Elbrus general purpose hardware */
340 /* architecture */
341 #define EM_ECOG16 176 /* Cyan Technology eCOG16 family */
342 #define EM_CR16 177 /* National Semiconductor CompactRISC */
343 /* CR16 16-bit microprocessor */
344 #define EM_ETPU 178 /* Freescale Extended Time Processing Unit */
345 #define EM_SLE9X 179 /* Infineon Technologies SLE9X core */
346 #define EM_L10M 180 /* Intel L10M */
347 #define EM_K10M 181 /* Intel K10M */
349 #define EM_AARCH64 183 /* ARM 64-bit architecture (AARCH64) */
351 #define EM_AVR32 185 /* Atmel Corporation 32-bit microprocessor */
352 /* family */
353 #define EM_STM8 186 /* STMicroeletronics STM8 8-bit */
354 /* microcontroller */
355 #define EM_TILE64 187 /* Tilera TILE64 multicore architecture */
356 /* family */
357 #define EM_TILEPRO 188 /* Tilera TILEPro multicore architecture */
358 /* family */
359 #define EM_MICROBLAZE 189 /* Xilinx MicroBlaze 32-bit RISC soft */
360 /* processor core */
361 #define EM_CUDA 190 /* NVIDIA CUDA architecture */
362 #define EM_TILEGX 191 /* Tilera TILE-Gx multicore architecture */
363 /* family */
364 #define EM_CLOUDSHIELD 192 /* CloudShield architecture family */
365 #define EM_COREA_1ST 193 /* KIPO-KAIST Core-A 1st generation processor */
366 /* family */
367 #define EM_COREA_2ND 194 /* KIPO-KAIST Core-A 2nd generation processor */
368 /* family */
369 #define EM_ARC_COMPACT2 195 /* Synopsys ARCompact V2 */
370 #define EM_OPEN8 196 /* Open8 8-bit RISC soft processor core */
371 #define EM_RL78 197 /* Renesas RL78 family */
372 #define EM_VIDEOCORE5 198 /* Broadcom VideoCore V processor */
373 #define EM_78KOR 199 /* Renesas 78KOR family */
374 #define EM_56800EX 200 /* Freescale 56800EX Digital Signal */
375 /* Controller (DSC) */
376 #define EM_BA1 201 /* Beyond BA1 CPU architecture */
377 #define EM_BA2 202 /* Beyond BA2 CPU architecture */
378 #define EM_XCORE 203 /* XMOS xCORE processor family */
379 #define EM_MCHP_PIC 204 /* Microchip 8-bit PIC(r) family */
380 #define EM_INTEL205 205 /* Reserved by Intel */
381 #define EM_INTEL206 206 /* Reserved by Intel */
382 #define EM_INTEL207 207 /* Reserved by Intel */
383 #define EM_INTEL208 208 /* Reserved by Intel */
384 #define EM_INTEL209 209 /* Reserved by Intel */
385 #define EM_KM32 210 /* KM211 KM32 32-bit processor */
386 #define EM_KMX32 211 /* KM211 KMX32 32-bit processor */
387 #define EM_KMX16 212 /* KM211 KMX16 16-bit processor */
388 #define EM_KMX8 213 /* KM211 KMX8 8-bit processor */
389 #define EM_KVARC 214 /* KM211 KVARC processor */
390 #define EM_CDP 215 /* Paneve CDP architecture family */
391 #define EM_COGE 216 /* Cognitive Smart Memory Processor */
392 #define EM_COOL 217 /* Bluechip Systems CoolEngine */
393 #define EM_NORC 218 /* Nanoradio Optimized RISC */
394 #define EM_CSR_KALIMBA 219 /* CSR Kalimba architecture family */
395 #define EM_Z80 220 /* Zilog Z80 */
396 #define EM_VISIUM 221 /* Controls and Data Services VISIUMcore */
397 /* processor */
398 #define EM_FT32 222 /* FTDI Chip FT32 high performance 32-bit */
399 /* RISC architecture */
400 #define EM_MOXIE 223 /* Moxie processor family */
401 #define EM_AMDGPU 224 /* AMD GPU architecture */
403 #define EM_RISCV 243 /* RISC-V */
405 #define EM_NUM 244
407 #define EV_NONE 0 /* e_version, EI_VERSION */
408 #define EV_CURRENT 1
409 #define EV_NUM 2
412 #define ELFOSABI_NONE 0 /* No extensions or unspecified */
413 #define ELFOSABI_SYSV ELFOSABI_NONE
414 #define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */
415 #define ELFOSABI_NETBSD 2 /* NetBSD */
416 #define ELFOSABI_LINUX 3 /* Linux */
417 #define ELFOSABI_UNKNOWN4 4
418 #define ELFOSABI_UNKNOWN5 5
419 #define ELFOSABI_SOLARIS 6 /* Sun Solaris */
420 #define ELFOSABI_AIX 7 /* AIX */
421 #define ELFOSABI_IRIX 8 /* IRIX */
422 #define ELFOSABI_FREEBSD 9 /* FreeBSD */
423 #define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX */
424 #define ELFOSABI_MODESTO 11 /* Novell Modesto */
425 #define ELFOSABI_OPENBSD 12 /* Open BSD */
426 #define ELFOSABI_OPENVMS 13 /* Open VMS */
427 #define ELFOSABI_NSK 14 /* Hewlett-Packard Non-Stop Kernel */
428 #define ELFOSABI_AROS 15 /* Amiga Research OS */
429 #define ELFOSABI_FENIXOS 16 /* The FenixOS highly scalable */
430 /* multi-core OS */
431 #define ELFOSABI_CLOUDABI 17 /* Nuxi CloudABI */
432 #define ELFOSABI_OPENVOS 18 /* Stratus Technologies OpenVOS */
433 #define ELFOSABI_ARM 97 /* ARM */
434 #define ELFOSABI_STANDALONE 255 /* standalone (embedded) application */
436 #define EAV_SUNW_NONE 0 /* EI_ABIVERSION */
437 #define EAV_SUNW_CURRENT 1
438 #define EAV_SUNW_NUM 2
442 * Program header
445 typedef struct {
446 Elf32_Word p_type; /* entry type */
447 Elf32_Off p_offset; /* file offset */
448 Elf32_Addr p_vaddr; /* virtual address */
449 Elf32_Addr p_paddr; /* physical address */
450 Elf32_Word p_filesz; /* file size */
451 Elf32_Word p_memsz; /* memory size */
452 Elf32_Word p_flags; /* entry flags */
453 Elf32_Word p_align; /* memory/file alignment */
454 } Elf32_Phdr;
456 typedef struct {
457 Elf64_Word p_type; /* entry type */
458 Elf64_Word p_flags; /* entry flags */
459 Elf64_Off p_offset; /* file offset */
460 Elf64_Addr p_vaddr; /* virtual address */
461 Elf64_Addr p_paddr; /* physical address */
462 Elf64_Xword p_filesz; /* file size */
463 Elf64_Xword p_memsz; /* memory size */
464 Elf64_Xword p_align; /* memory/file alignment */
465 } Elf64_Phdr;
467 #define PT_NULL 0 /* p_type */
468 #define PT_LOAD 1
469 #define PT_DYNAMIC 2
470 #define PT_INTERP 3
471 #define PT_NOTE 4
472 #define PT_SHLIB 5
473 #define PT_PHDR 6
474 #define PT_TLS 7
475 #define PT_NUM 8
477 #define PT_LOOS 0x60000000 /* OS specific range */
480 * PT_SUNW_UNWIND and PT_SUNW_EH_FRAME perform the same function,
481 * providing access to the .eh_frame_hdr section of the object.
482 * PT_SUNW_UNWIND is the original value, while PT_SUNW_EH_FRAME is
483 * required by the amd64 psABI. The Solaris link-editor (ld) tags output
484 * objects with PT_SUNW_UNWIND, but the Solaris runtime linker (ld.so.1)
485 * will accept and use either value.
487 #define PT_SUNW_UNWIND 0x6464e550
488 #define PT_SUNW_EH_FRAME 0x6474e550
489 #define PT_GNU_EH_FRAME PT_SUNW_EH_FRAME
492 * Linux specific program headers not currently used by Solaris
494 #define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
495 #define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */
497 #define PT_LOSUNW 0x6ffffffa
498 #define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment (unused) */
499 #define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */
500 #define PT_SUNWDTRACE 0x6ffffffc /* private */
501 #define PT_SUNWCAP 0x6ffffffd /* hard/soft capabilities segment */
502 #define PT_HISUNW 0x6fffffff
503 #define PT_HIOS 0x6fffffff
505 #define PT_LOPROC 0x70000000 /* processor specific range */
506 #define PT_HIPROC 0x7fffffff
508 #define PF_R 0x4 /* p_flags */
509 #define PF_W 0x2
510 #define PF_X 0x1
512 #define PF_MASKOS 0x0ff00000 /* OS specific values */
513 #define PF_MASKPROC 0xf0000000 /* processor specific values */
515 #define PF_SUNW_FAILURE 0x00100000 /* mapping absent due to failure */
516 #define PF_SUNW_KILLED 0x00200000 /* signal received during dump */
517 #define PF_SUNW_SIGINFO 0x00400000 /* segment has killing sig's siginfo */
519 #define PN_XNUM 0xffff /* extended program header index */
522 * Section header
525 typedef struct {
526 Elf32_Word sh_name; /* section name */
527 Elf32_Word sh_type; /* SHT_... */
528 Elf32_Word sh_flags; /* SHF_... */
529 Elf32_Addr sh_addr; /* virtual address */
530 Elf32_Off sh_offset; /* file offset */
531 Elf32_Word sh_size; /* section size */
532 Elf32_Word sh_link; /* misc info */
533 Elf32_Word sh_info; /* misc info */
534 Elf32_Word sh_addralign; /* memory alignment */
535 Elf32_Word sh_entsize; /* entry size if table */
536 } Elf32_Shdr;
538 typedef struct {
539 Elf64_Word sh_name; /* section name */
540 Elf64_Word sh_type; /* SHT_... */
541 Elf64_Xword sh_flags; /* SHF_... */
542 Elf64_Addr sh_addr; /* virtual address */
543 Elf64_Off sh_offset; /* file offset */
544 Elf64_Xword sh_size; /* section size */
545 Elf64_Word sh_link; /* misc info */
546 Elf64_Word sh_info; /* misc info */
547 Elf64_Xword sh_addralign; /* memory alignment */
548 Elf64_Xword sh_entsize; /* entry size if table */
549 } Elf64_Shdr;
551 #define SHT_NULL 0 /* sh_type */
552 #define SHT_PROGBITS 1
553 #define SHT_SYMTAB 2
554 #define SHT_STRTAB 3
555 #define SHT_RELA 4
556 #define SHT_HASH 5
557 #define SHT_DYNAMIC 6
558 #define SHT_NOTE 7
559 #define SHT_NOBITS 8
560 #define SHT_REL 9
561 #define SHT_SHLIB 10
562 #define SHT_DYNSYM 11
563 #define SHT_UNKNOWN12 12
564 #define SHT_UNKNOWN13 13
565 #define SHT_INIT_ARRAY 14
566 #define SHT_FINI_ARRAY 15
567 #define SHT_PREINIT_ARRAY 16
568 #define SHT_GROUP 17
569 #define SHT_SYMTAB_SHNDX 18
570 #define SHT_NUM 19
572 /* Solaris ABI specific values */
573 #define SHT_LOOS 0x60000000 /* OS specific range */
574 #define SHT_LOSUNW 0x6fffffef
575 #define SHT_SUNW_capchain 0x6fffffef
576 #define SHT_SUNW_capinfo 0x6ffffff0
577 #define SHT_SUNW_symsort 0x6ffffff1
578 #define SHT_SUNW_tlssort 0x6ffffff2
579 #define SHT_SUNW_LDYNSYM 0x6ffffff3
580 #define SHT_SUNW_dof 0x6ffffff4
581 #define SHT_SUNW_cap 0x6ffffff5
582 #define SHT_SUNW_SIGNATURE 0x6ffffff6
583 #define SHT_SUNW_ANNOTATE 0x6ffffff7
584 #define SHT_SUNW_DEBUGSTR 0x6ffffff8
585 #define SHT_SUNW_DEBUG 0x6ffffff9
586 #define SHT_SUNW_move 0x6ffffffa
587 #define SHT_SUNW_COMDAT 0x6ffffffb
588 #define SHT_SUNW_syminfo 0x6ffffffc
589 #define SHT_SUNW_verdef 0x6ffffffd
590 #define SHT_GNU_verdef SHT_SUNW_verdef
591 #define SHT_SUNW_verneed 0x6ffffffe
592 #define SHT_GNU_verneed SHT_SUNW_verneed
593 #define SHT_SUNW_versym 0x6fffffff
594 #define SHT_GNU_versym SHT_SUNW_versym
595 #define SHT_HISUNW 0x6fffffff
596 #define SHT_HIOS 0x6fffffff
599 * GNU/Linux OSABI specific values with different meanings than under Solaris.
600 * Due to the overlap in assigned values with the Solaris OSABI, correct
601 * interpretation of these values requires knowledge of the OSABI used by
602 * the object.
604 #define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes */
605 #define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table */
606 #define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */
607 #define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content */
609 #define SHT_LOPROC 0x70000000 /* processor specific range */
610 #define SHT_HIPROC 0x7fffffff
612 #define SHT_LOUSER 0x80000000
613 #define SHT_HIUSER 0xffffffff
615 #define SHF_WRITE 0x01 /* sh_flags */
616 #define SHF_ALLOC 0x02
617 #define SHF_EXECINSTR 0x04
618 #define SHF_MERGE 0x10
619 #define SHF_STRINGS 0x20
620 #define SHF_INFO_LINK 0x40
621 #define SHF_LINK_ORDER 0x80
622 #define SHF_OS_NONCONFORMING 0x100
623 #define SHF_GROUP 0x200
624 #define SHF_TLS 0x400
626 #define SHF_MASKOS 0x0ff00000 /* OS specific values */
629 #define SHF_MASKPROC 0xf0000000 /* processor specific values */
631 #define SHN_UNDEF 0 /* special section numbers */
632 #define SHN_LORESERVE 0xff00
633 #define SHN_LOPROC 0xff00 /* processor specific range */
634 #define SHN_HIPROC 0xff1f
635 #define SHN_LOOS 0xff20 /* OS specific range */
636 #define SHN_LOSUNW 0xff3f
637 #define SHN_SUNW_IGNORE 0xff3f
638 #define SHN_HISUNW 0xff3f
639 #define SHN_HIOS 0xff3f
640 #define SHN_ABS 0xfff1
641 #define SHN_COMMON 0xfff2
642 #define SHN_XINDEX 0xffff /* extended sect index */
643 #define SHN_HIRESERVE 0xffff
648 * Symbol table
651 typedef struct {
652 Elf32_Word st_name;
653 Elf32_Addr st_value;
654 Elf32_Word st_size;
655 unsigned char st_info; /* bind, type: ELF_32_ST_... */
656 unsigned char st_other;
657 Elf32_Half st_shndx; /* SHN_... */
658 } Elf32_Sym;
660 typedef struct {
661 Elf64_Word st_name;
662 unsigned char st_info; /* bind, type: ELF_64_ST_... */
663 unsigned char st_other;
664 Elf64_Half st_shndx; /* SHN_... */
665 Elf64_Addr st_value;
666 Elf64_Xword st_size;
667 } Elf64_Sym;
669 #define STN_UNDEF 0
672 * Macros to compose and decompose values for S.st_info
674 * bind = ELF32_ST_BIND(S.st_info)
675 * type = ELF32_ST_TYPE(S.st_info)
676 * S.st_info = ELF32_ST_INFO(bind, type)
679 #define ELF32_ST_BIND(info) ((info) >> 4)
680 #define ELF32_ST_TYPE(info) ((info) & 0xf)
681 #define ELF32_ST_INFO(bind, type) (((bind)<<4)+((type)&0xf))
683 #define ELF64_ST_BIND(info) ((info) >> 4)
684 #define ELF64_ST_TYPE(info) ((info) & 0xf)
685 #define ELF64_ST_INFO(bind, type) (((bind)<<4)+((type)&0xf))
688 #define STB_LOCAL 0 /* BIND */
689 #define STB_GLOBAL 1
690 #define STB_WEAK 2
691 #define STB_NUM 3
693 #define STB_LOPROC 13 /* processor specific range */
694 #define STB_HIPROC 15
696 #define STT_NOTYPE 0 /* symbol type is unspecified */
697 #define STT_OBJECT 1 /* data object */
698 #define STT_FUNC 2 /* code object */
699 #define STT_SECTION 3 /* symbol identifies an ELF section */
700 #define STT_FILE 4 /* symbol's name is file name */
701 #define STT_COMMON 5 /* common data object */
702 #define STT_TLS 6 /* thread-local data object */
703 #define STT_NUM 7 /* # defined types in generic range */
704 #define STT_LOOS 10 /* OS specific range */
705 #define STT_HIOS 12
706 #define STT_LOPROC 13 /* processor specific range */
707 #define STT_HIPROC 15
710 * Macros to decompose values for S.st_other
712 * visibility = ELF32_ST_VISIBILITY(S.st_other)
714 #define ELF32_ST_VISIBILITY(other) ((other)&0x7)
715 #define ELF64_ST_VISIBILITY(other) ((other)&0x7)
717 #define STV_DEFAULT 0
718 #define STV_INTERNAL 1
719 #define STV_HIDDEN 2
720 #define STV_PROTECTED 3
721 #define STV_EXPORTED 4
722 #define STV_SINGLETON 5
723 #define STV_ELIMINATE 6
725 #define STV_NUM 7
728 * Relocation
731 typedef struct {
732 Elf32_Addr r_offset;
733 Elf32_Word r_info; /* sym, type: ELF32_R_... */
734 } Elf32_Rel;
736 typedef struct {
737 Elf32_Addr r_offset;
738 Elf32_Word r_info; /* sym, type: ELF32_R_... */
739 Elf32_Sword r_addend;
740 } Elf32_Rela;
742 typedef struct {
743 Elf64_Addr r_offset;
744 Elf64_Xword r_info; /* sym, type: ELF64_R_... */
745 } Elf64_Rel;
747 typedef struct {
748 Elf64_Addr r_offset;
749 Elf64_Xword r_info; /* sym, type: ELF64_R_... */
750 Elf64_Sxword r_addend;
751 } Elf64_Rela;
754 * Macros to compose and decompose values for Rel.r_info, Rela.f_info
756 * sym = ELF32_R_SYM(R.r_info)
757 * type = ELF32_R_TYPE(R.r_info)
758 * R.r_info = ELF32_R_INFO(sym, type)
761 #define ELF32_R_SYM(info) ((info)>>8)
762 #define ELF32_R_TYPE(info) ((unsigned char)(info))
763 #define ELF32_R_INFO(sym, type) (((sym)<<8)+(unsigned char)(type))
765 #define ELF64_R_SYM(info) ((info)>>32)
766 #define ELF64_R_TYPE(info) ((Elf64_Word)(info))
767 #define ELF64_R_INFO(sym, type) (((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(type))
771 * The r_info field is composed of two 32-bit components: the symbol
772 * table index and the relocation type. The relocation type for SPARC V9
773 * is further decomposed into an 8-bit type identifier and a 24-bit type
774 * dependent data field. For the existing Elf32 relocation types,
775 * that data field is zero.
777 #define ELF64_R_TYPE_DATA(info) (((Elf64_Xword)(info)<<32)>>40)
778 #define ELF64_R_TYPE_ID(info) (((Elf64_Xword)(info)<<56)>>56)
779 #define ELF64_R_TYPE_INFO(data, type) \
780 (((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type))
784 * Section Group Flags (SHT_GROUP)
786 #define GRP_COMDAT 0x01
790 * Note entry header
793 typedef struct {
794 Elf32_Word n_namesz; /* length of note's name */
795 Elf32_Word n_descsz; /* length of note's "desc" */
796 Elf32_Word n_type; /* type of note */
797 } Elf32_Nhdr;
799 typedef struct {
800 Elf64_Word n_namesz; /* length of note's name */
801 Elf64_Word n_descsz; /* length of note's "desc" */
802 Elf64_Word n_type; /* type of note */
803 } Elf64_Nhdr;
806 * Move entry
808 typedef struct {
809 Elf32_Lword m_value; /* symbol value */
810 Elf32_Word m_info; /* size + index */
811 Elf32_Word m_poffset; /* symbol offset */
812 Elf32_Half m_repeat; /* repeat count */
813 Elf32_Half m_stride; /* stride info */
814 } Elf32_Move;
817 * Macros to compose and decompose values for Move.r_info
819 * sym = ELF32_M_SYM(M.m_info)
820 * size = ELF32_M_SIZE(M.m_info)
821 * M.m_info = ELF32_M_INFO(sym, size)
823 #define ELF32_M_SYM(info) ((info)>>8)
824 #define ELF32_M_SIZE(info) ((unsigned char)(info))
825 #define ELF32_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size))
827 typedef struct {
828 Elf64_Lword m_value; /* symbol value */
829 Elf64_Xword m_info; /* size + index */
830 Elf64_Xword m_poffset; /* symbol offset */
831 Elf64_Half m_repeat; /* repeat count */
832 Elf64_Half m_stride; /* stride info */
833 } Elf64_Move;
834 #define ELF64_M_SYM(info) ((info)>>8)
835 #define ELF64_M_SIZE(info) ((unsigned char)(info))
836 #define ELF64_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size))
839 * Capabilities entry, Capabilities info and Capabilities chain.
841 #ifndef _ASM
842 typedef struct {
843 Elf32_Word c_tag; /* how to interpret value */
844 union {
845 Elf32_Word c_val;
846 Elf32_Addr c_ptr;
847 } c_un;
848 } Elf32_Cap;
850 typedef Elf32_Word Elf32_Capinfo;
851 typedef Elf32_Word Elf32_Capchain;
854 * Macros to compose and decompose values for capabilities info.
856 * sym = ELF32_C_SYM(info)
857 * grp = ELF32_C_GROUP(info)
858 * info = ELF32_C_INFO(sym, grp)
860 #define ELF32_C_SYM(info) ((info)>>8)
861 #define ELF32_C_GROUP(info) ((unsigned char)(info))
862 #define ELF32_C_INFO(sym, grp) (((sym)<<8)+(unsigned char)(grp))
865 typedef struct {
866 Elf64_Xword c_tag; /* how to interpret value */
867 union {
868 Elf64_Xword c_val;
869 Elf64_Addr c_ptr;
870 } c_un;
871 } Elf64_Cap;
873 typedef Elf64_Xword Elf64_Capinfo;
874 typedef Elf64_Word Elf64_Capchain;
877 * Macros to compose and decompose values for capabilities info.
879 * sym = ELF64_C_SYM(info)
880 * grp = ELF64_C_GROUP(info)
881 * info = ELF64_C_INFO(sym, grp)
883 #define ELF64_C_SYM(info) ((info)>>32)
884 #define ELF64_C_GROUP(info) ((Elf64_Word)(info))
885 #define ELF64_C_INFO(sym, grp) (((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(grp))
887 #endif
890 * Version numbers for SHT_SUNW_capinfo and SHT_SUNW_capchain.
892 #define CAPINFO_NONE 0
893 #define CAPINFO_CURRENT 1
894 #define CAPINFO_NUM 2
896 #define CAPCHAIN_NONE 0
897 #define CAPCHAIN_CURRENT 1
898 #define CAPCHAIN_NUM 2
901 * A SHT_SUNW_capinfo table mirrors a symbol table. A capabilities symbol has
902 * a SHT_SUNW_capinfo table entry that provides an index into the associated
903 * SHT_SUNW_cap capabilities group, and the symbol index of the associated lead
904 * symbol. A capabilities symbol is a local symbol. A global lead capabilities
905 * symbol is tagged with a group CAPINFO_SUNW_GLOB.
907 #define CAPINFO_SUNW_GLOB 0xff
910 * Capabilities values.
912 #define CA_SUNW_NULL 0
913 #define CA_SUNW_HW_1 1 /* first hardware capabilities entry */
914 #define CA_SUNW_SF_1 2 /* first software capabilities entry */
915 #define CA_SUNW_HW_2 3 /* second hardware capabilities entry */
916 #define CA_SUNW_PLAT 4 /* platform capability entry */
917 #define CA_SUNW_MACH 5 /* machine capability entry */
918 #define CA_SUNW_ID 6 /* capability identifier */
919 #define CA_SUNW_NUM 7
922 * Define software capabilities (CA_SUNW_SF_1 values). Note, hardware
923 * capabilities (CA_SUNW_HW_1 values) are taken directly from sys/auxv_$MACH.h.
925 #define SF1_SUNW_FPKNWN 0x001 /* frame pointer usage is known */
926 #define SF1_SUNW_FPUSED 0x002 /* frame pointer is in use */
927 #define SF1_SUNW_ADDR32 0x004 /* 32-bit address space requirement */
928 #define SF1_SUNW_MASK 0x007 /* known software capabilities mask */
931 * Known values for note entry types (e_type == ET_CORE)
933 #define NT_PRSTATUS 1 /* prstatus_t <sys/old_procfs.h> */
934 #define NT_PRFPREG 2 /* prfpregset_t <sys/old_procfs.h> */
935 #define NT_PRPSINFO 3 /* prpsinfo_t <sys/old_procfs.h> */
936 #define NT_PRXREG 4 /* prxregset_t <sys/procfs.h> */
937 #define NT_PLATFORM 5 /* string from sysinfo(SI_PLATFORM) */
938 #define NT_AUXV 6 /* auxv_t array <sys/auxv.h> */
939 #define NT_GWINDOWS 7 /* gwindows_t SPARC only */
940 #define NT_ASRS 8 /* asrset_t SPARC V9 only */
941 #define NT_LDT 9 /* ssd array <sys/sysi86.h> IA32 only */
942 #define NT_PSTATUS 10 /* pstatus_t <sys/procfs.h> */
943 #define NT_PSINFO 13 /* psinfo_t <sys/procfs.h> */
944 #define NT_PRCRED 14 /* prcred_t <sys/procfs.h> */
945 #define NT_UTSNAME 15 /* struct utsname <sys/utsname.h> */
946 #define NT_LWPSTATUS 16 /* lwpstatus_t <sys/procfs.h> */
947 #define NT_LWPSINFO 17 /* lwpsinfo_t <sys/procfs.h> */
948 #define NT_PRPRIV 18 /* prpriv_t <sys/procfs.h> */
949 #define NT_PRPRIVINFO 19 /* priv_impl_info_t <sys/priv.h> */
950 #define NT_CONTENT 20 /* core_content_t <sys/corectl.h> */
951 #define NT_ZONENAME 21 /* string from getzonenamebyid(3C) */
952 #define NT_FDINFO 22 /* open fd info */
953 #define NT_SPYMASTER 23 /* psinfo_t for agent LWP spymaster */
954 #define NT_SECFLAGS 24 /* process security-flags */
955 #define NT_NUM 24
958 #ifdef _KERNEL
960 * The following routine checks the processor-specific
961 * fields of an ELF header.
963 int elfheadcheck(unsigned char, Elf32_Half, Elf32_Word);
964 #endif
966 #ifdef __cplusplus
968 #endif
970 #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_SPARC)
971 #include <sys/elf_SPARC.h>
972 #endif
974 #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_386)
975 #include <sys/elf_386.h>
976 #endif
978 #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_AMD64)
979 #include <sys/elf_amd64.h>
980 #endif
982 #endif /* _SYS_ELF_H */