xref: /illumos-gate/usr/src/uts/common/sys/elf.h (revision ff4c9ae3)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5c13de8f6Sab  * Common Development and Distribution License (the "License").
6c13de8f6Sab  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
2134bdffbfSGarrett D'Amore /*
2234bdffbfSGarrett D'Amore  * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
23856f620eSRobert Mustacchi  * Copyright (c) 2018, Joyent, Inc.
24350ffdd5SRobert Mustacchi  * Copyright 2020 Oxide Computer Company
2534bdffbfSGarrett D'Amore  */
267c478bd9Sstevel@tonic-gate /*
2769112eddSAli Bahrami  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
287c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
297c478bd9Sstevel@tonic-gate  */
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
32b4203d75SMarcel Telka /*	  All Rights Reserved	*/
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifndef _SYS_ELF_H
367c478bd9Sstevel@tonic-gate #define	_SYS_ELF_H
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #include <sys/elftypes.h>
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
417c478bd9Sstevel@tonic-gate extern "C" {
427c478bd9Sstevel@tonic-gate #endif
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #define	ELF32_FSZ_ADDR	4
457c478bd9Sstevel@tonic-gate #define	ELF32_FSZ_HALF	2
467c478bd9Sstevel@tonic-gate #define	ELF32_FSZ_OFF	4
477c478bd9Sstevel@tonic-gate #define	ELF32_FSZ_SWORD	4
487c478bd9Sstevel@tonic-gate #define	ELF32_FSZ_WORD	4
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_ADDR	8
517c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_HALF	2
527c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_OFF	8
537c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_SWORD	4
547c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_WORD	4
557c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_SXWORD 8
567c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_XWORD	8
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate /*
597c478bd9Sstevel@tonic-gate  *	"Enumerations" below use ...NUM as the number of
607c478bd9Sstevel@tonic-gate  *	values in the list.  It should be 1 greater than the
617c478bd9Sstevel@tonic-gate  *	highest "real" value.
627c478bd9Sstevel@tonic-gate  */
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  *	ELF header
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #define	EI_NIDENT	16
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate typedef struct {
717c478bd9Sstevel@tonic-gate 	unsigned char	e_ident[EI_NIDENT];	/* ident bytes */
727c478bd9Sstevel@tonic-gate 	Elf32_Half	e_type;			/* file type */
737c478bd9Sstevel@tonic-gate 	Elf32_Half	e_machine;		/* target machine */
747c478bd9Sstevel@tonic-gate 	Elf32_Word	e_version;		/* file version */
757c478bd9Sstevel@tonic-gate 	Elf32_Addr	e_entry;		/* start address */
767c478bd9Sstevel@tonic-gate 	Elf32_Off	e_phoff;		/* phdr file offset */
777c478bd9Sstevel@tonic-gate 	Elf32_Off	e_shoff;		/* shdr file offset */
787c478bd9Sstevel@tonic-gate 	Elf32_Word	e_flags;		/* file flags */
797c478bd9Sstevel@tonic-gate 	Elf32_Half	e_ehsize;		/* sizeof ehdr */
807c478bd9Sstevel@tonic-gate 	Elf32_Half	e_phentsize;		/* sizeof phdr */
817c478bd9Sstevel@tonic-gate 	Elf32_Half	e_phnum;		/* number phdrs */
827c478bd9Sstevel@tonic-gate 	Elf32_Half	e_shentsize;		/* sizeof shdr */
837c478bd9Sstevel@tonic-gate 	Elf32_Half	e_shnum;		/* number shdrs */
847c478bd9Sstevel@tonic-gate 	Elf32_Half	e_shstrndx;		/* shdr string index */
857c478bd9Sstevel@tonic-gate } Elf32_Ehdr;
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
887c478bd9Sstevel@tonic-gate typedef struct {
897c478bd9Sstevel@tonic-gate 	unsigned char	e_ident[EI_NIDENT];	/* ident bytes */
907c478bd9Sstevel@tonic-gate 	Elf64_Half	e_type;			/* file type */
917c478bd9Sstevel@tonic-gate 	Elf64_Half	e_machine;		/* target machine */
927c478bd9Sstevel@tonic-gate 	Elf64_Word	e_version;		/* file version */
937c478bd9Sstevel@tonic-gate 	Elf64_Addr	e_entry;		/* start address */
947c478bd9Sstevel@tonic-gate 	Elf64_Off	e_phoff;		/* phdr file offset */
957c478bd9Sstevel@tonic-gate 	Elf64_Off	e_shoff;		/* shdr file offset */
967c478bd9Sstevel@tonic-gate 	Elf64_Word	e_flags;		/* file flags */
977c478bd9Sstevel@tonic-gate 	Elf64_Half	e_ehsize;		/* sizeof ehdr */
987c478bd9Sstevel@tonic-gate 	Elf64_Half	e_phentsize;		/* sizeof phdr */
997c478bd9Sstevel@tonic-gate 	Elf64_Half	e_phnum;		/* number phdrs */
1007c478bd9Sstevel@tonic-gate 	Elf64_Half	e_shentsize;		/* sizeof shdr */
1017c478bd9Sstevel@tonic-gate 	Elf64_Half	e_shnum;		/* number shdrs */
1027c478bd9Sstevel@tonic-gate 	Elf64_Half	e_shstrndx;		/* shdr string index */
1037c478bd9Sstevel@tonic-gate } Elf64_Ehdr;
1047c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate #define	EI_MAG0		0	/* e_ident[] indexes */
1087c478bd9Sstevel@tonic-gate #define	EI_MAG1		1
1097c478bd9Sstevel@tonic-gate #define	EI_MAG2		2
1107c478bd9Sstevel@tonic-gate #define	EI_MAG3		3
1117c478bd9Sstevel@tonic-gate #define	EI_CLASS	4	/* File class */
1127c478bd9Sstevel@tonic-gate #define	EI_DATA		5	/* Data encoding */
1137c478bd9Sstevel@tonic-gate #define	EI_VERSION	6	/* File version */
1147c478bd9Sstevel@tonic-gate #define	EI_OSABI	7	/* Operating system/ABI identification */
1157c478bd9Sstevel@tonic-gate #define	EI_ABIVERSION	8	/* ABI version */
1167c478bd9Sstevel@tonic-gate #define	EI_PAD		9	/* Start of padding bytes */
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate #define	ELFMAG0		0x7f		/* EI_MAG */
1197c478bd9Sstevel@tonic-gate #define	ELFMAG1		'E'
1207c478bd9Sstevel@tonic-gate #define	ELFMAG2		'L'
1217c478bd9Sstevel@tonic-gate #define	ELFMAG3		'F'
1227c478bd9Sstevel@tonic-gate #define	ELFMAG		"\177ELF"
1237c478bd9Sstevel@tonic-gate #define	SELFMAG		4
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate #define	ELFCLASSNONE	0		/* EI_CLASS */
1267c478bd9Sstevel@tonic-gate #define	ELFCLASS32	1
1277c478bd9Sstevel@tonic-gate #define	ELFCLASS64	2
1287c478bd9Sstevel@tonic-gate #define	ELFCLASSNUM	3
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate #define	ELFDATANONE	0		/* EI_DATA */
1317c478bd9Sstevel@tonic-gate #define	ELFDATA2LSB	1
1327c478bd9Sstevel@tonic-gate #define	ELFDATA2MSB	2
1337c478bd9Sstevel@tonic-gate #define	ELFDATANUM	3
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate #define	ET_NONE		0		/* e_type */
1367c478bd9Sstevel@tonic-gate #define	ET_REL		1
1377c478bd9Sstevel@tonic-gate #define	ET_EXEC		2
1387c478bd9Sstevel@tonic-gate #define	ET_DYN		3
1397c478bd9Sstevel@tonic-gate #define	ET_CORE		4
1407c478bd9Sstevel@tonic-gate #define	ET_NUM		5
1417c478bd9Sstevel@tonic-gate #define	ET_LOOS		0xfe00		/* OS specific range */
1427c478bd9Sstevel@tonic-gate #define	ET_LOSUNW	0xfeff
1437c478bd9Sstevel@tonic-gate #define	ET_SUNWPSEUDO	0xfeff
1447c478bd9Sstevel@tonic-gate #define	ET_HISUNW	0xfeff
1457c478bd9Sstevel@tonic-gate #define	ET_HIOS		0xfeff
1467c478bd9Sstevel@tonic-gate #define	ET_LOPROC	0xff00		/* processor specific range */
1477c478bd9Sstevel@tonic-gate #define	ET_HIPROC	0xffff
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate #define	ET_LOPROC	0xff00		/* processor specific range */
1507c478bd9Sstevel@tonic-gate #define	ET_HIPROC	0xffff
1517c478bd9Sstevel@tonic-gate 
152856f620eSRobert Mustacchi #define	EM_NONE		0	/* e_machine */
153856f620eSRobert Mustacchi #define	EM_M32		1	/* AT&T WE 32100 */
154856f620eSRobert Mustacchi #define	EM_SPARC	2	/* Sun SPARC */
155856f620eSRobert Mustacchi #define	EM_386		3	/* Intel 80386 */
156856f620eSRobert Mustacchi #define	EM_68K		4	/* Motorola 68000 */
157856f620eSRobert Mustacchi #define	EM_88K		5	/* Motorola 88000 */
158856f620eSRobert Mustacchi #define	EM_486		6	/* Intel 80486 */
159856f620eSRobert Mustacchi #define	EM_860		7	/* Intel i860 */
160856f620eSRobert Mustacchi #define	EM_MIPS		8	/* MIPS RS3000 Big-Endian */
161856f620eSRobert Mustacchi #define	EM_S370		9	/* IBM System/370 Processor */
162856f620eSRobert Mustacchi #define	EM_MIPS_RS3_LE	10	/* MIPS RS3000 Little-Endian */
163856f620eSRobert Mustacchi #define	EM_RS6000	11	/* RS6000 */
1647c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN12	12
1657c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN13	13
1667c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN14	14
167856f620eSRobert Mustacchi #define	EM_PA_RISC	15	/* PA-RISC */
1681638af81Sab #define	EM_PARISC	EM_PA_RISC	/* Alias: GNU compatibility */
169856f620eSRobert Mustacchi #define	EM_nCUBE	16	/* nCUBE */
170856f620eSRobert Mustacchi #define	EM_VPP500	17	/* Fujitsu VPP500 */
171856f620eSRobert Mustacchi #define	EM_SPARC32PLUS	18	/* Sun SPARC 32+ */
172856f620eSRobert Mustacchi #define	EM_960		19	/* Intel 80960 */
173856f620eSRobert Mustacchi #define	EM_PPC		20	/* PowerPC */
174856f620eSRobert Mustacchi #define	EM_PPC64	21	/* 64-bit PowerPC */
175856f620eSRobert Mustacchi #define	EM_S390		22	/* IBM System/390 Processor */
1761638af81Sab #define	EM_UNKNOWN22	EM_S390		/* Alias: Older published name */
1777c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN23	23
1787c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN24	24
1797c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN25	25
1807c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN26	26
1817c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN27	27
1827c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN28	28
1837c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN29	29
1847c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN30	30
1857c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN31	31
1867c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN32	32
1877c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN33	33
1887c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN34	34
1897c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN35	35
190856f620eSRobert Mustacchi #define	EM_V800		36	/* NEX V800 */
191856f620eSRobert Mustacchi #define	EM_FR20		37	/* Fujitsu FR20 */
192856f620eSRobert Mustacchi #define	EM_RH32		38	/* TRW RH-32 */
193856f620eSRobert Mustacchi #define	EM_RCE		39	/* Motorola RCE */
194856f620eSRobert Mustacchi #define	EM_ARM		40	/* Advanced RISC Marchines ARM */
195856f620eSRobert Mustacchi #define	EM_ALPHA	41	/* Digital Alpha */
196856f620eSRobert Mustacchi #define	EM_SH		42	/* Hitachi SH */
197856f620eSRobert Mustacchi #define	EM_SPARCV9	43	/* Sun SPARC V9 (64-bit) */
198856f620eSRobert Mustacchi #define	EM_TRICORE	44	/* Siemens Tricore embedded processor */
199856f620eSRobert Mustacchi #define	EM_ARC		45	/* Argonaut RISC Core, */
200856f620eSRobert Mustacchi 				/*	Argonaut Technologies Inc. */
201856f620eSRobert Mustacchi #define	EM_H8_300	46	/* Hitachi H8/300 */
202856f620eSRobert Mustacchi #define	EM_H8_300H	47	/* Hitachi H8/300H */
203856f620eSRobert Mustacchi #define	EM_H8S		48	/* Hitachi H8S */
204856f620eSRobert Mustacchi #define	EM_H8_500	49	/* Hitachi H8/500 */
205856f620eSRobert Mustacchi #define	EM_IA_64	50	/* Intel IA64 */
206856f620eSRobert Mustacchi #define	EM_MIPS_X	51	/* Stanford MIPS-X */
207856f620eSRobert Mustacchi #define	EM_COLDFIRE	52	/* Motorola ColdFire */
208856f620eSRobert Mustacchi #define	EM_68HC12	53	/* Motorola M68HC12 */
209856f620eSRobert Mustacchi #define	EM_MMA		54	/* Fujitsu MMA Mulimedia Accelerator */
210856f620eSRobert Mustacchi #define	EM_PCP		55	/* Siemens PCP */
211856f620eSRobert Mustacchi #define	EM_NCPU		56	/* Sony nCPU embedded RISC processor */
212856f620eSRobert Mustacchi #define	EM_NDR1		57	/* Denso NDR1 microprocessor */
213856f620eSRobert Mustacchi #define	EM_STARCORE	58	/* Motorola Star*Core processor */
214856f620eSRobert Mustacchi #define	EM_ME16		59	/* Toyota ME16 processor */
215856f620eSRobert Mustacchi #define	EM_ST100	60	/* STMicroelectronics ST100 processor */
216856f620eSRobert Mustacchi #define	EM_TINYJ	61	/* Advanced Logic Corp. TinyJ */
217856f620eSRobert Mustacchi 				/*	embedded processor family */
218856f620eSRobert Mustacchi #define	EM_AMD64	62	/* AMDs x86-64 architecture */
2197c478bd9Sstevel@tonic-gate #define	EM_X86_64	EM_AMD64	/* (compatibility) */
2207c478bd9Sstevel@tonic-gate 
221856f620eSRobert Mustacchi #define	EM_PDSP		63	/* Sony DSP Processor */
2227c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN64	64
2237c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN65	65
224856f620eSRobert Mustacchi #define	EM_FX66		66	/* Siemens FX66 microcontroller */
225856f620eSRobert Mustacchi #define	EM_ST9PLUS	67	/* STMicroelectronics ST9+8/16 bit */
226856f620eSRobert Mustacchi 				/*	microcontroller */
227856f620eSRobert Mustacchi #define	EM_ST7		68	/* STMicroelectronics ST7 8-bit */
228856f620eSRobert Mustacchi 				/*	microcontroller */
229856f620eSRobert Mustacchi #define	EM_68HC16	69	/* Motorola MC68HC16 Microcontroller */
230856f620eSRobert Mustacchi #define	EM_68HC11	70	/* Motorola MC68HC11 Microcontroller */
231856f620eSRobert Mustacchi #define	EM_68HC08	71	/* Motorola MC68HC08 Microcontroller */
232856f620eSRobert Mustacchi #define	EM_68HC05	72	/* Motorola MC68HC05 Microcontroller */
233856f620eSRobert Mustacchi #define	EM_SVX		73	/* Silicon Graphics SVx */
234856f620eSRobert Mustacchi #define	EM_ST19		74	/* STMicroelectronics ST19 8-bit */
235856f620eSRobert Mustacchi 				/*	microcontroller */
236856f620eSRobert Mustacchi #define	EM_VAX		75	/* Digital VAX */
237856f620eSRobert Mustacchi #define	EM_CRIS		76	/* Axis Communications 32-bit */
238856f620eSRobert Mustacchi 				/*	embedded processor */
239856f620eSRobert Mustacchi #define	EM_JAVELIN	77	/* Infineon Technologies 32-bit */
240856f620eSRobert Mustacchi 				/*	embedded processor */
241856f620eSRobert Mustacchi #define	EM_FIREPATH	78	/* Element 14 64-bit DSP Processor */
242856f620eSRobert Mustacchi #define	EM_ZSP		79	/* LSI Logic 16-bit DSP Processor */
243856f620eSRobert Mustacchi #define	EM_MMIX		80	/* Donald Knuth's educational */
244856f620eSRobert Mustacchi 				/*	64-bit processor */
245856f620eSRobert Mustacchi #define	EM_HUANY	81	/* Harvard University */
246856f620eSRobert Mustacchi 				/*	machine-independent */
247856f620eSRobert Mustacchi 				/*	object files */
248856f620eSRobert Mustacchi #define	EM_PRISM	82	/* SiTera Prism */
249856f620eSRobert Mustacchi #define	EM_AVR		83	/* Atmel AVR 8-bit microcontroller */
250856f620eSRobert Mustacchi #define	EM_FR30		84	/* Fujitsu FR30 */
251856f620eSRobert Mustacchi #define	EM_D10V		85	/* Mitsubishi D10V */
252856f620eSRobert Mustacchi #define	EM_D30V		86	/* Mitsubishi D30V */
253856f620eSRobert Mustacchi #define	EM_V850		87	/* NEC v850 */
254856f620eSRobert Mustacchi #define	EM_M32R		88	/* Mitsubishi M32R */
255856f620eSRobert Mustacchi #define	EM_MN10300	89	/* Matsushita MN10300 */
256856f620eSRobert Mustacchi #define	EM_MN10200	90	/* Matsushita MN10200 */
257856f620eSRobert Mustacchi #define	EM_PJ		91	/* picoJava */
258856f620eSRobert Mustacchi #define	EM_OPENRISC	92	/* OpenRISC 32-bit embedded processor */
259856f620eSRobert Mustacchi #define	EM_ARC_A5	93	/* ARC Cores Tangent-A5 */
260856f620eSRobert Mustacchi #define	EM_XTENSA	94	/* Tensilica Xtensa architecture */
261856f620eSRobert Mustacchi 
262856f620eSRobert Mustacchi #define	EM_VIDEOCORE	95	/* Alphamosaic VideoCore processor */
263856f620eSRobert Mustacchi #define	EM_TMM_GPP	96	/* Thompson Multimedia General Purpose */
264856f620eSRobert Mustacchi 				/* Processor */
265856f620eSRobert Mustacchi #define	EM_NS32K	97	/* National Semiconductor 32000 series */
266856f620eSRobert Mustacchi #define	EM_TPC		98	/* Tenor Network TPC processor */
267856f620eSRobert Mustacchi #define	EM_SNP1K	99	/* Trebia SNP 1000 processor */
268856f620eSRobert Mustacchi #define	EM_ST200	100	/* STMicroelectronics (www.st.com) ST200 */
269856f620eSRobert Mustacchi 				/* microcontroller */
270856f620eSRobert Mustacchi #define	EM_IP2K		101	/* Ubicom IP2xxx microcontroller family */
271856f620eSRobert Mustacchi #define	EM_MAX		102	/* MAX Processor */
272856f620eSRobert Mustacchi #define	EM_CR		103	/* National Semiconductor CompactRISC */
273856f620eSRobert Mustacchi 				/* microprocessor */
274856f620eSRobert Mustacchi #define	EM_F2MC16	104	/* Fujitsu F2MC16 */
275856f620eSRobert Mustacchi #define	EM_MSP430	105	/* Texas Instruments embedded microcontroller */
276856f620eSRobert Mustacchi 				/* msp430 */
277856f620eSRobert Mustacchi #define	EM_BLACKFIN	106	/* Analog Devices Blackfin (DSP) processor */
278856f620eSRobert Mustacchi #define	EM_SE_C33	107	/* S1C33 Family of Seiko Epson processors */
279856f620eSRobert Mustacchi #define	EM_SEP		108	/* Sharp embedded microprocessor */
280856f620eSRobert Mustacchi #define	EM_ARCA		109	/* Arca RISC Microprocessor */
281856f620eSRobert Mustacchi #define	EM_UNICORE	110	/* Microprocessor series from PKU-Unity Ltd. */
282856f620eSRobert Mustacchi 				/* and MPRC of Peking University */
283856f620eSRobert Mustacchi #define	EM_EXCESS	111	/* eXcess: 16/32/64-bit configurable embedded */
284856f620eSRobert Mustacchi 				/* CPU */
285856f620eSRobert Mustacchi #define	EM_DXP		112	/* Icera Semiconductor Inc. Deep Execution */
286856f620eSRobert Mustacchi 				/* Processor */
287856f620eSRobert Mustacchi #define	EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
288856f620eSRobert Mustacchi #define	EM_CRX		114	/* National Semiconductor CompactRISC CRX */
289856f620eSRobert Mustacchi 				/* microprocessor */
290856f620eSRobert Mustacchi #define	EM_XGATE	115	/* Motorola XGATE embedded processor */
291856f620eSRobert Mustacchi #define	EM_C166		116	/* Infineon C16x/XC16x processor */
292856f620eSRobert Mustacchi #define	EM_M16C		117	/* Renesas M16C series microprocessors */
293856f620eSRobert Mustacchi #define	EM_DSPIC30F	118	/* Microchip Technology dsPIC30F Digital */
294856f620eSRobert Mustacchi 				/* Signal Controller */
295856f620eSRobert Mustacchi #define	EM_CE		119	/* Freescale Communication Engine RISC core */
296856f620eSRobert Mustacchi #define	EM_M32C		120	/* Renesas M32C series microprocessors */
297856f620eSRobert Mustacchi 
298856f620eSRobert Mustacchi #define	EM_TSK3000	131	/* Altium TSK3000 core */
299856f620eSRobert Mustacchi #define	EM_RS08		132	/* Freescale RS08 embedded processor */
300856f620eSRobert Mustacchi #define	EM_SHARC	133	/* Analog Devices SHARC family of 32-bit DSP */
301856f620eSRobert Mustacchi 				/* processors */
302856f620eSRobert Mustacchi #define	EM_ECOG2	134	/* Cyan Technology eCOG2 microprocessor */
303856f620eSRobert Mustacchi #define	EM_SCORE7	135	/* Sunplus S+core7 RISC processor */
304856f620eSRobert Mustacchi #define	EM_DSP24	136	/* New Japan Radio (NJR) 24-bit DSP Processor */
305856f620eSRobert Mustacchi #define	EM_VIDEOCORE3	137	/* Broadcom VideoCore III processor */
306856f620eSRobert Mustacchi #define	EM_LATTICEMICO32	138	/* RISC processor for Lattice FPGA */
307856f620eSRobert Mustacchi 					/* architecture */
308856f620eSRobert Mustacchi #define	EM_SE_C17	139	/* Seiko Epson C17 family */
309856f620eSRobert Mustacchi #define	EM_TI_C6000	140	/* The Texas Instruments TMS320C6000 DSP */
310856f620eSRobert Mustacchi 				/* family */
311856f620eSRobert Mustacchi #define	EM_TI_C2000	141	/* The Texas Instruments TMS320C2000 DSP */
312856f620eSRobert Mustacchi 				/* family */
313856f620eSRobert Mustacchi #define	EM_TI_C5500	142	/* The Texas Instruments TMS320C55x DSP */
314856f620eSRobert Mustacchi 				/* family */
315856f620eSRobert Mustacchi #define	EM_TI_ARP32	143	/* Texas Instruments Application Specific */
316856f620eSRobert Mustacchi 				/* RISC Processor, 32bit fetch */
317856f620eSRobert Mustacchi #define	EM_TI_PRU	144	/* Texas Instruments Programmable Realtime */
318856f620eSRobert Mustacchi 				/* Unit */
319856f620eSRobert Mustacchi 
320856f620eSRobert Mustacchi #define	EM_MMDSP_PLUS	160	/* STMicroelectronics 64bit VLIW Data Signal */
321856f620eSRobert Mustacchi 				/* Processor */
322856f620eSRobert Mustacchi #define	EM_CYPRESS_M8C	161	/* Cypress M8C microprocessor */
323856f620eSRobert Mustacchi #define	EM_R32C		162	/* Renesas R32C series microprocessors */
324856f620eSRobert Mustacchi #define	EM_TRIMEDIA	163	/* NXP Semiconductors TriMedia architecture */
325856f620eSRobert Mustacchi 				/* family */
326856f620eSRobert Mustacchi #define	EM_QDSP6	164	/* QUALCOMM DSP6 Processor */
327856f620eSRobert Mustacchi #define	EM_8051		165	/* Intel 8051 and variants */
328856f620eSRobert Mustacchi #define	EM_STXP7X	166	/* STMicroelectronics STxP7x family of */
329856f620eSRobert Mustacchi 				/* configurable and extensible RISC */
330856f620eSRobert Mustacchi 				/* processors */
331856f620eSRobert Mustacchi #define	EM_NDS32	167	/* Andes Technology compact code size */
332856f620eSRobert Mustacchi 				/* embedded RISC processor family */
333856f620eSRobert Mustacchi #define	EM_ECOG1	168	/* Cyan Technology eCOG1X family */
334856f620eSRobert Mustacchi #define	EM_ECOG1X	EM_EC0G1X	/* Cyan Technology eCOG1X family */
335856f620eSRobert Mustacchi #define	EM_MAXQ30	169	/* Dallas Semiconductor MAXQ30 Core */
336856f620eSRobert Mustacchi 				/* Micro-controllers */
337856f620eSRobert Mustacchi #define	EM_XIMO16	170	/* New Japan Radio (NJR) 16-bit DSP Processor */
338856f620eSRobert Mustacchi #define	EM_MANIK	171	/* M2000 Reconfigurable RISC Microprocessor */
339856f620eSRobert Mustacchi #define	EM_CRAYNV2	172	/* Cray Inc. NV2 vector architecture */
340856f620eSRobert Mustacchi #define	EM_RX		173	/* Renesas RX family */
341856f620eSRobert Mustacchi #define	EM_METAG	174	/* Imagination Technologies META processor */
342856f620eSRobert Mustacchi 				/* architecture */
343856f620eSRobert Mustacchi #define	EM_MCST_ELBRUS	175	/* MCST Elbrus general purpose hardware */
344856f620eSRobert Mustacchi 				/* architecture */
345856f620eSRobert Mustacchi #define	EM_ECOG16	176	/* Cyan Technology eCOG16 family */
346856f620eSRobert Mustacchi #define	EM_CR16		177	/* National Semiconductor CompactRISC */
347856f620eSRobert Mustacchi 				/* CR16 16-bit microprocessor */
348856f620eSRobert Mustacchi #define	EM_ETPU		178	/* Freescale Extended Time Processing Unit */
349856f620eSRobert Mustacchi #define	EM_SLE9X	179	/* Infineon Technologies SLE9X core */
350856f620eSRobert Mustacchi #define	EM_L10M		180	/* Intel L10M */
351856f620eSRobert Mustacchi #define	EM_K10M		181	/* Intel K10M */
352856f620eSRobert Mustacchi 
353856f620eSRobert Mustacchi #define	EM_AARCH64	183	/* ARM 64-bit architecture (AARCH64) */
354856f620eSRobert Mustacchi 
355856f620eSRobert Mustacchi #define	EM_AVR32	185	/* Atmel Corporation 32-bit microprocessor */
356856f620eSRobert Mustacchi 				/* family */
357856f620eSRobert Mustacchi #define	EM_STM8		186	/* STMicroeletronics STM8 8-bit */
358856f620eSRobert Mustacchi 				/* microcontroller */
359856f620eSRobert Mustacchi #define	EM_TILE64	187	/* Tilera TILE64 multicore architecture */
360856f620eSRobert Mustacchi 				/* family */
361856f620eSRobert Mustacchi #define	EM_TILEPRO	188	/* Tilera TILEPro multicore architecture */
362856f620eSRobert Mustacchi 				/* family */
363856f620eSRobert Mustacchi #define	EM_MICROBLAZE	189	/* Xilinx MicroBlaze 32-bit RISC soft */
364856f620eSRobert Mustacchi 				/* processor core */
365856f620eSRobert Mustacchi #define	EM_CUDA		190	/* NVIDIA CUDA architecture */
366856f620eSRobert Mustacchi #define	EM_TILEGX	191	/* Tilera TILE-Gx multicore architecture */
367856f620eSRobert Mustacchi 				/* family */
368856f620eSRobert Mustacchi #define	EM_CLOUDSHIELD	192	/* CloudShield architecture family */
369856f620eSRobert Mustacchi #define	EM_COREA_1ST	193	/* KIPO-KAIST Core-A 1st generation processor */
370856f620eSRobert Mustacchi 				/* family */
371856f620eSRobert Mustacchi #define	EM_COREA_2ND	194	/* KIPO-KAIST Core-A 2nd generation processor */
372856f620eSRobert Mustacchi 				/* family */
373856f620eSRobert Mustacchi #define	EM_ARC_COMPACT2	195	/* Synopsys ARCompact V2 */
374856f620eSRobert Mustacchi #define	EM_OPEN8	196	/* Open8 8-bit RISC soft processor core */
375856f620eSRobert Mustacchi #define	EM_RL78		197	/* Renesas RL78 family */
376856f620eSRobert Mustacchi #define	EM_VIDEOCORE5	198	/* Broadcom VideoCore V processor */
377856f620eSRobert Mustacchi #define	EM_78KOR	199	/* Renesas 78KOR family */
378856f620eSRobert Mustacchi #define	EM_56800EX	200	/* Freescale 56800EX Digital Signal */
379856f620eSRobert Mustacchi 				/* Controller (DSC) */
380856f620eSRobert Mustacchi #define	EM_BA1		201	/* Beyond BA1 CPU architecture */
381856f620eSRobert Mustacchi #define	EM_BA2		202	/* Beyond BA2 CPU architecture */
382856f620eSRobert Mustacchi #define	EM_XCORE	203	/* XMOS xCORE processor family */
383856f620eSRobert Mustacchi #define	EM_MCHP_PIC	204	/* Microchip 8-bit PIC(r) family */
384856f620eSRobert Mustacchi #define	EM_INTEL205	205	/* Reserved by Intel */
385856f620eSRobert Mustacchi #define	EM_INTEL206	206	/* Reserved by Intel */
386856f620eSRobert Mustacchi #define	EM_INTEL207	207	/* Reserved by Intel */
387856f620eSRobert Mustacchi #define	EM_INTEL208	208	/* Reserved by Intel */
388856f620eSRobert Mustacchi #define	EM_INTEL209	209	/* Reserved by Intel */
389856f620eSRobert Mustacchi #define	EM_KM32		210	/* KM211 KM32 32-bit processor */
390856f620eSRobert Mustacchi #define	EM_KMX32	211	/* KM211 KMX32 32-bit processor */
391856f620eSRobert Mustacchi #define	EM_KMX16	212	/* KM211 KMX16 16-bit processor */
392856f620eSRobert Mustacchi #define	EM_KMX8		213	/* KM211 KMX8 8-bit processor */
393856f620eSRobert Mustacchi #define	EM_KVARC	214	/* KM211 KVARC processor */
394856f620eSRobert Mustacchi #define	EM_CDP		215	/* Paneve CDP architecture family */
395856f620eSRobert Mustacchi #define	EM_COGE		216	/* Cognitive Smart Memory Processor */
396856f620eSRobert Mustacchi #define	EM_COOL		217	/* Bluechip Systems CoolEngine */
397856f620eSRobert Mustacchi #define	EM_NORC		218	/* Nanoradio Optimized RISC */
398856f620eSRobert Mustacchi #define	EM_CSR_KALIMBA	219	/* CSR Kalimba architecture family */
399856f620eSRobert Mustacchi #define	EM_Z80		220	/* Zilog Z80 */
400856f620eSRobert Mustacchi #define	EM_VISIUM	221	/* Controls and Data Services VISIUMcore */
401856f620eSRobert Mustacchi 				/* processor */
402856f620eSRobert Mustacchi #define	EM_FT32		222	/* FTDI Chip FT32 high performance 32-bit */
403856f620eSRobert Mustacchi 				/* RISC architecture */
404856f620eSRobert Mustacchi #define	EM_MOXIE	223	/* Moxie processor family */
405856f620eSRobert Mustacchi #define	EM_AMDGPU	224	/* AMD GPU architecture */
406856f620eSRobert Mustacchi 
407856f620eSRobert Mustacchi #define	EM_RISCV	243	/* RISC-V */
408856f620eSRobert Mustacchi 
409856f620eSRobert Mustacchi #define	EM_NUM		244
4107c478bd9Sstevel@tonic-gate 
4117c478bd9Sstevel@tonic-gate #define	EV_NONE		0		/* e_version, EI_VERSION */
4127c478bd9Sstevel@tonic-gate #define	EV_CURRENT	1
4137c478bd9Sstevel@tonic-gate #define	EV_NUM		2
4147c478bd9Sstevel@tonic-gate 
4157c478bd9Sstevel@tonic-gate 
4167c478bd9Sstevel@tonic-gate #define	ELFOSABI_NONE		0	/* No extensions or unspecified */
4171638af81Sab #define	ELFOSABI_SYSV		ELFOSABI_NONE
4187c478bd9Sstevel@tonic-gate #define	ELFOSABI_HPUX		1	/* Hewlett-Packard HP-UX */
4197c478bd9Sstevel@tonic-gate #define	ELFOSABI_NETBSD		2	/* NetBSD */
4207c478bd9Sstevel@tonic-gate #define	ELFOSABI_LINUX		3	/* Linux */
4217c478bd9Sstevel@tonic-gate #define	ELFOSABI_UNKNOWN4	4
4227c478bd9Sstevel@tonic-gate #define	ELFOSABI_UNKNOWN5	5
4237c478bd9Sstevel@tonic-gate #define	ELFOSABI_SOLARIS	6	/* Sun Solaris */
4247c478bd9Sstevel@tonic-gate #define	ELFOSABI_AIX		7	/* AIX */
4257c478bd9Sstevel@tonic-gate #define	ELFOSABI_IRIX		8	/* IRIX */
4267c478bd9Sstevel@tonic-gate #define	ELFOSABI_FREEBSD	9	/* FreeBSD */
4277c478bd9Sstevel@tonic-gate #define	ELFOSABI_TRU64		10	/* Compaq TRU64 UNIX */
4287c478bd9Sstevel@tonic-gate #define	ELFOSABI_MODESTO	11	/* Novell Modesto */
4297c478bd9Sstevel@tonic-gate #define	ELFOSABI_OPENBSD	12	/* Open BSD */
4301638af81Sab #define	ELFOSABI_OPENVMS	13	/* Open VMS */
4311638af81Sab #define	ELFOSABI_NSK		14	/* Hewlett-Packard Non-Stop Kernel */
4321638af81Sab #define	ELFOSABI_AROS		15	/* Amiga Research OS */
433ab618543SJohn Levon #define	ELFOSABI_FENIXOS	16	/* The FenixOS highly scalable */
434856f620eSRobert Mustacchi 					/* multi-core OS */
435ab618543SJohn Levon #define	ELFOSABI_CLOUDABI	17	/* Nuxi CloudABI */
436ab618543SJohn Levon #define	ELFOSABI_OPENVOS	18	/* Stratus Technologies OpenVOS */
4371638af81Sab #define	ELFOSABI_ARM		97	/* ARM */
4381638af81Sab #define	ELFOSABI_STANDALONE	255	/* standalone (embedded) application */
4397c478bd9Sstevel@tonic-gate 
4404f680cc6SAli Bahrami #define	EAV_SUNW_NONE		0	/* EI_ABIVERSION */
4414f680cc6SAli Bahrami #define	EAV_SUNW_CURRENT	1
4424f680cc6SAli Bahrami #define	EAV_SUNW_NUM		2
4434f680cc6SAli Bahrami 
4444f680cc6SAli Bahrami 
4457c478bd9Sstevel@tonic-gate /*
4467c478bd9Sstevel@tonic-gate  *	Program header
4477c478bd9Sstevel@tonic-gate  */
4487c478bd9Sstevel@tonic-gate 
4497c478bd9Sstevel@tonic-gate typedef struct {
4507c478bd9Sstevel@tonic-gate 	Elf32_Word	p_type;		/* entry type */
4517c478bd9Sstevel@tonic-gate 	Elf32_Off	p_offset;	/* file offset */
4527c478bd9Sstevel@tonic-gate 	Elf32_Addr	p_vaddr;	/* virtual address */
4537c478bd9Sstevel@tonic-gate 	Elf32_Addr	p_paddr;	/* physical address */
4547c478bd9Sstevel@tonic-gate 	Elf32_Word	p_filesz;	/* file size */
4557c478bd9Sstevel@tonic-gate 	Elf32_Word	p_memsz;	/* memory size */
4567c478bd9Sstevel@tonic-gate 	Elf32_Word	p_flags;	/* entry flags */
4577c478bd9Sstevel@tonic-gate 	Elf32_Word	p_align;	/* memory/file alignment */
4587c478bd9Sstevel@tonic-gate } Elf32_Phdr;
4597c478bd9Sstevel@tonic-gate 
4607c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
4617c478bd9Sstevel@tonic-gate typedef struct {
4627c478bd9Sstevel@tonic-gate 	Elf64_Word	p_type;		/* entry type */
4637c478bd9Sstevel@tonic-gate 	Elf64_Word	p_flags;	/* entry flags */
4647c478bd9Sstevel@tonic-gate 	Elf64_Off	p_offset;	/* file offset */
4657c478bd9Sstevel@tonic-gate 	Elf64_Addr	p_vaddr;	/* virtual address */
4667c478bd9Sstevel@tonic-gate 	Elf64_Addr	p_paddr;	/* physical address */
4677c478bd9Sstevel@tonic-gate 	Elf64_Xword	p_filesz;	/* file size */
4687c478bd9Sstevel@tonic-gate 	Elf64_Xword	p_memsz;	/* memory size */
4697c478bd9Sstevel@tonic-gate 	Elf64_Xword	p_align;	/* memory/file alignment */
4707c478bd9Sstevel@tonic-gate } Elf64_Phdr;
4717c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
4727c478bd9Sstevel@tonic-gate 
4737c478bd9Sstevel@tonic-gate 
4747c478bd9Sstevel@tonic-gate #define	PT_NULL		0		/* p_type */
4757c478bd9Sstevel@tonic-gate #define	PT_LOAD		1
4767c478bd9Sstevel@tonic-gate #define	PT_DYNAMIC	2
4777c478bd9Sstevel@tonic-gate #define	PT_INTERP	3
4787c478bd9Sstevel@tonic-gate #define	PT_NOTE		4
4797c478bd9Sstevel@tonic-gate #define	PT_SHLIB	5
4807c478bd9Sstevel@tonic-gate #define	PT_PHDR		6
4817c478bd9Sstevel@tonic-gate #define	PT_TLS		7
4827c478bd9Sstevel@tonic-gate #define	PT_NUM		8
4837c478bd9Sstevel@tonic-gate 
4847c478bd9Sstevel@tonic-gate #define	PT_LOOS		0x60000000	/* OS specific range */
4857c478bd9Sstevel@tonic-gate 
4867c478bd9Sstevel@tonic-gate /*
4877e16fca0SAli Bahrami  * PT_SUNW_UNWIND and PT_SUNW_EH_FRAME perform the same function,
4887e16fca0SAli Bahrami  * providing access to the .eh_frame_hdr section of the object.
4897e16fca0SAli Bahrami  * PT_SUNW_UNWIND is the original value, while PT_SUNW_EH_FRAME is
4907e16fca0SAli Bahrami  * required by the amd64 psABI. The Solaris link-editor (ld) tags output
4917e16fca0SAli Bahrami  * objects with PT_SUNW_UNWIND, but the Solaris runtime linker (ld.so.1)
4927e16fca0SAli Bahrami  * will accept and use either value.
4937c478bd9Sstevel@tonic-gate  */
4947e16fca0SAli Bahrami #define	PT_SUNW_UNWIND		0x6464e550
4957e16fca0SAli Bahrami #define	PT_SUNW_EH_FRAME	0x6474e550
4967e16fca0SAli Bahrami #define	PT_GNU_EH_FRAME		PT_SUNW_EH_FRAME
4977c478bd9Sstevel@tonic-gate 
4987e16fca0SAli Bahrami /*
4997e16fca0SAli Bahrami  * Linux specific program headers not currently used by Solaris
5007e16fca0SAli Bahrami  */
5017e16fca0SAli Bahrami #define	PT_GNU_STACK	0x6474e551	/* Indicates stack executability */
5027e16fca0SAli Bahrami #define	PT_GNU_RELRO	0x6474e552	/* Read-only after relocation */
5037c478bd9Sstevel@tonic-gate 
5047c478bd9Sstevel@tonic-gate #define	PT_LOSUNW	0x6ffffffa
50535450702SAli Bahrami #define	PT_SUNWBSS	0x6ffffffa	/* Sun Specific segment (unused) */
5067c478bd9Sstevel@tonic-gate #define	PT_SUNWSTACK	0x6ffffffb	/* describes the stack segment */
5077c478bd9Sstevel@tonic-gate #define	PT_SUNWDTRACE	0x6ffffffc	/* private */
5087c478bd9Sstevel@tonic-gate #define	PT_SUNWCAP	0x6ffffffd	/* hard/soft capabilities segment */
5097c478bd9Sstevel@tonic-gate #define	PT_HISUNW	0x6fffffff
5107c478bd9Sstevel@tonic-gate #define	PT_HIOS		0x6fffffff
5117c478bd9Sstevel@tonic-gate 
5127c478bd9Sstevel@tonic-gate #define	PT_LOPROC	0x70000000	/* processor specific range */
5137c478bd9Sstevel@tonic-gate #define	PT_HIPROC	0x7fffffff
5147c478bd9Sstevel@tonic-gate 
5157c478bd9Sstevel@tonic-gate #define	PF_R		0x4		/* p_flags */
5167c478bd9Sstevel@tonic-gate #define	PF_W		0x2
5177c478bd9Sstevel@tonic-gate #define	PF_X		0x1
5187c478bd9Sstevel@tonic-gate 
5197c478bd9Sstevel@tonic-gate #define	PF_MASKOS	0x0ff00000	/* OS specific values */
5207c478bd9Sstevel@tonic-gate #define	PF_MASKPROC	0xf0000000	/* processor specific values */
5217c478bd9Sstevel@tonic-gate 
5227c478bd9Sstevel@tonic-gate #define	PF_SUNW_FAILURE	0x00100000	/* mapping absent due to failure */
523f971a346SBryan Cantrill #define	PF_SUNW_KILLED	0x00200000	/* signal received during dump */
524f971a346SBryan Cantrill #define	PF_SUNW_SIGINFO	0x00400000	/* segment has killing sig's siginfo */
5257c478bd9Sstevel@tonic-gate 
52630da1432Sahl #define	PN_XNUM		0xffff		/* extended program header index */
52730da1432Sahl 
5287c478bd9Sstevel@tonic-gate /*
5297c478bd9Sstevel@tonic-gate  *	Section header
5307c478bd9Sstevel@tonic-gate  */
5317c478bd9Sstevel@tonic-gate 
5327c478bd9Sstevel@tonic-gate typedef struct {
5337c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_name;	/* section name */
5347c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_type;	/* SHT_... */
5357c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_flags;	/* SHF_... */
5367c478bd9Sstevel@tonic-gate 	Elf32_Addr	sh_addr;	/* virtual address */
5377c478bd9Sstevel@tonic-gate 	Elf32_Off	sh_offset;	/* file offset */
5387c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_size;	/* section size */
5397c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_link;	/* misc info */
5407c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_info;	/* misc info */
5417c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_addralign;	/* memory alignment */
5427c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_entsize;	/* entry size if table */
5437c478bd9Sstevel@tonic-gate } Elf32_Shdr;
5447c478bd9Sstevel@tonic-gate 
5457c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
5467c478bd9Sstevel@tonic-gate typedef struct {
5477c478bd9Sstevel@tonic-gate 	Elf64_Word	sh_name;	/* section name */
5487c478bd9Sstevel@tonic-gate 	Elf64_Word	sh_type;	/* SHT_... */
5497c478bd9Sstevel@tonic-gate 	Elf64_Xword	sh_flags;	/* SHF_... */
5507c478bd9Sstevel@tonic-gate 	Elf64_Addr	sh_addr;	/* virtual address */
5517c478bd9Sstevel@tonic-gate 	Elf64_Off	sh_offset;	/* file offset */
5527c478bd9Sstevel@tonic-gate 	Elf64_Xword	sh_size;	/* section size */
5537c478bd9Sstevel@tonic-gate 	Elf64_Word	sh_link;	/* misc info */
5547c478bd9Sstevel@tonic-gate 	Elf64_Word	sh_info;	/* misc info */
5557c478bd9Sstevel@tonic-gate 	Elf64_Xword	sh_addralign;	/* memory alignment */
5567c478bd9Sstevel@tonic-gate 	Elf64_Xword	sh_entsize;	/* entry size if table */
5577c478bd9Sstevel@tonic-gate } Elf64_Shdr;
5587c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
5597c478bd9Sstevel@tonic-gate 
5607c478bd9Sstevel@tonic-gate #define	SHT_NULL		0		/* sh_type */
5617c478bd9Sstevel@tonic-gate #define	SHT_PROGBITS		1
5627c478bd9Sstevel@tonic-gate #define	SHT_SYMTAB		2
5637c478bd9Sstevel@tonic-gate #define	SHT_STRTAB		3
5647c478bd9Sstevel@tonic-gate #define	SHT_RELA		4
5657c478bd9Sstevel@tonic-gate #define	SHT_HASH		5
5667c478bd9Sstevel@tonic-gate #define	SHT_DYNAMIC		6
5677c478bd9Sstevel@tonic-gate #define	SHT_NOTE		7
5687c478bd9Sstevel@tonic-gate #define	SHT_NOBITS		8
5697c478bd9Sstevel@tonic-gate #define	SHT_REL			9
5707c478bd9Sstevel@tonic-gate #define	SHT_SHLIB		10
5717c478bd9Sstevel@tonic-gate #define	SHT_DYNSYM		11
5727c478bd9Sstevel@tonic-gate #define	SHT_UNKNOWN12		12
5737c478bd9Sstevel@tonic-gate #define	SHT_UNKNOWN13		13
5747c478bd9Sstevel@tonic-gate #define	SHT_INIT_ARRAY		14
5757c478bd9Sstevel@tonic-gate #define	SHT_FINI_ARRAY		15
5767c478bd9Sstevel@tonic-gate #define	SHT_PREINIT_ARRAY	16
5777c478bd9Sstevel@tonic-gate #define	SHT_GROUP		17
5787c478bd9Sstevel@tonic-gate #define	SHT_SYMTAB_SHNDX	18
5797c478bd9Sstevel@tonic-gate #define	SHT_NUM			19
5807c478bd9Sstevel@tonic-gate 
5811638af81Sab /* Solaris ABI specific values */
5827c478bd9Sstevel@tonic-gate #define	SHT_LOOS		0x60000000	/* OS specific range */
58308278a5eSRod Evans #define	SHT_LOSUNW		0x6fffffef
58408278a5eSRod Evans #define	SHT_SUNW_capchain	0x6fffffef
58508278a5eSRod Evans #define	SHT_SUNW_capinfo	0x6ffffff0
586d579eb63Sab #define	SHT_SUNW_symsort	0x6ffffff1
587d579eb63Sab #define	SHT_SUNW_tlssort	0x6ffffff2
5889039eeafSab #define	SHT_SUNW_LDYNSYM	0x6ffffff3
5897c478bd9Sstevel@tonic-gate #define	SHT_SUNW_dof		0x6ffffff4
5907c478bd9Sstevel@tonic-gate #define	SHT_SUNW_cap		0x6ffffff5
5917c478bd9Sstevel@tonic-gate #define	SHT_SUNW_SIGNATURE	0x6ffffff6
5927c478bd9Sstevel@tonic-gate #define	SHT_SUNW_ANNOTATE	0x6ffffff7
5937c478bd9Sstevel@tonic-gate #define	SHT_SUNW_DEBUGSTR	0x6ffffff8
5947c478bd9Sstevel@tonic-gate #define	SHT_SUNW_DEBUG		0x6ffffff9
5957c478bd9Sstevel@tonic-gate #define	SHT_SUNW_move		0x6ffffffa
5967c478bd9Sstevel@tonic-gate #define	SHT_SUNW_COMDAT		0x6ffffffb
5977c478bd9Sstevel@tonic-gate #define	SHT_SUNW_syminfo	0x6ffffffc
5987c478bd9Sstevel@tonic-gate #define	SHT_SUNW_verdef		0x6ffffffd
5997e16fca0SAli Bahrami #define	SHT_GNU_verdef		SHT_SUNW_verdef
6007c478bd9Sstevel@tonic-gate #define	SHT_SUNW_verneed	0x6ffffffe
6017e16fca0SAli Bahrami #define	SHT_GNU_verneed		SHT_SUNW_verneed
6027c478bd9Sstevel@tonic-gate #define	SHT_SUNW_versym		0x6fffffff
6037e16fca0SAli Bahrami #define	SHT_GNU_versym		SHT_SUNW_versym
6047c478bd9Sstevel@tonic-gate #define	SHT_HISUNW		0x6fffffff
6057c478bd9Sstevel@tonic-gate #define	SHT_HIOS		0x6fffffff
6067c478bd9Sstevel@tonic-gate 
6077e16fca0SAli Bahrami /*
6087e16fca0SAli Bahrami  * GNU/Linux OSABI specific values with different meanings than under Solaris.
6097e16fca0SAli Bahrami  * Due to the overlap in assigned values with the Solaris OSABI, correct
6107e16fca0SAli Bahrami  * interpretation of these values requires knowledge of the OSABI used by
6117e16fca0SAli Bahrami  * the object.
6127e16fca0SAli Bahrami  */
6137e16fca0SAli Bahrami #define	SHT_GNU_ATTRIBUTES	0x6ffffff5	/* Object attributes */
6147e16fca0SAli Bahrami #define	SHT_GNU_HASH		0x6ffffff6	/* GNU-style hash table */
6157e16fca0SAli Bahrami #define	SHT_GNU_LIBLIST		0x6ffffff7	/* Prelink library list */
6167e16fca0SAli Bahrami #define	SHT_CHECKSUM		0x6ffffff8	/* Checksum for DSO content */
6171638af81Sab 
618*ff4c9ae3SRichard Lowe /*
619*ff4c9ae3SRichard Lowe  * LLVM-specific section types, actually independent of any (ELF) OS.
620*ff4c9ae3SRichard Lowe  * See: https://llvm.org/docs/Extensions.html
621*ff4c9ae3SRichard Lowe  */
622*ff4c9ae3SRichard Lowe #define	SHT_LLVM_ODRTAB		0x6fff4c00 /* ODR Table */
623*ff4c9ae3SRichard Lowe #define	SHT_LLVM_LINKER_OPTIONS	0x6fff4c01 /* Linker options */
624*ff4c9ae3SRichard Lowe #define	SHT_LLVM_UNKNOWN1	0x6fff4c02 /* previously call graph profile */
625*ff4c9ae3SRichard Lowe #define	SHT_LLVM_ADDRSIG	0x6fff4c03 /* significant address table */
626*ff4c9ae3SRichard Lowe #define	SHT_LLVM_DEPENDENT_LIBRARIES	0x6fff4c04 /* dependent libraries. */
627*ff4c9ae3SRichard Lowe #define	SHT_LLVM_SYMPART	0x6fff4c05 /* symbol partition specs. */
628*ff4c9ae3SRichard Lowe #define	SHT_LLVM_PART_EHDR	0x6fff4c06 /* ehdr for loadable part. */
629*ff4c9ae3SRichard Lowe #define	SHT_LLVM_PART_PHDR	0x6fff4c07 /* phdrs for loadable part. */
630*ff4c9ae3SRichard Lowe #define	SHT_LLVM_BB_ADDR_MAP	0x6fff4c08 /* basic block addr map */
631*ff4c9ae3SRichard Lowe #define	SHT_LLVM_CALL_GRAPH_PROFILE	0x6fff4c09 /* call graph profile */
632*ff4c9ae3SRichard Lowe 
6337c478bd9Sstevel@tonic-gate #define	SHT_LOPROC	0x70000000	/* processor specific range */
6347c478bd9Sstevel@tonic-gate #define	SHT_HIPROC	0x7fffffff
6357c478bd9Sstevel@tonic-gate 
6367c478bd9Sstevel@tonic-gate #define	SHT_LOUSER	0x80000000
6377c478bd9Sstevel@tonic-gate #define	SHT_HIUSER	0xffffffff
6387c478bd9Sstevel@tonic-gate 
6397c478bd9Sstevel@tonic-gate #define	SHF_WRITE		0x01		/* sh_flags */
6407c478bd9Sstevel@tonic-gate #define	SHF_ALLOC		0x02
6417c478bd9Sstevel@tonic-gate #define	SHF_EXECINSTR		0x04
6427c478bd9Sstevel@tonic-gate #define	SHF_MERGE		0x10
6437c478bd9Sstevel@tonic-gate #define	SHF_STRINGS		0x20
6447c478bd9Sstevel@tonic-gate #define	SHF_INFO_LINK		0x40
6457c478bd9Sstevel@tonic-gate #define	SHF_LINK_ORDER		0x80
6467c478bd9Sstevel@tonic-gate #define	SHF_OS_NONCONFORMING	0x100
6477c478bd9Sstevel@tonic-gate #define	SHF_GROUP		0x200
6487c478bd9Sstevel@tonic-gate #define	SHF_TLS			0x400
6497c478bd9Sstevel@tonic-gate 
6507c478bd9Sstevel@tonic-gate #define	SHF_MASKOS	0x0ff00000	/* OS specific values */
6517c478bd9Sstevel@tonic-gate 
6527c478bd9Sstevel@tonic-gate 
6537c478bd9Sstevel@tonic-gate #define	SHF_MASKPROC	0xf0000000	/* processor specific values */
6547c478bd9Sstevel@tonic-gate 
6557c478bd9Sstevel@tonic-gate #define	SHN_UNDEF	0		/* special section numbers */
6567c478bd9Sstevel@tonic-gate #define	SHN_LORESERVE	0xff00
6577c478bd9Sstevel@tonic-gate #define	SHN_LOPROC	0xff00		/* processor specific range */
6587c478bd9Sstevel@tonic-gate #define	SHN_HIPROC	0xff1f
6597c478bd9Sstevel@tonic-gate #define	SHN_LOOS	0xff20		/* OS specific range */
6607c478bd9Sstevel@tonic-gate #define	SHN_LOSUNW	0xff3f
6617c478bd9Sstevel@tonic-gate #define	SHN_SUNW_IGNORE	0xff3f
6627c478bd9Sstevel@tonic-gate #define	SHN_HISUNW	0xff3f
6637c478bd9Sstevel@tonic-gate #define	SHN_HIOS	0xff3f
6647c478bd9Sstevel@tonic-gate #define	SHN_ABS		0xfff1
6657c478bd9Sstevel@tonic-gate #define	SHN_COMMON	0xfff2
6667c478bd9Sstevel@tonic-gate #define	SHN_XINDEX	0xffff		/* extended sect index */
6677c478bd9Sstevel@tonic-gate #define	SHN_HIRESERVE	0xffff
6687c478bd9Sstevel@tonic-gate 
6697c478bd9Sstevel@tonic-gate 
6707c478bd9Sstevel@tonic-gate 
6717c478bd9Sstevel@tonic-gate /*
6727c478bd9Sstevel@tonic-gate  *	Symbol table
6737c478bd9Sstevel@tonic-gate  */
6747c478bd9Sstevel@tonic-gate 
6757c478bd9Sstevel@tonic-gate typedef struct {
6767c478bd9Sstevel@tonic-gate 	Elf32_Word	st_name;
6777c478bd9Sstevel@tonic-gate 	Elf32_Addr	st_value;
6787c478bd9Sstevel@tonic-gate 	Elf32_Word	st_size;
6797c478bd9Sstevel@tonic-gate 	unsigned char	st_info;	/* bind, type: ELF_32_ST_... */
6807c478bd9Sstevel@tonic-gate 	unsigned char	st_other;
6817c478bd9Sstevel@tonic-gate 	Elf32_Half	st_shndx;	/* SHN_... */
6827c478bd9Sstevel@tonic-gate } Elf32_Sym;
6837c478bd9Sstevel@tonic-gate 
6847c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
6857c478bd9Sstevel@tonic-gate typedef struct {
6867c478bd9Sstevel@tonic-gate 	Elf64_Word	st_name;
6877c478bd9Sstevel@tonic-gate 	unsigned char	st_info;	/* bind, type: ELF_64_ST_... */
6887c478bd9Sstevel@tonic-gate 	unsigned char	st_other;
6897c478bd9Sstevel@tonic-gate 	Elf64_Half	st_shndx;	/* SHN_... */
6907c478bd9Sstevel@tonic-gate 	Elf64_Addr	st_value;
6917c478bd9Sstevel@tonic-gate 	Elf64_Xword	st_size;
6927c478bd9Sstevel@tonic-gate } Elf64_Sym;
6937c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
6947c478bd9Sstevel@tonic-gate 
6957c478bd9Sstevel@tonic-gate #define	STN_UNDEF	0
6967c478bd9Sstevel@tonic-gate 
6977c478bd9Sstevel@tonic-gate /*
69808278a5eSRod Evans  *	Macros to compose and decompose values for S.st_info
6997c478bd9Sstevel@tonic-gate  *
7007c478bd9Sstevel@tonic-gate  *	bind = ELF32_ST_BIND(S.st_info)
7017c478bd9Sstevel@tonic-gate  *	type = ELF32_ST_TYPE(S.st_info)
7027c478bd9Sstevel@tonic-gate  *	S.st_info = ELF32_ST_INFO(bind, type)
7037c478bd9Sstevel@tonic-gate  */
7047c478bd9Sstevel@tonic-gate 
7057c478bd9Sstevel@tonic-gate #define	ELF32_ST_BIND(info)		((info) >> 4)
7067c478bd9Sstevel@tonic-gate #define	ELF32_ST_TYPE(info)		((info) & 0xf)
7077c478bd9Sstevel@tonic-gate #define	ELF32_ST_INFO(bind, type)	(((bind)<<4)+((type)&0xf))
7087c478bd9Sstevel@tonic-gate 
7097c478bd9Sstevel@tonic-gate #define	ELF64_ST_BIND(info)		((info) >> 4)
7107c478bd9Sstevel@tonic-gate #define	ELF64_ST_TYPE(info)		((info) & 0xf)
7117c478bd9Sstevel@tonic-gate #define	ELF64_ST_INFO(bind, type)	(((bind)<<4)+((type)&0xf))
7127c478bd9Sstevel@tonic-gate 
7137c478bd9Sstevel@tonic-gate 
7147c478bd9Sstevel@tonic-gate #define	STB_LOCAL	0		/* BIND */
7157c478bd9Sstevel@tonic-gate #define	STB_GLOBAL	1
7167c478bd9Sstevel@tonic-gate #define	STB_WEAK	2
7177c478bd9Sstevel@tonic-gate #define	STB_NUM		3
7187c478bd9Sstevel@tonic-gate 
719ee57561bSRichard Lowe #define	STB_LOOS	10		/* operating system specific range */
720ee57561bSRichard Lowe #define	STB_HIOS	12
721ee57561bSRichard Lowe 
7227c478bd9Sstevel@tonic-gate #define	STB_LOPROC	13		/* processor specific range */
7237c478bd9Sstevel@tonic-gate #define	STB_HIPROC	15
7247c478bd9Sstevel@tonic-gate 
7257e16fca0SAli Bahrami #define	STT_NOTYPE	0		/* symbol type is unspecified */
7267e16fca0SAli Bahrami #define	STT_OBJECT	1		/* data object */
7277e16fca0SAli Bahrami #define	STT_FUNC	2		/* code object */
7287e16fca0SAli Bahrami #define	STT_SECTION	3		/* symbol identifies an ELF section */
7297e16fca0SAli Bahrami #define	STT_FILE	4		/* symbol's name is file name */
7307e16fca0SAli Bahrami #define	STT_COMMON	5		/* common data object */
7317e16fca0SAli Bahrami #define	STT_TLS		6		/* thread-local data object */
73262b628a6SAli Bahrami #define	STT_NUM		7		/* # defined types in generic range */
7337e16fca0SAli Bahrami #define	STT_LOOS	10		/* OS specific range */
7347e16fca0SAli Bahrami #define	STT_HIOS	12
7357c478bd9Sstevel@tonic-gate #define	STT_LOPROC	13		/* processor specific range */
7367c478bd9Sstevel@tonic-gate #define	STT_HIPROC	15
7377c478bd9Sstevel@tonic-gate 
7387c478bd9Sstevel@tonic-gate /*
73908278a5eSRod Evans  *	Macros to decompose values for S.st_other
7407c478bd9Sstevel@tonic-gate  *
7417c478bd9Sstevel@tonic-gate  *	visibility = ELF32_ST_VISIBILITY(S.st_other)
7427c478bd9Sstevel@tonic-gate  */
74360758829Srie #define	ELF32_ST_VISIBILITY(other)	((other)&0x7)
74460758829Srie #define	ELF64_ST_VISIBILITY(other)	((other)&0x7)
7457c478bd9Sstevel@tonic-gate 
7467c478bd9Sstevel@tonic-gate #define	STV_DEFAULT	0
7477c478bd9Sstevel@tonic-gate #define	STV_INTERNAL	1
7487c478bd9Sstevel@tonic-gate #define	STV_HIDDEN	2
7497c478bd9Sstevel@tonic-gate #define	STV_PROTECTED	3
75060758829Srie #define	STV_EXPORTED	4
75160758829Srie #define	STV_SINGLETON	5
75260758829Srie #define	STV_ELIMINATE	6
7537c478bd9Sstevel@tonic-gate 
75460758829Srie #define	STV_NUM		7
7557c478bd9Sstevel@tonic-gate 
7567c478bd9Sstevel@tonic-gate /*
7577c478bd9Sstevel@tonic-gate  *	Relocation
7587c478bd9Sstevel@tonic-gate  */
7597c478bd9Sstevel@tonic-gate 
7607c478bd9Sstevel@tonic-gate typedef struct {
7617c478bd9Sstevel@tonic-gate 	Elf32_Addr	r_offset;
7627c478bd9Sstevel@tonic-gate 	Elf32_Word	r_info;		/* sym, type: ELF32_R_... */
7637c478bd9Sstevel@tonic-gate } Elf32_Rel;
7647c478bd9Sstevel@tonic-gate 
7657c478bd9Sstevel@tonic-gate typedef struct {
7667c478bd9Sstevel@tonic-gate 	Elf32_Addr	r_offset;
7677c478bd9Sstevel@tonic-gate 	Elf32_Word	r_info;		/* sym, type: ELF32_R_... */
7687c478bd9Sstevel@tonic-gate 	Elf32_Sword	r_addend;
7697c478bd9Sstevel@tonic-gate } Elf32_Rela;
7707c478bd9Sstevel@tonic-gate 
7717c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
7727c478bd9Sstevel@tonic-gate typedef struct {
7737c478bd9Sstevel@tonic-gate 	Elf64_Addr	r_offset;
7747c478bd9Sstevel@tonic-gate 	Elf64_Xword	r_info;		/* sym, type: ELF64_R_... */
7757c478bd9Sstevel@tonic-gate } Elf64_Rel;
7767c478bd9Sstevel@tonic-gate 
7777c478bd9Sstevel@tonic-gate typedef struct {
7787c478bd9Sstevel@tonic-gate 	Elf64_Addr	r_offset;
7797c478bd9Sstevel@tonic-gate 	Elf64_Xword	r_info;		/* sym, type: ELF64_R_... */
7807c478bd9Sstevel@tonic-gate 	Elf64_Sxword	r_addend;
7817c478bd9Sstevel@tonic-gate } Elf64_Rela;
7827c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
7837c478bd9Sstevel@tonic-gate 
7847c478bd9Sstevel@tonic-gate 
7857c478bd9Sstevel@tonic-gate /*
78608278a5eSRod Evans  *	Macros to compose and decompose values for Rel.r_info, Rela.f_info
7877c478bd9Sstevel@tonic-gate  *
7887c478bd9Sstevel@tonic-gate  *	sym = ELF32_R_SYM(R.r_info)
7897c478bd9Sstevel@tonic-gate  *	type = ELF32_R_TYPE(R.r_info)
7907c478bd9Sstevel@tonic-gate  *	R.r_info = ELF32_R_INFO(sym, type)
7917c478bd9Sstevel@tonic-gate  */
7927c478bd9Sstevel@tonic-gate 
7937c478bd9Sstevel@tonic-gate #define	ELF32_R_SYM(info)	((info)>>8)
7947c478bd9Sstevel@tonic-gate #define	ELF32_R_TYPE(info)	((unsigned char)(info))
7957c478bd9Sstevel@tonic-gate #define	ELF32_R_INFO(sym, type)	(((sym)<<8)+(unsigned char)(type))
7967c478bd9Sstevel@tonic-gate 
7977c478bd9Sstevel@tonic-gate #define	ELF64_R_SYM(info)	((info)>>32)
798ab618543SJohn Levon #define	ELF64_R_TYPE(info)	((Elf64_Word)(info))
7997c478bd9Sstevel@tonic-gate #define	ELF64_R_INFO(sym, type)	(((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(type))
8007c478bd9Sstevel@tonic-gate 
8017c478bd9Sstevel@tonic-gate 
8027c478bd9Sstevel@tonic-gate /*
8037c478bd9Sstevel@tonic-gate  * The r_info field is composed of two 32-bit components: the symbol
8047c478bd9Sstevel@tonic-gate  * table index and the relocation type.  The relocation type for SPARC V9
8057c478bd9Sstevel@tonic-gate  * is further decomposed into an 8-bit type identifier and a 24-bit type
8067c478bd9Sstevel@tonic-gate  * dependent data field.  For the existing Elf32 relocation types,
8077c478bd9Sstevel@tonic-gate  * that data field is zero.
8087c478bd9Sstevel@tonic-gate  */
8097c478bd9Sstevel@tonic-gate #define	ELF64_R_TYPE_DATA(info)	(((Elf64_Xword)(info)<<32)>>40)
8107c478bd9Sstevel@tonic-gate #define	ELF64_R_TYPE_ID(info)	(((Elf64_Xword)(info)<<56)>>56)
8117c478bd9Sstevel@tonic-gate #define	ELF64_R_TYPE_INFO(data, type)	\
8127c478bd9Sstevel@tonic-gate 		(((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type))
8137c478bd9Sstevel@tonic-gate 
8147c478bd9Sstevel@tonic-gate 
8157c478bd9Sstevel@tonic-gate /*
8167c478bd9Sstevel@tonic-gate  * Section Group Flags (SHT_GROUP)
8177c478bd9Sstevel@tonic-gate  */
8187c478bd9Sstevel@tonic-gate #define	GRP_COMDAT	0x01
8197c478bd9Sstevel@tonic-gate 
8207c478bd9Sstevel@tonic-gate 
8217c478bd9Sstevel@tonic-gate /*
8227c478bd9Sstevel@tonic-gate  *	Note entry header
8237c478bd9Sstevel@tonic-gate  */
8247c478bd9Sstevel@tonic-gate 
8257c478bd9Sstevel@tonic-gate typedef struct {
8267c478bd9Sstevel@tonic-gate 	Elf32_Word	n_namesz;	/* length of note's name */
8277c478bd9Sstevel@tonic-gate 	Elf32_Word	n_descsz;	/* length of note's "desc" */
8287c478bd9Sstevel@tonic-gate 	Elf32_Word	n_type;		/* type of note */
8297c478bd9Sstevel@tonic-gate } Elf32_Nhdr;
8307c478bd9Sstevel@tonic-gate 
8317c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
8327c478bd9Sstevel@tonic-gate typedef struct {
8337c478bd9Sstevel@tonic-gate 	Elf64_Word	n_namesz;	/* length of note's name */
8347c478bd9Sstevel@tonic-gate 	Elf64_Word	n_descsz;	/* length of note's "desc" */
8357c478bd9Sstevel@tonic-gate 	Elf64_Word	n_type;		/* type of note */
8367c478bd9Sstevel@tonic-gate } Elf64_Nhdr;
8377c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
8387c478bd9Sstevel@tonic-gate 
8397c478bd9Sstevel@tonic-gate /*
8407c478bd9Sstevel@tonic-gate  *	Move entry
8417c478bd9Sstevel@tonic-gate  */
8427c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
8437c478bd9Sstevel@tonic-gate typedef struct {
8447c478bd9Sstevel@tonic-gate 	Elf32_Lword	m_value;	/* symbol value */
845ab618543SJohn Levon 	Elf32_Word	m_info;		/* size + index */
8467c478bd9Sstevel@tonic-gate 	Elf32_Word	m_poffset;	/* symbol offset */
8477c478bd9Sstevel@tonic-gate 	Elf32_Half	m_repeat;	/* repeat count */
8487c478bd9Sstevel@tonic-gate 	Elf32_Half	m_stride;	/* stride info */
8497c478bd9Sstevel@tonic-gate } Elf32_Move;
8507c478bd9Sstevel@tonic-gate 
8517c478bd9Sstevel@tonic-gate /*
85208278a5eSRod Evans  *	Macros to compose and decompose values for Move.r_info
8537c478bd9Sstevel@tonic-gate  *
8547c478bd9Sstevel@tonic-gate  *	sym = ELF32_M_SYM(M.m_info)
8557c478bd9Sstevel@tonic-gate  *	size = ELF32_M_SIZE(M.m_info)
8567c478bd9Sstevel@tonic-gate  *	M.m_info = ELF32_M_INFO(sym, size)
8577c478bd9Sstevel@tonic-gate  */
8587c478bd9Sstevel@tonic-gate #define	ELF32_M_SYM(info)	((info)>>8)
8597c478bd9Sstevel@tonic-gate #define	ELF32_M_SIZE(info)	((unsigned char)(info))
8607c478bd9Sstevel@tonic-gate #define	ELF32_M_INFO(sym, size)	(((sym)<<8)+(unsigned char)(size))
8617c478bd9Sstevel@tonic-gate 
8627c478bd9Sstevel@tonic-gate typedef struct {
8637c478bd9Sstevel@tonic-gate 	Elf64_Lword	m_value;	/* symbol value */
864ab618543SJohn Levon 	Elf64_Xword	m_info;		/* size + index */
8657c478bd9Sstevel@tonic-gate 	Elf64_Xword	m_poffset;	/* symbol offset */
8667c478bd9Sstevel@tonic-gate 	Elf64_Half	m_repeat;	/* repeat count */
8677c478bd9Sstevel@tonic-gate 	Elf64_Half	m_stride;	/* stride info */
8687c478bd9Sstevel@tonic-gate } Elf64_Move;
8697c478bd9Sstevel@tonic-gate #define	ELF64_M_SYM(info)	((info)>>8)
8707c478bd9Sstevel@tonic-gate #define	ELF64_M_SIZE(info)	((unsigned char)(info))
8717c478bd9Sstevel@tonic-gate #define	ELF64_M_INFO(sym, size)	(((sym)<<8)+(unsigned char)(size))
8727c478bd9Sstevel@tonic-gate 
8737c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
8747c478bd9Sstevel@tonic-gate 
8757c478bd9Sstevel@tonic-gate 
8767c478bd9Sstevel@tonic-gate /*
87708278a5eSRod Evans  *	Capabilities entry, Capabilities info and Capabilities chain.
8787c478bd9Sstevel@tonic-gate  */
8797c478bd9Sstevel@tonic-gate #ifndef	_ASM
8807c478bd9Sstevel@tonic-gate typedef struct {
8817c478bd9Sstevel@tonic-gate 	Elf32_Word	c_tag;		/* how to interpret value */
8827c478bd9Sstevel@tonic-gate 	union {
8837c478bd9Sstevel@tonic-gate 		Elf32_Word	c_val;
8847c478bd9Sstevel@tonic-gate 		Elf32_Addr	c_ptr;
8857c478bd9Sstevel@tonic-gate 	} c_un;
8867c478bd9Sstevel@tonic-gate } Elf32_Cap;
8877c478bd9Sstevel@tonic-gate 
88808278a5eSRod Evans typedef	Elf32_Word	Elf32_Capinfo;
88908278a5eSRod Evans typedef	Elf32_Word	Elf32_Capchain;
89008278a5eSRod Evans 
89108278a5eSRod Evans /*
89208278a5eSRod Evans  *	Macros to compose and decompose values for capabilities info.
89308278a5eSRod Evans  *
89408278a5eSRod Evans  *	sym = ELF32_C_SYM(info)
89508278a5eSRod Evans  *	grp = ELF32_C_GROUP(info)
89608278a5eSRod Evans  *	info = ELF32_C_INFO(sym, grp)
89708278a5eSRod Evans  */
89808278a5eSRod Evans #define	ELF32_C_SYM(info)	((info)>>8)
89908278a5eSRod Evans #define	ELF32_C_GROUP(info)	((unsigned char)(info))
90008278a5eSRod Evans #define	ELF32_C_INFO(sym, grp)	(((sym)<<8)+(unsigned char)(grp))
90108278a5eSRod Evans 
90208278a5eSRod Evans 
9037c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
9047c478bd9Sstevel@tonic-gate typedef struct {
9057c478bd9Sstevel@tonic-gate 	Elf64_Xword	c_tag;		/* how to interpret value */
9067c478bd9Sstevel@tonic-gate 	union {
9077c478bd9Sstevel@tonic-gate 		Elf64_Xword	c_val;
9087c478bd9Sstevel@tonic-gate 		Elf64_Addr	c_ptr;
9097c478bd9Sstevel@tonic-gate 	} c_un;
9107c478bd9Sstevel@tonic-gate } Elf64_Cap;
91108278a5eSRod Evans 
91208278a5eSRod Evans typedef	Elf64_Xword	Elf64_Capinfo;
91308278a5eSRod Evans typedef	Elf64_Word	Elf64_Capchain;
91408278a5eSRod Evans 
91508278a5eSRod Evans /*
91608278a5eSRod Evans  *	Macros to compose and decompose values for capabilities info.
91708278a5eSRod Evans  *
91808278a5eSRod Evans  *	sym = ELF64_C_SYM(info)
91908278a5eSRod Evans  *	grp = ELF64_C_GROUP(info)
92008278a5eSRod Evans  *	info = ELF64_C_INFO(sym, grp)
92108278a5eSRod Evans  */
92208278a5eSRod Evans #define	ELF64_C_SYM(info)	((info)>>32)
923ab618543SJohn Levon #define	ELF64_C_GROUP(info)	((Elf64_Word)(info))
92408278a5eSRod Evans #define	ELF64_C_INFO(sym, grp)	(((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(grp))
92508278a5eSRod Evans 
9267c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
9277c478bd9Sstevel@tonic-gate #endif
9287c478bd9Sstevel@tonic-gate 
92908278a5eSRod Evans /*
93008278a5eSRod Evans  * Version numbers for SHT_SUNW_capinfo and SHT_SUNW_capchain.
93108278a5eSRod Evans  */
93208278a5eSRod Evans #define	CAPINFO_NONE		0
93308278a5eSRod Evans #define	CAPINFO_CURRENT		1
93408278a5eSRod Evans #define	CAPINFO_NUM		2
93508278a5eSRod Evans 
93608278a5eSRod Evans #define	CAPCHAIN_NONE		0
93708278a5eSRod Evans #define	CAPCHAIN_CURRENT	1
93808278a5eSRod Evans #define	CAPCHAIN_NUM		2
93908278a5eSRod Evans 
94008278a5eSRod Evans /*
94108278a5eSRod Evans  * A SHT_SUNW_capinfo table mirrors a symbol table.  A capabilities symbol has
94208278a5eSRod Evans  * a SHT_SUNW_capinfo table entry that provides an index into the associated
94308278a5eSRod Evans  * SHT_SUNW_cap capabilities group, and the symbol index of the associated lead
94408278a5eSRod Evans  * symbol.  A capabilities symbol is a local symbol.  A global lead capabilities
94508278a5eSRod Evans  * symbol is tagged with a group CAPINFO_SUNW_GLOB.
94608278a5eSRod Evans  */
94708278a5eSRod Evans #define	CAPINFO_SUNW_GLOB	0xff
94808278a5eSRod Evans 
94908278a5eSRod Evans /*
95008278a5eSRod Evans  * Capabilities values.
95108278a5eSRod Evans  */
9527c478bd9Sstevel@tonic-gate #define	CA_SUNW_NULL	0
9537c478bd9Sstevel@tonic-gate #define	CA_SUNW_HW_1	1		/* first hardware capabilities entry */
9547c478bd9Sstevel@tonic-gate #define	CA_SUNW_SF_1	2		/* first software capabilities entry */
95569112eddSAli Bahrami #define	CA_SUNW_HW_2	3		/* second hardware capabilities entry */
95608278a5eSRod Evans #define	CA_SUNW_PLAT	4		/* platform capability entry */
95708278a5eSRod Evans #define	CA_SUNW_MACH	5		/* machine capability entry */
95808278a5eSRod Evans #define	CA_SUNW_ID	6		/* capability identifier */
95908278a5eSRod Evans #define	CA_SUNW_NUM	7
9607c478bd9Sstevel@tonic-gate 
9617c478bd9Sstevel@tonic-gate /*
9627c478bd9Sstevel@tonic-gate  * Define software capabilities (CA_SUNW_SF_1 values).  Note, hardware
9637c478bd9