xref: /dragonfly/sys/sys/elf_common.h (revision 32efd857)
1 /*-
2  * Copyright (c) 1998 John D. Polstra.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26 
27 #ifndef _SYS_ELF_COMMON_H_
28 #define _SYS_ELF_COMMON_H_
29 
30 #ifndef _SYS_TYPES_H_
31 #include <sys/types.h>
32 #endif
33 
34 /*
35  * ELF definitions that are independent of architecture or word size.
36  */
37 
38 /*
39  * Note header.  The ".note" section contains an array of notes.  Each
40  * begins with this header, aligned to a word boundary.  Immediately
41  * following the note header is n_namesz bytes of name, padded to the
42  * next word boundary.  Then comes n_descsz bytes of descriptor, again
43  * padded to a word boundary.  The values of n_namesz and n_descsz do
44  * not include the padding.
45  */
46 
47 typedef struct {
48 	uint32_t	n_namesz;	/* Length of name. */
49 	uint32_t	n_descsz;	/* Length of descriptor. */
50 	uint32_t	n_type;		/* Type of this note. */
51 } Elf_Note;
52 typedef Elf_Note Elf_Nhdr;
53 
54 /* Indexes into the e_ident array.  Keep synced with
55    http://www.sco.com/developers/gabi/latest/ch4.eheader.html */
56 #define EI_MAG0		0	/* Magic number, byte 0. */
57 #define EI_MAG1		1	/* Magic number, byte 1. */
58 #define EI_MAG2		2	/* Magic number, byte 2. */
59 #define EI_MAG3		3	/* Magic number, byte 3. */
60 #define EI_CLASS	4	/* Class of machine. */
61 #define EI_DATA		5	/* Data format. */
62 #define EI_VERSION	6	/* ELF format version. */
63 #define EI_OSABI	7	/* Operating system / ABI identification */
64 #define EI_ABIVERSION	8	/* ABI version */
65 #define EI_PAD		9	/* Start of padding (per SVR4 ABI). */
66 #define EI_NIDENT	16	/* Size of e_ident array. */
67 
68 /* Values for the magic number bytes. */
69 #define ELFMAG0		0x7f
70 #define ELFMAG1		'E'
71 #define ELFMAG2		'L'
72 #define ELFMAG3		'F'
73 #define ELFMAG		"\177ELF"	/* magic string */
74 #define SELFMAG		4		/* magic string size */
75 
76 /* Values for e_ident[EI_VERSION] and e_version. */
77 #define EV_NONE		0
78 #define EV_CURRENT	1
79 
80 /* Values for e_ident[EI_CLASS]. */
81 #define ELFCLASSNONE	0	/* Unknown class. */
82 #define ELFCLASS32	1	/* 32-bit architecture. */
83 #define ELFCLASS64	2	/* 64-bit architecture. */
84 
85 /* Values for e_ident[EI_DATA]. */
86 #define ELFDATANONE	0	/* Unknown data format. */
87 #define ELFDATA2LSB	1	/* 2's complement little-endian. */
88 #define ELFDATA2MSB	2	/* 2's complement big-endian. */
89 
90 /* Values for e_ident[EI_OSABI]. */
91 #define ELFOSABI_SYSV		0	/* symbol used in old spec */
92 #define ELFOSABI_NONE		0	/* UNIX System V ABI */
93 #define ELFOSABI_HPUX		1	/* HP-UX operating system */
94 #define ELFOSABI_NETBSD 	2	/* NetBSD */
95 #define ELFOSABI_GNU		3	/* GNU */
96 #define ELFOSABI_LINUX		3	/* Alias for ELFOSABI_GNU */
97 #define ELFOSABI_SOLARIS	6	/* Solaris */
98 #define ELFOSABI_AIX		7	/* AIX */
99 #define ELFOSABI_IRIX		8	/* IRIX */
100 #define ELFOSABI_FREEBSD	9	/* FreeBSD */
101 #define ELFOSABI_TRU64		10	/* TRU64 UNIX */
102 #define ELFOSABI_MODESTO	11	/* Novell Modesto */
103 #define ELFOSABI_OPENBSD	12	/* OpenBSD */
104 #define ELFOSABI_OPENVMS	13	/* OpenVMS */
105 #define ELFOSABI_NSK		14	/* Hewlett-Packard Non-Stop Kernel */
106 #define ELFOSABI_AROS		15	/* AROS */
107 #define ELFOSABI_FENIXOS	16	/* FenixOS */
108 #define ELFOSABI_C6000_ELFABI	64	/* Bare-metal TMS320C6000 */
109 #define ELFOSABI_C6000_LINUX	65	/* Linux TMS320C6000 */
110 #define ELFOSABI_ARM		97	/* ARM */
111 #define ELFOSABI_STANDALONE	255	/* Standalone (embedded) application */
112 
113 /* e_ident */
114 #define IS_ELF(ehdr)	((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
115 			 (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
116 			 (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
117 			 (ehdr).e_ident[EI_MAG3] == ELFMAG3)
118 
119 /* Values for e_type, which identifies the object file type.  */
120 
121 #define ET_NONE 	0	/* No file type */
122 #define ET_REL		1	/* Relocatable file */
123 #define ET_EXEC 	2	/* Executable file */
124 #define ET_DYN		3	/* Shared object file */
125 #define ET_CORE 	4	/* Core file */
126 #define ET_LOOS 	0xFE00	/* Operating system-specific */
127 #define ET_HIOS 	0xFEFF	/* Operating system-specific */
128 #define ET_LOPROC	0xFF00	/* Processor-specific */
129 #define ET_HIPROC	0xFFFF	/* Processor-specific */
130 
131 /* Values for e_machine, which identifies the architecture.  These numbers
132    are officially assigned by registry@sco.com.  See below for a list of
133    ad-hoc numbers used during initial development.  */
134 
135 #define EM_NONE 	  0	/* No machine */
136 #define EM_M32		  1	/* AT&T WE 32100 */
137 #define EM_SPARC	  2	/* SUN SPARC */
138 #define EM_386		  3	/* Intel 80386 */
139 #define EM_68K		  4	/* Motorola m68k family */
140 #define EM_88K		  5	/* Motorola m88k family */
141 #define EM_486		  6	/* Intel 80486 *//* Reserved for future use */
142 #define EM_860		  7	/* Intel 80860 */
143 #define EM_MIPS 	  8	/* MIPS R3000 (officially, big-endian only) */
144 #define EM_S370 	  9	/* IBM System/370 */
145 #define EM_MIPS_RS3_LE	 10	/* MIPS R3000 little-endian (Oct 4 1999 Draft) Deprecated */
146 #define EM_res011	 11	/* Reserved */
147 #define EM_res012	 12	/* Reserved */
148 #define EM_res013	 13	/* Reserved */
149 #define EM_res014	 14	/* Reserved */
150 #define EM_PARISC	 15	/* HPPA */
151 #define EM_res016	 16	/* Reserved */
152 #define EM_VPP550	 17	/* Fujitsu VPP500 */
153 #define EM_SPARC32PLUS	 18	/* Sun's "v8plus" */
154 #define EM_960		 19	/* Intel 80960 */
155 #define EM_PPC		 20	/* PowerPC */
156 #define EM_PPC64	 21	/* 64-bit PowerPC */
157 #define EM_S390 	 22	/* IBM S/390 */
158 #define EM_SPU		 23	/* Sony/Toshiba/IBM SPU */
159 #define EM_res024	 24	/* Reserved */
160 #define EM_res025	 25	/* Reserved */
161 #define EM_res026	 26	/* Reserved */
162 #define EM_res027	 27	/* Reserved */
163 #define EM_res028	 28	/* Reserved */
164 #define EM_res029	 29	/* Reserved */
165 #define EM_res030	 30	/* Reserved */
166 #define EM_res031	 31	/* Reserved */
167 #define EM_res032	 32	/* Reserved */
168 #define EM_res033	 33	/* Reserved */
169 #define EM_res034	 34	/* Reserved */
170 #define EM_res035	 35	/* Reserved */
171 #define EM_V800 	 36	/* NEC V800 series */
172 #define EM_FR20 	 37	/* Fujitsu FR20 */
173 #define EM_RH32 	 38	/* TRW RH32 */
174 #define EM_MCORE	 39	/* Motorola M*Core */ /* May also be taken by Fujitsu MMA */
175 #define EM_RCE		 39	/* Old name for MCore */
176 #define EM_ARM		 40	/* ARM */
177 #define EM_OLD_ALPHA	 41	/* Digital Alpha */
178 #define EM_SH		 42	/* Renesas (formerly Hitachi) / SuperH SH */
179 #define EM_SPARCV9	 43	/* SPARC v9 64-bit */
180 #define EM_TRICORE	 44	/* Siemens Tricore embedded processor */
181 #define EM_ARC		 45	/* ARC Cores */
182 #define EM_H8_300	 46	/* Renesas (formerly Hitachi) H8/300 */
183 #define EM_H8_300H	 47	/* Renesas (formerly Hitachi) H8/300H */
184 #define EM_H8S		 48	/* Renesas (formerly Hitachi) H8S */
185 #define EM_H8_500	 49	/* Renesas (formerly Hitachi) H8/500 */
186 #define EM_IA_64	 50	/* Intel IA-64 Processor */
187 #define EM_MIPS_X	 51	/* Stanford MIPS-X */
188 #define EM_COLDFIRE	 52	/* Motorola Coldfire */
189 #define EM_68HC12	 53	/* Motorola M68HC12 */
190 #define EM_MMA		 54	/* Fujitsu Multimedia Accelerator */
191 #define EM_PCP		 55	/* Siemens PCP */
192 #define EM_NCPU 	 56	/* Sony nCPU embedded RISC processor */
193 #define EM_NDR1 	 57	/* Denso NDR1 microprocessor */
194 #define EM_STARCORE	 58	/* Motorola Star*Core processor */
195 #define EM_ME16 	 59	/* Toyota ME16 processor */
196 #define EM_ST100	 60	/* STMicroelectronics ST100 processor */
197 #define EM_TINYJ	 61	/* Advanced Logic Corp. TinyJ embedded processor */
198 #define EM_X86_64	 62	/* Advanced Micro Devices X86-64 processor */
199 #define EM_AMD64	 62	/* Advanced Micro Devices X86-64 (compat) */
200 #define EM_PDSP 	 63	/* Sony DSP Processor */
201 #define EM_PDP10	 64	/* Digital Equipment Corp. PDP-10 */
202 #define EM_PDP11	 65	/* Digital Equipment Corp. PDP-11 */
203 #define EM_FX66 	 66	/* Siemens FX66 microcontroller */
204 #define EM_ST9PLUS	 67	/* STMicroelectronics ST9+ 8/16 bit microcontroller */
205 #define EM_ST7		 68	/* STMicroelectronics ST7 8-bit microcontroller */
206 #define EM_68HC16	 69	/* Motorola MC68HC16 Microcontroller */
207 #define EM_68HC11	 70	/* Motorola MC68HC11 Microcontroller */
208 #define EM_68HC08	 71	/* Motorola MC68HC08 Microcontroller */
209 #define EM_68HC05	 72	/* Motorola MC68HC05 Microcontroller */
210 #define EM_SVX		 73	/* Silicon Graphics SVx */
211 #define EM_ST19 	 74	/* STMicroelectronics ST19 8-bit cpu */
212 #define EM_VAX		 75	/* Digital VAX */
213 #define EM_CRIS 	 76	/* Axis Communications 32-bit embedded processor */
214 #define EM_JAVELIN	 77	/* Infineon Technologies 32-bit embedded cpu */
215 #define EM_FIREPATH	 78	/* Element 14 64-bit DSP processor */
216 #define EM_ZSP		 79	/* LSI Logic's 16-bit DSP processor */
217 #define EM_MMIX 	 80	/* Donald Knuth's educational 64-bit processor */
218 #define EM_HUANY	 81	/* Harvard's machine-independent format */
219 #define EM_PRISM	 82	/* SiTera Prism */
220 #define EM_AVR		 83	/* Atmel AVR 8-bit microcontroller */
221 #define EM_FR30 	 84	/* Fujitsu FR30 */
222 #define EM_D10V 	 85	/* Mitsubishi D10V */
223 #define EM_D30V 	 86	/* Mitsubishi D30V */
224 #define EM_V850 	 87	/* Renesas V850 (formerly NEC V850) */
225 #define EM_M32R 	 88	/* Renesas M32R (formerly Mitsubishi M32R) */
226 #define EM_MN10300	 89	/* Matsushita MN10300 */
227 #define EM_MN10200	 90	/* Matsushita MN10200 */
228 #define EM_PJ		 91	/* picoJava */
229 #define EM_OPENRISC	 92	/* OpenRISC 32-bit embedded processor */
230 #define EM_ARC_A5	 93	/* ARC Cores Tangent-A5 */
231 #define EM_XTENSA	 94	/* Tensilica Xtensa Architecture */
232 #define EM_VIDEOCORE	 95	/* Alphamosaic VideoCore processor */
233 #define EM_TMM_GPP	 96	/* Thompson Multimedia General Purpose Processor */
234 #define EM_NS32K	 97	/* National Semiconductor 32000 series */
235 #define EM_TPC		 98	/* Tenor Network TPC processor */
236 #define EM_SNP1K	 99	/* Trebia SNP 1000 processor */
237 #define EM_ST200	100	/* STMicroelectronics ST200 microcontroller */
238 #define EM_IP2K 	101	/* Ubicom IP2022 micro controller */
239 #define EM_MAX		102	/* MAX Processor */
240 #define EM_CR		103	/* National Semiconductor CompactRISC */
241 #define EM_F2MC16	104	/* Fujitsu F2MC16 */
242 #define EM_MSP430	105	/* TI msp430 micro controller */
243 #define EM_BLACKFIN	106	/* ADI Blackfin */
244 #define EM_SE_C33	107	/* S1C33 Family of Seiko Epson processors */
245 #define EM_SEP		108	/* Sharp embedded microprocessor */
246 #define EM_ARCA 	109	/* Arca RISC Microprocessor */
247 #define EM_UNICORE	110	/* Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University */
248 #define EM_EXCESS	111	/* eXcess: 16/32/64-bit configurable embedded CPU */
249 #define EM_DXP		112	/* Icera Semiconductor Inc. Deep Execution Processor */
250 #define EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
251 #define EM_CRX		114	/* National Semiconductor CRX */
252 #define EM_XGATE	115	/* Motorola XGATE embedded processor */
253 #define EM_C166 	116	/* Infineon C16x/XC16x processor */
254 #define EM_M16C 	117	/* Renesas M16C series microprocessors */
255 #define EM_DSPIC30F	118	/* Microchip Technology dsPIC30F Digital Signal Controller */
256 #define EM_CE		119	/* Freescale Communication Engine RISC core */
257 #define EM_M32C 	120	/* Renesas M32C series microprocessors */
258 #define EM_res121	121	/* Reserved */
259 #define EM_res122	122	/* Reserved */
260 #define EM_res123	123	/* Reserved */
261 #define EM_res124	124	/* Reserved */
262 #define EM_res125	125	/* Reserved */
263 #define EM_res126	126	/* Reserved */
264 #define EM_res127	127	/* Reserved */
265 #define EM_res128	128	/* Reserved */
266 #define EM_res129	129	/* Reserved */
267 #define EM_res130	130	/* Reserved */
268 #define EM_TSK3000	131	/* Altium TSK3000 core */
269 #define EM_RS08 	132	/* Freescale RS08 embedded processor */
270 #define EM_res133	133	/* Reserved */
271 #define EM_ECOG2	134	/* Cyan Technology eCOG2 microprocessor */
272 #define EM_SCORE	135	/* Sunplus Score */
273 #define EM_SCORE7	135	/* Sunplus S+core7 RISC processor */
274 #define EM_DSP24	136	/* New Japan Radio (NJR) 24-bit DSP Processor */
275 #define EM_VIDEOCORE3	137	/* Broadcom VideoCore III processor */
276 #define EM_LATTICEMICO32 138	/* RISC processor for Lattice FPGA architecture */
277 #define EM_SE_C17	139	/* Seiko Epson C17 family */
278 #define EM_TI_C6000	140	/* Texas Instruments TMS320C6000 DSP family */
279 #define EM_TI_C2000	141	/* Texas Instruments TMS320C2000 DSP family */
280 #define EM_TI_C5500	142	/* Texas Instruments TMS320C55x DSP family */
281 #define EM_res143	143	/* Reserved */
282 #define EM_res144	144	/* Reserved */
283 #define EM_res145	145	/* Reserved */
284 #define EM_res146	146	/* Reserved */
285 #define EM_res147	147	/* Reserved */
286 #define EM_res148	148	/* Reserved */
287 #define EM_res149	149	/* Reserved */
288 #define EM_res150	150	/* Reserved */
289 #define EM_res151	151	/* Reserved */
290 #define EM_res152	152	/* Reserved */
291 #define EM_res153	153	/* Reserved */
292 #define EM_res154	154	/* Reserved */
293 #define EM_res155	155	/* Reserved */
294 #define EM_res156	156	/* Reserved */
295 #define EM_res157	157	/* Reserved */
296 #define EM_res158	158	/* Reserved */
297 #define EM_res159	159	/* Reserved */
298 #define EM_MMDSP_PLUS	160	/* STMicroelectronics 64bit VLIW Data Signal Processor */
299 #define EM_CYPRESS_M8C	161	/* Cypress M8C microprocessor */
300 #define EM_R32C 	162	/* Renesas R32C series microprocessors */
301 #define EM_TRIMEDIA	163	/* NXP Semiconductors TriMedia architecture family */
302 #define EM_QDSP6	164	/* QUALCOMM DSP6 Processor */
303 #define EM_8051 	165	/* Intel 8051 and variants */
304 #define EM_STXP7X	166	/* STMicroelectronics STxP7x family */
305 #define EM_NDS32	167	/* Andes Technology compact code size embedded RISC processor family */
306 #define EM_ECOG1	168	/* Cyan Technology eCOG1X family */
307 #define EM_ECOG1X	168	/* Cyan Technology eCOG1X family */
308 #define EM_MAXQ30	169	/* Dallas Semiconductor MAXQ30 Core Micro-controllers */
309 #define EM_XIMO16	170	/* New Japan Radio (NJR) 16-bit DSP Processor */
310 #define EM_MANIK	171	/* M2000 Reconfigurable RISC Microprocessor */
311 #define EM_CRAYNV2	172	/* Cray Inc. NV2 vector architecture */
312 #define EM_RX		173	/* Renesas RX family */
313 #define EM_METAG	174	/* Imagination Technologies META processor architecture */
314 #define EM_MCST_ELBRUS	175	/* MCST Elbrus general purpose hardware architecture */
315 #define EM_ECOG16	176	/* Cyan Technology eCOG16 family */
316 #define EM_CR16 	177	/* National Semiconductor CompactRISC 16-bit processor */
317 #define EM_ETPU 	178	/* Freescale Extended Time Processing Unit */
318 #define EM_SLE9X	179	/* Infineon Technologies SLE9X core */
319 #define EM_L1OM 	180	/* Intel L1OM */
320 #define EM_K1OM 	181	/* Intel K1OM */
321 #define EM_INTEL182	182	/* Reserved by Intel */
322 #define EM_res183	183	/* Reserved by ARM */
323 #define EM_res184	184	/* Reserved by ARM */
324 #define EM_AVR32	185	/* Atmel Corporation 32-bit microprocessor family */
325 #define EM_STM8 	186	/* STMicroeletronics STM8 8-bit microcontroller */
326 #define EM_TILE64	187	/* Tilera TILE64 multicore architecture family */
327 #define EM_TILEPRO	188	/* Tilera TILEPro multicore architecture family */
328 #define EM_MICROBLAZE	189	/* Xilinx MicroBlaze 32-bit RISC soft processor core */
329 #define EM_CUDA 	190	/* NVIDIA CUDA architecture */
330 #define EM_TILEGX	191	/* Tilera TILE-Gx multicore architecture family */
331 
332 /* Alpha backend magic number.  Written in the absence of an ABI.  */
333 #define EM_ALPHA		0x9026
334 
335 /* Special section indexes. */
336 
337 #define SHN_UNDEF	     0		/* Undefined, missing, irrelevant. */
338 #define SHN_LORESERVE	0xff00		/* First of reserved range. */
339 #define SHN_LOPROC	0xff00		/* First processor-specific. */
340 #define SHN_HIPROC	0xff1f		/* Last processor-specific. */
341 #define SHN_LOOS	0xff20		/* First operating system-specific. */
342 #define SHN_HIOS	0xff3f		/* Last operating system-specific. */
343 #define SHN_ABS 	0xfff1		/* Absolute values. */
344 #define SHN_COMMON	0xfff2		/* Common data. */
345 #define SHN_XINDEX	0xffff		/* Escape -- index stored elsewhere. */
346 #define SHN_HIRESERVE	0xffff		/* Last of reserved range. */
347 
348 /* Values for program header, p_type field. */
349 
350 #define PT_NULL 	0		/* Program header table entry unused */
351 #define PT_LOAD 	1		/* Loadable program segment */
352 #define PT_DYNAMIC	2		/* Dynamic linking information */
353 #define PT_INTERP	3		/* Program interpreter */
354 #define PT_NOTE 	4		/* Auxiliary information */
355 #define PT_SHLIB	5		/* Reserved, unspecified semantics */
356 #define PT_PHDR 	6		/* Entry for header table itself */
357 #define PT_TLS		7		/* Thread local storage segment */
358 #define PT_LOOS 	0x60000000	/* OS-specific */
359 #define PT_HIOS 	0x6fffffff	/* OS-specific */
360 #define PT_LOPROC	0x70000000	/* Processor-specific */
361 #define PT_HIPROC	0x7FFFFFFF	/* Processor-specific */
362 
363 #define PT_GNU_EH_FRAME (PT_LOOS + 0x474e550) /* Frame unwind information */
364 #define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME      /* Solaris uses the same value */
365 #define PT_GNU_STACK    (PT_LOOS + 0x474e551) /* Stack flags */
366 #define PT_GNU_RELRO    (PT_LOOS + 0x474e552) /* Read-only after relocation */
367 
368 /* Program segment permissions, in program header p_flags field.  */
369 
370 #define PF_X		0x1		/* Segment is executable */
371 #define PF_W		0x2		/* Segment is writable */
372 #define PF_R		0x4		/* Segment is readable */
373 #define PF_MASKOS	0x0FF00000	/* New value, Oct 4, 1999 Draft */
374 #define PF_MASKPROC	0xF0000000	/* Processor-specific reserved bits */
375 
376 /* Values for section header, sh_type field.  */
377 
378 #define SHT_NULL		 0	/* Section header table entry unused */
379 #define SHT_PROGBITS		 1	/* Program specific (private) data */
380 #define SHT_SYMTAB		 2	/* Link editing symbol table */
381 #define SHT_STRTAB		 3	/* A string table */
382 #define SHT_RELA		 4	/* Relocation entries with addends */
383 #define SHT_HASH		 5	/* A symbol hash table */
384 #define SHT_DYNAMIC		 6	/* Information for dynamic linking */
385 #define SHT_NOTE		 7	/* Information that marks file */
386 #define SHT_NOBITS		 8	/* Section occupies no space in file */
387 #define SHT_REL 		 9	/* Relocation entries, no addends */
388 #define SHT_SHLIB		10	/* Reserved, unspecified semantics */
389 #define SHT_DYNSYM		11	/* Dynamic linking symbol table */
390 
391 #define SHT_INIT_ARRAY		14	/* Array of ptrs to init functions */
392 #define SHT_FINI_ARRAY		15	/* Array of ptrs to finish functions */
393 #define SHT_PREINIT_ARRAY	16	/* Array of ptrs to pre-init funcs */
394 #define SHT_GROUP		17	/* Section contains a section group */
395 #define SHT_SYMTAB_SHNDX	18	/* Indicies for SHN_XINDEX entries */
396 
397 #define SHT_LOOS		0x60000000	/* First of OS specific semantics */
398 #define SHT_HIOS		0x6fffffff	/* Last of OS specific semantics */
399 
400 #define SHT_GNU_INCREMENTAL_INPUTS 0x6fff4700	/* incremental build data */
401 #define SHT_GNU_ATTRIBUTES	0x6ffffff5	/* Object attributes */
402 #define SHT_GNU_HASH		0x6ffffff6	/* GNU style symbol hash table */
403 #define SHT_GNU_LIBLIST 	0x6ffffff7	/* List of prelink dependencies */
404 
405 /* The next three section types are defined by Solaris, and are named
406    SHT_SUNW*.  We use them in GNU code, so we also define SHT_GNU*
407    versions.  */
408 #define SHT_SUNW_verdef 	0x6ffffffd	/* Versions defined by file */
409 #define SHT_SUNW_verneed	0x6ffffffe	/* Versions needed by file */
410 #define SHT_SUNW_versym 	0x6fffffff	/* Symbol versions */
411 
412 #define SHT_GNU_verdef		SHT_SUNW_verdef
413 #define SHT_GNU_verneed 	SHT_SUNW_verneed
414 #define SHT_GNU_versym		SHT_SUNW_versym
415 
416 #define SHT_LOPROC	0x70000000	/* Processor-specific semantics, lo */
417 #define SHT_HIPROC	0x7FFFFFFF	/* Processor-specific semantics, hi */
418 #define SHT_LOUSER	0x80000000	/* Application-specific semantics */
419 #define SHT_HIUSER	0xFFFFFFFF	/* New value, defined in Oct 4, 1999 Draft */
420 
421 /* Values for section header, sh_flags field.  */
422 
423 #define SHF_WRITE		0x1	/* Writable data during execution */
424 #define SHF_ALLOC		0x2	/* Occupies memory during execution */
425 #define SHF_EXECINSTR		0x4	/* Executable machine instructions */
426 #define SHF_MERGE		0x10	/* Data in this section can be merged */
427 #define SHF_STRINGS		0x20	/* Contains null terminated character strings */
428 #define SHF_INFO_LINK		0x40	/* sh_info holds section header table index */
429 #define SHF_LINK_ORDER		0x80	/* Preserve section ordering when linking */
430 #define SHF_OS_NONCONFORMING	0x100	/* OS specific processing required */
431 #define SHF_GROUP		0x200	/* Member of a section group */
432 #define SHF_TLS			0x400	/* Thread local storage section */
433 
434 #define SHF_MASKOS	0x0FF00000	/* New value, Oct 4, 1999 Draft */
435 #define SHF_MASKPROC	0xF0000000	/* Processor-specific semantics */
436 
437 /* Values of note segment descriptor types for core files. */
438 
439 #define NT_PRSTATUS	1		/* Contains copy of prstatus struct */
440 #define NT_FPREGSET	2		/* Contains copy of fpregset struct */
441 #define NT_PRPSINFO	3		/* Contains copy of prpsinfo struct */
442 #define NT_TASKSTRUCT	4		/* Contains copy of task struct */
443 #define NT_AUXV 	6		/* Contains copy of Elfxx_auxv_t */
444 
445 /* GNU note types. */
446 #define NT_GNU_ABI_TAG		1
447 #define NT_GNU_HWCAP		2
448 #define NT_GNU_BUILD_ID		3
449 #define NT_GNU_GOLD_VERSION	4
450 #define NT_GNU_PROPERTY_TYPE_0	5
451 
452 #define GNU_PROPERTY_LOPROC			0xc0000000
453 #define GNU_PROPERTY_HIPROC			0xdfffffff
454 
455 #define GNU_PROPERTY_X86_FEATURE_1_AND		0xc0000002
456 
457 #define GNU_PROPERTY_X86_FEATURE_1_IBT		0x00000001
458 #define GNU_PROPERTY_X86_FEATURE_1_SHSTK	0x00000002
459 
460 #define STN_UNDEF	0		/* Undefined symbol index */
461 
462 #define STB_LOCAL	0		/* Symbol not visible outside obj */
463 #define STB_GLOBAL	1		/* Symbol visible outside obj */
464 #define STB_WEAK	2		/* Like globals, lower precedence */
465 #define STB_LOOS	10		/* OS-specific semantics */
466 #define STB_GNU_UNIQUE	10		/* Symbol is unique in namespace */
467 #define STB_HIOS	12		/* OS-specific semantics */
468 #define STB_LOPROC	13		/* Processor-specific semantics */
469 #define STB_HIPROC	15		/* Processor-specific semantics */
470 
471 #define STT_NOTYPE	0		/* Symbol type is unspecified */
472 #define STT_OBJECT	1		/* Symbol is a data object */
473 #define STT_FUNC	2		/* Symbol is a code object */
474 #define STT_SECTION	3		/* Symbol associated with a section */
475 #define STT_FILE	4		/* Symbol gives a file name */
476 #define STT_COMMON	5		/* An uninitialised common block */
477 #define STT_TLS 	6		/* Thread local data object */
478 #define STT_RELC	8		/* Complex relocation expression */
479 #define STT_SRELC	9		/* Signed Complex relocation expression */
480 #define STT_LOOS	10		/* OS-specific semantics */
481 #define STT_GNU_IFUNC	10		/* Symbol is an indirect code object */
482 #define STT_HIOS	12		/* OS-specific semantics */
483 #define STT_LOPROC	13		/* Processor-specific semantics */
484 #define STT_HIPROC	15		/* Processor-specific semantics */
485 
486 /* The following constants control how a symbol may be accessed once it has
487    become part of an executable or shared library.  */
488 
489 #define STV_DEFAULT	0		/* Visibility is specified by binding type */
490 #define STV_INTERNAL	1		/* OS specific version of STV_HIDDEN */
491 #define STV_HIDDEN	2		/* Can only be seen inside currect component */
492 #define STV_PROTECTED	3		/* Treat as STB_LOCAL inside current component */
493 
494 /* Dynamic section tags.  */
495 
496 #define DT_NULL 	0	/* Terminating entry. */
497 #define DT_NEEDED	1	/* String table offset of a needed shared
498 				   library. */
499 #define DT_PLTRELSZ	2	/* Total size in bytes of PLT relocations. */
500 #define DT_PLTGOT	3	/* Processor-dependent address. */
501 #define DT_HASH 	4	/* Address of symbol hash table. */
502 #define DT_STRTAB	5	/* Address of string table. */
503 #define DT_SYMTAB	6	/* Address of symbol table. */
504 #define DT_RELA 	7	/* Address of ElfNN_Rela relocations. */
505 #define DT_RELASZ	8	/* Total size of ElfNN_Rela relocations. */
506 #define DT_RELAENT	9	/* Size of each ElfNN_Rela relocation entry. */
507 #define DT_STRSZ	10	/* Size of string table. */
508 #define DT_SYMENT	11	/* Size of each symbol table entry. */
509 #define DT_INIT 	12	/* Address of initialization function. */
510 #define DT_FINI 	13	/* Address of finalization function. */
511 #define DT_SONAME	14	/* String table offset of shared object
512 				   name. */
513 #define DT_RPATH	15	/* String table offset of library path. [sup] */
514 #define DT_SYMBOLIC	16	/* Indicates "symbolic" linking. [sup] */
515 #define DT_REL		17	/* Address of ElfNN_Rel relocations. */
516 #define DT_RELSZ	18	/* Total size of ElfNN_Rel relocations. */
517 #define DT_RELENT	19	/* Size of each ElfNN_Rel relocation. */
518 #define DT_PLTREL	20	/* Type of relocation used for PLT. */
519 #define DT_DEBUG	21	/* Reserved (not used). */
520 #define DT_TEXTREL	22	/* Indicates there may be relocations in
521 				   non-writable segments. [sup] */
522 #define DT_JMPREL	23	/* Address of PLT relocations. */
523 #define DT_BIND_NOW	24	/* [sup] */
524 #define DT_INIT_ARRAY	25	/* Address of the array of pointers to
525 				   initialization functions */
526 #define DT_FINI_ARRAY	26	/* Address of the array of pointers to
527 				   termination functions */
528 #define DT_INIT_ARRAYSZ	27	/* Size in bytes of the array of
529 				   initialization functions. */
530 #define DT_FINI_ARRAYSZ	28	/* Size in bytes of the array of
531 				   terminationfunctions. */
532 #define DT_RUNPATH	29	/* String table offset of a null-terminated
533 				   library search path string. */
534 #define DT_FLAGS	30	/* Object specific flag values. */
535 #define DT_ENCODING	32	/* Values greater than or equal to DT_ENCODING
536 				   and less than DT_LOOS follow the rules for
537 				   the interpretation of the d_un union
538 				   as follows: even == 'd_ptr', odd == 'd_val'
539 				   or none */
540 #define DT_PREINIT_ARRAY 32	/* Address of the array of pointers to
541 				   pre-initialization functions. */
542 #define DT_PREINIT_ARRAYSZ 33	/* Size in bytes of the array of
543 				   pre-initialization functions. */
544 
545 #define DT_LOOS		0x6000000d	/* First OS-specific */
546 #define DT_HIOS		0x6fff0000	/* Last OS-specific */
547 
548 /* The next 2 dynamic tag ranges, integer value range (DT_VALRNGLO to
549    DT_VALRNGHI) and virtual address range (DT_ADDRRNGLO to DT_ADDRRNGHI),
550    are used on Solaris.  We support them everywhere.  Note these values
551    lie outside of the (new) range for OS specific values.  This is a
552    deliberate special case and we maintain it for backwards compatibility.
553  */
554 #define DT_VALRNGLO		0x6ffffd00
555 #define DT_GNU_PRELINKED	0x6ffffdf5
556 #define DT_GNU_CONFLICTSZ	0x6ffffdf6
557 #define DT_GNU_LIBLISTSZ	0x6ffffdf7
558 #define DT_CHECKSUM	0x6ffffdf8	/* elf checksum */
559 #define DT_PLTPADSZ	0x6ffffdf9	/* pltpadding size */
560 #define DT_MOVEENT	0x6ffffdfa	/* move table entry size */
561 #define DT_MOVESZ	0x6ffffdfb	/* move table size */
562 #define DT_FEATURE	0x6ffffdfc	/* feature holder */
563 #define DT_POSFLAG_1	0x6ffffdfd	/* flags for DT_* entries, effecting */
564 					/*   the following DT_* entry. */
565 					/*   See DF_P1_* definitions */
566 #define DT_SYMINSZ	0x6ffffdfe	/* syminfo table size (in bytes) */
567 #define DT_SYMINENT	0x6ffffdff	/* syminfo entry size (in bytes) */
568 #define DT_VALRNGHI	0x6ffffdff
569 
570 #define DT_ADDRRNGLO	0x6ffffe00
571 #define DT_GNU_HASH	0x6ffffef5	/* GNU-style hash table */
572 #define DT_TLSDESC_PLT	0x6ffffef6
573 #define DT_TLSDESC_GOT	0x6ffffef7
574 #define DT_GNU_CONFLICT 0x6ffffef8
575 #define DT_GNU_LIBLIST	0x6ffffef9
576 #define DT_CONFIG	0x6ffffefa	/* configuration information */
577 #define DT_DEPAUDIT	0x6ffffefb	/* dependency auditing */
578 #define DT_AUDIT	0x6ffffefc	/* object auditing */
579 #define DT_PLTPAD	0x6ffffefd	/* pltpadding (sparcv9) */
580 #define DT_MOVETAB	0x6ffffefe	/* move table */
581 #define DT_SYMINFO	0x6ffffeff	/* syminfo table */
582 #define DT_ADDRRNGHI	0x6ffffeff
583 
584 #define DT_RELACOUNT	0x6ffffff9	/* number of RELATIVE relocations */
585 #define DT_RELCOUNT	0x6ffffffa	/* number of RELATIVE relocations */
586 #define DT_FLAGS_1	0x6ffffffb	/* state flags - see DF_1_* defs */
587 #define DT_VERDEF	0x6ffffffc	/* Address of verdef section. */
588 #define DT_VERDEFNUM	0x6ffffffd	/* Number of elems in verdef section */
589 #define DT_VERNEED	0x6ffffffe	/* Address of verneed section. */
590 #define DT_VERNEEDNUM	0x6fffffff	/* Number of elems in verneed section */
591 
592 /* This tag is a GNU extension to the Solaris version scheme.  */
593 #define DT_VERSYM	0x6ffffff0
594 
595 #define DT_LOPROC	0x70000000	/* First processor-specific type. */
596 #define DT_HIPROC	0x7fffffff	/* Last processor-specific type. */
597 
598 /* These section tags are used on Solaris.  We support them
599    everywhere, and hope they do not conflict.  */
600 
601 #define DT_AUXILIARY	0x7ffffffd	/* shared library auxiliary name */
602 #define DT_USED 	0x7ffffffe	/* ignored - same as needed */
603 #define DT_FILTER	0x7fffffff	/* shared library filter name */
604 
605 
606 /* Values used in DT_FEATURE .dynamic entry.  */
607 #define DTF_1_PARINIT	0x00000001
608 /* From
609 
610    http://docs.sun.com:80/ab2/coll.45.13/LLM/@Ab2PageView/21165?Ab2Lang=C&Ab2Enc=iso-8859-1
611 
612    DTF_1_CONFEXP is the same as DTF_1_PARINIT. It is a typo. The value
613    defined here is the same as the one in <sys/link.h> on Solaris 8.  */
614 #define DTF_1_CONFEXP	0x00000002
615 
616 /* Flag values used in the DT_POSFLAG_1 .dynamic entry.	 */
617 #define DF_P1_LAZYLOAD	0x00000001
618 #define DF_P1_GROUPPERM 0x00000002
619 
620 /* Flag value in in the DT_FLAGS_1 .dynamic entry.  */
621 #define DF_1_NOW	0x00000001
622 #define DF_1_BIND_NOW	0x00000001	/* Same as DF_BIND_NOW */
623 #define DF_1_GLOBAL	0x00000002	/* Set the RTLD_GLOBAL for object */
624 #define DF_1_GROUP	0x00000004
625 #define DF_1_NODELETE	0x00000008	/* Set the RTLD_NODELETE for object */
626 #define DF_1_LOADFLTR	0x00000010	/* Immediate loading of filtees */
627 #define DF_1_INITFIRST	0x00000020
628 #define DF_1_NOOPEN	0x00000040	/* Do not allow loading on dlopen() */
629 #define DF_1_ORIGIN	0x00000080	/* Process $ORIGIN */
630 #define DF_1_DIRECT	0x00000100
631 #define DF_1_TRANS	0x00000200
632 #define DF_1_INTERPOSE	0x00000400
633 #define DF_1_NODEFLIB	0x00000800
634 #define DF_1_NODUMP	0x00001000
635 #define DF_1_CONLFAT	0x00002000
636 
637 /* Flag values for the DT_FLAGS entry. */
638 #define DF_ORIGIN	0x1	/* Indicates that the object being loaded may
639 				   make reference to the $ORIGIN substitution
640 				   string */
641 #define DF_SYMBOLIC	0x2	/* Indicates "symbolic" linking. */
642 #define DF_TEXTREL	0x4	/* Indicates there may be relocations in
643 				   non-writable segments. */
644 #define DF_BIND_NOW	0x8	/* Indicates that the dynamic linker should
645 				   process all relocations for the object
646 				   containing this entry before transferring
647 				   control to the program. */
648 #define DF_STATIC_TLS	0x10	/* Indicates that the shared object or
649 				   executable contains code using a static
650 				   thread-local storage scheme. */
651 
652 /* These constants are used for the version number of a Elf32_Verdef
653    structure.  */
654 
655 #define VER_DEF_NONE		0
656 #define VER_DEF_CURRENT 	1
657 #define VER_DEF_IDX(x)		VER_NDX(x)
658 
659 /* These constants appear in the vd_flags field of a Elf32_Verdef
660    structure.
661 
662    Cf. the Solaris Linker and Libraries Guide, Ch. 7, Object File Format,
663    Versioning Sections, for a description:
664 
665    http://docs.sun.com/app/docs/doc/819-0690/chapter6-93046?l=en&a=view  */
666 
667 #define VER_FLG_BASE		0x1
668 #define VER_FLG_WEAK		0x2
669 #define VER_FLG_INFO		0x4
670 
671 /* These special constants can be found in an Elf32_Versym field.  */
672 
673 #define VER_NDX_LOCAL		0
674 #define VER_NDX_GLOBAL		1
675 #define VER_NDX_GIVEN		2
676 #define VER_NDX_HIDDEN		(1u << 15)
677 #define VER_NDX(x)		((x) & ~(1u << 15))
678 /* These constants are used for the version number of a Elf32_Verneed
679    structure.  */
680 
681 #define VER_NEED_NONE		0
682 #define VER_NEED_CURRENT	1
683 #define VER_NEED_WEAK		(1u << 15)
684 #define VER_NEED_HIDDEN 	VER_NDX_HIDDEN
685 #define VER_NEED_IDX(x) 	VER_NDX(x)
686 
687 /* This flag appears in a Versym structure.  It means that the symbol
688    is hidden, and is only visible with an explicit version number.
689    This is a GNU extension.  */
690 
691 #define VERSYM_HIDDEN		0x8000
692 
693 /* This is the mask for the rest of the Versym information.  */
694 
695 #define VERSYM_VERSION		0x7fff
696 
697 /* This is a special token which appears as part of a symbol name.  It
698    indictes that the rest of the name is actually the name of a
699    version node, and is not part of the actual name.  This is a GNU
700    extension.  For example, the symbol name `stat@ver2' is taken to
701    mean the symbol `stat' in version `ver2'.  */
702 
703 #define ELF_VER_CHR		'@'
704 
705 /* Possible values for si_boundto.  */
706 
707 #define SYMINFO_BT_SELF 	0xffff	/* Symbol bound to self */
708 #define SYMINFO_BT_PARENT	0xfffe	/* Symbol bound to parent */
709 #define SYMINFO_BT_LOWRESERVE	0xff00	/* Beginning of reserved entries */
710 
711 /* Possible bitmasks for si_flags.  */
712 
713 #define SYMINFO_FLG_DIRECT	0x0001	/* Direct bound symbol */
714 #define SYMINFO_FLG_PASSTHRU	0x0002	/* Pass-thru symbol for translator */
715 #define SYMINFO_FLG_COPY	0x0004	/* Symbol is a copy-reloc */
716 #define SYMINFO_FLG_LAZYLOAD	0x0008	/* Symbol bound to object to be lazy loaded */
717 
718 /* Syminfo version values.  */
719 
720 #define SYMINFO_NONE		0
721 #define SYMINFO_CURRENT 	1
722 #define SYMINFO_NUM		2
723 
724 /* Section Group Flags.	 */
725 
726 #define GRP_COMDAT		0x1	/* A COMDAT group */
727 
728 #endif /* !_SYS_ELF_COMMON_H_ */
729