xref: /titanic_50/usr/src/uts/common/sys/elf.h (revision 6075882998740edfaff4dd844974e188f8bd6793)
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
5c13de8f6Sab196087  * Common Development and Distribution License (the "License").
6c13de8f6Sab196087  * 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  */
217c478bd9Sstevel@tonic-gate /*
22d579eb63Sab196087  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
277c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifndef _SYS_ELF_H
317c478bd9Sstevel@tonic-gate #define	_SYS_ELF_H
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <sys/elftypes.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
387c478bd9Sstevel@tonic-gate extern "C" {
397c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #define	ELF32_FSZ_ADDR	4
427c478bd9Sstevel@tonic-gate #define	ELF32_FSZ_HALF	2
437c478bd9Sstevel@tonic-gate #define	ELF32_FSZ_OFF	4
447c478bd9Sstevel@tonic-gate #define	ELF32_FSZ_SWORD	4
457c478bd9Sstevel@tonic-gate #define	ELF32_FSZ_WORD	4
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_ADDR	8
487c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_HALF	2
497c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_OFF	8
507c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_SWORD	4
517c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_WORD	4
527c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_SXWORD 8
537c478bd9Sstevel@tonic-gate #define	ELF64_FSZ_XWORD	8
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate /*
567c478bd9Sstevel@tonic-gate  *	"Enumerations" below use ...NUM as the number of
577c478bd9Sstevel@tonic-gate  *	values in the list.  It should be 1 greater than the
587c478bd9Sstevel@tonic-gate  *	highest "real" value.
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /*
627c478bd9Sstevel@tonic-gate  *	ELF header
637c478bd9Sstevel@tonic-gate  */
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate #define	EI_NIDENT	16
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate typedef struct {
687c478bd9Sstevel@tonic-gate 	unsigned char	e_ident[EI_NIDENT];	/* ident bytes */
697c478bd9Sstevel@tonic-gate 	Elf32_Half	e_type;			/* file type */
707c478bd9Sstevel@tonic-gate 	Elf32_Half	e_machine;		/* target machine */
717c478bd9Sstevel@tonic-gate 	Elf32_Word	e_version;		/* file version */
727c478bd9Sstevel@tonic-gate 	Elf32_Addr	e_entry;		/* start address */
737c478bd9Sstevel@tonic-gate 	Elf32_Off	e_phoff;		/* phdr file offset */
747c478bd9Sstevel@tonic-gate 	Elf32_Off	e_shoff;		/* shdr file offset */
757c478bd9Sstevel@tonic-gate 	Elf32_Word	e_flags;		/* file flags */
767c478bd9Sstevel@tonic-gate 	Elf32_Half	e_ehsize;		/* sizeof ehdr */
777c478bd9Sstevel@tonic-gate 	Elf32_Half	e_phentsize;		/* sizeof phdr */
787c478bd9Sstevel@tonic-gate 	Elf32_Half	e_phnum;		/* number phdrs */
797c478bd9Sstevel@tonic-gate 	Elf32_Half	e_shentsize;		/* sizeof shdr */
807c478bd9Sstevel@tonic-gate 	Elf32_Half	e_shnum;		/* number shdrs */
817c478bd9Sstevel@tonic-gate 	Elf32_Half	e_shstrndx;		/* shdr string index */
827c478bd9Sstevel@tonic-gate } Elf32_Ehdr;
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
857c478bd9Sstevel@tonic-gate typedef struct {
867c478bd9Sstevel@tonic-gate 	unsigned char	e_ident[EI_NIDENT];	/* ident bytes */
877c478bd9Sstevel@tonic-gate 	Elf64_Half	e_type;			/* file type */
887c478bd9Sstevel@tonic-gate 	Elf64_Half	e_machine;		/* target machine */
897c478bd9Sstevel@tonic-gate 	Elf64_Word	e_version;		/* file version */
907c478bd9Sstevel@tonic-gate 	Elf64_Addr	e_entry;		/* start address */
917c478bd9Sstevel@tonic-gate 	Elf64_Off	e_phoff;		/* phdr file offset */
927c478bd9Sstevel@tonic-gate 	Elf64_Off	e_shoff;		/* shdr file offset */
937c478bd9Sstevel@tonic-gate 	Elf64_Word	e_flags;		/* file flags */
947c478bd9Sstevel@tonic-gate 	Elf64_Half	e_ehsize;		/* sizeof ehdr */
957c478bd9Sstevel@tonic-gate 	Elf64_Half	e_phentsize;		/* sizeof phdr */
967c478bd9Sstevel@tonic-gate 	Elf64_Half	e_phnum;		/* number phdrs */
977c478bd9Sstevel@tonic-gate 	Elf64_Half	e_shentsize;		/* sizeof shdr */
987c478bd9Sstevel@tonic-gate 	Elf64_Half	e_shnum;		/* number shdrs */
997c478bd9Sstevel@tonic-gate 	Elf64_Half	e_shstrndx;		/* shdr string index */
1007c478bd9Sstevel@tonic-gate } Elf64_Ehdr;
1017c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate #define	EI_MAG0		0	/* e_ident[] indexes */
1057c478bd9Sstevel@tonic-gate #define	EI_MAG1		1
1067c478bd9Sstevel@tonic-gate #define	EI_MAG2		2
1077c478bd9Sstevel@tonic-gate #define	EI_MAG3		3
1087c478bd9Sstevel@tonic-gate #define	EI_CLASS	4	/* File class */
1097c478bd9Sstevel@tonic-gate #define	EI_DATA		5	/* Data encoding */
1107c478bd9Sstevel@tonic-gate #define	EI_VERSION	6	/* File version */
1117c478bd9Sstevel@tonic-gate #define	EI_OSABI	7	/* Operating system/ABI identification */
1127c478bd9Sstevel@tonic-gate #define	EI_ABIVERSION	8	/* ABI version */
1137c478bd9Sstevel@tonic-gate #define	EI_PAD		9	/* Start of padding bytes */
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate #define	ELFMAG0		0x7f		/* EI_MAG */
1167c478bd9Sstevel@tonic-gate #define	ELFMAG1		'E'
1177c478bd9Sstevel@tonic-gate #define	ELFMAG2		'L'
1187c478bd9Sstevel@tonic-gate #define	ELFMAG3		'F'
1197c478bd9Sstevel@tonic-gate #define	ELFMAG		"\177ELF"
1207c478bd9Sstevel@tonic-gate #define	SELFMAG		4
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate #define	ELFCLASSNONE	0		/* EI_CLASS */
1237c478bd9Sstevel@tonic-gate #define	ELFCLASS32	1
1247c478bd9Sstevel@tonic-gate #define	ELFCLASS64	2
1257c478bd9Sstevel@tonic-gate #define	ELFCLASSNUM	3
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate #define	ELFDATANONE	0		/* EI_DATA */
1287c478bd9Sstevel@tonic-gate #define	ELFDATA2LSB	1
1297c478bd9Sstevel@tonic-gate #define	ELFDATA2MSB	2
1307c478bd9Sstevel@tonic-gate #define	ELFDATANUM	3
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate #define	ET_NONE		0		/* e_type */
1337c478bd9Sstevel@tonic-gate #define	ET_REL		1
1347c478bd9Sstevel@tonic-gate #define	ET_EXEC		2
1357c478bd9Sstevel@tonic-gate #define	ET_DYN		3
1367c478bd9Sstevel@tonic-gate #define	ET_CORE		4
1377c478bd9Sstevel@tonic-gate #define	ET_NUM		5
1387c478bd9Sstevel@tonic-gate #define	ET_LOOS		0xfe00		/* OS specific range */
1397c478bd9Sstevel@tonic-gate #define	ET_LOSUNW	0xfeff
1407c478bd9Sstevel@tonic-gate #define	ET_SUNWPSEUDO	0xfeff
1417c478bd9Sstevel@tonic-gate #define	ET_HISUNW	0xfeff
1427c478bd9Sstevel@tonic-gate #define	ET_HIOS		0xfeff
1437c478bd9Sstevel@tonic-gate #define	ET_LOPROC	0xff00		/* processor specific range */
1447c478bd9Sstevel@tonic-gate #define	ET_HIPROC	0xffff
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate #define	ET_LOPROC	0xff00		/* processor specific range */
1477c478bd9Sstevel@tonic-gate #define	ET_HIPROC	0xffff
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate #define	EM_NONE		0		/* e_machine */
1507c478bd9Sstevel@tonic-gate #define	EM_M32		1		/* AT&T WE 32100 */
1517c478bd9Sstevel@tonic-gate #define	EM_SPARC	2		/* Sun SPARC */
1527c478bd9Sstevel@tonic-gate #define	EM_386		3		/* Intel 80386 */
1537c478bd9Sstevel@tonic-gate #define	EM_68K		4		/* Motorola 68000 */
1547c478bd9Sstevel@tonic-gate #define	EM_88K		5		/* Motorola 88000 */
1557c478bd9Sstevel@tonic-gate #define	EM_486		6		/* Intel 80486 */
1567c478bd9Sstevel@tonic-gate #define	EM_860		7		/* Intel i860 */
1577c478bd9Sstevel@tonic-gate #define	EM_MIPS		8		/* MIPS RS3000 Big-Endian */
1587c478bd9Sstevel@tonic-gate #define	EM_S370		9		/* IBM System/370 Processor */
1597c478bd9Sstevel@tonic-gate #define	EM_MIPS_RS3_LE	10		/* MIPS RS3000 Little-Endian */
1607c478bd9Sstevel@tonic-gate #define	EM_RS6000	11		/* RS6000 */
1617c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN12	12
1627c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN13	13
1637c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN14	14
1647c478bd9Sstevel@tonic-gate #define	EM_PA_RISC	15		/* PA-RISC */
1651638af81Sab196087 #define	EM_PARISC	EM_PA_RISC	/* Alias: GNU compatibility */
1667c478bd9Sstevel@tonic-gate #define	EM_nCUBE	16		/* nCUBE */
1677c478bd9Sstevel@tonic-gate #define	EM_VPP500	17		/* Fujitsu VPP500 */
1687c478bd9Sstevel@tonic-gate #define	EM_SPARC32PLUS	18		/* Sun SPARC 32+ */
1697c478bd9Sstevel@tonic-gate #define	EM_960		19		/* Intel 80960 */
1707c478bd9Sstevel@tonic-gate #define	EM_PPC		20		/* PowerPC */
1717c478bd9Sstevel@tonic-gate #define	EM_PPC64	21		/* 64-bit PowerPC */
1721638af81Sab196087 #define	EM_S390		22		/* IBM System/390 Processor */
1731638af81Sab196087 #define	EM_UNKNOWN22	EM_S390		/* Alias: Older published name */
1747c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN23	23
1757c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN24	24
1767c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN25	25
1777c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN26	26
1787c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN27	27
1797c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN28	28
1807c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN29	29
1817c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN30	30
1827c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN31	31
1837c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN32	32
1847c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN33	33
1857c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN34	34
1867c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN35	35
1877c478bd9Sstevel@tonic-gate #define	EM_V800		36		/* NEX V800 */
1887c478bd9Sstevel@tonic-gate #define	EM_FR20		37		/* Fujitsu FR20 */
1897c478bd9Sstevel@tonic-gate #define	EM_RH32		38		/* TRW RH-32 */
1907c478bd9Sstevel@tonic-gate #define	EM_RCE		39		/* Motorola RCE */
1917c478bd9Sstevel@tonic-gate #define	EM_ARM		40		/* Advanced RISC Marchines ARM */
1927c478bd9Sstevel@tonic-gate #define	EM_ALPHA	41		/* Digital Alpha */
1937c478bd9Sstevel@tonic-gate #define	EM_SH		42		/* Hitachi SH */
1947c478bd9Sstevel@tonic-gate #define	EM_SPARCV9	43		/* Sun SPARC V9 (64-bit) */
1957c478bd9Sstevel@tonic-gate #define	EM_TRICORE	44		/* Siemens Tricore embedded processor */
1967c478bd9Sstevel@tonic-gate #define	EM_ARC		45		/* Argonaut RISC Core, */
1977c478bd9Sstevel@tonic-gate 					/*	Argonaut Technologies Inc. */
1987c478bd9Sstevel@tonic-gate #define	EM_H8_300	46		/* Hitachi H8/300 */
1997c478bd9Sstevel@tonic-gate #define	EM_H8_300H	47		/* Hitachi H8/300H */
2007c478bd9Sstevel@tonic-gate #define	EM_H8S		48		/* Hitachi H8S */
2017c478bd9Sstevel@tonic-gate #define	EM_H8_500	49		/* Hitachi H8/500 */
2027c478bd9Sstevel@tonic-gate #define	EM_IA_64	50		/* Intel IA64 */
2037c478bd9Sstevel@tonic-gate #define	EM_MIPS_X	51		/* Stanford MIPS-X */
2047c478bd9Sstevel@tonic-gate #define	EM_COLDFIRE	52		/* Motorola ColdFire */
2057c478bd9Sstevel@tonic-gate #define	EM_68HC12	53		/* Motorola M68HC12 */
2067c478bd9Sstevel@tonic-gate #define	EM_MMA		54		/* Fujitsu MMA Mulimedia Accelerator */
2077c478bd9Sstevel@tonic-gate #define	EM_PCP		55		/* Siemens PCP */
2087c478bd9Sstevel@tonic-gate #define	EM_NCPU		56		/* Sony nCPU embedded RISC processor */
2097c478bd9Sstevel@tonic-gate #define	EM_NDR1		57		/* Denso NDR1 microprocessor */
2107c478bd9Sstevel@tonic-gate #define	EM_STARCORE	58		/* Motorola Star*Core processor */
2117c478bd9Sstevel@tonic-gate #define	EM_ME16		59		/* Toyota ME16 processor */
2127c478bd9Sstevel@tonic-gate #define	EM_ST100	60		/* STMicroelectronics ST100 processor */
2137c478bd9Sstevel@tonic-gate #define	EM_TINYJ	61		/* Advanced Logic Corp. TinyJ */
2147c478bd9Sstevel@tonic-gate 					/*	embedded processor family */
2157c478bd9Sstevel@tonic-gate #define	EM_AMD64	62		/* AMDs x86-64 architecture */
2167c478bd9Sstevel@tonic-gate #define	EM_X86_64	EM_AMD64	/* (compatibility) */
2177c478bd9Sstevel@tonic-gate 
2187c478bd9Sstevel@tonic-gate #define	EM_PDSP		63		/* Sony DSP Processor */
2197c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN64	64
2207c478bd9Sstevel@tonic-gate #define	EM_UNKNOWN65	65
2217c478bd9Sstevel@tonic-gate #define	EM_FX66		66		/* Siemens FX66 microcontroller */
2227c478bd9Sstevel@tonic-gate #define	EM_ST9PLUS	67		/* STMicroelectronics ST9+8/16 bit */
2237c478bd9Sstevel@tonic-gate 					/*	microcontroller */
2247c478bd9Sstevel@tonic-gate #define	EM_ST7		68		/* STMicroelectronics ST7 8-bit */
2257c478bd9Sstevel@tonic-gate 					/*	microcontroller */
2267c478bd9Sstevel@tonic-gate #define	EM_68HC16	69		/* Motorola MC68HC16 Microcontroller */
2277c478bd9Sstevel@tonic-gate #define	EM_68HC11	70		/* Motorola MC68HC11 Microcontroller */
2287c478bd9Sstevel@tonic-gate #define	EM_68HC08	71		/* Motorola MC68HC08 Microcontroller */
2297c478bd9Sstevel@tonic-gate #define	EM_68HC05	72		/* Motorola MC68HC05 Microcontroller */
2307c478bd9Sstevel@tonic-gate #define	EM_SVX		73		/* Silicon Graphics SVx */
2317c478bd9Sstevel@tonic-gate #define	EM_ST19		74		/* STMicroelectronics ST19 8-bit */
2327c478bd9Sstevel@tonic-gate 					/*	microcontroller */
2337c478bd9Sstevel@tonic-gate #define	EM_VAX		75		/* Digital VAX */
2347c478bd9Sstevel@tonic-gate #define	EM_CRIS		76		/* Axis Communications 32-bit */
2357c478bd9Sstevel@tonic-gate 					/*	embedded processor */
2367c478bd9Sstevel@tonic-gate #define	EM_JAVELIN	77		/* Infineon Technologies 32-bit */
2377c478bd9Sstevel@tonic-gate 					/*	embedded processor */
2387c478bd9Sstevel@tonic-gate #define	EM_FIREPATH	78		/* Element 14 64-bit DSP Processor */
2397c478bd9Sstevel@tonic-gate #define	EM_ZSP		79		/* LSI Logic 16-bit DSP Processor */
2407c478bd9Sstevel@tonic-gate #define	EM_MMIX		80		/* Donald Knuth's educational */
2417c478bd9Sstevel@tonic-gate 					/*	64-bit processor */
2427c478bd9Sstevel@tonic-gate #define	EM_HUANY	81		/* Harvard University */
2437c478bd9Sstevel@tonic-gate 					/*	machine-independent */
2447c478bd9Sstevel@tonic-gate 					/*	object files */
2457c478bd9Sstevel@tonic-gate #define	EM_PRISM	82		/* SiTera Prism */
2467c478bd9Sstevel@tonic-gate #define	EM_AVR		83		/* Atmel AVR 8-bit microcontroller */
2477c478bd9Sstevel@tonic-gate #define	EM_FR30		84		/* Fujitsu FR30 */
2487c478bd9Sstevel@tonic-gate #define	EM_D10V		85		/* Mitsubishi D10V */
2497c478bd9Sstevel@tonic-gate #define	EM_D30V		86		/* Mitsubishi D30V */
2507c478bd9Sstevel@tonic-gate #define	EM_V850		87		/* NEC v850 */
2517c478bd9Sstevel@tonic-gate #define	EM_M32R		88		/* Mitsubishi M32R */
2527c478bd9Sstevel@tonic-gate #define	EM_MN10300	89		/* Matsushita MN10300 */
2537c478bd9Sstevel@tonic-gate #define	EM_MN10200	90		/* Matsushita MN10200 */
2547c478bd9Sstevel@tonic-gate #define	EM_PJ		91		/* picoJava */
2557c478bd9Sstevel@tonic-gate #define	EM_OPENRISC	92		/* OpenRISC 32-bit embedded processor */
2567c478bd9Sstevel@tonic-gate #define	EM_ARC_A5	93		/* ARC Cores Tangent-A5 */
2577c478bd9Sstevel@tonic-gate #define	EM_XTENSA	94		/* Tensilica Xtensa architecture */
2587c478bd9Sstevel@tonic-gate #define	EM_NUM		95
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate #define	EV_NONE		0		/* e_version, EI_VERSION */
2617c478bd9Sstevel@tonic-gate #define	EV_CURRENT	1
2627c478bd9Sstevel@tonic-gate #define	EV_NUM		2
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate #define	ELFOSABI_NONE		0	/* No extensions or unspecified */
2661638af81Sab196087 #define	ELFOSABI_SYSV		ELFOSABI_NONE
2677c478bd9Sstevel@tonic-gate #define	ELFOSABI_HPUX		1	/* Hewlett-Packard HP-UX */
2687c478bd9Sstevel@tonic-gate #define	ELFOSABI_NETBSD		2	/* NetBSD */
2697c478bd9Sstevel@tonic-gate #define	ELFOSABI_LINUX		3	/* Linux */
2707c478bd9Sstevel@tonic-gate #define	ELFOSABI_UNKNOWN4	4
2717c478bd9Sstevel@tonic-gate #define	ELFOSABI_UNKNOWN5	5
2727c478bd9Sstevel@tonic-gate #define	ELFOSABI_SOLARIS	6	/* Sun Solaris */
2737c478bd9Sstevel@tonic-gate #define	ELFOSABI_AIX		7	/* AIX */
2747c478bd9Sstevel@tonic-gate #define	ELFOSABI_IRIX		8	/* IRIX */
2757c478bd9Sstevel@tonic-gate #define	ELFOSABI_FREEBSD	9	/* FreeBSD */
2767c478bd9Sstevel@tonic-gate #define	ELFOSABI_TRU64		10	/* Compaq TRU64 UNIX */
2777c478bd9Sstevel@tonic-gate #define	ELFOSABI_MODESTO	11	/* Novell Modesto */
2787c478bd9Sstevel@tonic-gate #define	ELFOSABI_OPENBSD	12	/* Open BSD */
2791638af81Sab196087 #define	ELFOSABI_OPENVMS	13	/* Open VMS */
2801638af81Sab196087 #define	ELFOSABI_NSK		14	/* Hewlett-Packard Non-Stop Kernel */
2811638af81Sab196087 #define	ELFOSABI_AROS		15	/* Amiga Research OS */
2821638af81Sab196087 #define	ELFOSABI_ARM		97	/* ARM */
2831638af81Sab196087 #define	ELFOSABI_STANDALONE	255	/* standalone (embedded) application */
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate /*
2867c478bd9Sstevel@tonic-gate  *	Program header
2877c478bd9Sstevel@tonic-gate  */
2887c478bd9Sstevel@tonic-gate 
2897c478bd9Sstevel@tonic-gate typedef struct {
2907c478bd9Sstevel@tonic-gate 	Elf32_Word	p_type;		/* entry type */
2917c478bd9Sstevel@tonic-gate 	Elf32_Off	p_offset;	/* file offset */
2927c478bd9Sstevel@tonic-gate 	Elf32_Addr	p_vaddr;	/* virtual address */
2937c478bd9Sstevel@tonic-gate 	Elf32_Addr	p_paddr;	/* physical address */
2947c478bd9Sstevel@tonic-gate 	Elf32_Word	p_filesz;	/* file size */
2957c478bd9Sstevel@tonic-gate 	Elf32_Word	p_memsz;	/* memory size */
2967c478bd9Sstevel@tonic-gate 	Elf32_Word	p_flags;	/* entry flags */
2977c478bd9Sstevel@tonic-gate 	Elf32_Word	p_align;	/* memory/file alignment */
2987c478bd9Sstevel@tonic-gate } Elf32_Phdr;
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
3017c478bd9Sstevel@tonic-gate typedef struct {
3027c478bd9Sstevel@tonic-gate 	Elf64_Word	p_type;		/* entry type */
3037c478bd9Sstevel@tonic-gate 	Elf64_Word	p_flags;	/* entry flags */
3047c478bd9Sstevel@tonic-gate 	Elf64_Off	p_offset;	/* file offset */
3057c478bd9Sstevel@tonic-gate 	Elf64_Addr	p_vaddr;	/* virtual address */
3067c478bd9Sstevel@tonic-gate 	Elf64_Addr	p_paddr;	/* physical address */
3077c478bd9Sstevel@tonic-gate 	Elf64_Xword	p_filesz;	/* file size */
3087c478bd9Sstevel@tonic-gate 	Elf64_Xword	p_memsz;	/* memory size */
3097c478bd9Sstevel@tonic-gate 	Elf64_Xword	p_align;	/* memory/file alignment */
3107c478bd9Sstevel@tonic-gate } Elf64_Phdr;
3117c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate #define	PT_NULL		0		/* p_type */
3157c478bd9Sstevel@tonic-gate #define	PT_LOAD		1
3167c478bd9Sstevel@tonic-gate #define	PT_DYNAMIC	2
3177c478bd9Sstevel@tonic-gate #define	PT_INTERP	3
3187c478bd9Sstevel@tonic-gate #define	PT_NOTE		4
3197c478bd9Sstevel@tonic-gate #define	PT_SHLIB	5
3207c478bd9Sstevel@tonic-gate #define	PT_PHDR		6
3217c478bd9Sstevel@tonic-gate #define	PT_TLS		7
3227c478bd9Sstevel@tonic-gate #define	PT_NUM		8
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate #define	PT_LOOS		0x60000000	/* OS specific range */
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate /*
3277c478bd9Sstevel@tonic-gate  * Note: The amd64 psABI defines that the UNWIND program header
3287c478bd9Sstevel@tonic-gate  *	 should reside in the OS specific range of the program
3297c478bd9Sstevel@tonic-gate  *	 headers.
3307c478bd9Sstevel@tonic-gate  */
3317c478bd9Sstevel@tonic-gate #define	PT_SUNW_UNWIND	0x6464e550	/* amd64 UNWIND program header */
3327c478bd9Sstevel@tonic-gate #define	PT_GNU_EH_FRAME	PT_SUNW_UNWIND
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate #define	PT_LOSUNW	0x6ffffffa
3367c478bd9Sstevel@tonic-gate #define	PT_SUNWBSS	0x6ffffffa	/* Sun Specific segment */
3377c478bd9Sstevel@tonic-gate #define	PT_SUNWSTACK	0x6ffffffb	/* describes the stack segment */
3387c478bd9Sstevel@tonic-gate #define	PT_SUNWDTRACE	0x6ffffffc	/* private */
3397c478bd9Sstevel@tonic-gate #define	PT_SUNWCAP	0x6ffffffd	/* hard/soft capabilities segment */
3407c478bd9Sstevel@tonic-gate #define	PT_HISUNW	0x6fffffff
3417c478bd9Sstevel@tonic-gate #define	PT_HIOS		0x6fffffff
3427c478bd9Sstevel@tonic-gate 
3437c478bd9Sstevel@tonic-gate #define	PT_LOPROC	0x70000000	/* processor specific range */
3447c478bd9Sstevel@tonic-gate #define	PT_HIPROC	0x7fffffff
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate #define	PF_R		0x4		/* p_flags */
3477c478bd9Sstevel@tonic-gate #define	PF_W		0x2
3487c478bd9Sstevel@tonic-gate #define	PF_X		0x1
3497c478bd9Sstevel@tonic-gate 
3507c478bd9Sstevel@tonic-gate #define	PF_MASKOS	0x0ff00000	/* OS specific values */
3517c478bd9Sstevel@tonic-gate #define	PF_MASKPROC	0xf0000000	/* processor specific values */
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate #define	PF_SUNW_FAILURE	0x00100000	/* mapping absent due to failure */
3547c478bd9Sstevel@tonic-gate 
35530da1432Sahl #define	PN_XNUM		0xffff		/* extended program header index */
35630da1432Sahl 
3577c478bd9Sstevel@tonic-gate /*
3587c478bd9Sstevel@tonic-gate  *	Section header
3597c478bd9Sstevel@tonic-gate  */
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate typedef struct {
3627c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_name;	/* section name */
3637c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_type;	/* SHT_... */
3647c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_flags;	/* SHF_... */
3657c478bd9Sstevel@tonic-gate 	Elf32_Addr	sh_addr;	/* virtual address */
3667c478bd9Sstevel@tonic-gate 	Elf32_Off	sh_offset;	/* file offset */
3677c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_size;	/* section size */
3687c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_link;	/* misc info */
3697c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_info;	/* misc info */
3707c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_addralign;	/* memory alignment */
3717c478bd9Sstevel@tonic-gate 	Elf32_Word	sh_entsize;	/* entry size if table */
3727c478bd9Sstevel@tonic-gate } Elf32_Shdr;
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
3757c478bd9Sstevel@tonic-gate typedef struct {
3767c478bd9Sstevel@tonic-gate 	Elf64_Word	sh_name;	/* section name */
3777c478bd9Sstevel@tonic-gate 	Elf64_Word	sh_type;	/* SHT_... */
3787c478bd9Sstevel@tonic-gate 	Elf64_Xword	sh_flags;	/* SHF_... */
3797c478bd9Sstevel@tonic-gate 	Elf64_Addr	sh_addr;	/* virtual address */
3807c478bd9Sstevel@tonic-gate 	Elf64_Off	sh_offset;	/* file offset */
3817c478bd9Sstevel@tonic-gate 	Elf64_Xword	sh_size;	/* section size */
3827c478bd9Sstevel@tonic-gate 	Elf64_Word	sh_link;	/* misc info */
3837c478bd9Sstevel@tonic-gate 	Elf64_Word	sh_info;	/* misc info */
3847c478bd9Sstevel@tonic-gate 	Elf64_Xword	sh_addralign;	/* memory alignment */
3857c478bd9Sstevel@tonic-gate 	Elf64_Xword	sh_entsize;	/* entry size if table */
3867c478bd9Sstevel@tonic-gate } Elf64_Shdr;
3877c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
3887c478bd9Sstevel@tonic-gate 
3897c478bd9Sstevel@tonic-gate #define	SHT_NULL		0		/* sh_type */
3907c478bd9Sstevel@tonic-gate #define	SHT_PROGBITS		1
3917c478bd9Sstevel@tonic-gate #define	SHT_SYMTAB		2
3927c478bd9Sstevel@tonic-gate #define	SHT_STRTAB		3
3937c478bd9Sstevel@tonic-gate #define	SHT_RELA		4
3947c478bd9Sstevel@tonic-gate #define	SHT_HASH		5
3957c478bd9Sstevel@tonic-gate #define	SHT_DYNAMIC		6
3967c478bd9Sstevel@tonic-gate #define	SHT_NOTE		7
3977c478bd9Sstevel@tonic-gate #define	SHT_NOBITS		8
3987c478bd9Sstevel@tonic-gate #define	SHT_REL			9
3997c478bd9Sstevel@tonic-gate #define	SHT_SHLIB		10
4007c478bd9Sstevel@tonic-gate #define	SHT_DYNSYM		11
4017c478bd9Sstevel@tonic-gate #define	SHT_UNKNOWN12		12
4027c478bd9Sstevel@tonic-gate #define	SHT_UNKNOWN13		13
4037c478bd9Sstevel@tonic-gate #define	SHT_INIT_ARRAY		14
4047c478bd9Sstevel@tonic-gate #define	SHT_FINI_ARRAY		15
4057c478bd9Sstevel@tonic-gate #define	SHT_PREINIT_ARRAY	16
4067c478bd9Sstevel@tonic-gate #define	SHT_GROUP		17
4077c478bd9Sstevel@tonic-gate #define	SHT_SYMTAB_SHNDX	18
4087c478bd9Sstevel@tonic-gate #define	SHT_NUM			19
4097c478bd9Sstevel@tonic-gate 
4101638af81Sab196087 /* Solaris ABI specific values */
4117c478bd9Sstevel@tonic-gate #define	SHT_LOOS		0x60000000	/* OS specific range */
412d579eb63Sab196087 #define	SHT_LOSUNW		0x6ffffff1
413d579eb63Sab196087 #define	SHT_SUNW_symsort	0x6ffffff1
414d579eb63Sab196087 #define	SHT_SUNW_tlssort	0x6ffffff2
4159039eeafSab196087 #define	SHT_SUNW_LDYNSYM	0x6ffffff3
4167c478bd9Sstevel@tonic-gate #define	SHT_SUNW_dof		0x6ffffff4
4177c478bd9Sstevel@tonic-gate #define	SHT_SUNW_cap		0x6ffffff5
4187c478bd9Sstevel@tonic-gate #define	SHT_SUNW_SIGNATURE	0x6ffffff6
4197c478bd9Sstevel@tonic-gate #define	SHT_SUNW_ANNOTATE	0x6ffffff7
4207c478bd9Sstevel@tonic-gate #define	SHT_SUNW_DEBUGSTR	0x6ffffff8
4217c478bd9Sstevel@tonic-gate #define	SHT_SUNW_DEBUG		0x6ffffff9
4227c478bd9Sstevel@tonic-gate #define	SHT_SUNW_move		0x6ffffffa
4237c478bd9Sstevel@tonic-gate #define	SHT_SUNW_COMDAT		0x6ffffffb
4247c478bd9Sstevel@tonic-gate #define	SHT_SUNW_syminfo	0x6ffffffc
4257c478bd9Sstevel@tonic-gate #define	SHT_SUNW_verdef		0x6ffffffd
4267c478bd9Sstevel@tonic-gate #define	SHT_SUNW_verneed	0x6ffffffe
4277c478bd9Sstevel@tonic-gate #define	SHT_SUNW_versym		0x6fffffff
4287c478bd9Sstevel@tonic-gate #define	SHT_HISUNW		0x6fffffff
4297c478bd9Sstevel@tonic-gate #define	SHT_HIOS		0x6fffffff
4307c478bd9Sstevel@tonic-gate 
4311638af81Sab196087 /* GNU/Linux ABI specific values */
4321638af81Sab196087 #define	SHT_GNU_verdef		0x6ffffffd
4331638af81Sab196087 #define	SHT_GNU_verneed		0x6ffffffe
4341638af81Sab196087 #define	SHT_GNU_versym		0x6fffffff
4351638af81Sab196087 
4367c478bd9Sstevel@tonic-gate #define	SHT_LOPROC	0x70000000	/* processor specific range */
4377c478bd9Sstevel@tonic-gate #define	SHT_HIPROC	0x7fffffff
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate #define	SHT_LOUSER	0x80000000
4407c478bd9Sstevel@tonic-gate #define	SHT_HIUSER	0xffffffff
4417c478bd9Sstevel@tonic-gate 
4427c478bd9Sstevel@tonic-gate #define	SHF_WRITE		0x01		/* sh_flags */
4437c478bd9Sstevel@tonic-gate #define	SHF_ALLOC		0x02
4447c478bd9Sstevel@tonic-gate #define	SHF_EXECINSTR		0x04
4457c478bd9Sstevel@tonic-gate #define	SHF_MERGE		0x10
4467c478bd9Sstevel@tonic-gate #define	SHF_STRINGS		0x20
4477c478bd9Sstevel@tonic-gate #define	SHF_INFO_LINK		0x40
4487c478bd9Sstevel@tonic-gate #define	SHF_LINK_ORDER		0x80
4497c478bd9Sstevel@tonic-gate #define	SHF_OS_NONCONFORMING	0x100
4507c478bd9Sstevel@tonic-gate #define	SHF_GROUP		0x200
4517c478bd9Sstevel@tonic-gate #define	SHF_TLS			0x400
4527c478bd9Sstevel@tonic-gate 
4537c478bd9Sstevel@tonic-gate #define	SHF_MASKOS	0x0ff00000	/* OS specific values */
4547c478bd9Sstevel@tonic-gate 
4557c478bd9Sstevel@tonic-gate 
4567c478bd9Sstevel@tonic-gate #define	SHF_MASKPROC	0xf0000000	/* processor specific values */
4577c478bd9Sstevel@tonic-gate 
4587c478bd9Sstevel@tonic-gate #define	SHN_UNDEF	0		/* special section numbers */
4597c478bd9Sstevel@tonic-gate #define	SHN_LORESERVE	0xff00
4607c478bd9Sstevel@tonic-gate #define	SHN_LOPROC	0xff00		/* processor specific range */
4617c478bd9Sstevel@tonic-gate #define	SHN_HIPROC	0xff1f
4627c478bd9Sstevel@tonic-gate #define	SHN_LOOS	0xff20		/* OS specific range */
4637c478bd9Sstevel@tonic-gate #define	SHN_LOSUNW	0xff3f
4647c478bd9Sstevel@tonic-gate #define	SHN_SUNW_IGNORE	0xff3f
4657c478bd9Sstevel@tonic-gate #define	SHN_HISUNW	0xff3f
4667c478bd9Sstevel@tonic-gate #define	SHN_HIOS	0xff3f
4677c478bd9Sstevel@tonic-gate #define	SHN_ABS		0xfff1
4687c478bd9Sstevel@tonic-gate #define	SHN_COMMON	0xfff2
4697c478bd9Sstevel@tonic-gate #define	SHN_XINDEX	0xffff		/* extended sect index */
4707c478bd9Sstevel@tonic-gate #define	SHN_HIRESERVE	0xffff
4717c478bd9Sstevel@tonic-gate 
4727c478bd9Sstevel@tonic-gate 
4737c478bd9Sstevel@tonic-gate 
4747c478bd9Sstevel@tonic-gate /*
4757c478bd9Sstevel@tonic-gate  *	Symbol table
4767c478bd9Sstevel@tonic-gate  */
4777c478bd9Sstevel@tonic-gate 
4787c478bd9Sstevel@tonic-gate typedef struct {
4797c478bd9Sstevel@tonic-gate 	Elf32_Word	st_name;
4807c478bd9Sstevel@tonic-gate 	Elf32_Addr	st_value;
4817c478bd9Sstevel@tonic-gate 	Elf32_Word	st_size;
4827c478bd9Sstevel@tonic-gate 	unsigned char	st_info;	/* bind, type: ELF_32_ST_... */
4837c478bd9Sstevel@tonic-gate 	unsigned char	st_other;
4847c478bd9Sstevel@tonic-gate 	Elf32_Half	st_shndx;	/* SHN_... */
4857c478bd9Sstevel@tonic-gate } Elf32_Sym;
4867c478bd9Sstevel@tonic-gate 
4877c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
4887c478bd9Sstevel@tonic-gate typedef struct {
4897c478bd9Sstevel@tonic-gate 	Elf64_Word	st_name;
4907c478bd9Sstevel@tonic-gate 	unsigned char	st_info;	/* bind, type: ELF_64_ST_... */
4917c478bd9Sstevel@tonic-gate 	unsigned char	st_other;
4927c478bd9Sstevel@tonic-gate 	Elf64_Half	st_shndx;	/* SHN_... */
4937c478bd9Sstevel@tonic-gate 	Elf64_Addr	st_value;
4947c478bd9Sstevel@tonic-gate 	Elf64_Xword	st_size;
4957c478bd9Sstevel@tonic-gate } Elf64_Sym;
4967c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
4977c478bd9Sstevel@tonic-gate 
4987c478bd9Sstevel@tonic-gate #define	STN_UNDEF	0
4997c478bd9Sstevel@tonic-gate 
5007c478bd9Sstevel@tonic-gate /*
5017c478bd9Sstevel@tonic-gate  *	The macros compose and decompose values for S.st_info
5027c478bd9Sstevel@tonic-gate  *
5037c478bd9Sstevel@tonic-gate  *	bind = ELF32_ST_BIND(S.st_info)
5047c478bd9Sstevel@tonic-gate  *	type = ELF32_ST_TYPE(S.st_info)
5057c478bd9Sstevel@tonic-gate  *	S.st_info = ELF32_ST_INFO(bind, type)
5067c478bd9Sstevel@tonic-gate  */
5077c478bd9Sstevel@tonic-gate 
5087c478bd9Sstevel@tonic-gate #define	ELF32_ST_BIND(info)		((info) >> 4)
5097c478bd9Sstevel@tonic-gate #define	ELF32_ST_TYPE(info)		((info) & 0xf)
5107c478bd9Sstevel@tonic-gate #define	ELF32_ST_INFO(bind, type)	(((bind)<<4)+((type)&0xf))
5117c478bd9Sstevel@tonic-gate 
5127c478bd9Sstevel@tonic-gate #define	ELF64_ST_BIND(info)		((info) >> 4)
5137c478bd9Sstevel@tonic-gate #define	ELF64_ST_TYPE(info)		((info) & 0xf)
5147c478bd9Sstevel@tonic-gate #define	ELF64_ST_INFO(bind, type)	(((bind)<<4)+((type)&0xf))
5157c478bd9Sstevel@tonic-gate 
5167c478bd9Sstevel@tonic-gate 
5177c478bd9Sstevel@tonic-gate #define	STB_LOCAL	0		/* BIND */
5187c478bd9Sstevel@tonic-gate #define	STB_GLOBAL	1
5197c478bd9Sstevel@tonic-gate #define	STB_WEAK	2
5207c478bd9Sstevel@tonic-gate #define	STB_NUM		3
5217c478bd9Sstevel@tonic-gate 
5227c478bd9Sstevel@tonic-gate #define	STB_LOPROC	13		/* processor specific range */
5237c478bd9Sstevel@tonic-gate #define	STB_HIPROC	15
5247c478bd9Sstevel@tonic-gate 
5257c478bd9Sstevel@tonic-gate #define	STT_NOTYPE	0		/* TYPE */
5267c478bd9Sstevel@tonic-gate #define	STT_OBJECT	1
5277c478bd9Sstevel@tonic-gate #define	STT_FUNC	2
5287c478bd9Sstevel@tonic-gate #define	STT_SECTION	3
5297c478bd9Sstevel@tonic-gate #define	STT_FILE	4
5307c478bd9Sstevel@tonic-gate #define	STT_COMMON	5
5317c478bd9Sstevel@tonic-gate #define	STT_TLS		6
5327c478bd9Sstevel@tonic-gate #define	STT_NUM		7
5337c478bd9Sstevel@tonic-gate 
5347c478bd9Sstevel@tonic-gate #define	STT_LOPROC	13		/* processor specific range */
5357c478bd9Sstevel@tonic-gate #define	STT_HIPROC	15
5367c478bd9Sstevel@tonic-gate 
5377c478bd9Sstevel@tonic-gate /*
5387c478bd9Sstevel@tonic-gate  *	The macros decompose values for S.st_other
5397c478bd9Sstevel@tonic-gate  *
5407c478bd9Sstevel@tonic-gate  *	visibility = ELF32_ST_VISIBILITY(S.st_other)
5417c478bd9Sstevel@tonic-gate  */
542*60758829Srie #define	ELF32_ST_VISIBILITY(other)	((other)&0x7)
543*60758829Srie #define	ELF64_ST_VISIBILITY(other)	((other)&0x7)
5447c478bd9Sstevel@tonic-gate 
5457c478bd9Sstevel@tonic-gate #define	STV_DEFAULT	0
5467c478bd9Sstevel@tonic-gate #define	STV_INTERNAL	1
5477c478bd9Sstevel@tonic-gate #define	STV_HIDDEN	2
5487c478bd9Sstevel@tonic-gate #define	STV_PROTECTED	3
549*60758829Srie #define	STV_EXPORTED	4
550*60758829Srie #define	STV_SINGLETON	5
551*60758829Srie #define	STV_ELIMINATE	6
5527c478bd9Sstevel@tonic-gate 
553*60758829Srie #define	STV_NUM		7
5547c478bd9Sstevel@tonic-gate 
5557c478bd9Sstevel@tonic-gate /*
5567c478bd9Sstevel@tonic-gate  *	Relocation
5577c478bd9Sstevel@tonic-gate  */
5587c478bd9Sstevel@tonic-gate 
5597c478bd9Sstevel@tonic-gate typedef struct {
5607c478bd9Sstevel@tonic-gate 	Elf32_Addr	r_offset;
5617c478bd9Sstevel@tonic-gate 	Elf32_Word	r_info;		/* sym, type: ELF32_R_... */
5627c478bd9Sstevel@tonic-gate } Elf32_Rel;
5637c478bd9Sstevel@tonic-gate 
5647c478bd9Sstevel@tonic-gate typedef struct {
5657c478bd9Sstevel@tonic-gate 	Elf32_Addr	r_offset;
5667c478bd9Sstevel@tonic-gate 	Elf32_Word	r_info;		/* sym, type: ELF32_R_... */
5677c478bd9Sstevel@tonic-gate 	Elf32_Sword	r_addend;
5687c478bd9Sstevel@tonic-gate } Elf32_Rela;
5697c478bd9Sstevel@tonic-gate 
5707c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
5717c478bd9Sstevel@tonic-gate typedef struct {
5727c478bd9Sstevel@tonic-gate 	Elf64_Addr	r_offset;
5737c478bd9Sstevel@tonic-gate 	Elf64_Xword	r_info;		/* sym, type: ELF64_R_... */
5747c478bd9Sstevel@tonic-gate } Elf64_Rel;
5757c478bd9Sstevel@tonic-gate 
5767c478bd9Sstevel@tonic-gate typedef struct {
5777c478bd9Sstevel@tonic-gate 	Elf64_Addr	r_offset;
5787c478bd9Sstevel@tonic-gate 	Elf64_Xword	r_info;		/* sym, type: ELF64_R_... */
5797c478bd9Sstevel@tonic-gate 	Elf64_Sxword	r_addend;
5807c478bd9Sstevel@tonic-gate } Elf64_Rela;
5817c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
5827c478bd9Sstevel@tonic-gate 
5837c478bd9Sstevel@tonic-gate 
5847c478bd9Sstevel@tonic-gate /*
5857c478bd9Sstevel@tonic-gate  *	The macros compose and decompose values for Rel.r_info, Rela.f_info
5867c478bd9Sstevel@tonic-gate  *
5877c478bd9Sstevel@tonic-gate  *	sym = ELF32_R_SYM(R.r_info)
5887c478bd9Sstevel@tonic-gate  *	type = ELF32_R_TYPE(R.r_info)
5897c478bd9Sstevel@tonic-gate  *	R.r_info = ELF32_R_INFO(sym, type)
5907c478bd9Sstevel@tonic-gate  */
5917c478bd9Sstevel@tonic-gate 
5927c478bd9Sstevel@tonic-gate #define	ELF32_R_SYM(info)	((info)>>8)
5937c478bd9Sstevel@tonic-gate #define	ELF32_R_TYPE(info)	((unsigned char)(info))
5947c478bd9Sstevel@tonic-gate #define	ELF32_R_INFO(sym, type)	(((sym)<<8)+(unsigned char)(type))
5957c478bd9Sstevel@tonic-gate 
5967c478bd9Sstevel@tonic-gate #define	ELF64_R_SYM(info)	((info)>>32)
5977c478bd9Sstevel@tonic-gate #define	ELF64_R_TYPE(info)    	((Elf64_Word)(info))
5987c478bd9Sstevel@tonic-gate #define	ELF64_R_INFO(sym, type)	(((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(type))
5997c478bd9Sstevel@tonic-gate 
6007c478bd9Sstevel@tonic-gate 
6017c478bd9Sstevel@tonic-gate /*
6027c478bd9Sstevel@tonic-gate  * The r_info field is composed of two 32-bit components: the symbol
6037c478bd9Sstevel@tonic-gate  * table index and the relocation type.  The relocation type for SPARC V9
6047c478bd9Sstevel@tonic-gate  * is further decomposed into an 8-bit type identifier and a 24-bit type
6057c478bd9Sstevel@tonic-gate  * dependent data field.  For the existing Elf32 relocation types,
6067c478bd9Sstevel@tonic-gate  * that data field is zero.
6077c478bd9Sstevel@tonic-gate  */
6087c478bd9Sstevel@tonic-gate #define	ELF64_R_TYPE_DATA(info)	(((Elf64_Xword)(info)<<32)>>40)
6097c478bd9Sstevel@tonic-gate #define	ELF64_R_TYPE_ID(info)	(((Elf64_Xword)(info)<<56)>>56)
6107c478bd9Sstevel@tonic-gate #define	ELF64_R_TYPE_INFO(data, type)	\
6117c478bd9Sstevel@tonic-gate 		(((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type))
6127c478bd9Sstevel@tonic-gate 
6137c478bd9Sstevel@tonic-gate 
6147c478bd9Sstevel@tonic-gate /*
6157c478bd9Sstevel@tonic-gate  * Section Group Flags (SHT_GROUP)
6167c478bd9Sstevel@tonic-gate  */
6177c478bd9Sstevel@tonic-gate #define	GRP_COMDAT	0x01
6187c478bd9Sstevel@tonic-gate 
6197c478bd9Sstevel@tonic-gate 
6207c478bd9Sstevel@tonic-gate /*
6217c478bd9Sstevel@tonic-gate  *	Note entry header
6227c478bd9Sstevel@tonic-gate  */
6237c478bd9Sstevel@tonic-gate 
6247c478bd9Sstevel@tonic-gate typedef struct {
6257c478bd9Sstevel@tonic-gate 	Elf32_Word	n_namesz;	/* length of note's name */
6267c478bd9Sstevel@tonic-gate 	Elf32_Word	n_descsz;	/* length of note's "desc" */
6277c478bd9Sstevel@tonic-gate 	Elf32_Word	n_type;		/* type of note */
6287c478bd9Sstevel@tonic-gate } Elf32_Nhdr;
6297c478bd9Sstevel@tonic-gate 
6307c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
6317c478bd9Sstevel@tonic-gate typedef struct {
6327c478bd9Sstevel@tonic-gate 	Elf64_Word	n_namesz;	/* length of note's name */
6337c478bd9Sstevel@tonic-gate 	Elf64_Word	n_descsz;	/* length of note's "desc" */
6347c478bd9Sstevel@tonic-gate 	Elf64_Word	n_type;		/* type of note */
6357c478bd9Sstevel@tonic-gate } Elf64_Nhdr;
6367c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
6377c478bd9Sstevel@tonic-gate 
6387c478bd9Sstevel@tonic-gate /*
6397c478bd9Sstevel@tonic-gate  *	Move entry
6407c478bd9Sstevel@tonic-gate  */
6417c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
6427c478bd9Sstevel@tonic-gate typedef struct {
6437c478bd9Sstevel@tonic-gate 	Elf32_Lword	m_value;	/* symbol value */
6447c478bd9Sstevel@tonic-gate 	Elf32_Word 	m_info;		/* size + index */
6457c478bd9Sstevel@tonic-gate 	Elf32_Word	m_poffset;	/* symbol offset */
6467c478bd9Sstevel@tonic-gate 	Elf32_Half	m_repeat;	/* repeat count */
6477c478bd9Sstevel@tonic-gate 	Elf32_Half	m_stride;	/* stride info */
6487c478bd9Sstevel@tonic-gate } Elf32_Move;
6497c478bd9Sstevel@tonic-gate 
6507c478bd9Sstevel@tonic-gate /*
6517c478bd9Sstevel@tonic-gate  *	The macros compose and decompose values for Move.r_info
6527c478bd9Sstevel@tonic-gate  *
6537c478bd9Sstevel@tonic-gate  *	sym = ELF32_M_SYM(M.m_info)
6547c478bd9Sstevel@tonic-gate  *	size = ELF32_M_SIZE(M.m_info)
6557c478bd9Sstevel@tonic-gate  *	M.m_info = ELF32_M_INFO(sym, size)
6567c478bd9Sstevel@tonic-gate  */
6577c478bd9Sstevel@tonic-gate #define	ELF32_M_SYM(info)	((info)>>8)
6587c478bd9Sstevel@tonic-gate #define	ELF32_M_SIZE(info)	((unsigned char)(info))
6597c478bd9Sstevel@tonic-gate #define	ELF32_M_INFO(sym, size)	(((sym)<<8)+(unsigned char)(size))
6607c478bd9Sstevel@tonic-gate 
6617c478bd9Sstevel@tonic-gate typedef struct {
6627c478bd9Sstevel@tonic-gate 	Elf64_Lword	m_value;	/* symbol value */
6637c478bd9Sstevel@tonic-gate 	Elf64_Xword 	m_info;		/* size + index */
6647c478bd9Sstevel@tonic-gate 	Elf64_Xword	m_poffset;	/* symbol offset */
6657c478bd9Sstevel@tonic-gate 	Elf64_Half	m_repeat;	/* repeat count */
6667c478bd9Sstevel@tonic-gate 	Elf64_Half	m_stride;	/* stride info */
6677c478bd9Sstevel@tonic-gate } Elf64_Move;
6687c478bd9Sstevel@tonic-gate #define	ELF64_M_SYM(info)	((info)>>8)
6697c478bd9Sstevel@tonic-gate #define	ELF64_M_SIZE(info)	((unsigned char)(info))
6707c478bd9Sstevel@tonic-gate #define	ELF64_M_INFO(sym, size)	(((sym)<<8)+(unsigned char)(size))
6717c478bd9Sstevel@tonic-gate 
6727c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
6737c478bd9Sstevel@tonic-gate 
6747c478bd9Sstevel@tonic-gate 
6757c478bd9Sstevel@tonic-gate /*
6767c478bd9Sstevel@tonic-gate  *	Hardware/Software capabilities entry
6777c478bd9Sstevel@tonic-gate  */
6787c478bd9Sstevel@tonic-gate #ifndef	_ASM
6797c478bd9Sstevel@tonic-gate typedef struct {
6807c478bd9Sstevel@tonic-gate 	Elf32_Word	c_tag;		/* how to interpret value */
6817c478bd9Sstevel@tonic-gate 	union {
6827c478bd9Sstevel@tonic-gate 		Elf32_Word	c_val;
6837c478bd9Sstevel@tonic-gate 		Elf32_Addr	c_ptr;
6847c478bd9Sstevel@tonic-gate 	} c_un;
6857c478bd9Sstevel@tonic-gate } Elf32_Cap;
6867c478bd9Sstevel@tonic-gate 
6877c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
6887c478bd9Sstevel@tonic-gate typedef struct {
6897c478bd9Sstevel@tonic-gate 	Elf64_Xword	c_tag;		/* how to interpret value */
6907c478bd9Sstevel@tonic-gate 	union {
6917c478bd9Sstevel@tonic-gate 		Elf64_Xword	c_val;
6927c478bd9Sstevel@tonic-gate 		Elf64_Addr	c_ptr;
6937c478bd9Sstevel@tonic-gate 	} c_un;
6947c478bd9Sstevel@tonic-gate } Elf64_Cap;
6957c478bd9Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
6967c478bd9Sstevel@tonic-gate #endif
6977c478bd9Sstevel@tonic-gate 
6987c478bd9Sstevel@tonic-gate #define	CA_SUNW_NULL	0
6997c478bd9Sstevel@tonic-gate #define	CA_SUNW_HW_1	1		/* first hardware capabilities entry */
7007c478bd9Sstevel@tonic-gate #define	CA_SUNW_SF_1	2		/* first software capabilities entry */
7017c478bd9Sstevel@tonic-gate 
7027c478bd9Sstevel@tonic-gate /*
7037c478bd9Sstevel@tonic-gate  * Define software capabilities (CA_SUNW_SF_1 values).  Note, hardware
7047c478bd9Sstevel@tonic-gate  * capabilities (CA_SUNW_HW_1 values) are taken directly from sys/auxv_$MACH.h.
7057c478bd9Sstevel@tonic-gate  */
7067c478bd9Sstevel@tonic-gate #define	SF1_SUNW_FPKNWN	0x001		/* use/non-use of frame pointer is */
7077c478bd9Sstevel@tonic-gate #define	SF1_SUNW_FPUSED	0x002		/*	known, and frame pointer is */
7087c478bd9Sstevel@tonic-gate 					/*	in use */
7097c478bd9Sstevel@tonic-gate #define	SF1_SUNW_MASK	0x003		/* known software capabilities mask */
7107c478bd9Sstevel@tonic-gate 
7117c478bd9Sstevel@tonic-gate 
7127c478bd9Sstevel@tonic-gate /*
7137c478bd9Sstevel@tonic-gate  *	Known values for note entry types (e_type == ET_CORE)
7147c478bd9Sstevel@tonic-gate  */
7157c478bd9Sstevel@tonic-gate 
7167c478bd9Sstevel@tonic-gate #define	NT_PRSTATUS	1	/* prstatus_t	<sys/old_procfs.h>	*/
7177c478bd9Sstevel@tonic-gate #define	NT_PRFPREG	2	/* prfpregset_t	<sys/old_procfs.h>	*/
7187c478bd9Sstevel@tonic-gate #define	NT_PRPSINFO	3	/* prpsinfo_t	<sys/old_procfs.h>	*/
7197c478bd9Sstevel@tonic-gate #define	NT_PRXREG	4	/* prxregset_t	<sys/procfs.h>		*/
7207c478bd9Sstevel@tonic-gate #define	NT_PLATFORM	5	/* string from sysinfo(SI_PLATFORM)	*/
7217c478bd9Sstevel@tonic-gate #define	NT_AUXV		6	/* auxv_t array	<sys/auxv.h>		*/
7227c478bd9Sstevel@tonic-gate #define	NT_GWINDOWS	7	/* gwindows_t	SPARC only		*/
7237c478bd9Sstevel@tonic-gate #define	NT_ASRS		8	/* asrset_t	SPARC V9 only		*/
7247c478bd9Sstevel@tonic-gate #define	NT_LDT		9	/* ssd array	<sys/sysi86.h> IA32 only */
7257c478bd9Sstevel@tonic-gate #define	NT_PSTATUS	10	/* pstatus_t	<sys/procfs.h>		*/
7267c478bd9Sstevel@tonic-gate #define	NT_PSINFO	13	/* psinfo_t	<sys/procfs.h>		*/
7277c478bd9Sstevel@tonic-gate #define	NT_PRCRED	14	/* prcred_t	<sys/procfs.h>		*/
7287c478bd9Sstevel@tonic-gate #define	NT_UTSNAME	15	/* struct utsname <sys/utsname.h>	*/
7297c478bd9Sstevel@tonic-gate #define	NT_LWPSTATUS	16	/* lwpstatus_t	<sys/procfs.h>		*/
7307c478bd9Sstevel@tonic-gate #define	NT_LWPSINFO	17	/* lwpsinfo_t	<sys/procfs.h>		*/
7317c478bd9Sstevel@tonic-gate #define	NT_PRPRIV	18	/* prpriv_t	<sys/procfs.h>		*/
7327c478bd9Sstevel@tonic-gate #define	NT_PRPRIVINFO	19	/* priv_impl_info_t <sys/priv.h>	*/
7337c478bd9Sstevel@tonic-gate #define	NT_CONTENT	20	/* core_content_t <sys/corectl.h>	*/
7347c478bd9Sstevel@tonic-gate #define	NT_ZONENAME	21	/* string from getzonenamebyid(3C)	*/
7357c478bd9Sstevel@tonic-gate 
7367c478bd9Sstevel@tonic-gate #ifdef _KERNEL
7377c478bd9Sstevel@tonic-gate /*
7387c478bd9Sstevel@tonic-gate  * The following routine checks the processor-specific
7397c478bd9Sstevel@tonic-gate  * fields of an ELF header.
7407c478bd9Sstevel@tonic-gate  */
7417c478bd9Sstevel@tonic-gate int	elfheadcheck(unsigned char, Elf32_Half, Elf32_Word);
7427c478bd9Sstevel@tonic-gate #endif
7437c478bd9Sstevel@tonic-gate 
7447c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
7457c478bd9Sstevel@tonic-gate }
7467c478bd9Sstevel@tonic-gate #endif
7477c478bd9Sstevel@tonic-gate 
7487c478bd9Sstevel@tonic-gate #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_SPARC)
7497c478bd9Sstevel@tonic-gate #include <sys/elf_SPARC.h>
7507c478bd9Sstevel@tonic-gate #endif
7517c478bd9Sstevel@tonic-gate 
7527c478bd9Sstevel@tonic-gate #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_386)
7537c478bd9Sstevel@tonic-gate #include <sys/elf_386.h>
7547c478bd9Sstevel@tonic-gate #endif
7557c478bd9Sstevel@tonic-gate 
7567c478bd9Sstevel@tonic-gate #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_AMD64)
7577c478bd9Sstevel@tonic-gate #include <sys/elf_amd64.h>
7587c478bd9Sstevel@tonic-gate #endif
7597c478bd9Sstevel@tonic-gate 
7607c478bd9Sstevel@tonic-gate #endif	/* _SYS_ELF_H */
761