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