xref: /onnv-gate/usr/src/uts/common/sys/elf.h (revision 11827:d7ef53deac3f)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51976Sab196087  * Common Development and Distribution License (the "License").
61976Sab196087  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
2211734SAli.Bahrami@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
270Sstevel@tonic-gate /*	  All Rights Reserved  	*/
280Sstevel@tonic-gate 
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifndef _SYS_ELF_H
310Sstevel@tonic-gate #define	_SYS_ELF_H
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #include <sys/elftypes.h>
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef	__cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #define	ELF32_FSZ_ADDR	4
400Sstevel@tonic-gate #define	ELF32_FSZ_HALF	2
410Sstevel@tonic-gate #define	ELF32_FSZ_OFF	4
420Sstevel@tonic-gate #define	ELF32_FSZ_SWORD	4
430Sstevel@tonic-gate #define	ELF32_FSZ_WORD	4
440Sstevel@tonic-gate 
450Sstevel@tonic-gate #define	ELF64_FSZ_ADDR	8
460Sstevel@tonic-gate #define	ELF64_FSZ_HALF	2
470Sstevel@tonic-gate #define	ELF64_FSZ_OFF	8
480Sstevel@tonic-gate #define	ELF64_FSZ_SWORD	4
490Sstevel@tonic-gate #define	ELF64_FSZ_WORD	4
500Sstevel@tonic-gate #define	ELF64_FSZ_SXWORD 8
510Sstevel@tonic-gate #define	ELF64_FSZ_XWORD	8
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /*
540Sstevel@tonic-gate  *	"Enumerations" below use ...NUM as the number of
550Sstevel@tonic-gate  *	values in the list.  It should be 1 greater than the
560Sstevel@tonic-gate  *	highest "real" value.
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate 
590Sstevel@tonic-gate /*
600Sstevel@tonic-gate  *	ELF header
610Sstevel@tonic-gate  */
620Sstevel@tonic-gate 
630Sstevel@tonic-gate #define	EI_NIDENT	16
640Sstevel@tonic-gate 
650Sstevel@tonic-gate typedef struct {
660Sstevel@tonic-gate 	unsigned char	e_ident[EI_NIDENT];	/* ident bytes */
670Sstevel@tonic-gate 	Elf32_Half	e_type;			/* file type */
680Sstevel@tonic-gate 	Elf32_Half	e_machine;		/* target machine */
690Sstevel@tonic-gate 	Elf32_Word	e_version;		/* file version */
700Sstevel@tonic-gate 	Elf32_Addr	e_entry;		/* start address */
710Sstevel@tonic-gate 	Elf32_Off	e_phoff;		/* phdr file offset */
720Sstevel@tonic-gate 	Elf32_Off	e_shoff;		/* shdr file offset */
730Sstevel@tonic-gate 	Elf32_Word	e_flags;		/* file flags */
740Sstevel@tonic-gate 	Elf32_Half	e_ehsize;		/* sizeof ehdr */
750Sstevel@tonic-gate 	Elf32_Half	e_phentsize;		/* sizeof phdr */
760Sstevel@tonic-gate 	Elf32_Half	e_phnum;		/* number phdrs */
770Sstevel@tonic-gate 	Elf32_Half	e_shentsize;		/* sizeof shdr */
780Sstevel@tonic-gate 	Elf32_Half	e_shnum;		/* number shdrs */
790Sstevel@tonic-gate 	Elf32_Half	e_shstrndx;		/* shdr string index */
800Sstevel@tonic-gate } Elf32_Ehdr;
810Sstevel@tonic-gate 
820Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
830Sstevel@tonic-gate typedef struct {
840Sstevel@tonic-gate 	unsigned char	e_ident[EI_NIDENT];	/* ident bytes */
850Sstevel@tonic-gate 	Elf64_Half	e_type;			/* file type */
860Sstevel@tonic-gate 	Elf64_Half	e_machine;		/* target machine */
870Sstevel@tonic-gate 	Elf64_Word	e_version;		/* file version */
880Sstevel@tonic-gate 	Elf64_Addr	e_entry;		/* start address */
890Sstevel@tonic-gate 	Elf64_Off	e_phoff;		/* phdr file offset */
900Sstevel@tonic-gate 	Elf64_Off	e_shoff;		/* shdr file offset */
910Sstevel@tonic-gate 	Elf64_Word	e_flags;		/* file flags */
920Sstevel@tonic-gate 	Elf64_Half	e_ehsize;		/* sizeof ehdr */
930Sstevel@tonic-gate 	Elf64_Half	e_phentsize;		/* sizeof phdr */
940Sstevel@tonic-gate 	Elf64_Half	e_phnum;		/* number phdrs */
950Sstevel@tonic-gate 	Elf64_Half	e_shentsize;		/* sizeof shdr */
960Sstevel@tonic-gate 	Elf64_Half	e_shnum;		/* number shdrs */
970Sstevel@tonic-gate 	Elf64_Half	e_shstrndx;		/* shdr string index */
980Sstevel@tonic-gate } Elf64_Ehdr;
990Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate #define	EI_MAG0		0	/* e_ident[] indexes */
1030Sstevel@tonic-gate #define	EI_MAG1		1
1040Sstevel@tonic-gate #define	EI_MAG2		2
1050Sstevel@tonic-gate #define	EI_MAG3		3
1060Sstevel@tonic-gate #define	EI_CLASS	4	/* File class */
1070Sstevel@tonic-gate #define	EI_DATA		5	/* Data encoding */
1080Sstevel@tonic-gate #define	EI_VERSION	6	/* File version */
1090Sstevel@tonic-gate #define	EI_OSABI	7	/* Operating system/ABI identification */
1100Sstevel@tonic-gate #define	EI_ABIVERSION	8	/* ABI version */
1110Sstevel@tonic-gate #define	EI_PAD		9	/* Start of padding bytes */
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate #define	ELFMAG0		0x7f		/* EI_MAG */
1140Sstevel@tonic-gate #define	ELFMAG1		'E'
1150Sstevel@tonic-gate #define	ELFMAG2		'L'
1160Sstevel@tonic-gate #define	ELFMAG3		'F'
1170Sstevel@tonic-gate #define	ELFMAG		"\177ELF"
1180Sstevel@tonic-gate #define	SELFMAG		4
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate #define	ELFCLASSNONE	0		/* EI_CLASS */
1210Sstevel@tonic-gate #define	ELFCLASS32	1
1220Sstevel@tonic-gate #define	ELFCLASS64	2
1230Sstevel@tonic-gate #define	ELFCLASSNUM	3
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate #define	ELFDATANONE	0		/* EI_DATA */
1260Sstevel@tonic-gate #define	ELFDATA2LSB	1
1270Sstevel@tonic-gate #define	ELFDATA2MSB	2
1280Sstevel@tonic-gate #define	ELFDATANUM	3
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate #define	ET_NONE		0		/* e_type */
1310Sstevel@tonic-gate #define	ET_REL		1
1320Sstevel@tonic-gate #define	ET_EXEC		2
1330Sstevel@tonic-gate #define	ET_DYN		3
1340Sstevel@tonic-gate #define	ET_CORE		4
1350Sstevel@tonic-gate #define	ET_NUM		5
1360Sstevel@tonic-gate #define	ET_LOOS		0xfe00		/* OS specific range */
1370Sstevel@tonic-gate #define	ET_LOSUNW	0xfeff
1380Sstevel@tonic-gate #define	ET_SUNWPSEUDO	0xfeff
1390Sstevel@tonic-gate #define	ET_HISUNW	0xfeff
1400Sstevel@tonic-gate #define	ET_HIOS		0xfeff
1410Sstevel@tonic-gate #define	ET_LOPROC	0xff00		/* processor specific range */
1420Sstevel@tonic-gate #define	ET_HIPROC	0xffff
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate #define	ET_LOPROC	0xff00		/* processor specific range */
1450Sstevel@tonic-gate #define	ET_HIPROC	0xffff
1460Sstevel@tonic-gate 
1470Sstevel@tonic-gate #define	EM_NONE		0		/* e_machine */
1480Sstevel@tonic-gate #define	EM_M32		1		/* AT&T WE 32100 */
1490Sstevel@tonic-gate #define	EM_SPARC	2		/* Sun SPARC */
1500Sstevel@tonic-gate #define	EM_386		3		/* Intel 80386 */
1510Sstevel@tonic-gate #define	EM_68K		4		/* Motorola 68000 */
1520Sstevel@tonic-gate #define	EM_88K		5		/* Motorola 88000 */
1530Sstevel@tonic-gate #define	EM_486		6		/* Intel 80486 */
1540Sstevel@tonic-gate #define	EM_860		7		/* Intel i860 */
1550Sstevel@tonic-gate #define	EM_MIPS		8		/* MIPS RS3000 Big-Endian */
1560Sstevel@tonic-gate #define	EM_S370		9		/* IBM System/370 Processor */
1570Sstevel@tonic-gate #define	EM_MIPS_RS3_LE	10		/* MIPS RS3000 Little-Endian */
1580Sstevel@tonic-gate #define	EM_RS6000	11		/* RS6000 */
1590Sstevel@tonic-gate #define	EM_UNKNOWN12	12
1600Sstevel@tonic-gate #define	EM_UNKNOWN13	13
1610Sstevel@tonic-gate #define	EM_UNKNOWN14	14
1620Sstevel@tonic-gate #define	EM_PA_RISC	15		/* PA-RISC */
1632802Sab196087 #define	EM_PARISC	EM_PA_RISC	/* Alias: GNU compatibility */
1640Sstevel@tonic-gate #define	EM_nCUBE	16		/* nCUBE */
1650Sstevel@tonic-gate #define	EM_VPP500	17		/* Fujitsu VPP500 */
1660Sstevel@tonic-gate #define	EM_SPARC32PLUS	18		/* Sun SPARC 32+ */
1670Sstevel@tonic-gate #define	EM_960		19		/* Intel 80960 */
1680Sstevel@tonic-gate #define	EM_PPC		20		/* PowerPC */
1690Sstevel@tonic-gate #define	EM_PPC64	21		/* 64-bit PowerPC */
1702802Sab196087 #define	EM_S390		22		/* IBM System/390 Processor */
1712802Sab196087 #define	EM_UNKNOWN22	EM_S390		/* Alias: Older published name */
1720Sstevel@tonic-gate #define	EM_UNKNOWN23	23
1730Sstevel@tonic-gate #define	EM_UNKNOWN24	24
1740Sstevel@tonic-gate #define	EM_UNKNOWN25	25
1750Sstevel@tonic-gate #define	EM_UNKNOWN26	26
1760Sstevel@tonic-gate #define	EM_UNKNOWN27	27
1770Sstevel@tonic-gate #define	EM_UNKNOWN28	28
1780Sstevel@tonic-gate #define	EM_UNKNOWN29	29
1790Sstevel@tonic-gate #define	EM_UNKNOWN30	30
1800Sstevel@tonic-gate #define	EM_UNKNOWN31	31
1810Sstevel@tonic-gate #define	EM_UNKNOWN32	32
1820Sstevel@tonic-gate #define	EM_UNKNOWN33	33
1830Sstevel@tonic-gate #define	EM_UNKNOWN34	34
1840Sstevel@tonic-gate #define	EM_UNKNOWN35	35
1850Sstevel@tonic-gate #define	EM_V800		36		/* NEX V800 */
1860Sstevel@tonic-gate #define	EM_FR20		37		/* Fujitsu FR20 */
1870Sstevel@tonic-gate #define	EM_RH32		38		/* TRW RH-32 */
1880Sstevel@tonic-gate #define	EM_RCE		39		/* Motorola RCE */
1890Sstevel@tonic-gate #define	EM_ARM		40		/* Advanced RISC Marchines ARM */
1900Sstevel@tonic-gate #define	EM_ALPHA	41		/* Digital Alpha */
1910Sstevel@tonic-gate #define	EM_SH		42		/* Hitachi SH */
1920Sstevel@tonic-gate #define	EM_SPARCV9	43		/* Sun SPARC V9 (64-bit) */
1930Sstevel@tonic-gate #define	EM_TRICORE	44		/* Siemens Tricore embedded processor */
1940Sstevel@tonic-gate #define	EM_ARC		45		/* Argonaut RISC Core, */
1950Sstevel@tonic-gate 					/*	Argonaut Technologies Inc. */
1960Sstevel@tonic-gate #define	EM_H8_300	46		/* Hitachi H8/300 */
1970Sstevel@tonic-gate #define	EM_H8_300H	47		/* Hitachi H8/300H */
1980Sstevel@tonic-gate #define	EM_H8S		48		/* Hitachi H8S */
1990Sstevel@tonic-gate #define	EM_H8_500	49		/* Hitachi H8/500 */
2000Sstevel@tonic-gate #define	EM_IA_64	50		/* Intel IA64 */
2010Sstevel@tonic-gate #define	EM_MIPS_X	51		/* Stanford MIPS-X */
2020Sstevel@tonic-gate #define	EM_COLDFIRE	52		/* Motorola ColdFire */
2030Sstevel@tonic-gate #define	EM_68HC12	53		/* Motorola M68HC12 */
2040Sstevel@tonic-gate #define	EM_MMA		54		/* Fujitsu MMA Mulimedia Accelerator */
2050Sstevel@tonic-gate #define	EM_PCP		55		/* Siemens PCP */
2060Sstevel@tonic-gate #define	EM_NCPU		56		/* Sony nCPU embedded RISC processor */
2070Sstevel@tonic-gate #define	EM_NDR1		57		/* Denso NDR1 microprocessor */
2080Sstevel@tonic-gate #define	EM_STARCORE	58		/* Motorola Star*Core processor */
2090Sstevel@tonic-gate #define	EM_ME16		59		/* Toyota ME16 processor */
2100Sstevel@tonic-gate #define	EM_ST100	60		/* STMicroelectronics ST100 processor */
2110Sstevel@tonic-gate #define	EM_TINYJ	61		/* Advanced Logic Corp. TinyJ */
2120Sstevel@tonic-gate 					/*	embedded processor family */
2130Sstevel@tonic-gate #define	EM_AMD64	62		/* AMDs x86-64 architecture */
2140Sstevel@tonic-gate #define	EM_X86_64	EM_AMD64	/* (compatibility) */
2150Sstevel@tonic-gate 
2160Sstevel@tonic-gate #define	EM_PDSP		63		/* Sony DSP Processor */
2170Sstevel@tonic-gate #define	EM_UNKNOWN64	64
2180Sstevel@tonic-gate #define	EM_UNKNOWN65	65
2190Sstevel@tonic-gate #define	EM_FX66		66		/* Siemens FX66 microcontroller */
2200Sstevel@tonic-gate #define	EM_ST9PLUS	67		/* STMicroelectronics ST9+8/16 bit */
2210Sstevel@tonic-gate 					/*	microcontroller */
2220Sstevel@tonic-gate #define	EM_ST7		68		/* STMicroelectronics ST7 8-bit */
2230Sstevel@tonic-gate 					/*	microcontroller */
2240Sstevel@tonic-gate #define	EM_68HC16	69		/* Motorola MC68HC16 Microcontroller */
2250Sstevel@tonic-gate #define	EM_68HC11	70		/* Motorola MC68HC11 Microcontroller */
2260Sstevel@tonic-gate #define	EM_68HC08	71		/* Motorola MC68HC08 Microcontroller */
2270Sstevel@tonic-gate #define	EM_68HC05	72		/* Motorola MC68HC05 Microcontroller */
2280Sstevel@tonic-gate #define	EM_SVX		73		/* Silicon Graphics SVx */
2290Sstevel@tonic-gate #define	EM_ST19		74		/* STMicroelectronics ST19 8-bit */
2300Sstevel@tonic-gate 					/*	microcontroller */
2310Sstevel@tonic-gate #define	EM_VAX		75		/* Digital VAX */
2320Sstevel@tonic-gate #define	EM_CRIS		76		/* Axis Communications 32-bit */
2330Sstevel@tonic-gate 					/*	embedded processor */
2340Sstevel@tonic-gate #define	EM_JAVELIN	77		/* Infineon Technologies 32-bit */
2350Sstevel@tonic-gate 					/*	embedded processor */
2360Sstevel@tonic-gate #define	EM_FIREPATH	78		/* Element 14 64-bit DSP Processor */
2370Sstevel@tonic-gate #define	EM_ZSP		79		/* LSI Logic 16-bit DSP Processor */
2380Sstevel@tonic-gate #define	EM_MMIX		80		/* Donald Knuth's educational */
2390Sstevel@tonic-gate 					/*	64-bit processor */
2400Sstevel@tonic-gate #define	EM_HUANY	81		/* Harvard University */
2410Sstevel@tonic-gate 					/*	machine-independent */
2420Sstevel@tonic-gate 					/*	object files */
2430Sstevel@tonic-gate #define	EM_PRISM	82		/* SiTera Prism */
2440Sstevel@tonic-gate #define	EM_AVR		83		/* Atmel AVR 8-bit microcontroller */
2450Sstevel@tonic-gate #define	EM_FR30		84		/* Fujitsu FR30 */
2460Sstevel@tonic-gate #define	EM_D10V		85		/* Mitsubishi D10V */
2470Sstevel@tonic-gate #define	EM_D30V		86		/* Mitsubishi D30V */
2480Sstevel@tonic-gate #define	EM_V850		87		/* NEC v850 */
2490Sstevel@tonic-gate #define	EM_M32R		88		/* Mitsubishi M32R */
2500Sstevel@tonic-gate #define	EM_MN10300	89		/* Matsushita MN10300 */
2510Sstevel@tonic-gate #define	EM_MN10200	90		/* Matsushita MN10200 */
2520Sstevel@tonic-gate #define	EM_PJ		91		/* picoJava */
2530Sstevel@tonic-gate #define	EM_OPENRISC	92		/* OpenRISC 32-bit embedded processor */
2540Sstevel@tonic-gate #define	EM_ARC_A5	93		/* ARC Cores Tangent-A5 */
2550Sstevel@tonic-gate #define	EM_XTENSA	94		/* Tensilica Xtensa architecture */
2560Sstevel@tonic-gate #define	EM_NUM		95
2570Sstevel@tonic-gate 
2580Sstevel@tonic-gate #define	EV_NONE		0		/* e_version, EI_VERSION */
2590Sstevel@tonic-gate #define	EV_CURRENT	1
2600Sstevel@tonic-gate #define	EV_NUM		2
2610Sstevel@tonic-gate 
2620Sstevel@tonic-gate 
2630Sstevel@tonic-gate #define	ELFOSABI_NONE		0	/* No extensions or unspecified */
2642802Sab196087 #define	ELFOSABI_SYSV		ELFOSABI_NONE
2650Sstevel@tonic-gate #define	ELFOSABI_HPUX		1	/* Hewlett-Packard HP-UX */
2660Sstevel@tonic-gate #define	ELFOSABI_NETBSD		2	/* NetBSD */
2670Sstevel@tonic-gate #define	ELFOSABI_LINUX		3	/* Linux */
2680Sstevel@tonic-gate #define	ELFOSABI_UNKNOWN4	4
2690Sstevel@tonic-gate #define	ELFOSABI_UNKNOWN5	5
2700Sstevel@tonic-gate #define	ELFOSABI_SOLARIS	6	/* Sun Solaris */
2710Sstevel@tonic-gate #define	ELFOSABI_AIX		7	/* AIX */
2720Sstevel@tonic-gate #define	ELFOSABI_IRIX		8	/* IRIX */
2730Sstevel@tonic-gate #define	ELFOSABI_FREEBSD	9	/* FreeBSD */
2740Sstevel@tonic-gate #define	ELFOSABI_TRU64		10	/* Compaq TRU64 UNIX */
2750Sstevel@tonic-gate #define	ELFOSABI_MODESTO	11	/* Novell Modesto */
2760Sstevel@tonic-gate #define	ELFOSABI_OPENBSD	12	/* Open BSD */
2772802Sab196087 #define	ELFOSABI_OPENVMS	13	/* Open VMS */
2782802Sab196087 #define	ELFOSABI_NSK		14	/* Hewlett-Packard Non-Stop Kernel */
2792802Sab196087 #define	ELFOSABI_AROS		15	/* Amiga Research OS */
2802802Sab196087 #define	ELFOSABI_ARM		97	/* ARM */
2812802Sab196087 #define	ELFOSABI_STANDALONE	255	/* standalone (embedded) application */
2820Sstevel@tonic-gate 
2839273SAli.Bahrami@Sun.COM #define	EAV_SUNW_NONE		0	/* EI_ABIVERSION */
2849273SAli.Bahrami@Sun.COM #define	EAV_SUNW_CURRENT	1
2859273SAli.Bahrami@Sun.COM #define	EAV_SUNW_NUM		2
2869273SAli.Bahrami@Sun.COM 
2879273SAli.Bahrami@Sun.COM 
2880Sstevel@tonic-gate /*
2890Sstevel@tonic-gate  *	Program header
2900Sstevel@tonic-gate  */
2910Sstevel@tonic-gate 
2920Sstevel@tonic-gate typedef struct {
2930Sstevel@tonic-gate 	Elf32_Word	p_type;		/* entry type */
2940Sstevel@tonic-gate 	Elf32_Off	p_offset;	/* file offset */
2950Sstevel@tonic-gate 	Elf32_Addr	p_vaddr;	/* virtual address */
2960Sstevel@tonic-gate 	Elf32_Addr	p_paddr;	/* physical address */
2970Sstevel@tonic-gate 	Elf32_Word	p_filesz;	/* file size */
2980Sstevel@tonic-gate 	Elf32_Word	p_memsz;	/* memory size */
2990Sstevel@tonic-gate 	Elf32_Word	p_flags;	/* entry flags */
3000Sstevel@tonic-gate 	Elf32_Word	p_align;	/* memory/file alignment */
3010Sstevel@tonic-gate } Elf32_Phdr;
3020Sstevel@tonic-gate 
3030Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
3040Sstevel@tonic-gate typedef struct {
3050Sstevel@tonic-gate 	Elf64_Word	p_type;		/* entry type */
3060Sstevel@tonic-gate 	Elf64_Word	p_flags;	/* entry flags */
3070Sstevel@tonic-gate 	Elf64_Off	p_offset;	/* file offset */
3080Sstevel@tonic-gate 	Elf64_Addr	p_vaddr;	/* virtual address */
3090Sstevel@tonic-gate 	Elf64_Addr	p_paddr;	/* physical address */
3100Sstevel@tonic-gate 	Elf64_Xword	p_filesz;	/* file size */
3110Sstevel@tonic-gate 	Elf64_Xword	p_memsz;	/* memory size */
3120Sstevel@tonic-gate 	Elf64_Xword	p_align;	/* memory/file alignment */
3130Sstevel@tonic-gate } Elf64_Phdr;
3140Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
3150Sstevel@tonic-gate 
3160Sstevel@tonic-gate 
3170Sstevel@tonic-gate #define	PT_NULL		0		/* p_type */
3180Sstevel@tonic-gate #define	PT_LOAD		1
3190Sstevel@tonic-gate #define	PT_DYNAMIC	2
3200Sstevel@tonic-gate #define	PT_INTERP	3
3210Sstevel@tonic-gate #define	PT_NOTE		4
3220Sstevel@tonic-gate #define	PT_SHLIB	5
3230Sstevel@tonic-gate #define	PT_PHDR		6
3240Sstevel@tonic-gate #define	PT_TLS		7
3250Sstevel@tonic-gate #define	PT_NUM		8
3260Sstevel@tonic-gate 
3270Sstevel@tonic-gate #define	PT_LOOS		0x60000000	/* OS specific range */
3280Sstevel@tonic-gate 
3290Sstevel@tonic-gate /*
3309085SAli.Bahrami@Sun.COM  * PT_SUNW_UNWIND and PT_SUNW_EH_FRAME perform the same function,
3319085SAli.Bahrami@Sun.COM  * providing access to the .eh_frame_hdr section of the object.
3329085SAli.Bahrami@Sun.COM  * PT_SUNW_UNWIND is the original value, while PT_SUNW_EH_FRAME is
3339085SAli.Bahrami@Sun.COM  * required by the amd64 psABI. The Solaris link-editor (ld) tags output
3349085SAli.Bahrami@Sun.COM  * objects with PT_SUNW_UNWIND, but the Solaris runtime linker (ld.so.1)
3359085SAli.Bahrami@Sun.COM  * will accept and use either value.
3360Sstevel@tonic-gate  */
3379085SAli.Bahrami@Sun.COM #define	PT_SUNW_UNWIND		0x6464e550
3389085SAli.Bahrami@Sun.COM #define	PT_SUNW_EH_FRAME	0x6474e550
3399085SAli.Bahrami@Sun.COM #define	PT_GNU_EH_FRAME		PT_SUNW_EH_FRAME
3400Sstevel@tonic-gate 
3419085SAli.Bahrami@Sun.COM /*
3429085SAli.Bahrami@Sun.COM  * Linux specific program headers not currently used by Solaris
3439085SAli.Bahrami@Sun.COM  */
3449085SAli.Bahrami@Sun.COM #define	PT_GNU_STACK	0x6474e551	/* Indicates stack executability */
3459085SAli.Bahrami@Sun.COM #define	PT_GNU_RELRO	0x6474e552	/* Read-only after relocation */
3460Sstevel@tonic-gate 
3470Sstevel@tonic-gate #define	PT_LOSUNW	0x6ffffffa
3488159SAli.Bahrami@Sun.COM #define	PT_SUNWBSS	0x6ffffffa	/* Sun Specific segment (unused) */
3490Sstevel@tonic-gate #define	PT_SUNWSTACK	0x6ffffffb	/* describes the stack segment */
3500Sstevel@tonic-gate #define	PT_SUNWDTRACE	0x6ffffffc	/* private */
3510Sstevel@tonic-gate #define	PT_SUNWCAP	0x6ffffffd	/* hard/soft capabilities segment */
3520Sstevel@tonic-gate #define	PT_HISUNW	0x6fffffff
3530Sstevel@tonic-gate #define	PT_HIOS		0x6fffffff
3540Sstevel@tonic-gate 
3550Sstevel@tonic-gate #define	PT_LOPROC	0x70000000	/* processor specific range */
3560Sstevel@tonic-gate #define	PT_HIPROC	0x7fffffff
3570Sstevel@tonic-gate 
3580Sstevel@tonic-gate #define	PF_R		0x4		/* p_flags */
3590Sstevel@tonic-gate #define	PF_W		0x2
3600Sstevel@tonic-gate #define	PF_X		0x1
3610Sstevel@tonic-gate 
3620Sstevel@tonic-gate #define	PF_MASKOS	0x0ff00000	/* OS specific values */
3630Sstevel@tonic-gate #define	PF_MASKPROC	0xf0000000	/* processor specific values */
3640Sstevel@tonic-gate 
3650Sstevel@tonic-gate #define	PF_SUNW_FAILURE	0x00100000	/* mapping absent due to failure */
3660Sstevel@tonic-gate 
367942Sahl #define	PN_XNUM		0xffff		/* extended program header index */
368942Sahl 
3690Sstevel@tonic-gate /*
3700Sstevel@tonic-gate  *	Section header
3710Sstevel@tonic-gate  */
3720Sstevel@tonic-gate 
3730Sstevel@tonic-gate typedef struct {
3740Sstevel@tonic-gate 	Elf32_Word	sh_name;	/* section name */
3750Sstevel@tonic-gate 	Elf32_Word	sh_type;	/* SHT_... */
3760Sstevel@tonic-gate 	Elf32_Word	sh_flags;	/* SHF_... */
3770Sstevel@tonic-gate 	Elf32_Addr	sh_addr;	/* virtual address */
3780Sstevel@tonic-gate 	Elf32_Off	sh_offset;	/* file offset */
3790Sstevel@tonic-gate 	Elf32_Word	sh_size;	/* section size */
3800Sstevel@tonic-gate 	Elf32_Word	sh_link;	/* misc info */
3810Sstevel@tonic-gate 	Elf32_Word	sh_info;	/* misc info */
3820Sstevel@tonic-gate 	Elf32_Word	sh_addralign;	/* memory alignment */
3830Sstevel@tonic-gate 	Elf32_Word	sh_entsize;	/* entry size if table */
3840Sstevel@tonic-gate } Elf32_Shdr;
3850Sstevel@tonic-gate 
3860Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
3870Sstevel@tonic-gate typedef struct {
3880Sstevel@tonic-gate 	Elf64_Word	sh_name;	/* section name */
3890Sstevel@tonic-gate 	Elf64_Word	sh_type;	/* SHT_... */
3900Sstevel@tonic-gate 	Elf64_Xword	sh_flags;	/* SHF_... */
3910Sstevel@tonic-gate 	Elf64_Addr	sh_addr;	/* virtual address */
3920Sstevel@tonic-gate 	Elf64_Off	sh_offset;	/* file offset */
3930Sstevel@tonic-gate 	Elf64_Xword	sh_size;	/* section size */
3940Sstevel@tonic-gate 	Elf64_Word	sh_link;	/* misc info */
3950Sstevel@tonic-gate 	Elf64_Word	sh_info;	/* misc info */
3960Sstevel@tonic-gate 	Elf64_Xword	sh_addralign;	/* memory alignment */
3970Sstevel@tonic-gate 	Elf64_Xword	sh_entsize;	/* entry size if table */
3980Sstevel@tonic-gate } Elf64_Shdr;
3990Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
4000Sstevel@tonic-gate 
4010Sstevel@tonic-gate #define	SHT_NULL		0		/* sh_type */
4020Sstevel@tonic-gate #define	SHT_PROGBITS		1
4030Sstevel@tonic-gate #define	SHT_SYMTAB		2
4040Sstevel@tonic-gate #define	SHT_STRTAB		3
4050Sstevel@tonic-gate #define	SHT_RELA		4
4060Sstevel@tonic-gate #define	SHT_HASH		5
4070Sstevel@tonic-gate #define	SHT_DYNAMIC		6
4080Sstevel@tonic-gate #define	SHT_NOTE		7
4090Sstevel@tonic-gate #define	SHT_NOBITS		8
4100Sstevel@tonic-gate #define	SHT_REL			9
4110Sstevel@tonic-gate #define	SHT_SHLIB		10
4120Sstevel@tonic-gate #define	SHT_DYNSYM		11
4130Sstevel@tonic-gate #define	SHT_UNKNOWN12		12
4140Sstevel@tonic-gate #define	SHT_UNKNOWN13		13
4150Sstevel@tonic-gate #define	SHT_INIT_ARRAY		14
4160Sstevel@tonic-gate #define	SHT_FINI_ARRAY		15
4170Sstevel@tonic-gate #define	SHT_PREINIT_ARRAY	16
4180Sstevel@tonic-gate #define	SHT_GROUP		17
4190Sstevel@tonic-gate #define	SHT_SYMTAB_SHNDX	18
4200Sstevel@tonic-gate #define	SHT_NUM			19
4210Sstevel@tonic-gate 
4222802Sab196087 /* Solaris ABI specific values */
4230Sstevel@tonic-gate #define	SHT_LOOS		0x60000000	/* OS specific range */
424*11827SRod.Evans@Sun.COM #define	SHT_LOSUNW		0x6fffffef
425*11827SRod.Evans@Sun.COM #define	SHT_SUNW_capchain	0x6fffffef
426*11827SRod.Evans@Sun.COM #define	SHT_SUNW_capinfo	0x6ffffff0
4273492Sab196087 #define	SHT_SUNW_symsort	0x6ffffff1
4283492Sab196087 #define	SHT_SUNW_tlssort	0x6ffffff2
4292766Sab196087 #define	SHT_SUNW_LDYNSYM	0x6ffffff3
4300Sstevel@tonic-gate #define	SHT_SUNW_dof		0x6ffffff4
4310Sstevel@tonic-gate #define	SHT_SUNW_cap		0x6ffffff5
4320Sstevel@tonic-gate #define	SHT_SUNW_SIGNATURE	0x6ffffff6
4330Sstevel@tonic-gate #define	SHT_SUNW_ANNOTATE	0x6ffffff7
4340Sstevel@tonic-gate #define	SHT_SUNW_DEBUGSTR	0x6ffffff8
4350Sstevel@tonic-gate #define	SHT_SUNW_DEBUG		0x6ffffff9
4360Sstevel@tonic-gate #define	SHT_SUNW_move		0x6ffffffa
4370Sstevel@tonic-gate #define	SHT_SUNW_COMDAT		0x6ffffffb
4380Sstevel@tonic-gate #define	SHT_SUNW_syminfo	0x6ffffffc
4390Sstevel@tonic-gate #define	SHT_SUNW_verdef		0x6ffffffd
4409085SAli.Bahrami@Sun.COM #define	SHT_GNU_verdef		SHT_SUNW_verdef
4410Sstevel@tonic-gate #define	SHT_SUNW_verneed	0x6ffffffe
4429085SAli.Bahrami@Sun.COM #define	SHT_GNU_verneed		SHT_SUNW_verneed
4430Sstevel@tonic-gate #define	SHT_SUNW_versym		0x6fffffff
4449085SAli.Bahrami@Sun.COM #define	SHT_GNU_versym		SHT_SUNW_versym
4450Sstevel@tonic-gate #define	SHT_HISUNW		0x6fffffff
4460Sstevel@tonic-gate #define	SHT_HIOS		0x6fffffff
4470Sstevel@tonic-gate 
4489085SAli.Bahrami@Sun.COM /*
4499085SAli.Bahrami@Sun.COM  * GNU/Linux OSABI specific values with different meanings than under Solaris.
4509085SAli.Bahrami@Sun.COM  * Due to the overlap in assigned values with the Solaris OSABI, correct
4519085SAli.Bahrami@Sun.COM  * interpretation of these values requires knowledge of the OSABI used by
4529085SAli.Bahrami@Sun.COM  * the object.
4539085SAli.Bahrami@Sun.COM  */
4549085SAli.Bahrami@Sun.COM #define	SHT_GNU_ATTRIBUTES	0x6ffffff5	/* Object attributes */
4559085SAli.Bahrami@Sun.COM #define	SHT_GNU_HASH		0x6ffffff6	/* GNU-style hash table */
4569085SAli.Bahrami@Sun.COM #define	SHT_GNU_LIBLIST		0x6ffffff7	/* Prelink library list */
4579085SAli.Bahrami@Sun.COM #define	SHT_CHECKSUM		0x6ffffff8	/* Checksum for DSO content */
4582802Sab196087 
4590Sstevel@tonic-gate #define	SHT_LOPROC	0x70000000	/* processor specific range */
4600Sstevel@tonic-gate #define	SHT_HIPROC	0x7fffffff
4610Sstevel@tonic-gate 
4620Sstevel@tonic-gate #define	SHT_LOUSER	0x80000000
4630Sstevel@tonic-gate #define	SHT_HIUSER	0xffffffff
4640Sstevel@tonic-gate 
4650Sstevel@tonic-gate #define	SHF_WRITE		0x01		/* sh_flags */
4660Sstevel@tonic-gate #define	SHF_ALLOC		0x02
4670Sstevel@tonic-gate #define	SHF_EXECINSTR		0x04
4680Sstevel@tonic-gate #define	SHF_MERGE		0x10
4690Sstevel@tonic-gate #define	SHF_STRINGS		0x20
4700Sstevel@tonic-gate #define	SHF_INFO_LINK		0x40
4710Sstevel@tonic-gate #define	SHF_LINK_ORDER		0x80
4720Sstevel@tonic-gate #define	SHF_OS_NONCONFORMING	0x100
4730Sstevel@tonic-gate #define	SHF_GROUP		0x200
4740Sstevel@tonic-gate #define	SHF_TLS			0x400
4750Sstevel@tonic-gate 
4760Sstevel@tonic-gate #define	SHF_MASKOS	0x0ff00000	/* OS specific values */
4770Sstevel@tonic-gate 
4780Sstevel@tonic-gate 
4790Sstevel@tonic-gate #define	SHF_MASKPROC	0xf0000000	/* processor specific values */
4800Sstevel@tonic-gate 
4810Sstevel@tonic-gate #define	SHN_UNDEF	0		/* special section numbers */
4820Sstevel@tonic-gate #define	SHN_LORESERVE	0xff00
4830Sstevel@tonic-gate #define	SHN_LOPROC	0xff00		/* processor specific range */
4840Sstevel@tonic-gate #define	SHN_HIPROC	0xff1f
4850Sstevel@tonic-gate #define	SHN_LOOS	0xff20		/* OS specific range */
4860Sstevel@tonic-gate #define	SHN_LOSUNW	0xff3f
4870Sstevel@tonic-gate #define	SHN_SUNW_IGNORE	0xff3f
4880Sstevel@tonic-gate #define	SHN_HISUNW	0xff3f
4890Sstevel@tonic-gate #define	SHN_HIOS	0xff3f
4900Sstevel@tonic-gate #define	SHN_ABS		0xfff1
4910Sstevel@tonic-gate #define	SHN_COMMON	0xfff2
4920Sstevel@tonic-gate #define	SHN_XINDEX	0xffff		/* extended sect index */
4930Sstevel@tonic-gate #define	SHN_HIRESERVE	0xffff
4940Sstevel@tonic-gate 
4950Sstevel@tonic-gate 
4960Sstevel@tonic-gate 
4970Sstevel@tonic-gate /*
4980Sstevel@tonic-gate  *	Symbol table
4990Sstevel@tonic-gate  */
5000Sstevel@tonic-gate 
5010Sstevel@tonic-gate typedef struct {
5020Sstevel@tonic-gate 	Elf32_Word	st_name;
5030Sstevel@tonic-gate 	Elf32_Addr	st_value;
5040Sstevel@tonic-gate 	Elf32_Word	st_size;
5050Sstevel@tonic-gate 	unsigned char	st_info;	/* bind, type: ELF_32_ST_... */
5060Sstevel@tonic-gate 	unsigned char	st_other;
5070Sstevel@tonic-gate 	Elf32_Half	st_shndx;	/* SHN_... */
5080Sstevel@tonic-gate } Elf32_Sym;
5090Sstevel@tonic-gate 
5100Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
5110Sstevel@tonic-gate typedef struct {
5120Sstevel@tonic-gate 	Elf64_Word	st_name;
5130Sstevel@tonic-gate 	unsigned char	st_info;	/* bind, type: ELF_64_ST_... */
5140Sstevel@tonic-gate 	unsigned char	st_other;
5150Sstevel@tonic-gate 	Elf64_Half	st_shndx;	/* SHN_... */
5160Sstevel@tonic-gate 	Elf64_Addr	st_value;
5170Sstevel@tonic-gate 	Elf64_Xword	st_size;
5180Sstevel@tonic-gate } Elf64_Sym;
5190Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
5200Sstevel@tonic-gate 
5210Sstevel@tonic-gate #define	STN_UNDEF	0
5220Sstevel@tonic-gate 
5230Sstevel@tonic-gate /*
524*11827SRod.Evans@Sun.COM  *	Macros to compose and decompose values for S.st_info
5250Sstevel@tonic-gate  *
5260Sstevel@tonic-gate  *	bind = ELF32_ST_BIND(S.st_info)
5270Sstevel@tonic-gate  *	type = ELF32_ST_TYPE(S.st_info)
5280Sstevel@tonic-gate  *	S.st_info = ELF32_ST_INFO(bind, type)
5290Sstevel@tonic-gate  */
5300Sstevel@tonic-gate 
5310Sstevel@tonic-gate #define	ELF32_ST_BIND(info)		((info) >> 4)
5320Sstevel@tonic-gate #define	ELF32_ST_TYPE(info)		((info) & 0xf)
5330Sstevel@tonic-gate #define	ELF32_ST_INFO(bind, type)	(((bind)<<4)+((type)&0xf))
5340Sstevel@tonic-gate 
5350Sstevel@tonic-gate #define	ELF64_ST_BIND(info)		((info) >> 4)
5360Sstevel@tonic-gate #define	ELF64_ST_TYPE(info)		((info) & 0xf)
5370Sstevel@tonic-gate #define	ELF64_ST_INFO(bind, type)	(((bind)<<4)+((type)&0xf))
5380Sstevel@tonic-gate 
5390Sstevel@tonic-gate 
5400Sstevel@tonic-gate #define	STB_LOCAL	0		/* BIND */
5410Sstevel@tonic-gate #define	STB_GLOBAL	1
5420Sstevel@tonic-gate #define	STB_WEAK	2
5430Sstevel@tonic-gate #define	STB_NUM		3
5440Sstevel@tonic-gate 
5450Sstevel@tonic-gate #define	STB_LOPROC	13		/* processor specific range */
5460Sstevel@tonic-gate #define	STB_HIPROC	15
5470Sstevel@tonic-gate 
5489085SAli.Bahrami@Sun.COM #define	STT_NOTYPE	0		/* symbol type is unspecified */
5499085SAli.Bahrami@Sun.COM #define	STT_OBJECT	1		/* data object */
5509085SAli.Bahrami@Sun.COM #define	STT_FUNC	2		/* code object */
5519085SAli.Bahrami@Sun.COM #define	STT_SECTION	3		/* symbol identifies an ELF section */
5529085SAli.Bahrami@Sun.COM #define	STT_FILE	4		/* symbol's name is file name */
5539085SAli.Bahrami@Sun.COM #define	STT_COMMON	5		/* common data object */
5549085SAli.Bahrami@Sun.COM #define	STT_TLS		6		/* thread-local data object */
5559900SAli.Bahrami@Sun.COM #define	STT_NUM		7		/* # defined types in generic range */
5569085SAli.Bahrami@Sun.COM #define	STT_LOOS	10		/* OS specific range */
5579085SAli.Bahrami@Sun.COM #define	STT_HIOS	12
5580Sstevel@tonic-gate #define	STT_LOPROC	13		/* processor specific range */
5590Sstevel@tonic-gate #define	STT_HIPROC	15
5600Sstevel@tonic-gate 
5610Sstevel@tonic-gate /*
562*11827SRod.Evans@Sun.COM  *	Macros to decompose values for S.st_other
5630Sstevel@tonic-gate  *
5640Sstevel@tonic-gate  *	visibility = ELF32_ST_VISIBILITY(S.st_other)
5650Sstevel@tonic-gate  */
5665220Srie #define	ELF32_ST_VISIBILITY(other)	((other)&0x7)
5675220Srie #define	ELF64_ST_VISIBILITY(other)	((other)&0x7)
5680Sstevel@tonic-gate 
5690Sstevel@tonic-gate #define	STV_DEFAULT	0
5700Sstevel@tonic-gate #define	STV_INTERNAL	1
5710Sstevel@tonic-gate #define	STV_HIDDEN	2
5720Sstevel@tonic-gate #define	STV_PROTECTED	3
5735220Srie #define	STV_EXPORTED	4
5745220Srie #define	STV_SINGLETON	5
5755220Srie #define	STV_ELIMINATE	6
5760Sstevel@tonic-gate 
5775220Srie #define	STV_NUM		7
5780Sstevel@tonic-gate 
5790Sstevel@tonic-gate /*
5800Sstevel@tonic-gate  *	Relocation
5810Sstevel@tonic-gate  */
5820Sstevel@tonic-gate 
5830Sstevel@tonic-gate typedef struct {
5840Sstevel@tonic-gate 	Elf32_Addr	r_offset;
5850Sstevel@tonic-gate 	Elf32_Word	r_info;		/* sym, type: ELF32_R_... */
5860Sstevel@tonic-gate } Elf32_Rel;
5870Sstevel@tonic-gate 
5880Sstevel@tonic-gate typedef struct {
5890Sstevel@tonic-gate 	Elf32_Addr	r_offset;
5900Sstevel@tonic-gate 	Elf32_Word	r_info;		/* sym, type: ELF32_R_... */
5910Sstevel@tonic-gate 	Elf32_Sword	r_addend;
5920Sstevel@tonic-gate } Elf32_Rela;
5930Sstevel@tonic-gate 
5940Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
5950Sstevel@tonic-gate typedef struct {
5960Sstevel@tonic-gate 	Elf64_Addr	r_offset;
5970Sstevel@tonic-gate 	Elf64_Xword	r_info;		/* sym, type: ELF64_R_... */
5980Sstevel@tonic-gate } Elf64_Rel;
5990Sstevel@tonic-gate 
6000Sstevel@tonic-gate typedef struct {
6010Sstevel@tonic-gate 	Elf64_Addr	r_offset;
6020Sstevel@tonic-gate 	Elf64_Xword	r_info;		/* sym, type: ELF64_R_... */
6030Sstevel@tonic-gate 	Elf64_Sxword	r_addend;
6040Sstevel@tonic-gate } Elf64_Rela;
6050Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
6060Sstevel@tonic-gate 
6070Sstevel@tonic-gate 
6080Sstevel@tonic-gate /*
609*11827SRod.Evans@Sun.COM  *	Macros to compose and decompose values for Rel.r_info, Rela.f_info
6100Sstevel@tonic-gate  *
6110Sstevel@tonic-gate  *	sym = ELF32_R_SYM(R.r_info)
6120Sstevel@tonic-gate  *	type = ELF32_R_TYPE(R.r_info)
6130Sstevel@tonic-gate  *	R.r_info = ELF32_R_INFO(sym, type)
6140Sstevel@tonic-gate  */
6150Sstevel@tonic-gate 
6160Sstevel@tonic-gate #define	ELF32_R_SYM(info)	((info)>>8)
6170Sstevel@tonic-gate #define	ELF32_R_TYPE(info)	((unsigned char)(info))
6180Sstevel@tonic-gate #define	ELF32_R_INFO(sym, type)	(((sym)<<8)+(unsigned char)(type))
6190Sstevel@tonic-gate 
6200Sstevel@tonic-gate #define	ELF64_R_SYM(info)	((info)>>32)
6210Sstevel@tonic-gate #define	ELF64_R_TYPE(info)    	((Elf64_Word)(info))
6220Sstevel@tonic-gate #define	ELF64_R_INFO(sym, type)	(((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(type))
6230Sstevel@tonic-gate 
6240Sstevel@tonic-gate 
6250Sstevel@tonic-gate /*
6260Sstevel@tonic-gate  * The r_info field is composed of two 32-bit components: the symbol
6270Sstevel@tonic-gate  * table index and the relocation type.  The relocation type for SPARC V9
6280Sstevel@tonic-gate  * is further decomposed into an 8-bit type identifier and a 24-bit type
6290Sstevel@tonic-gate  * dependent data field.  For the existing Elf32 relocation types,
6300Sstevel@tonic-gate  * that data field is zero.
6310Sstevel@tonic-gate  */
6320Sstevel@tonic-gate #define	ELF64_R_TYPE_DATA(info)	(((Elf64_Xword)(info)<<32)>>40)
6330Sstevel@tonic-gate #define	ELF64_R_TYPE_ID(info)	(((Elf64_Xword)(info)<<56)>>56)
6340Sstevel@tonic-gate #define	ELF64_R_TYPE_INFO(data, type)	\
6350Sstevel@tonic-gate 		(((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type))
6360Sstevel@tonic-gate 
6370Sstevel@tonic-gate 
6380Sstevel@tonic-gate /*
6390Sstevel@tonic-gate  * Section Group Flags (SHT_GROUP)
6400Sstevel@tonic-gate  */
6410Sstevel@tonic-gate #define	GRP_COMDAT	0x01
6420Sstevel@tonic-gate 
6430Sstevel@tonic-gate 
6440Sstevel@tonic-gate /*
6450Sstevel@tonic-gate  *	Note entry header
6460Sstevel@tonic-gate  */
6470Sstevel@tonic-gate 
6480Sstevel@tonic-gate typedef struct {
6490Sstevel@tonic-gate 	Elf32_Word	n_namesz;	/* length of note's name */
6500Sstevel@tonic-gate 	Elf32_Word	n_descsz;	/* length of note's "desc" */
6510Sstevel@tonic-gate 	Elf32_Word	n_type;		/* type of note */
6520Sstevel@tonic-gate } Elf32_Nhdr;
6530Sstevel@tonic-gate 
6540Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
6550Sstevel@tonic-gate typedef struct {
6560Sstevel@tonic-gate 	Elf64_Word	n_namesz;	/* length of note's name */
6570Sstevel@tonic-gate 	Elf64_Word	n_descsz;	/* length of note's "desc" */
6580Sstevel@tonic-gate 	Elf64_Word	n_type;		/* type of note */
6590Sstevel@tonic-gate } Elf64_Nhdr;
6600Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
6610Sstevel@tonic-gate 
6620Sstevel@tonic-gate /*
6630Sstevel@tonic-gate  *	Move entry
6640Sstevel@tonic-gate  */
6650Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
6660Sstevel@tonic-gate typedef struct {
6670Sstevel@tonic-gate 	Elf32_Lword	m_value;	/* symbol value */
6680Sstevel@tonic-gate 	Elf32_Word 	m_info;		/* size + index */
6690Sstevel@tonic-gate 	Elf32_Word	m_poffset;	/* symbol offset */
6700Sstevel@tonic-gate 	Elf32_Half	m_repeat;	/* repeat count */
6710Sstevel@tonic-gate 	Elf32_Half	m_stride;	/* stride info */
6720Sstevel@tonic-gate } Elf32_Move;
6730Sstevel@tonic-gate 
6740Sstevel@tonic-gate /*
675*11827SRod.Evans@Sun.COM  *	Macros to compose and decompose values for Move.r_info
6760Sstevel@tonic-gate  *
6770Sstevel@tonic-gate  *	sym = ELF32_M_SYM(M.m_info)
6780Sstevel@tonic-gate  *	size = ELF32_M_SIZE(M.m_info)
6790Sstevel@tonic-gate  *	M.m_info = ELF32_M_INFO(sym, size)
6800Sstevel@tonic-gate  */
6810Sstevel@tonic-gate #define	ELF32_M_SYM(info)	((info)>>8)
6820Sstevel@tonic-gate #define	ELF32_M_SIZE(info)	((unsigned char)(info))
6830Sstevel@tonic-gate #define	ELF32_M_INFO(sym, size)	(((sym)<<8)+(unsigned char)(size))
6840Sstevel@tonic-gate 
6850Sstevel@tonic-gate typedef struct {
6860Sstevel@tonic-gate 	Elf64_Lword	m_value;	/* symbol value */
6870Sstevel@tonic-gate 	Elf64_Xword 	m_info;		/* size + index */
6880Sstevel@tonic-gate 	Elf64_Xword	m_poffset;	/* symbol offset */
6890Sstevel@tonic-gate 	Elf64_Half	m_repeat;	/* repeat count */
6900Sstevel@tonic-gate 	Elf64_Half	m_stride;	/* stride info */
6910Sstevel@tonic-gate } Elf64_Move;
6920Sstevel@tonic-gate #define	ELF64_M_SYM(info)	((info)>>8)
6930Sstevel@tonic-gate #define	ELF64_M_SIZE(info)	((unsigned char)(info))
6940Sstevel@tonic-gate #define	ELF64_M_INFO(sym, size)	(((sym)<<8)+(unsigned char)(size))
6950Sstevel@tonic-gate 
6960Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
6970Sstevel@tonic-gate 
6980Sstevel@tonic-gate 
6990Sstevel@tonic-gate /*
700*11827SRod.Evans@Sun.COM  *	Capabilities entry, Capabilities info and Capabilities chain.
7010Sstevel@tonic-gate  */
7020Sstevel@tonic-gate #ifndef	_ASM
7030Sstevel@tonic-gate typedef struct {
7040Sstevel@tonic-gate 	Elf32_Word	c_tag;		/* how to interpret value */
7050Sstevel@tonic-gate 	union {
7060Sstevel@tonic-gate 		Elf32_Word	c_val;
7070Sstevel@tonic-gate 		Elf32_Addr	c_ptr;
7080Sstevel@tonic-gate 	} c_un;
7090Sstevel@tonic-gate } Elf32_Cap;
7100Sstevel@tonic-gate 
711*11827SRod.Evans@Sun.COM typedef	Elf32_Word	Elf32_Capinfo;
712*11827SRod.Evans@Sun.COM typedef	Elf32_Word	Elf32_Capchain;
713*11827SRod.Evans@Sun.COM 
714*11827SRod.Evans@Sun.COM /*
715*11827SRod.Evans@Sun.COM  *	Macros to compose and decompose values for capabilities info.
716*11827SRod.Evans@Sun.COM  *
717*11827SRod.Evans@Sun.COM  *	sym = ELF32_C_SYM(info)
718*11827SRod.Evans@Sun.COM  *	grp = ELF32_C_GROUP(info)
719*11827SRod.Evans@Sun.COM  *	info = ELF32_C_INFO(sym, grp)
720*11827SRod.Evans@Sun.COM  */
721*11827SRod.Evans@Sun.COM #define	ELF32_C_SYM(info)	((info)>>8)
722*11827SRod.Evans@Sun.COM #define	ELF32_C_GROUP(info)	((unsigned char)(info))
723*11827SRod.Evans@Sun.COM #define	ELF32_C_INFO(sym, grp)	(((sym)<<8)+(unsigned char)(grp))
724*11827SRod.Evans@Sun.COM 
725*11827SRod.Evans@Sun.COM 
7260Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
7270Sstevel@tonic-gate typedef struct {
7280Sstevel@tonic-gate 	Elf64_Xword	c_tag;		/* how to interpret value */
7290Sstevel@tonic-gate 	union {
7300Sstevel@tonic-gate 		Elf64_Xword	c_val;
7310Sstevel@tonic-gate 		Elf64_Addr	c_ptr;
7320Sstevel@tonic-gate 	} c_un;
7330Sstevel@tonic-gate } Elf64_Cap;
734*11827SRod.Evans@Sun.COM 
735*11827SRod.Evans@Sun.COM typedef	Elf64_Xword	Elf64_Capinfo;
736*11827SRod.Evans@Sun.COM typedef	Elf64_Word	Elf64_Capchain;
737*11827SRod.Evans@Sun.COM 
738*11827SRod.Evans@Sun.COM /*
739*11827SRod.Evans@Sun.COM  *	Macros to compose and decompose values for capabilities info.
740*11827SRod.Evans@Sun.COM  *
741*11827SRod.Evans@Sun.COM  *	sym = ELF64_C_SYM(info)
742*11827SRod.Evans@Sun.COM  *	grp = ELF64_C_GROUP(info)
743*11827SRod.Evans@Sun.COM  *	info = ELF64_C_INFO(sym, grp)
744*11827SRod.Evans@Sun.COM  */
745*11827SRod.Evans@Sun.COM #define	ELF64_C_SYM(info)	((info)>>32)
746*11827SRod.Evans@Sun.COM #define	ELF64_C_GROUP(info)    	((Elf64_Word)(info))
747*11827SRod.Evans@Sun.COM #define	ELF64_C_INFO(sym, grp)	(((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(grp))
748*11827SRod.Evans@Sun.COM 
7490Sstevel@tonic-gate #endif	/* defined(_LP64) || defined(_LONGLONG_TYPE) */
7500Sstevel@tonic-gate #endif
7510Sstevel@tonic-gate 
752*11827SRod.Evans@Sun.COM /*
753*11827SRod.Evans@Sun.COM  * Version numbers for SHT_SUNW_capinfo and SHT_SUNW_capchain.
754*11827SRod.Evans@Sun.COM  */
755*11827SRod.Evans@Sun.COM #define	CAPINFO_NONE		0
756*11827SRod.Evans@Sun.COM #define	CAPINFO_CURRENT		1
757*11827SRod.Evans@Sun.COM #define	CAPINFO_NUM		2
758*11827SRod.Evans@Sun.COM 
759*11827SRod.Evans@Sun.COM #define	CAPCHAIN_NONE		0
760*11827SRod.Evans@Sun.COM #define	CAPCHAIN_CURRENT	1
761*11827SRod.Evans@Sun.COM #define	CAPCHAIN_NUM		2
762*11827SRod.Evans@Sun.COM 
763*11827SRod.Evans@Sun.COM /*
764*11827SRod.Evans@Sun.COM  * A SHT_SUNW_capinfo table mirrors a symbol table.  A capabilities symbol has
765*11827SRod.Evans@Sun.COM  * a SHT_SUNW_capinfo table entry that provides an index into the associated
766*11827SRod.Evans@Sun.COM  * SHT_SUNW_cap capabilities group, and the symbol index of the associated lead
767*11827SRod.Evans@Sun.COM  * symbol.  A capabilities symbol is a local symbol.  A global lead capabilities
768*11827SRod.Evans@Sun.COM  * symbol is tagged with a group CAPINFO_SUNW_GLOB.
769*11827SRod.Evans@Sun.COM  */
770*11827SRod.Evans@Sun.COM #define	CAPINFO_SUNW_GLOB	0xff
771*11827SRod.Evans@Sun.COM 
772*11827SRod.Evans@Sun.COM /*
773*11827SRod.Evans@Sun.COM  * Capabilities values.
774*11827SRod.Evans@Sun.COM  */
7750Sstevel@tonic-gate #define	CA_SUNW_NULL	0
7760Sstevel@tonic-gate #define	CA_SUNW_HW_1	1		/* first hardware capabilities entry */
7770Sstevel@tonic-gate #define	CA_SUNW_SF_1	2		/* first software capabilities entry */
77811734SAli.Bahrami@Sun.COM #define	CA_SUNW_HW_2	3		/* second hardware capabilities entry */
779*11827SRod.Evans@Sun.COM #define	CA_SUNW_PLAT	4		/* platform capability entry */
780*11827SRod.Evans@Sun.COM #define	CA_SUNW_MACH	5		/* machine capability entry */
781*11827SRod.Evans@Sun.COM #define	CA_SUNW_ID	6		/* capability identifier */
782*11827SRod.Evans@Sun.COM #define	CA_SUNW_NUM	7
7830Sstevel@tonic-gate 
7840Sstevel@tonic-gate /*
7850Sstevel@tonic-gate  * Define software capabilities (CA_SUNW_SF_1 values).  Note, hardware
7860Sstevel@tonic-gate  * capabilities (CA_SUNW_HW_1 values) are taken directly from sys/auxv_$MACH.h.
7870Sstevel@tonic-gate  */
7887833SRod.Evans@Sun.COM #define	SF1_SUNW_FPKNWN	0x001		/* frame pointer usage is known */
7897833SRod.Evans@Sun.COM #define	SF1_SUNW_FPUSED	0x002		/* frame pointer is in use */
7907833SRod.Evans@Sun.COM #define	SF1_SUNW_ADDR32	0x004		/* 32-bit address space requirement */
7917833SRod.Evans@Sun.COM #define	SF1_SUNW_MASK	0x007		/* known software capabilities mask */
7920Sstevel@tonic-gate 
7930Sstevel@tonic-gate /*
7940Sstevel@tonic-gate  *	Known values for note entry types (e_type == ET_CORE)
7950Sstevel@tonic-gate  */
7960Sstevel@tonic-gate #define	NT_PRSTATUS	1	/* prstatus_t	<sys/old_procfs.h>	*/
7970Sstevel@tonic-gate #define	NT_PRFPREG	2	/* prfpregset_t	<sys/old_procfs.h>	*/
7980Sstevel@tonic-gate #define	NT_PRPSINFO	3	/* prpsinfo_t	<sys/old_procfs.h>	*/
7990Sstevel@tonic-gate #define	NT_PRXREG	4	/* prxregset_t	<sys/procfs.h>		*/
8000Sstevel@tonic-gate #define	NT_PLATFORM	5	/* string from sysinfo(SI_PLATFORM)	*/
8010Sstevel@tonic-gate #define	NT_AUXV		6	/* auxv_t array	<sys/auxv.h>		*/
8020Sstevel@tonic-gate #define	NT_GWINDOWS	7	/* gwindows_t	SPARC only		*/
8030Sstevel@tonic-gate #define	NT_ASRS		8	/* asrset_t	SPARC V9 only		*/
8040Sstevel@tonic-gate #define	NT_LDT		9	/* ssd array	<sys/sysi86.h> IA32 only */
8050Sstevel@tonic-gate #define	NT_PSTATUS	10	/* pstatus_t	<sys/procfs.h>		*/
8060Sstevel@tonic-gate #define	NT_PSINFO	13	/* psinfo_t	<sys/procfs.h>		*/
8070Sstevel@tonic-gate #define	NT_PRCRED	14	/* prcred_t	<sys/procfs.h>		*/
8080Sstevel@tonic-gate #define	NT_UTSNAME	15	/* struct utsname <sys/utsname.h>	*/
8090Sstevel@tonic-gate #define	NT_LWPSTATUS	16	/* lwpstatus_t	<sys/procfs.h>		*/
8100Sstevel@tonic-gate #define	NT_LWPSINFO	17	/* lwpsinfo_t	<sys/procfs.h>		*/
8110Sstevel@tonic-gate #define	NT_PRPRIV	18	/* prpriv_t	<sys/procfs.h>		*/
8120Sstevel@tonic-gate #define	NT_PRPRIVINFO	19	/* priv_impl_info_t <sys/priv.h>	*/
8130Sstevel@tonic-gate #define	NT_CONTENT	20	/* core_content_t <sys/corectl.h>	*/
8140Sstevel@tonic-gate #define	NT_ZONENAME	21	/* string from getzonenamebyid(3C)	*/
8156635Sab196087 #define	NT_NUM		21
8166635Sab196087 
8170Sstevel@tonic-gate 
8180Sstevel@tonic-gate #ifdef _KERNEL
8190Sstevel@tonic-gate /*
8200Sstevel@tonic-gate  * The following routine checks the processor-specific
8210Sstevel@tonic-gate  * fields of an ELF header.
8220Sstevel@tonic-gate  */
8230Sstevel@tonic-gate int	elfheadcheck(unsigned char, Elf32_Half, Elf32_Word);
8240Sstevel@tonic-gate #endif
8250Sstevel@tonic-gate 
8260Sstevel@tonic-gate #ifdef	__cplusplus
8270Sstevel@tonic-gate }
8280Sstevel@tonic-gate #endif
8290Sstevel@tonic-gate 
8300Sstevel@tonic-gate #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_SPARC)
8310Sstevel@tonic-gate #include <sys/elf_SPARC.h>
8320Sstevel@tonic-gate #endif
8330Sstevel@tonic-gate 
8340Sstevel@tonic-gate #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_386)
8350Sstevel@tonic-gate #include <sys/elf_386.h>
8360Sstevel@tonic-gate #endif
8370Sstevel@tonic-gate 
8380Sstevel@tonic-gate #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_AMD64)
8390Sstevel@tonic-gate #include <sys/elf_amd64.h>
8400Sstevel@tonic-gate #endif
8410Sstevel@tonic-gate 
8420Sstevel@tonic-gate #endif	/* _SYS_ELF_H */
843