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