153196cd4Sbellard/* This file defines standard ELF types, structures, and macros.
228f02864SThomas Preud'homme   Copyright (C) 1995-2012 Free Software Foundation, Inc.
353196cd4Sbellard   This file is part of the GNU C Library.
453196cd4Sbellard
553196cd4Sbellard   The GNU C Library is free software; you can redistribute it and/or
628f02864SThomas Preud'homme   modify it under the terms of the GNU Lesser General Public
728f02864SThomas Preud'homme   License as published by the Free Software Foundation; either
828f02864SThomas Preud'homme   version 2.1 of the License, or (at your option) any later version.
953196cd4Sbellard
1053196cd4Sbellard   The GNU C Library is distributed in the hope that it will be useful,
1153196cd4Sbellard   but WITHOUT ANY WARRANTY; without even the implied warranty of
1253196cd4Sbellard   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1328f02864SThomas Preud'homme   Lesser General Public License for more details.
1453196cd4Sbellard
1528f02864SThomas Preud'homme   You should have received a copy of the GNU Lesser General Public
1628f02864SThomas Preud'homme   License along with the GNU C Library; if not, see
1728f02864SThomas Preud'homme   <http://www.gnu.org/licenses/>.  */
1853196cd4Sbellard
1953196cd4Sbellard#ifndef _ELF_H
2028f02864SThomas Preud'homme#define	_ELF_H 1
2153196cd4Sbellard
2234140dd6Sgrischka#ifndef _WIN32
2353196cd4Sbellard#include <inttypes.h>
2453196cd4Sbellard#else
2553196cd4Sbellard#ifndef __int8_t_defined
2653196cd4Sbellard#define __int8_t_defined
27484ee920Sbellardtypedef signed char int8_t;
2834140dd6Sgrischkatypedef short int int16_t;
2934140dd6Sgrischkatypedef int int32_t;
3053196cd4Sbellardtypedef long long int int64_t;
3134140dd6Sgrischkatypedef unsigned char           uint8_t;
3234140dd6Sgrischkatypedef unsigned short int      uint16_t;
3334140dd6Sgrischkatypedef unsigned int            uint32_t;
3434140dd6Sgrischkatypedef unsigned long long int  uint64_t;
3553196cd4Sbellard#endif
36d48662d4Sgrischka#endif
3753196cd4Sbellard
3853196cd4Sbellard/* Standard ELF types.  */
3953196cd4Sbellard
4053196cd4Sbellard/* Type for a 16-bit quantity.  */
4153196cd4Sbellardtypedef uint16_t Elf32_Half;
4253196cd4Sbellardtypedef uint16_t Elf64_Half;
4353196cd4Sbellard
4453196cd4Sbellard/* Types for signed and unsigned 32-bit quantities.  */
4553196cd4Sbellardtypedef uint32_t Elf32_Word;
4628f02864SThomas Preud'hommetypedef	int32_t  Elf32_Sword;
4753196cd4Sbellardtypedef uint32_t Elf64_Word;
4828f02864SThomas Preud'hommetypedef	int32_t  Elf64_Sword;
4953196cd4Sbellard
5053196cd4Sbellard/* Types for signed and unsigned 64-bit quantities.  */
5153196cd4Sbellardtypedef uint64_t Elf32_Xword;
5228f02864SThomas Preud'hommetypedef	int64_t  Elf32_Sxword;
5353196cd4Sbellardtypedef uint64_t Elf64_Xword;
5428f02864SThomas Preud'hommetypedef	int64_t  Elf64_Sxword;
5553196cd4Sbellard
5653196cd4Sbellard/* Type of addresses.  */
5753196cd4Sbellardtypedef uint32_t Elf32_Addr;
5853196cd4Sbellardtypedef uint64_t Elf64_Addr;
5953196cd4Sbellard
6053196cd4Sbellard/* Type of file offsets.  */
6153196cd4Sbellardtypedef uint32_t Elf32_Off;
6253196cd4Sbellardtypedef uint64_t Elf64_Off;
6353196cd4Sbellard
6453196cd4Sbellard/* Type for section indices, which are 16-bit quantities.  */
6553196cd4Sbellardtypedef uint16_t Elf32_Section;
6653196cd4Sbellardtypedef uint16_t Elf64_Section;
6753196cd4Sbellard
6828f02864SThomas Preud'homme/* Type for version symbol information.  */
6928f02864SThomas Preud'hommetypedef Elf32_Half Elf32_Versym;
7028f02864SThomas Preud'hommetypedef Elf64_Half Elf64_Versym;
7153196cd4Sbellard
7253196cd4Sbellard
7353196cd4Sbellard/* The ELF file header.  This appears at the start of every ELF file.  */
7453196cd4Sbellard
7553196cd4Sbellard#define EI_NIDENT (16)
7653196cd4Sbellard
7753196cd4Sbellardtypedef struct
7853196cd4Sbellard{
7928f02864SThomas Preud'homme  unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
8028f02864SThomas Preud'homme  Elf32_Half	e_type;			/* Object file type */
8128f02864SThomas Preud'homme  Elf32_Half	e_machine;		/* Architecture */
8228f02864SThomas Preud'homme  Elf32_Word	e_version;		/* Object file version */
8328f02864SThomas Preud'homme  Elf32_Addr	e_entry;		/* Entry point virtual address */
8428f02864SThomas Preud'homme  Elf32_Off	e_phoff;		/* Program header table file offset */
8528f02864SThomas Preud'homme  Elf32_Off	e_shoff;		/* Section header table file offset */
8628f02864SThomas Preud'homme  Elf32_Word	e_flags;		/* Processor-specific flags */
8728f02864SThomas Preud'homme  Elf32_Half	e_ehsize;		/* ELF header size in bytes */
8828f02864SThomas Preud'homme  Elf32_Half	e_phentsize;		/* Program header table entry size */
8928f02864SThomas Preud'homme  Elf32_Half	e_phnum;		/* Program header table entry count */
9028f02864SThomas Preud'homme  Elf32_Half	e_shentsize;		/* Section header table entry size */
9128f02864SThomas Preud'homme  Elf32_Half	e_shnum;		/* Section header table entry count */
9228f02864SThomas Preud'homme  Elf32_Half	e_shstrndx;		/* Section header string table index */
9353196cd4Sbellard} Elf32_Ehdr;
9453196cd4Sbellard
9553196cd4Sbellardtypedef struct
9653196cd4Sbellard{
9728f02864SThomas Preud'homme  unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
9828f02864SThomas Preud'homme  Elf64_Half	e_type;			/* Object file type */
9928f02864SThomas Preud'homme  Elf64_Half	e_machine;		/* Architecture */
10028f02864SThomas Preud'homme  Elf64_Word	e_version;		/* Object file version */
10128f02864SThomas Preud'homme  Elf64_Addr	e_entry;		/* Entry point virtual address */
10228f02864SThomas Preud'homme  Elf64_Off	e_phoff;		/* Program header table file offset */
10328f02864SThomas Preud'homme  Elf64_Off	e_shoff;		/* Section header table file offset */
10428f02864SThomas Preud'homme  Elf64_Word	e_flags;		/* Processor-specific flags */
10528f02864SThomas Preud'homme  Elf64_Half	e_ehsize;		/* ELF header size in bytes */
10628f02864SThomas Preud'homme  Elf64_Half	e_phentsize;		/* Program header table entry size */
10728f02864SThomas Preud'homme  Elf64_Half	e_phnum;		/* Program header table entry count */
10828f02864SThomas Preud'homme  Elf64_Half	e_shentsize;		/* Section header table entry size */
10928f02864SThomas Preud'homme  Elf64_Half	e_shnum;		/* Section header table entry count */
11028f02864SThomas Preud'homme  Elf64_Half	e_shstrndx;		/* Section header string table index */
11153196cd4Sbellard} Elf64_Ehdr;
11253196cd4Sbellard
11353196cd4Sbellard/* Fields in the e_ident array.  The EI_* macros are indices into the
11453196cd4Sbellard   array.  The macros under each EI_* macro are the values the byte
11553196cd4Sbellard   may have.  */
11653196cd4Sbellard
11728f02864SThomas Preud'homme#define EI_MAG0		0		/* File identification byte 0 index */
11828f02864SThomas Preud'homme#define ELFMAG0		0x7f		/* Magic number byte 0 */
11953196cd4Sbellard
12028f02864SThomas Preud'homme#define EI_MAG1		1		/* File identification byte 1 index */
12128f02864SThomas Preud'homme#define ELFMAG1		'E'		/* Magic number byte 1 */
12253196cd4Sbellard
12328f02864SThomas Preud'homme#define EI_MAG2		2		/* File identification byte 2 index */
12428f02864SThomas Preud'homme#define ELFMAG2		'L'		/* Magic number byte 2 */
12553196cd4Sbellard
12628f02864SThomas Preud'homme#define EI_MAG3		3		/* File identification byte 3 index */
12728f02864SThomas Preud'homme#define ELFMAG3		'F'		/* Magic number byte 3 */
12853196cd4Sbellard
12953196cd4Sbellard/* Conglomeration of the identification bytes, for easy testing as a word.  */
13028f02864SThomas Preud'homme#define	ELFMAG		"\177ELF"
13128f02864SThomas Preud'homme#define	SELFMAG		4
13228f02864SThomas Preud'homme
13328f02864SThomas Preud'homme#define EI_CLASS	4		/* File class byte index */
13428f02864SThomas Preud'homme#define ELFCLASSNONE	0		/* Invalid class */
13528f02864SThomas Preud'homme#define ELFCLASS32	1		/* 32-bit objects */
13628f02864SThomas Preud'homme#define ELFCLASS64	2		/* 64-bit objects */
13728f02864SThomas Preud'homme#define ELFCLASSNUM	3
13828f02864SThomas Preud'homme
13928f02864SThomas Preud'homme#define EI_DATA		5		/* Data encoding byte index */
14028f02864SThomas Preud'homme#define ELFDATANONE	0		/* Invalid data encoding */
14128f02864SThomas Preud'homme#define ELFDATA2LSB	1		/* 2's complement, little endian */
14228f02864SThomas Preud'homme#define ELFDATA2MSB	2		/* 2's complement, big endian */
14328f02864SThomas Preud'homme#define ELFDATANUM	3
14428f02864SThomas Preud'homme
14528f02864SThomas Preud'homme#define EI_VERSION	6		/* File version byte index */
14628f02864SThomas Preud'homme					/* Value must be EV_CURRENT */
14728f02864SThomas Preud'homme
14828f02864SThomas Preud'homme#define EI_OSABI	7		/* OS ABI identification */
14928f02864SThomas Preud'homme#define ELFOSABI_NONE		0	/* UNIX System V ABI */
15028f02864SThomas Preud'homme#define ELFOSABI_SYSV		0	/* Alias.  */
15128f02864SThomas Preud'homme#define ELFOSABI_HPUX		1	/* HP-UX */
15228f02864SThomas Preud'homme#define ELFOSABI_NETBSD		2	/* NetBSD.  */
15328f02864SThomas Preud'homme#define ELFOSABI_GNU		3	/* Object uses GNU ELF extensions.  */
15428f02864SThomas Preud'homme#define ELFOSABI_LINUX		ELFOSABI_GNU /* Compatibility alias.  */
15528f02864SThomas Preud'homme#define ELFOSABI_SOLARIS	6	/* Sun Solaris.  */
15628f02864SThomas Preud'homme#define ELFOSABI_AIX		7	/* IBM AIX.  */
15728f02864SThomas Preud'homme#define ELFOSABI_IRIX		8	/* SGI Irix.  */
15828f02864SThomas Preud'homme#define ELFOSABI_FREEBSD	9	/* FreeBSD.  */
15928f02864SThomas Preud'homme#define ELFOSABI_TRU64		10	/* Compaq TRU64 UNIX.  */
16028f02864SThomas Preud'homme#define ELFOSABI_MODESTO	11	/* Novell Modesto.  */
16128f02864SThomas Preud'homme#define ELFOSABI_OPENBSD	12	/* OpenBSD.  */
16228f02864SThomas Preud'homme#define ELFOSABI_ARM_AEABI	64	/* ARM EABI */
16328f02864SThomas Preud'homme#define ELFOSABI_ARM		97	/* ARM */
16428f02864SThomas Preud'homme#define ELFOSABI_STANDALONE	255	/* Standalone (embedded) application */
16528f02864SThomas Preud'homme
16628f02864SThomas Preud'homme#define EI_ABIVERSION	8		/* ABI version */
16728f02864SThomas Preud'homme
16828f02864SThomas Preud'homme#define EI_PAD		9		/* Byte index of padding bytes */
16953196cd4Sbellard
17053196cd4Sbellard/* Legal values for e_type (object file type).  */
17153196cd4Sbellard
17228f02864SThomas Preud'homme#define ET_NONE		0		/* No file type */
17328f02864SThomas Preud'homme#define ET_REL		1		/* Relocatable file */
17428f02864SThomas Preud'homme#define ET_EXEC		2		/* Executable file */
17528f02864SThomas Preud'homme#define ET_DYN		3		/* Shared object file */
17628f02864SThomas Preud'homme#define ET_CORE		4		/* Core file */
17728f02864SThomas Preud'homme#define	ET_NUM		5		/* Number of defined types */
17828f02864SThomas Preud'homme#define ET_LOOS		0xfe00		/* OS-specific range start */
17928f02864SThomas Preud'homme#define ET_HIOS		0xfeff		/* OS-specific range end */
18028f02864SThomas Preud'homme#define ET_LOPROC	0xff00		/* Processor-specific range start */
18128f02864SThomas Preud'homme#define ET_HIPROC	0xffff		/* Processor-specific range end */
18253196cd4Sbellard
18353196cd4Sbellard/* Legal values for e_machine (architecture).  */
18453196cd4Sbellard
18528f02864SThomas Preud'homme#define EM_NONE		 0		/* No machine */
18628f02864SThomas Preud'homme#define EM_M32		 1		/* AT&T WE 32100 */
18728f02864SThomas Preud'homme#define EM_SPARC	 2		/* SUN SPARC */
18828f02864SThomas Preud'homme#define EM_386		 3		/* Intel 80386 */
18928f02864SThomas Preud'homme#define EM_68K		 4		/* Motorola m68k family */
19028f02864SThomas Preud'homme#define EM_88K		 5		/* Motorola m88k family */
19128f02864SThomas Preud'homme#define EM_860		 7		/* Intel 80860 */
19228f02864SThomas Preud'homme#define EM_MIPS		 8		/* MIPS R3000 big-endian */
19328f02864SThomas Preud'homme#define EM_S370		 9		/* IBM System/370 */
19428f02864SThomas Preud'homme#define EM_MIPS_RS3_LE	10		/* MIPS R3000 little-endian */
19528f02864SThomas Preud'homme
19628f02864SThomas Preud'homme#define EM_PARISC	15		/* HPPA */
19728f02864SThomas Preud'homme#define EM_VPP500	17		/* Fujitsu VPP500 */
19828f02864SThomas Preud'homme#define EM_SPARC32PLUS	18		/* Sun's "v8plus" */
19928f02864SThomas Preud'homme#define EM_960		19		/* Intel 80960 */
20028f02864SThomas Preud'homme#define EM_PPC		20		/* PowerPC */
20128f02864SThomas Preud'homme#define EM_PPC64	21		/* PowerPC 64-bit */
20228f02864SThomas Preud'homme#define EM_S390		22		/* IBM S390 */
20328f02864SThomas Preud'homme
20428f02864SThomas Preud'homme#define EM_V800		36		/* NEC V800 series */
20528f02864SThomas Preud'homme#define EM_FR20		37		/* Fujitsu FR20 */
20628f02864SThomas Preud'homme#define EM_RH32		38		/* TRW RH-32 */
20728f02864SThomas Preud'homme#define EM_RCE		39		/* Motorola RCE */
20828f02864SThomas Preud'homme#define EM_ARM		40		/* ARM */
20928f02864SThomas Preud'homme#define EM_FAKE_ALPHA	41		/* Digital Alpha */
21028f02864SThomas Preud'homme#define EM_SH		42		/* Hitachi SH */
21128f02864SThomas Preud'homme#define EM_SPARCV9	43		/* SPARC v9 64-bit */
21228f02864SThomas Preud'homme#define EM_TRICORE	44		/* Siemens Tricore */
21328f02864SThomas Preud'homme#define EM_ARC		45		/* Argonaut RISC Core */
21428f02864SThomas Preud'homme#define EM_H8_300	46		/* Hitachi H8/300 */
21528f02864SThomas Preud'homme#define EM_H8_300H	47		/* Hitachi H8/300H */
21628f02864SThomas Preud'homme#define EM_H8S		48		/* Hitachi H8S */
21728f02864SThomas Preud'homme#define EM_H8_500	49		/* Hitachi H8/500 */
21828f02864SThomas Preud'homme#define EM_IA_64	50		/* Intel Merced */
21928f02864SThomas Preud'homme#define EM_MIPS_X	51		/* Stanford MIPS-X */
22028f02864SThomas Preud'homme#define EM_COLDFIRE	52		/* Motorola Coldfire */
22128f02864SThomas Preud'homme#define EM_68HC12	53		/* Motorola M68HC12 */
22228f02864SThomas Preud'homme#define EM_MMA		54		/* Fujitsu MMA Multimedia Accelerator*/
22328f02864SThomas Preud'homme#define EM_PCP		55		/* Siemens PCP */
22419d8b8a1SLarry Doolittle#define EM_NCPU		56		/* Sony nCPU embedded RISC */
22528f02864SThomas Preud'homme#define EM_NDR1		57		/* Denso NDR1 microprocessor */
22628f02864SThomas Preud'homme#define EM_STARCORE	58		/* Motorola Start*Core processor */
22728f02864SThomas Preud'homme#define EM_ME16		59		/* Toyota ME16 processor */
22828f02864SThomas Preud'homme#define EM_ST100	60		/* STMicroelectronic ST100 processor */
22928f02864SThomas Preud'homme#define EM_TINYJ	61		/* Advanced Logic Corp. Tinyj emb.fam*/
23028f02864SThomas Preud'homme#define EM_X86_64	62		/* AMD x86-64 architecture */
23128f02864SThomas Preud'homme#define EM_PDSP		63		/* Sony DSP Processor */
23228f02864SThomas Preud'homme
23328f02864SThomas Preud'homme#define EM_FX66		66		/* Siemens FX66 microcontroller */
23428f02864SThomas Preud'homme#define EM_ST9PLUS	67		/* STMicroelectronics ST9+ 8/16 mc */
2351b6806e5SLarry Doolittle#define EM_ST7		68		/* STMicroelectronics ST7 8 bit mc */
23628f02864SThomas Preud'homme#define EM_68HC16	69		/* Motorola MC68HC16 microcontroller */
23728f02864SThomas Preud'homme#define EM_68HC11	70		/* Motorola MC68HC11 microcontroller */
23828f02864SThomas Preud'homme#define EM_68HC08	71		/* Motorola MC68HC08 microcontroller */
23928f02864SThomas Preud'homme#define EM_68HC05	72		/* Motorola MC68HC05 microcontroller */
24028f02864SThomas Preud'homme#define EM_SVX		73		/* Silicon Graphics SVx */
24128f02864SThomas Preud'homme#define EM_ST19		74		/* STMicroelectronics ST19 8 bit mc */
24228f02864SThomas Preud'homme#define EM_VAX		75		/* Digital VAX */
24328f02864SThomas Preud'homme#define EM_CRIS		76		/* Axis Communications 32-bit embedded processor */
24428f02864SThomas Preud'homme#define EM_JAVELIN	77		/* Infineon Technologies 32-bit embedded processor */
24528f02864SThomas Preud'homme#define EM_FIREPATH	78		/* Element 14 64-bit DSP Processor */
24628f02864SThomas Preud'homme#define EM_ZSP		79		/* LSI Logic 16-bit DSP Processor */
24728f02864SThomas Preud'homme#define EM_MMIX		80		/* Donald Knuth's educational 64-bit processor */
24828f02864SThomas Preud'homme#define EM_HUANY	81		/* Harvard University machine-independent object files */
24928f02864SThomas Preud'homme#define EM_PRISM	82		/* SiTera Prism */
25028f02864SThomas Preud'homme#define EM_AVR		83		/* Atmel AVR 8-bit microcontroller */
25128f02864SThomas Preud'homme#define EM_FR30		84		/* Fujitsu FR30 */
25228f02864SThomas Preud'homme#define EM_D10V		85		/* Mitsubishi D10V */
25328f02864SThomas Preud'homme#define EM_D30V		86		/* Mitsubishi D30V */
25428f02864SThomas Preud'homme#define EM_V850		87		/* NEC v850 */
25528f02864SThomas Preud'homme#define EM_M32R		88		/* Mitsubishi M32R */
25628f02864SThomas Preud'homme#define EM_MN10300	89		/* Matsushita MN10300 */
25728f02864SThomas Preud'homme#define EM_MN10200	90		/* Matsushita MN10200 */
25828f02864SThomas Preud'homme#define EM_PJ		91		/* picoJava */
25928f02864SThomas Preud'homme#define EM_OPENRISC	92		/* OpenRISC 32-bit embedded processor */
26028f02864SThomas Preud'homme#define EM_ARC_A5	93		/* ARC Cores Tangent-A5 */
26128f02864SThomas Preud'homme#define EM_XTENSA	94		/* Tensilica Xtensa Architecture */
26228f02864SThomas Preud'homme#define EM_AARCH64	183		/* ARM AARCH64 */
26328f02864SThomas Preud'homme#define EM_TILEPRO	188		/* Tilera TILEPro */
26428f02864SThomas Preud'homme#define EM_TILEGX	191		/* Tilera TILE-Gx */
2650676d5bcSMichael Matz#define EM_RISCV	243	        /* RISC-V */
2660676d5bcSMichael Matz#define EM_NUM		253
26753196cd4Sbellard
26853196cd4Sbellard/* If it is necessary to assign new unofficial EM_* values, please
26953196cd4Sbellard   pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
27053196cd4Sbellard   chances of collision with official or non-GNU unofficial values.  */
27153196cd4Sbellard
27228f02864SThomas Preud'homme#define EM_ALPHA	0x9026
27328f02864SThomas Preud'homme#define EM_C60		0x9c60
27453196cd4Sbellard
27553196cd4Sbellard/* Legal values for e_version (version).  */
27653196cd4Sbellard
27728f02864SThomas Preud'homme#define EV_NONE		0		/* Invalid ELF version */
27828f02864SThomas Preud'homme#define EV_CURRENT	1		/* Current version */
27928f02864SThomas Preud'homme#define EV_NUM		2
28053196cd4Sbellard
28153196cd4Sbellard/* Section header.  */
28253196cd4Sbellard
28353196cd4Sbellardtypedef struct
28453196cd4Sbellard{
28528f02864SThomas Preud'homme  Elf32_Word	sh_name;		/* Section name (string tbl index) */
28628f02864SThomas Preud'homme  Elf32_Word	sh_type;		/* Section type */
28728f02864SThomas Preud'homme  Elf32_Word	sh_flags;		/* Section flags */
28828f02864SThomas Preud'homme  Elf32_Addr	sh_addr;		/* Section virtual addr at execution */
28928f02864SThomas Preud'homme  Elf32_Off	sh_offset;		/* Section file offset */
29028f02864SThomas Preud'homme  Elf32_Word	sh_size;		/* Section size in bytes */
29128f02864SThomas Preud'homme  Elf32_Word	sh_link;		/* Link to another section */
29228f02864SThomas Preud'homme  Elf32_Word	sh_info;		/* Additional section information */
29328f02864SThomas Preud'homme  Elf32_Word	sh_addralign;		/* Section alignment */
29428f02864SThomas Preud'homme  Elf32_Word	sh_entsize;		/* Entry size if section holds table */
29553196cd4Sbellard} Elf32_Shdr;
29653196cd4Sbellard
29753196cd4Sbellardtypedef struct
29853196cd4Sbellard{
29928f02864SThomas Preud'homme  Elf64_Word	sh_name;		/* Section name (string tbl index) */
30028f02864SThomas Preud'homme  Elf64_Word	sh_type;		/* Section type */
30128f02864SThomas Preud'homme  Elf64_Xword	sh_flags;		/* Section flags */
30228f02864SThomas Preud'homme  Elf64_Addr	sh_addr;		/* Section virtual addr at execution */
30328f02864SThomas Preud'homme  Elf64_Off	sh_offset;		/* Section file offset */
30428f02864SThomas Preud'homme  Elf64_Xword	sh_size;		/* Section size in bytes */
30528f02864SThomas Preud'homme  Elf64_Word	sh_link;		/* Link to another section */
30628f02864SThomas Preud'homme  Elf64_Word	sh_info;		/* Additional section information */
30728f02864SThomas Preud'homme  Elf64_Xword	sh_addralign;		/* Section alignment */
30828f02864SThomas Preud'homme  Elf64_Xword	sh_entsize;		/* Entry size if section holds table */
30953196cd4Sbellard} Elf64_Shdr;
31053196cd4Sbellard
31153196cd4Sbellard/* Special section indices.  */
31253196cd4Sbellard
31328f02864SThomas Preud'homme#define SHN_UNDEF	0		/* Undefined section */
31428f02864SThomas Preud'homme#define SHN_LORESERVE	0xff00		/* Start of reserved indices */
31528f02864SThomas Preud'homme#define SHN_LOPROC	0xff00		/* Start of processor-specific */
31628f02864SThomas Preud'homme#define SHN_BEFORE	0xff00		/* Order section before all others
31728f02864SThomas Preud'homme					   (Solaris).  */
31828f02864SThomas Preud'homme#define SHN_AFTER	0xff01		/* Order section after all others
31928f02864SThomas Preud'homme					   (Solaris).  */
32028f02864SThomas Preud'homme#define SHN_HIPROC	0xff1f		/* End of processor-specific */
32128f02864SThomas Preud'homme#define SHN_LOOS	0xff20		/* Start of OS-specific */
32228f02864SThomas Preud'homme#define SHN_HIOS	0xff3f		/* End of OS-specific */
32328f02864SThomas Preud'homme#define SHN_ABS		0xfff1		/* Associated symbol is absolute */
32428f02864SThomas Preud'homme#define SHN_COMMON	0xfff2		/* Associated symbol is common */
32528f02864SThomas Preud'homme#define SHN_XINDEX	0xffff		/* Index is in extra table.  */
32628f02864SThomas Preud'homme#define SHN_HIRESERVE	0xffff		/* End of reserved indices */
32753196cd4Sbellard
32853196cd4Sbellard/* Legal values for sh_type (section type).  */
32953196cd4Sbellard
33028f02864SThomas Preud'homme#define SHT_NULL	  0		/* Section header table entry unused */
33128f02864SThomas Preud'homme#define SHT_PROGBITS	  1		/* Program data */
33228f02864SThomas Preud'homme#define SHT_SYMTAB	  2		/* Symbol table */
33328f02864SThomas Preud'homme#define SHT_STRTAB	  3		/* String table */
33428f02864SThomas Preud'homme#define SHT_RELA	  4		/* Relocation entries with addends */
33528f02864SThomas Preud'homme#define SHT_HASH	  5		/* Symbol hash table */
33628f02864SThomas Preud'homme#define SHT_DYNAMIC	  6		/* Dynamic linking information */
33728f02864SThomas Preud'homme#define SHT_NOTE	  7		/* Notes */
33828f02864SThomas Preud'homme#define SHT_NOBITS	  8		/* Program space with no data (bss) */
33928f02864SThomas Preud'homme#define SHT_REL		  9		/* Relocation entries, no addends */
34028f02864SThomas Preud'homme#define SHT_SHLIB	  10		/* Reserved */
34128f02864SThomas Preud'homme#define SHT_DYNSYM	  11		/* Dynamic linker symbol table */
34228f02864SThomas Preud'homme#define SHT_INIT_ARRAY	  14		/* Array of constructors */
34328f02864SThomas Preud'homme#define SHT_FINI_ARRAY	  15		/* Array of destructors */
34428f02864SThomas Preud'homme#define SHT_PREINIT_ARRAY 16		/* Array of pre-constructors */
34528f02864SThomas Preud'homme#define SHT_GROUP	  17		/* Section group */
34619d8b8a1SLarry Doolittle#define SHT_SYMTAB_SHNDX  18		/* Extended section indices */
34728f02864SThomas Preud'homme#define	SHT_NUM		  19		/* Number of defined types.  */
34828f02864SThomas Preud'homme#define SHT_LOOS	  0x60000000	/* Start OS-specific.  */
34928f02864SThomas Preud'homme#define SHT_GNU_ATTRIBUTES 0x6ffffff5	/* Object attributes.  */
35028f02864SThomas Preud'homme#define SHT_GNU_HASH	  0x6ffffff6	/* GNU-style hash table.  */
35128f02864SThomas Preud'homme#define SHT_GNU_LIBLIST	  0x6ffffff7	/* Prelink library list */
35228f02864SThomas Preud'homme#define SHT_CHECKSUM	  0x6ffffff8	/* Checksum for DSO content.  */
35328f02864SThomas Preud'homme#define SHT_LOSUNW	  0x6ffffffa	/* Sun-specific low bound.  */
35428f02864SThomas Preud'homme#define SHT_SUNW_move	  0x6ffffffa
35528f02864SThomas Preud'homme#define SHT_SUNW_COMDAT   0x6ffffffb
35628f02864SThomas Preud'homme#define SHT_SUNW_syminfo  0x6ffffffc
35728f02864SThomas Preud'homme#define SHT_GNU_verdef	  0x6ffffffd	/* Version definition section.  */
35828f02864SThomas Preud'homme#define SHT_GNU_verneed	  0x6ffffffe	/* Version needs section.  */
35928f02864SThomas Preud'homme#define SHT_GNU_versym	  0x6fffffff	/* Version symbol table.  */
36028f02864SThomas Preud'homme#define SHT_HISUNW	  0x6fffffff	/* Sun-specific high bound.  */
36128f02864SThomas Preud'homme#define SHT_HIOS	  0x6fffffff	/* End OS-specific type */
36228f02864SThomas Preud'homme#define SHT_LOPROC	  0x70000000	/* Start of processor-specific */
36328f02864SThomas Preud'homme#define SHT_HIPROC	  0x7fffffff	/* End of processor-specific */
36428f02864SThomas Preud'homme#define SHT_LOUSER	  0x80000000	/* Start of application-specific */
36528f02864SThomas Preud'homme#define SHT_HIUSER	  0x8fffffff	/* End of application-specific */
36653196cd4Sbellard
36753196cd4Sbellard/* Legal values for sh_flags (section flags).  */
36853196cd4Sbellard
36928f02864SThomas Preud'homme#define SHF_WRITE	     (1 << 0)	/* Writable */
37028f02864SThomas Preud'homme#define SHF_ALLOC	     (1 << 1)	/* Occupies memory during execution */
37128f02864SThomas Preud'homme#define SHF_EXECINSTR	     (1 << 2)	/* Executable */
37228f02864SThomas Preud'homme#define SHF_MERGE	     (1 << 4)	/* Might be merged */
37328f02864SThomas Preud'homme#define SHF_STRINGS	     (1 << 5)	/* Contains nul-terminated strings */
37428f02864SThomas Preud'homme#define SHF_INFO_LINK	     (1 << 6)	/* `sh_info' contains SHT index */
37528f02864SThomas Preud'homme#define SHF_LINK_ORDER	     (1 << 7)	/* Preserve order after combining */
37628f02864SThomas Preud'homme#define SHF_OS_NONCONFORMING (1 << 8)	/* Non-standard OS specific handling
37728f02864SThomas Preud'homme					   required */
37828f02864SThomas Preud'homme#define SHF_GROUP	     (1 << 9)	/* Section is member of a group.  */
37928f02864SThomas Preud'homme#define SHF_TLS		     (1 << 10)	/* Section hold thread-local data.  */
380600018ceSMichael Matz#define SHF_COMPRESSED	     (1 << 11)	/* Section with compressed data. */
38128f02864SThomas Preud'homme#define SHF_MASKOS	     0x0ff00000	/* OS-specific.  */
38228f02864SThomas Preud'homme#define SHF_MASKPROC	     0xf0000000	/* Processor-specific */
38328f02864SThomas Preud'homme#define SHF_ORDERED	     (1 << 30)	/* Special ordering requirement
38428f02864SThomas Preud'homme					   (Solaris).  */
3850676d5bcSMichael Matz#define SHF_EXCLUDE	     (1U << 31)	/* Section is excluded unless
38628f02864SThomas Preud'homme					   referenced or allocated (Solaris).*/
38728f02864SThomas Preud'homme
38828f02864SThomas Preud'homme/* Section group handling.  */
38928f02864SThomas Preud'homme#define GRP_COMDAT	0x1		/* Mark group as COMDAT.  */
390adc80009Sgrischka
39153196cd4Sbellard/* Symbol table entry.  */
39253196cd4Sbellard
39353196cd4Sbellardtypedef struct
39453196cd4Sbellard{
39528f02864SThomas Preud'homme  Elf32_Word	st_name;		/* Symbol name (string tbl index) */
39628f02864SThomas Preud'homme  Elf32_Addr	st_value;		/* Symbol value */
39728f02864SThomas Preud'homme  Elf32_Word	st_size;		/* Symbol size */
39828f02864SThomas Preud'homme  unsigned char	st_info;		/* Symbol type and binding */
39928f02864SThomas Preud'homme  unsigned char	st_other;		/* Symbol visibility */
40028f02864SThomas Preud'homme  Elf32_Section	st_shndx;		/* Section index */
40153196cd4Sbellard} Elf32_Sym;
40253196cd4Sbellard
40353196cd4Sbellardtypedef struct
40453196cd4Sbellard{
40528f02864SThomas Preud'homme  Elf64_Word	st_name;		/* Symbol name (string tbl index) */
40628f02864SThomas Preud'homme  unsigned char	st_info;		/* Symbol type and binding */
40728f02864SThomas Preud'homme  unsigned char st_other;		/* Symbol visibility */
40828f02864SThomas Preud'homme  Elf64_Section	st_shndx;		/* Section index */
40928f02864SThomas Preud'homme  Elf64_Addr	st_value;		/* Symbol value */
41028f02864SThomas Preud'homme  Elf64_Xword	st_size;		/* Symbol size */
41153196cd4Sbellard} Elf64_Sym;
41253196cd4Sbellard
41353196cd4Sbellard/* The syminfo section if available contains additional information about
41453196cd4Sbellard   every dynamic symbol.  */
41553196cd4Sbellard
41653196cd4Sbellardtypedef struct
41753196cd4Sbellard{
41828f02864SThomas Preud'homme  Elf32_Half si_boundto;		/* Direct bindings, symbol bound to */
41928f02864SThomas Preud'homme  Elf32_Half si_flags;			/* Per symbol flags */
42053196cd4Sbellard} Elf32_Syminfo;
42153196cd4Sbellard
42253196cd4Sbellardtypedef struct
42353196cd4Sbellard{
42428f02864SThomas Preud'homme  Elf64_Half si_boundto;		/* Direct bindings, symbol bound to */
42528f02864SThomas Preud'homme  Elf64_Half si_flags;			/* Per symbol flags */
42653196cd4Sbellard} Elf64_Syminfo;
42753196cd4Sbellard
42853196cd4Sbellard/* Possible values for si_boundto.  */
42928f02864SThomas Preud'homme#define SYMINFO_BT_SELF		0xffff	/* Symbol bound to self */
43028f02864SThomas Preud'homme#define SYMINFO_BT_PARENT	0xfffe	/* Symbol bound to parent */
43128f02864SThomas Preud'homme#define SYMINFO_BT_LOWRESERVE	0xff00	/* Beginning of reserved entries */
43253196cd4Sbellard
43353196cd4Sbellard/* Possible bitmasks for si_flags.  */
43428f02864SThomas Preud'homme#define SYMINFO_FLG_DIRECT	0x0001	/* Direct bound symbol */
43528f02864SThomas Preud'homme#define SYMINFO_FLG_PASSTHRU	0x0002	/* Pass-thru symbol for translator */
43628f02864SThomas Preud'homme#define SYMINFO_FLG_COPY	0x0004	/* Symbol is a copy-reloc */
43728f02864SThomas Preud'homme#define SYMINFO_FLG_LAZYLOAD	0x0008	/* Symbol bound to object to be lazy
43828f02864SThomas Preud'homme					   loaded */
43953196cd4Sbellard/* Syminfo version values.  */
44028f02864SThomas Preud'homme#define SYMINFO_NONE		0
44128f02864SThomas Preud'homme#define SYMINFO_CURRENT		1
44228f02864SThomas Preud'homme#define SYMINFO_NUM		2
44353196cd4Sbellard
44453196cd4Sbellard
44553196cd4Sbellard/* How to extract and insert information held in the st_info field.  */
44653196cd4Sbellard
44728f02864SThomas Preud'homme#define ELF32_ST_BIND(val)		(((unsigned char) (val)) >> 4)
44828f02864SThomas Preud'homme#define ELF32_ST_TYPE(val)		((val) & 0xf)
44928f02864SThomas Preud'homme#define ELF32_ST_INFO(bind, type)	(((bind) << 4) + ((type) & 0xf))
45053196cd4Sbellard
45153196cd4Sbellard/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field.  */
45228f02864SThomas Preud'homme#define ELF64_ST_BIND(val)		ELF32_ST_BIND (val)
45328f02864SThomas Preud'homme#define ELF64_ST_TYPE(val)		ELF32_ST_TYPE (val)
45428f02864SThomas Preud'homme#define ELF64_ST_INFO(bind, type)	ELF32_ST_INFO ((bind), (type))
45553196cd4Sbellard
45653196cd4Sbellard/* Legal values for ST_BIND subfield of st_info (symbol binding).  */
45753196cd4Sbellard
45828f02864SThomas Preud'homme#define STB_LOCAL	0		/* Local symbol */
45928f02864SThomas Preud'homme#define STB_GLOBAL	1		/* Global symbol */
46028f02864SThomas Preud'homme#define STB_WEAK	2		/* Weak symbol */
46128f02864SThomas Preud'homme#define	STB_NUM		3		/* Number of defined types.  */
46228f02864SThomas Preud'homme#define STB_LOOS	10		/* Start of OS-specific */
46328f02864SThomas Preud'homme#define STB_GNU_UNIQUE	10		/* Unique symbol.  */
46428f02864SThomas Preud'homme#define STB_HIOS	12		/* End of OS-specific */
46528f02864SThomas Preud'homme#define STB_LOPROC	13		/* Start of processor-specific */
46628f02864SThomas Preud'homme#define STB_HIPROC	15		/* End of processor-specific */
46753196cd4Sbellard
46853196cd4Sbellard/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
46953196cd4Sbellard
47028f02864SThomas Preud'homme#define STT_NOTYPE	0		/* Symbol type is unspecified */
47128f02864SThomas Preud'homme#define STT_OBJECT	1		/* Symbol is a data object */
47228f02864SThomas Preud'homme#define STT_FUNC	2		/* Symbol is a code object */
47328f02864SThomas Preud'homme#define STT_SECTION	3		/* Symbol associated with a section */
47428f02864SThomas Preud'homme#define STT_FILE	4		/* Symbol's name is file name */
47528f02864SThomas Preud'homme#define STT_COMMON	5		/* Symbol is a common data object */
47628f02864SThomas Preud'homme#define STT_TLS		6		/* Symbol is thread-local data object*/
47728f02864SThomas Preud'homme#define	STT_NUM		7		/* Number of defined types.  */
47828f02864SThomas Preud'homme#define STT_LOOS	10		/* Start of OS-specific */
47928f02864SThomas Preud'homme#define STT_GNU_IFUNC	10		/* Symbol is indirect code object */
48028f02864SThomas Preud'homme#define STT_HIOS	12		/* End of OS-specific */
48128f02864SThomas Preud'homme#define STT_LOPROC	13		/* Start of processor-specific */
48228f02864SThomas Preud'homme#define STT_HIPROC	15		/* End of processor-specific */
48353196cd4Sbellard
48453196cd4Sbellard
48553196cd4Sbellard/* Symbol table indices are found in the hash buckets and chain table
48653196cd4Sbellard   of a symbol hash table section.  This special index value indicates
48753196cd4Sbellard   the end of a chain, meaning no further symbols are found in that bucket.  */
48853196cd4Sbellard
48928f02864SThomas Preud'homme#define STN_UNDEF	0		/* End of a chain.  */
49053196cd4Sbellard
49153196cd4Sbellard
492bdd09709Sbellard/* How to extract and insert information held in the st_other field.  */
493bdd09709Sbellard
49428f02864SThomas Preud'homme#define ELF32_ST_VISIBILITY(o)	((o) & 0x03)
495bdd09709Sbellard
496bdd09709Sbellard/* For ELF64 the definitions are the same.  */
49728f02864SThomas Preud'homme#define ELF64_ST_VISIBILITY(o)	ELF32_ST_VISIBILITY (o)
498bdd09709Sbellard
499bdd09709Sbellard/* Symbol visibility specification encoded in the st_other field.  */
50028f02864SThomas Preud'homme#define STV_DEFAULT	0		/* Default symbol visibility rules */
50128f02864SThomas Preud'homme#define STV_INTERNAL	1		/* Processor specific hidden class */
50228f02864SThomas Preud'homme#define STV_HIDDEN	2		/* Sym unavailable in other modules */
50328f02864SThomas Preud'homme#define STV_PROTECTED	3		/* Not preemptible, not exported */
504bdd09709Sbellard
505bdd09709Sbellard
50653196cd4Sbellard/* Relocation table entry without addend (in section of type SHT_REL).  */
50753196cd4Sbellard
50853196cd4Sbellardtypedef struct
50953196cd4Sbellard{
51028f02864SThomas Preud'homme  Elf32_Addr	r_offset;		/* Address */
51128f02864SThomas Preud'homme  Elf32_Word	r_info;			/* Relocation type and symbol index */
51253196cd4Sbellard} Elf32_Rel;
51353196cd4Sbellard
51453196cd4Sbellard/* I have seen two different definitions of the Elf64_Rel and
51553196cd4Sbellard   Elf64_Rela structures, so we'll leave them out until Novell (or
51653196cd4Sbellard   whoever) gets their act together.  */
51753196cd4Sbellard/* The following, at least, is used on Sparc v9, MIPS, and Alpha.  */
51853196cd4Sbellard
51953196cd4Sbellardtypedef struct
52053196cd4Sbellard{
52128f02864SThomas Preud'homme  Elf64_Addr	r_offset;		/* Address */
52228f02864SThomas Preud'homme  Elf64_Xword	r_info;			/* Relocation type and symbol index */
52353196cd4Sbellard} Elf64_Rel;
52453196cd4Sbellard
52553196cd4Sbellard/* Relocation table entry with addend (in section of type SHT_RELA).  */
52653196cd4Sbellard
52753196cd4Sbellardtypedef struct
52853196cd4Sbellard{
52928f02864SThomas Preud'homme  Elf32_Addr	r_offset;		/* Address */
53028f02864SThomas Preud'homme  Elf32_Word	r_info;			/* Relocation type and symbol index */
53128f02864SThomas Preud'homme  Elf32_Sword	r_addend;		/* Addend */
53253196cd4Sbellard} Elf32_Rela;
53353196cd4Sbellard
53453196cd4Sbellardtypedef struct
53553196cd4Sbellard{
53628f02864SThomas Preud'homme  Elf64_Addr	r_offset;		/* Address */
53728f02864SThomas Preud'homme  Elf64_Xword	r_info;			/* Relocation type and symbol index */
53828f02864SThomas Preud'homme  Elf64_Sxword	r_addend;		/* Addend */
53953196cd4Sbellard} Elf64_Rela;
54053196cd4Sbellard
54153196cd4Sbellard/* How to extract and insert information held in the r_info field.  */
54253196cd4Sbellard
54328f02864SThomas Preud'homme#define ELF32_R_SYM(val)		((val) >> 8)
54428f02864SThomas Preud'homme#define ELF32_R_TYPE(val)		((val) & 0xff)
54528f02864SThomas Preud'homme#define ELF32_R_INFO(sym, type)		(((sym) << 8) + ((type) & 0xff))
54653196cd4Sbellard
54728f02864SThomas Preud'homme#define ELF64_R_SYM(i)			((i) >> 32)
54828f02864SThomas Preud'homme#define ELF64_R_TYPE(i)			((i) & 0xffffffff)
54928f02864SThomas Preud'homme#define ELF64_R_INFO(sym,type)		((((Elf64_Xword) (sym)) << 32) + (type))
55053196cd4Sbellard
55153196cd4Sbellard/* Program segment header.  */
55253196cd4Sbellard
55353196cd4Sbellardtypedef struct
55453196cd4Sbellard{
55528f02864SThomas Preud'homme  Elf32_Word	p_type;			/* Segment type */
55628f02864SThomas Preud'homme  Elf32_Off	p_offset;		/* Segment file offset */
55728f02864SThomas Preud'homme  Elf32_Addr	p_vaddr;		/* Segment virtual address */
55828f02864SThomas Preud'homme  Elf32_Addr	p_paddr;		/* Segment physical address */
55928f02864SThomas Preud'homme  Elf32_Word	p_filesz;		/* Segment size in file */
56028f02864SThomas Preud'homme  Elf32_Word	p_memsz;		/* Segment size in memory */
56128f02864SThomas Preud'homme  Elf32_Word	p_flags;		/* Segment flags */
56228f02864SThomas Preud'homme  Elf32_Word	p_align;		/* Segment alignment */
56353196cd4Sbellard} Elf32_Phdr;
56453196cd4Sbellard
56553196cd4Sbellardtypedef struct
56653196cd4Sbellard{
56728f02864SThomas Preud'homme  Elf64_Word	p_type;			/* Segment type */
56828f02864SThomas Preud'homme  Elf64_Word	p_flags;		/* Segment flags */
56928f02864SThomas Preud'homme  Elf64_Off	p_offset;		/* Segment file offset */
57028f02864SThomas Preud'homme  Elf64_Addr	p_vaddr;		/* Segment virtual address */
57128f02864SThomas Preud'homme  Elf64_Addr	p_paddr;		/* Segment physical address */
57228f02864SThomas Preud'homme  Elf64_Xword	p_filesz;		/* Segment size in file */
57328f02864SThomas Preud'homme  Elf64_Xword	p_memsz;		/* Segment size in memory */
57428f02864SThomas Preud'homme  Elf64_Xword	p_align;		/* Segment alignment */
57553196cd4Sbellard} Elf64_Phdr;
57653196cd4Sbellard
57728f02864SThomas Preud'homme/* Special value for e_phnum.  This indicates that the real number of
57828f02864SThomas Preud'homme   program headers is too large to fit into e_phnum.  Instead the real
57928f02864SThomas Preud'homme   value is in the field sh_info of section 0.  */
58028f02864SThomas Preud'homme
58128f02864SThomas Preud'homme#define PN_XNUM		0xffff
58228f02864SThomas Preud'homme
58353196cd4Sbellard/* Legal values for p_type (segment type).  */
58453196cd4Sbellard
58528f02864SThomas Preud'homme#define	PT_NULL		0		/* Program header table entry unused */
58628f02864SThomas Preud'homme#define PT_LOAD		1		/* Loadable program segment */
58728f02864SThomas Preud'homme#define PT_DYNAMIC	2		/* Dynamic linking information */
58828f02864SThomas Preud'homme#define PT_INTERP	3		/* Program interpreter */
58928f02864SThomas Preud'homme#define PT_NOTE		4		/* Auxiliary information */
59028f02864SThomas Preud'homme#define PT_SHLIB	5		/* Reserved */
59128f02864SThomas Preud'homme#define PT_PHDR		6		/* Entry for header table itself */
59228f02864SThomas Preud'homme#define PT_TLS		7		/* Thread-local storage segment */
59328f02864SThomas Preud'homme#define	PT_NUM		8		/* Number of defined types */
59428f02864SThomas Preud'homme#define PT_LOOS		0x60000000	/* Start of OS-specific */
59528f02864SThomas Preud'homme#define PT_GNU_EH_FRAME	0x6474e550	/* GCC .eh_frame_hdr segment */
59628f02864SThomas Preud'homme#define PT_GNU_STACK	0x6474e551	/* Indicates stack executability */
59728f02864SThomas Preud'homme#define PT_GNU_RELRO	0x6474e552	/* Read-only after relocation */
59828f02864SThomas Preud'homme#define PT_LOSUNW	0x6ffffffa
59928f02864SThomas Preud'homme#define PT_SUNWBSS	0x6ffffffa	/* Sun Specific segment */
60028f02864SThomas Preud'homme#define PT_SUNWSTACK	0x6ffffffb	/* Stack segment */
60128f02864SThomas Preud'homme#define PT_HISUNW	0x6fffffff
60228f02864SThomas Preud'homme#define PT_HIOS		0x6fffffff	/* End of OS-specific */
60328f02864SThomas Preud'homme#define PT_LOPROC	0x70000000	/* Start of processor-specific */
60428f02864SThomas Preud'homme#define PT_HIPROC	0x7fffffff	/* End of processor-specific */
60553196cd4Sbellard
60653196cd4Sbellard/* Legal values for p_flags (segment flags).  */
60753196cd4Sbellard
60828f02864SThomas Preud'homme#define PF_X		(1 << 0)	/* Segment is executable */
60928f02864SThomas Preud'homme#define PF_W		(1 << 1)	/* Segment is writable */
61028f02864SThomas Preud'homme#define PF_R		(1 << 2)	/* Segment is readable */
61128f02864SThomas Preud'homme#define PF_MASKOS	0x0ff00000	/* OS-specific */
61228f02864SThomas Preud'homme#define PF_MASKPROC	0xf0000000	/* Processor-specific */
61353196cd4Sbellard
61453196cd4Sbellard/* Legal values for note segment descriptor types for core files. */
61553196cd4Sbellard
61628f02864SThomas Preud'homme#define NT_PRSTATUS	1		/* Contains copy of prstatus struct */
61728f02864SThomas Preud'homme#define NT_FPREGSET	2		/* Contains copy of fpregset struct */
61828f02864SThomas Preud'homme#define NT_PRPSINFO	3		/* Contains copy of prpsinfo struct */
61928f02864SThomas Preud'homme#define NT_PRXREG	4		/* Contains copy of prxregset struct */
62028f02864SThomas Preud'homme#define NT_TASKSTRUCT	4		/* Contains copy of task structure */
62128f02864SThomas Preud'homme#define NT_PLATFORM	5		/* String from sysinfo(SI_PLATFORM) */
62228f02864SThomas Preud'homme#define NT_AUXV		6		/* Contains copy of auxv array */
62328f02864SThomas Preud'homme#define NT_GWINDOWS	7		/* Contains copy of gwindows struct */
62428f02864SThomas Preud'homme#define NT_ASRS		8		/* Contains copy of asrset struct */
62528f02864SThomas Preud'homme#define NT_PSTATUS	10		/* Contains copy of pstatus struct */
62628f02864SThomas Preud'homme#define NT_PSINFO	13		/* Contains copy of psinfo struct */
62728f02864SThomas Preud'homme#define NT_PRCRED	14		/* Contains copy of prcred struct */
62828f02864SThomas Preud'homme#define NT_UTSNAME	15		/* Contains copy of utsname struct */
62928f02864SThomas Preud'homme#define NT_LWPSTATUS	16		/* Contains copy of lwpstatus struct */
63028f02864SThomas Preud'homme#define NT_LWPSINFO	17		/* Contains copy of lwpinfo struct */
63128f02864SThomas Preud'homme#define NT_PRFPXREG	20		/* Contains copy of fprxregset struct */
63228f02864SThomas Preud'homme#define NT_PRXFPREG	0x46e62b7f	/* Contains copy of user_fxsr_struct */
63328f02864SThomas Preud'homme#define NT_PPC_VMX	0x100		/* PowerPC Altivec/VMX registers */
63428f02864SThomas Preud'homme#define NT_PPC_SPE	0x101		/* PowerPC SPE/EVR registers */
63528f02864SThomas Preud'homme#define NT_PPC_VSX	0x102		/* PowerPC VSX registers */
63628f02864SThomas Preud'homme#define NT_386_TLS	0x200		/* i386 TLS slots (struct user_desc) */
63728f02864SThomas Preud'homme#define NT_386_IOPERM	0x201		/* x86 io permission bitmap (1=deny) */
63828f02864SThomas Preud'homme#define NT_X86_XSTATE	0x202		/* x86 extended state using xsave */
63928f02864SThomas Preud'homme#define NT_S390_HIGH_GPRS	0x300	/* s390 upper register halves */
64028f02864SThomas Preud'homme#define NT_S390_TIMER	0x301		/* s390 timer register */
64128f02864SThomas Preud'homme#define NT_S390_TODCMP	0x302		/* s390 TOD clock comparator register */
64228f02864SThomas Preud'homme#define NT_S390_TODPREG	0x303		/* s390 TOD programmable register */
64328f02864SThomas Preud'homme#define NT_S390_CTRS	0x304		/* s390 control registers */
64428f02864SThomas Preud'homme#define NT_S390_PREFIX	0x305		/* s390 prefix register */
64528f02864SThomas Preud'homme#define NT_S390_LAST_BREAK	0x306	/* s390 breaking event address */
64628f02864SThomas Preud'homme#define NT_S390_SYSTEM_CALL	0x307	/* s390 system call restart data */
64728f02864SThomas Preud'homme#define NT_ARM_VFP	0x400		/* ARM VFP/NEON registers */
64828f02864SThomas Preud'homme#define NT_ARM_TLS	0x401		/* ARM TLS register */
64928f02864SThomas Preud'homme#define NT_ARM_HW_BREAK	0x402		/* ARM hardware breakpoint registers */
65028f02864SThomas Preud'homme#define NT_ARM_HW_WATCH	0x403		/* ARM hardware watchpoint registers */
65128f02864SThomas Preud'homme
65228f02864SThomas Preud'homme/* Legal values for the note segment descriptor types for object files.  */
65328f02864SThomas Preud'homme
65428f02864SThomas Preud'homme#define NT_VERSION	1		/* Contains a version string.  */
65553196cd4Sbellard
65653196cd4Sbellard
65753196cd4Sbellard/* Dynamic section entry.  */
65853196cd4Sbellard
65953196cd4Sbellardtypedef struct
66053196cd4Sbellard{
66128f02864SThomas Preud'homme  Elf32_Sword	d_tag;			/* Dynamic entry type */
66253196cd4Sbellard  union
66353196cd4Sbellard    {
66428f02864SThomas Preud'homme      Elf32_Word d_val;			/* Integer value */
66528f02864SThomas Preud'homme      Elf32_Addr d_ptr;			/* Address value */
66653196cd4Sbellard    } d_un;
66753196cd4Sbellard} Elf32_Dyn;
66853196cd4Sbellard
66953196cd4Sbellardtypedef struct
67053196cd4Sbellard{
67128f02864SThomas Preud'homme  Elf64_Sxword	d_tag;			/* Dynamic entry type */
67253196cd4Sbellard  union
67353196cd4Sbellard    {
67428f02864SThomas Preud'homme      Elf64_Xword d_val;		/* Integer value */
67528f02864SThomas Preud'homme      Elf64_Addr d_ptr;			/* Address value */
67653196cd4Sbellard    } d_un;
67753196cd4Sbellard} Elf64_Dyn;
67853196cd4Sbellard
67953196cd4Sbellard/* Legal values for d_tag (dynamic entry type).  */
68053196cd4Sbellard
68128f02864SThomas Preud'homme#define DT_NULL		0		/* Marks end of dynamic section */
68228f02864SThomas Preud'homme#define DT_NEEDED	1		/* Name of needed library */
68328f02864SThomas Preud'homme#define DT_PLTRELSZ	2		/* Size in bytes of PLT relocs */
68428f02864SThomas Preud'homme#define DT_PLTGOT	3		/* Processor defined value */
68528f02864SThomas Preud'homme#define DT_HASH		4		/* Address of symbol hash table */
68628f02864SThomas Preud'homme#define DT_STRTAB	5		/* Address of string table */
68728f02864SThomas Preud'homme#define DT_SYMTAB	6		/* Address of symbol table */
68828f02864SThomas Preud'homme#define DT_RELA		7		/* Address of Rela relocs */
68928f02864SThomas Preud'homme#define DT_RELASZ	8		/* Total size of Rela relocs */
69028f02864SThomas Preud'homme#define DT_RELAENT	9		/* Size of one Rela reloc */
69128f02864SThomas Preud'homme#define DT_STRSZ	10		/* Size of string table */
69228f02864SThomas Preud'homme#define DT_SYMENT	11		/* Size of one symbol table entry */
69328f02864SThomas Preud'homme#define DT_INIT		12		/* Address of init function */
69428f02864SThomas Preud'homme#define DT_FINI		13		/* Address of termination function */
69528f02864SThomas Preud'homme#define DT_SONAME	14		/* Name of shared object */
69628f02864SThomas Preud'homme#define DT_RPATH	15		/* Library search path (deprecated) */
69728f02864SThomas Preud'homme#define DT_SYMBOLIC	16		/* Start symbol search here */
69828f02864SThomas Preud'homme#define DT_REL		17		/* Address of Rel relocs */
69928f02864SThomas Preud'homme#define DT_RELSZ	18		/* Total size of Rel relocs */
70028f02864SThomas Preud'homme#define DT_RELENT	19		/* Size of one Rel reloc */
70128f02864SThomas Preud'homme#define DT_PLTREL	20		/* Type of reloc in PLT */
70228f02864SThomas Preud'homme#define DT_DEBUG	21		/* For debugging; unspecified */
70328f02864SThomas Preud'homme#define DT_TEXTREL	22		/* Reloc might modify .text */
70428f02864SThomas Preud'homme#define DT_JMPREL	23		/* Address of PLT relocs */
70528f02864SThomas Preud'homme#define	DT_BIND_NOW	24		/* Process relocations of object */
70628f02864SThomas Preud'homme#define	DT_INIT_ARRAY	25		/* Array with addresses of init fct */
70728f02864SThomas Preud'homme#define	DT_FINI_ARRAY	26		/* Array with addresses of fini fct */
70828f02864SThomas Preud'homme#define	DT_INIT_ARRAYSZ	27		/* Size in bytes of DT_INIT_ARRAY */
70928f02864SThomas Preud'homme#define	DT_FINI_ARRAYSZ	28		/* Size in bytes of DT_FINI_ARRAY */
71028f02864SThomas Preud'homme#define DT_RUNPATH	29		/* Library search path */
71128f02864SThomas Preud'homme#define DT_FLAGS	30		/* Flags for the object being loaded */
71228f02864SThomas Preud'homme#define DT_ENCODING	32		/* Start of encoded range */
71328f02864SThomas Preud'homme#define DT_PREINIT_ARRAY 32		/* Array with addresses of preinit fct*/
71428f02864SThomas Preud'homme#define DT_PREINIT_ARRAYSZ 33		/* size in bytes of DT_PREINIT_ARRAY */
71528f02864SThomas Preud'homme#define	DT_NUM		34		/* Number used */
71628f02864SThomas Preud'homme#define DT_LOOS		0x6000000d	/* Start of OS-specific */
71728f02864SThomas Preud'homme#define DT_HIOS		0x6ffff000	/* End of OS-specific */
71828f02864SThomas Preud'homme#define DT_LOPROC	0x70000000	/* Start of processor-specific */
71928f02864SThomas Preud'homme#define DT_HIPROC	0x7fffffff	/* End of processor-specific */
72028f02864SThomas Preud'homme#define	DT_PROCNUM	DT_MIPS_NUM	/* Most used by any processor */
72153196cd4Sbellard
72253196cd4Sbellard/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
72353196cd4Sbellard   Dyn.d_un.d_val field of the Elf*_Dyn structure.  This follows Sun's
72453196cd4Sbellard   approach.  */
72528f02864SThomas Preud'homme#define DT_VALRNGLO	0x6ffffd00
72628f02864SThomas Preud'homme#define DT_GNU_PRELINKED 0x6ffffdf5	/* Prelinking timestamp */
72728f02864SThomas Preud'homme#define DT_GNU_CONFLICTSZ 0x6ffffdf6	/* Size of conflict section */
72828f02864SThomas Preud'homme#define DT_GNU_LIBLISTSZ 0x6ffffdf7	/* Size of library list */
72928f02864SThomas Preud'homme#define DT_CHECKSUM	0x6ffffdf8
73028f02864SThomas Preud'homme#define DT_PLTPADSZ	0x6ffffdf9
73128f02864SThomas Preud'homme#define DT_MOVEENT	0x6ffffdfa
73228f02864SThomas Preud'homme#define DT_MOVESZ	0x6ffffdfb
73328f02864SThomas Preud'homme#define DT_FEATURE_1	0x6ffffdfc	/* Feature selection (DTF_*).  */
73428f02864SThomas Preud'homme#define DT_POSFLAG_1	0x6ffffdfd	/* Flags for DT_* entries, effecting
73528f02864SThomas Preud'homme					   the following DT_* entry.  */
73628f02864SThomas Preud'homme#define DT_SYMINSZ	0x6ffffdfe	/* Size of syminfo table (in bytes) */
73728f02864SThomas Preud'homme#define DT_SYMINENT	0x6ffffdff	/* Entry size of syminfo */
73828f02864SThomas Preud'homme#define DT_VALRNGHI	0x6ffffdff
73928f02864SThomas Preud'homme#define DT_VALTAGIDX(tag)	(DT_VALRNGHI - (tag))	/* Reverse order! */
74028f02864SThomas Preud'homme#define DT_VALNUM 12
74153196cd4Sbellard
74253196cd4Sbellard/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
74353196cd4Sbellard   Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
74453196cd4Sbellard
74553196cd4Sbellard   If any adjustment is made to the ELF object after it has been
74653196cd4Sbellard   built these entries will need to be adjusted.  */
74728f02864SThomas Preud'homme#define DT_ADDRRNGLO	0x6ffffe00
74828f02864SThomas Preud'homme#define DT_GNU_HASH	0x6ffffef5	/* GNU-style hash table.  */
74928f02864SThomas Preud'homme#define DT_TLSDESC_PLT	0x6ffffef6
75028f02864SThomas Preud'homme#define DT_TLSDESC_GOT	0x6ffffef7
75128f02864SThomas Preud'homme#define DT_GNU_CONFLICT	0x6ffffef8	/* Start of conflict section */
75228f02864SThomas Preud'homme#define DT_GNU_LIBLIST	0x6ffffef9	/* Library list */
75328f02864SThomas Preud'homme#define DT_CONFIG	0x6ffffefa	/* Configuration information.  */
75428f02864SThomas Preud'homme#define DT_DEPAUDIT	0x6ffffefb	/* Dependency auditing.  */
75528f02864SThomas Preud'homme#define DT_AUDIT	0x6ffffefc	/* Object auditing.  */
75628f02864SThomas Preud'homme#define	DT_PLTPAD	0x6ffffefd	/* PLT padding.  */
75728f02864SThomas Preud'homme#define	DT_MOVETAB	0x6ffffefe	/* Move table.  */
75828f02864SThomas Preud'homme#define DT_SYMINFO	0x6ffffeff	/* Syminfo table.  */
75928f02864SThomas Preud'homme#define DT_ADDRRNGHI	0x6ffffeff
76028f02864SThomas Preud'homme#define DT_ADDRTAGIDX(tag)	(DT_ADDRRNGHI - (tag))	/* Reverse order! */
76128f02864SThomas Preud'homme#define DT_ADDRNUM 11
76253196cd4Sbellard
76353196cd4Sbellard/* The versioning entry types.  The next are defined as part of the
76453196cd4Sbellard   GNU extension.  */
76528f02864SThomas Preud'homme#define DT_VERSYM	0x6ffffff0
76628f02864SThomas Preud'homme
76728f02864SThomas Preud'homme#define DT_RELACOUNT	0x6ffffff9
76828f02864SThomas Preud'homme#define DT_RELCOUNT	0x6ffffffa
76953196cd4Sbellard
77053196cd4Sbellard/* These were chosen by Sun.  */
77128f02864SThomas Preud'homme#define DT_FLAGS_1	0x6ffffffb	/* State flags, see DF_1_* below.  */
77228f02864SThomas Preud'homme#define	DT_VERDEF	0x6ffffffc	/* Address of version definition
77328f02864SThomas Preud'homme					   table */
77428f02864SThomas Preud'homme#define	DT_VERDEFNUM	0x6ffffffd	/* Number of version definitions */
77528f02864SThomas Preud'homme#define	DT_VERNEED	0x6ffffffe	/* Address of table with needed
77628f02864SThomas Preud'homme					   versions */
77728f02864SThomas Preud'homme#define	DT_VERNEEDNUM	0x6fffffff	/* Number of needed versions */
77828f02864SThomas Preud'homme#define DT_VERSIONTAGIDX(tag)	(DT_VERNEEDNUM - (tag))	/* Reverse order! */
77953196cd4Sbellard#define DT_VERSIONTAGNUM 16
78053196cd4Sbellard
78153196cd4Sbellard/* Sun added these machine-independent extensions in the "processor-specific"
78253196cd4Sbellard   range.  Be compatible.  */
78353196cd4Sbellard#define DT_AUXILIARY    0x7ffffffd      /* Shared object to load before self */
78453196cd4Sbellard#define DT_FILTER       0x7fffffff      /* Shared object to get values from */
78528f02864SThomas Preud'homme#define DT_EXTRATAGIDX(tag)	((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
78628f02864SThomas Preud'homme#define DT_EXTRANUM	3
78728f02864SThomas Preud'homme
78828f02864SThomas Preud'homme/* Values of `d_un.d_val' in the DT_FLAGS entry.  */
78928f02864SThomas Preud'homme#define DF_ORIGIN	0x00000001	/* Object may use DF_ORIGIN */
79028f02864SThomas Preud'homme#define DF_SYMBOLIC	0x00000002	/* Symbol resolutions starts here */
79128f02864SThomas Preud'homme#define DF_TEXTREL	0x00000004	/* Object contains text relocations */
79228f02864SThomas Preud'homme#define DF_BIND_NOW	0x00000008	/* No lazy binding for this object */
79328f02864SThomas Preud'homme#define DF_STATIC_TLS	0x00000010	/* Module uses the static TLS model */
79453196cd4Sbellard
79553196cd4Sbellard/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
79653196cd4Sbellard   entry in the dynamic section.  */
79728f02864SThomas Preud'homme#define DF_1_NOW	0x00000001	/* Set RTLD_NOW for this object.  */
79828f02864SThomas Preud'homme#define DF_1_GLOBAL	0x00000002	/* Set RTLD_GLOBAL for this object.  */
79928f02864SThomas Preud'homme#define DF_1_GROUP	0x00000004	/* Set RTLD_GROUP for this object.  */
80028f02864SThomas Preud'homme#define DF_1_NODELETE	0x00000008	/* Set RTLD_NODELETE for this object.*/
80128f02864SThomas Preud'homme#define DF_1_LOADFLTR	0x00000010	/* Trigger filtee loading at runtime.*/
80228f02864SThomas Preud'homme#define DF_1_INITFIRST	0x00000020	/* Set RTLD_INITFIRST for this object*/
80328f02864SThomas Preud'homme#define DF_1_NOOPEN	0x00000040	/* Set RTLD_NOOPEN for this object.  */
80428f02864SThomas Preud'homme#define DF_1_ORIGIN	0x00000080	/* $ORIGIN must be handled.  */
80528f02864SThomas Preud'homme#define DF_1_DIRECT	0x00000100	/* Direct binding enabled.  */
80628f02864SThomas Preud'homme#define DF_1_TRANS	0x00000200
80728f02864SThomas Preud'homme#define DF_1_INTERPOSE	0x00000400	/* Object is used to interpose.  */
80828f02864SThomas Preud'homme#define DF_1_NODEFLIB	0x00000800	/* Ignore default lib search path.  */
80928f02864SThomas Preud'homme#define DF_1_NODUMP	0x00001000	/* Object can't be dldump'ed.  */
81028f02864SThomas Preud'homme#define DF_1_CONFALT	0x00002000	/* Configuration alternative created.*/
81128f02864SThomas Preud'homme#define DF_1_ENDFILTEE	0x00004000	/* Filtee terminates filters search. */
81228f02864SThomas Preud'homme#define	DF_1_DISPRELDNE	0x00008000	/* Disp reloc applied at build time. */
81328f02864SThomas Preud'homme#define	DF_1_DISPRELPND	0x00010000	/* Disp reloc applied at run-time.  */
81428f02864SThomas Preud'homme#define	DF_1_NODIRECT	0x00020000	/* Object has no-direct binding. */
81528f02864SThomas Preud'homme#define	DF_1_IGNMULDEF	0x00040000
81628f02864SThomas Preud'homme#define	DF_1_NOKSYMS	0x00080000
81728f02864SThomas Preud'homme#define	DF_1_NOHDR	0x00100000
81828f02864SThomas Preud'homme#define	DF_1_EDITED	0x00200000	/* Object is modified after built.  */
81928f02864SThomas Preud'homme#define	DF_1_NORELOC	0x00400000
82028f02864SThomas Preud'homme#define	DF_1_SYMINTPOSE	0x00800000	/* Object has individual interposers.  */
8211b6806e5SLarry Doolittle#define	DF_1_GLOBAUDIT	0x01000000	/* Global auditing required.  */
82228f02864SThomas Preud'homme#define	DF_1_SINGLETON	0x02000000	/* Singleton symbols are used.  */
82328f02864SThomas Preud'homme
82428f02864SThomas Preud'homme/* Flags for the feature selection in DT_FEATURE_1.  */
82528f02864SThomas Preud'homme#define DTF_1_PARINIT	0x00000001
82628f02864SThomas Preud'homme#define DTF_1_CONFEXP	0x00000002
82728f02864SThomas Preud'homme
82828f02864SThomas Preud'homme/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry.  */
82928f02864SThomas Preud'homme#define DF_P1_LAZYLOAD	0x00000001	/* Lazyload following object.  */
83028f02864SThomas Preud'homme#define DF_P1_GROUPPERM	0x00000002	/* Symbols from next object are not
83128f02864SThomas Preud'homme					   generally available.  */
83253196cd4Sbellard
83353196cd4Sbellard/* Version definition sections.  */
83453196cd4Sbellard
83553196cd4Sbellardtypedef struct
83653196cd4Sbellard{
83728f02864SThomas Preud'homme  Elf32_Half	vd_version;		/* Version revision */
83828f02864SThomas Preud'homme  Elf32_Half	vd_flags;		/* Version information */
83928f02864SThomas Preud'homme  Elf32_Half	vd_ndx;			/* Version Index */
84028f02864SThomas Preud'homme  Elf32_Half	vd_cnt;			/* Number of associated aux entries */
84128f02864SThomas Preud'homme  Elf32_Word	vd_hash;		/* Version name hash value */
84228f02864SThomas Preud'homme  Elf32_Word	vd_aux;			/* Offset in bytes to verdaux array */
84328f02864SThomas Preud'homme  Elf32_Word	vd_next;		/* Offset in bytes to next verdef
84428f02864SThomas Preud'homme					   entry */
84553196cd4Sbellard} Elf32_Verdef;
84653196cd4Sbellard
84753196cd4Sbellardtypedef struct
84853196cd4Sbellard{
84928f02864SThomas Preud'homme  Elf64_Half	vd_version;		/* Version revision */
85028f02864SThomas Preud'homme  Elf64_Half	vd_flags;		/* Version information */
85128f02864SThomas Preud'homme  Elf64_Half	vd_ndx;			/* Version Index */
85228f02864SThomas Preud'homme  Elf64_Half	vd_cnt;			/* Number of associated aux entries */
85328f02864SThomas Preud'homme  Elf64_Word	vd_hash;		/* Version name hash value */
85428f02864SThomas Preud'homme  Elf64_Word	vd_aux;			/* Offset in bytes to verdaux array */
85528f02864SThomas Preud'homme  Elf64_Word	vd_next;		/* Offset in bytes to next verdef
85628f02864SThomas Preud'homme					   entry */
85753196cd4Sbellard} Elf64_Verdef;
85853196cd4Sbellard
85953196cd4Sbellard
86053196cd4Sbellard/* Legal values for vd_version (version revision).  */
86128f02864SThomas Preud'homme#define VER_DEF_NONE	0		/* No version */
86228f02864SThomas Preud'homme#define VER_DEF_CURRENT	1		/* Current version */
86328f02864SThomas Preud'homme#define VER_DEF_NUM	2		/* Given version number */
86453196cd4Sbellard
86553196cd4Sbellard/* Legal values for vd_flags (version information flags).  */
86628f02864SThomas Preud'homme#define VER_FLG_BASE	0x1		/* Version definition of file itself */
86728f02864SThomas Preud'homme#define VER_FLG_WEAK	0x2		/* Weak version identifier */
86828f02864SThomas Preud'homme
86928f02864SThomas Preud'homme/* Versym symbol index values.  */
87028f02864SThomas Preud'homme#define	VER_NDX_LOCAL		0	/* Symbol is local.  */
87128f02864SThomas Preud'homme#define	VER_NDX_GLOBAL		1	/* Symbol is global.  */
87228f02864SThomas Preud'homme#define	VER_NDX_LORESERVE	0xff00	/* Beginning of reserved entries.  */
87328f02864SThomas Preud'homme#define	VER_NDX_ELIMINATE	0xff01	/* Symbol is to be eliminated.  */
87453196cd4Sbellard
87519d8b8a1SLarry Doolittle/* Auxiliary version information.  */
87653196cd4Sbellard
87753196cd4Sbellardtypedef struct
87853196cd4Sbellard{
87928f02864SThomas Preud'homme  Elf32_Word	vda_name;		/* Version or dependency names */
88028f02864SThomas Preud'homme  Elf32_Word	vda_next;		/* Offset in bytes to next verdaux
88128f02864SThomas Preud'homme					   entry */
88253196cd4Sbellard} Elf32_Verdaux;
88353196cd4Sbellard
88453196cd4Sbellardtypedef struct
88553196cd4Sbellard{
88628f02864SThomas Preud'homme  Elf64_Word	vda_name;		/* Version or dependency names */
88728f02864SThomas Preud'homme  Elf64_Word	vda_next;		/* Offset in bytes to next verdaux
88828f02864SThomas Preud'homme					   entry */
88953196cd4Sbellard} Elf64_Verdaux;
89053196cd4Sbellard
89153196cd4Sbellard
89253196cd4Sbellard/* Version dependency section.  */
89353196cd4Sbellard
89453196cd4Sbellardtypedef struct
89553196cd4Sbellard{
89628f02864SThomas Preud'homme  Elf32_Half	vn_version;		/* Version of structure */
89728f02864SThomas Preud'homme  Elf32_Half	vn_cnt;			/* Number of associated aux entries */
89828f02864SThomas Preud'homme  Elf32_Word	vn_file;		/* Offset of filename for this
89928f02864SThomas Preud'homme					   dependency */
90028f02864SThomas Preud'homme  Elf32_Word	vn_aux;			/* Offset in bytes to vernaux array */
90128f02864SThomas Preud'homme  Elf32_Word	vn_next;		/* Offset in bytes to next verneed
90228f02864SThomas Preud'homme					   entry */
90353196cd4Sbellard} Elf32_Verneed;
90453196cd4Sbellard
90553196cd4Sbellardtypedef struct
90653196cd4Sbellard{
90728f02864SThomas Preud'homme  Elf64_Half	vn_version;		/* Version of structure */
90828f02864SThomas Preud'homme  Elf64_Half	vn_cnt;			/* Number of associated aux entries */
90928f02864SThomas Preud'homme  Elf64_Word	vn_file;		/* Offset of filename for this
91028f02864SThomas Preud'homme					   dependency */
91128f02864SThomas Preud'homme  Elf64_Word	vn_aux;			/* Offset in bytes to vernaux array */
91228f02864SThomas Preud'homme  Elf64_Word	vn_next;		/* Offset in bytes to next verneed
91328f02864SThomas Preud'homme					   entry */
91453196cd4Sbellard} Elf64_Verneed;
91553196cd4Sbellard
91653196cd4Sbellard
91753196cd4Sbellard/* Legal values for vn_version (version revision).  */
91828f02864SThomas Preud'homme#define VER_NEED_NONE	 0		/* No version */
91928f02864SThomas Preud'homme#define VER_NEED_CURRENT 1		/* Current version */
92028f02864SThomas Preud'homme#define VER_NEED_NUM	 2		/* Given version number */
92153196cd4Sbellard
92253196cd4Sbellard/* Auxiliary needed version information.  */
92353196cd4Sbellard
92453196cd4Sbellardtypedef struct
92553196cd4Sbellard{
92628f02864SThomas Preud'homme  Elf32_Word	vna_hash;		/* Hash value of dependency name */
92728f02864SThomas Preud'homme  Elf32_Half	vna_flags;		/* Dependency specific information */
92828f02864SThomas Preud'homme  Elf32_Half	vna_other;		/* Unused */
92928f02864SThomas Preud'homme  Elf32_Word	vna_name;		/* Dependency name string offset */
93028f02864SThomas Preud'homme  Elf32_Word	vna_next;		/* Offset in bytes to next vernaux
93128f02864SThomas Preud'homme					   entry */
93253196cd4Sbellard} Elf32_Vernaux;
93353196cd4Sbellard
93453196cd4Sbellardtypedef struct
93553196cd4Sbellard{
93628f02864SThomas Preud'homme  Elf64_Word	vna_hash;		/* Hash value of dependency name */
93728f02864SThomas Preud'homme  Elf64_Half	vna_flags;		/* Dependency specific information */
93828f02864SThomas Preud'homme  Elf64_Half	vna_other;		/* Unused */
93928f02864SThomas Preud'homme  Elf64_Word	vna_name;		/* Dependency name string offset */
94028f02864SThomas Preud'homme  Elf64_Word	vna_next;		/* Offset in bytes to next vernaux
94128f02864SThomas Preud'homme					   entry */
94253196cd4Sbellard} Elf64_Vernaux;
94353196cd4Sbellard
94453196cd4Sbellard
94553196cd4Sbellard/* Legal values for vna_flags.  */
94628f02864SThomas Preud'homme#define VER_FLG_WEAK	0x2		/* Weak version identifier */
94753196cd4Sbellard
94853196cd4Sbellard
94953196cd4Sbellard/* Auxiliary vector.  */
95053196cd4Sbellard
95153196cd4Sbellard/* This vector is normally only used by the program interpreter.  The
95253196cd4Sbellard   usual definition in an ABI supplement uses the name auxv_t.  The
95353196cd4Sbellard   vector is not usually defined in a standard <elf.h> file, but it
95453196cd4Sbellard   can't hurt.  We rename it to avoid conflicts.  The sizes of these
95553196cd4Sbellard   types are an arrangement between the exec server and the program
95653196cd4Sbellard   interpreter, so we don't fully specify them here.  */
95753196cd4Sbellard
95853196cd4Sbellardtypedef struct
95953196cd4Sbellard{
96028f02864SThomas Preud'homme  uint32_t a_type;		/* Entry type */
96153196cd4Sbellard  union
96253196cd4Sbellard    {
96328f02864SThomas Preud'homme      uint32_t a_val;		/* Integer value */
96428f02864SThomas Preud'homme      /* We use to have pointer elements added here.  We cannot do that,
96528f02864SThomas Preud'homme	 though, since it does not work when using 32-bit definitions
96628f02864SThomas Preud'homme	 on 64-bit platforms and vice versa.  */
96753196cd4Sbellard    } a_un;
96853196cd4Sbellard} Elf32_auxv_t;
96953196cd4Sbellard
97053196cd4Sbellardtypedef struct
97153196cd4Sbellard{
97228f02864SThomas Preud'homme  uint64_t a_type;		/* Entry type */
97353196cd4Sbellard  union
97453196cd4Sbellard    {
97528f02864SThomas Preud'homme      uint64_t a_val;		/* Integer value */
97628f02864SThomas Preud'homme      /* We use to have pointer elements added here.  We cannot do that,
97728f02864SThomas Preud'homme	 though, since it does not work when using 32-bit definitions
97828f02864SThomas Preud'homme	 on 64-bit platforms and vice versa.  */
97953196cd4Sbellard    } a_un;
98053196cd4Sbellard} Elf64_auxv_t;
98153196cd4Sbellard
98253196cd4Sbellard/* Legal values for a_type (entry type).  */
98353196cd4Sbellard
98428f02864SThomas Preud'homme#define AT_NULL		0		/* End of vector */
98528f02864SThomas Preud'homme#define AT_IGNORE	1		/* Entry should be ignored */
98628f02864SThomas Preud'homme#define AT_EXECFD	2		/* File descriptor of program */
98728f02864SThomas Preud'homme#define AT_PHDR		3		/* Program headers for program */
98828f02864SThomas Preud'homme#define AT_PHENT	4		/* Size of program header entry */
98928f02864SThomas Preud'homme#define AT_PHNUM	5		/* Number of program headers */
99028f02864SThomas Preud'homme#define AT_PAGESZ	6		/* System page size */
99128f02864SThomas Preud'homme#define AT_BASE		7		/* Base address of interpreter */
99228f02864SThomas Preud'homme#define AT_FLAGS	8		/* Flags */
99328f02864SThomas Preud'homme#define AT_ENTRY	9		/* Entry point of program */
99428f02864SThomas Preud'homme#define AT_NOTELF	10		/* Program is not ELF */
99528f02864SThomas Preud'homme#define AT_UID		11		/* Real uid */
99628f02864SThomas Preud'homme#define AT_EUID		12		/* Effective uid */
99728f02864SThomas Preud'homme#define AT_GID		13		/* Real gid */
99828f02864SThomas Preud'homme#define AT_EGID		14		/* Effective gid */
99928f02864SThomas Preud'homme#define AT_CLKTCK	17		/* Frequency of times() */
100053196cd4Sbellard
100153196cd4Sbellard/* Some more special a_type values describing the hardware.  */
100228f02864SThomas Preud'homme#define AT_PLATFORM	15		/* String identifying platform.  */
100328f02864SThomas Preud'homme#define AT_HWCAP	16		/* Machine dependent hints about
100428f02864SThomas Preud'homme					   processor capabilities.  */
100553196cd4Sbellard
100653196cd4Sbellard/* This entry gives some information about the FPU initialization
100753196cd4Sbellard   performed by the kernel.  */
100828f02864SThomas Preud'homme#define AT_FPUCW	18		/* Used FPU control word.  */
100928f02864SThomas Preud'homme
101028f02864SThomas Preud'homme/* Cache block sizes.  */
101128f02864SThomas Preud'homme#define AT_DCACHEBSIZE	19		/* Data cache block size.  */
101228f02864SThomas Preud'homme#define AT_ICACHEBSIZE	20		/* Instruction cache block size.  */
101328f02864SThomas Preud'homme#define AT_UCACHEBSIZE	21		/* Unified cache block size.  */
101453196cd4Sbellard
101528f02864SThomas Preud'homme/* A special ignored value for PPC, used by the kernel to control the
101628f02864SThomas Preud'homme   interpretation of the AUXV. Must be > 16.  */
101728f02864SThomas Preud'homme#define AT_IGNOREPPC	22		/* Entry should be ignored.  */
101828f02864SThomas Preud'homme
101928f02864SThomas Preud'homme#define	AT_SECURE	23		/* Boolean, was exec setuid-like?  */
102028f02864SThomas Preud'homme
102128f02864SThomas Preud'homme#define AT_BASE_PLATFORM 24		/* String identifying real platforms.*/
102228f02864SThomas Preud'homme
102328f02864SThomas Preud'homme#define AT_RANDOM	25		/* Address of 16 random bytes.  */
102428f02864SThomas Preud'homme
102528f02864SThomas Preud'homme#define AT_EXECFN	31		/* Filename of executable.  */
102628f02864SThomas Preud'homme
102728f02864SThomas Preud'homme/* Pointer to the global system page used for system calls and other
102828f02864SThomas Preud'homme   nice things.  */
102928f02864SThomas Preud'homme#define AT_SYSINFO	32
103028f02864SThomas Preud'homme#define AT_SYSINFO_EHDR	33
103128f02864SThomas Preud'homme
103228f02864SThomas Preud'homme/* Shapes of the caches.  Bits 0-3 contains associativity; bits 4-7 contains
103328f02864SThomas Preud'homme   log2 of line size; mask those to get cache size.  */
103428f02864SThomas Preud'homme#define AT_L1I_CACHESHAPE	34
103528f02864SThomas Preud'homme#define AT_L1D_CACHESHAPE	35
103628f02864SThomas Preud'homme#define AT_L2_CACHESHAPE	36
103728f02864SThomas Preud'homme#define AT_L3_CACHESHAPE	37
103853196cd4Sbellard
103953196cd4Sbellard/* Note section contents.  Each entry in the note section begins with
104053196cd4Sbellard   a header of a fixed form.  */
104153196cd4Sbellard
104253196cd4Sbellardtypedef struct
104353196cd4Sbellard{
104428f02864SThomas Preud'homme  Elf32_Word n_namesz;			/* Length of the note's name.  */
104528f02864SThomas Preud'homme  Elf32_Word n_descsz;			/* Length of the note's descriptor.  */
104628f02864SThomas Preud'homme  Elf32_Word n_type;			/* Type of the note.  */
104753196cd4Sbellard} Elf32_Nhdr;
104853196cd4Sbellard
104953196cd4Sbellardtypedef struct
105053196cd4Sbellard{
105128f02864SThomas Preud'homme  Elf64_Word n_namesz;			/* Length of the note's name.  */
105228f02864SThomas Preud'homme  Elf64_Word n_descsz;			/* Length of the note's descriptor.  */
105328f02864SThomas Preud'homme  Elf64_Word n_type;			/* Type of the note.  */
105453196cd4Sbellard} Elf64_Nhdr;
105553196cd4Sbellard
105653196cd4Sbellard/* Known names of notes.  */
105753196cd4Sbellard
105853196cd4Sbellard/* Solaris entries in the note section have this name.  */
105928f02864SThomas Preud'homme#define ELF_NOTE_SOLARIS	"SUNW Solaris"
106053196cd4Sbellard
106153196cd4Sbellard/* Note entries for GNU systems have this name.  */
106228f02864SThomas Preud'homme#define ELF_NOTE_GNU		"GNU"
106353196cd4Sbellard
106453196cd4Sbellard
106553196cd4Sbellard/* Defined types of notes for Solaris.  */
106653196cd4Sbellard
106753196cd4Sbellard/* Value of descriptor (one word) is desired pagesize for the binary.  */
106828f02864SThomas Preud'homme#define ELF_NOTE_PAGESIZE_HINT	1
106953196cd4Sbellard
107053196cd4Sbellard
107153196cd4Sbellard/* Defined note types for GNU systems.  */
107253196cd4Sbellard
107353196cd4Sbellard/* ABI information.  The descriptor consists of words:
107453196cd4Sbellard   word 0: OS descriptor
107553196cd4Sbellard   word 1: major version of the ABI
107653196cd4Sbellard   word 2: minor version of the ABI
107753196cd4Sbellard   word 3: subminor version of the ABI
107853196cd4Sbellard*/
107928f02864SThomas Preud'homme#define NT_GNU_ABI_TAG	1
108028f02864SThomas Preud'homme#define ELF_NOTE_ABI	NT_GNU_ABI_TAG /* Old name.  */
108128f02864SThomas Preud'homme
108228f02864SThomas Preud'homme/* Known OSes.  These values can appear in word 0 of an
108328f02864SThomas Preud'homme   NT_GNU_ABI_TAG note section entry.  */
108428f02864SThomas Preud'homme#define ELF_NOTE_OS_LINUX	0
108528f02864SThomas Preud'homme#define ELF_NOTE_OS_GNU		1
108628f02864SThomas Preud'homme#define ELF_NOTE_OS_SOLARIS2	2
108728f02864SThomas Preud'homme#define ELF_NOTE_OS_FREEBSD	3
108828f02864SThomas Preud'homme
108928f02864SThomas Preud'homme/* Synthetic hwcap information.  The descriptor begins with two words:
109028f02864SThomas Preud'homme   word 0: number of entries
109128f02864SThomas Preud'homme   word 1: bitmask of enabled entries
109228f02864SThomas Preud'homme   Then follow variable-length entries, one byte followed by a
109328f02864SThomas Preud'homme   '\0'-terminated hwcap name string.  The byte gives the bit
109428f02864SThomas Preud'homme   number to test if enabled, (1U << bit) & bitmask.  */
109528f02864SThomas Preud'homme#define NT_GNU_HWCAP	2
109653196cd4Sbellard
109728f02864SThomas Preud'homme/* Build ID bits as generated by ld --build-id.
109828f02864SThomas Preud'homme   The descriptor consists of any nonzero number of bytes.  */
109928f02864SThomas Preud'homme#define NT_GNU_BUILD_ID	3
110028f02864SThomas Preud'homme
110128f02864SThomas Preud'homme/* Version note generated by GNU gold containing a version string.  */
110228f02864SThomas Preud'homme#define NT_GNU_GOLD_VERSION	4
110328f02864SThomas Preud'homme
110428f02864SThomas Preud'homme
110528f02864SThomas Preud'homme/* Move records.  */
110628f02864SThomas Preud'hommetypedef struct
110728f02864SThomas Preud'homme{
110828f02864SThomas Preud'homme  Elf32_Xword m_value;		/* Symbol value.  */
110928f02864SThomas Preud'homme  Elf32_Word m_info;		/* Size and index.  */
111028f02864SThomas Preud'homme  Elf32_Word m_poffset;		/* Symbol offset.  */
111128f02864SThomas Preud'homme  Elf32_Half m_repeat;		/* Repeat count.  */
111228f02864SThomas Preud'homme  Elf32_Half m_stride;		/* Stride info.  */
111328f02864SThomas Preud'homme} Elf32_Move;
111428f02864SThomas Preud'homme
111528f02864SThomas Preud'hommetypedef struct
111628f02864SThomas Preud'homme{
111728f02864SThomas Preud'homme  Elf64_Xword m_value;		/* Symbol value.  */
111828f02864SThomas Preud'homme  Elf64_Xword m_info;		/* Size and index.  */
111928f02864SThomas Preud'homme  Elf64_Xword m_poffset;	/* Symbol offset.  */
112028f02864SThomas Preud'homme  Elf64_Half m_repeat;		/* Repeat count.  */
112128f02864SThomas Preud'homme  Elf64_Half m_stride;		/* Stride info.  */
112228f02864SThomas Preud'homme} Elf64_Move;
112328f02864SThomas Preud'homme
112428f02864SThomas Preud'homme/* Macro to construct move records.  */
112528f02864SThomas Preud'homme#define ELF32_M_SYM(info)	((info) >> 8)
112628f02864SThomas Preud'homme#define ELF32_M_SIZE(info)	((unsigned char) (info))
112728f02864SThomas Preud'homme#define ELF32_M_INFO(sym, size)	(((sym) << 8) + (unsigned char) (size))
112828f02864SThomas Preud'homme
112928f02864SThomas Preud'homme#define ELF64_M_SYM(info)	ELF32_M_SYM (info)
113028f02864SThomas Preud'homme#define ELF64_M_SIZE(info)	ELF32_M_SIZE (info)
113128f02864SThomas Preud'homme#define ELF64_M_INFO(sym, size)	ELF32_M_INFO (sym, size)
113253196cd4Sbellard
113353196cd4Sbellard
113453196cd4Sbellard/* Motorola 68k specific definitions.  */
113553196cd4Sbellard
113628f02864SThomas Preud'homme/* Values for Elf32_Ehdr.e_flags.  */
113728f02864SThomas Preud'homme#define EF_CPU32	0x00810000
113828f02864SThomas Preud'homme
113953196cd4Sbellard/* m68k relocs.  */
114053196cd4Sbellard
114128f02864SThomas Preud'homme#define R_68K_NONE	0		/* No reloc */
114228f02864SThomas Preud'homme#define R_68K_32	1		/* Direct 32 bit  */
114328f02864SThomas Preud'homme#define R_68K_16	2		/* Direct 16 bit  */
114428f02864SThomas Preud'homme#define R_68K_8		3		/* Direct 8 bit  */
114528f02864SThomas Preud'homme#define R_68K_PC32	4		/* PC relative 32 bit */
114628f02864SThomas Preud'homme#define R_68K_PC16	5		/* PC relative 16 bit */
114728f02864SThomas Preud'homme#define R_68K_PC8	6		/* PC relative 8 bit */
114828f02864SThomas Preud'homme#define R_68K_GOT32	7		/* 32 bit PC relative GOT entry */
114928f02864SThomas Preud'homme#define R_68K_GOT16	8		/* 16 bit PC relative GOT entry */
115028f02864SThomas Preud'homme#define R_68K_GOT8	9		/* 8 bit PC relative GOT entry */
115128f02864SThomas Preud'homme#define R_68K_GOT32O	10		/* 32 bit GOT offset */
115228f02864SThomas Preud'homme#define R_68K_GOT16O	11		/* 16 bit GOT offset */
115328f02864SThomas Preud'homme#define R_68K_GOT8O	12		/* 8 bit GOT offset */
115428f02864SThomas Preud'homme#define R_68K_PLT32	13		/* 32 bit PC relative PLT address */
115528f02864SThomas Preud'homme#define R_68K_PLT16	14		/* 16 bit PC relative PLT address */
115628f02864SThomas Preud'homme#define R_68K_PLT8	15		/* 8 bit PC relative PLT address */
115728f02864SThomas Preud'homme#define R_68K_PLT32O	16		/* 32 bit PLT offset */
115828f02864SThomas Preud'homme#define R_68K_PLT16O	17		/* 16 bit PLT offset */
115928f02864SThomas Preud'homme#define R_68K_PLT8O	18		/* 8 bit PLT offset */
116028f02864SThomas Preud'homme#define R_68K_COPY	19		/* Copy symbol at runtime */
116128f02864SThomas Preud'homme#define R_68K_GLOB_DAT	20		/* Create GOT entry */
116228f02864SThomas Preud'homme#define R_68K_JMP_SLOT	21		/* Create PLT entry */
116328f02864SThomas Preud'homme#define R_68K_RELATIVE	22		/* Adjust by program base */
116428f02864SThomas Preud'homme#define R_68K_TLS_GD32      25          /* 32 bit GOT offset for GD */
116528f02864SThomas Preud'homme#define R_68K_TLS_GD16      26          /* 16 bit GOT offset for GD */
116628f02864SThomas Preud'homme#define R_68K_TLS_GD8       27          /* 8 bit GOT offset for GD */
116728f02864SThomas Preud'homme#define R_68K_TLS_LDM32     28          /* 32 bit GOT offset for LDM */
116828f02864SThomas Preud'homme#define R_68K_TLS_LDM16     29          /* 16 bit GOT offset for LDM */
116928f02864SThomas Preud'homme#define R_68K_TLS_LDM8      30          /* 8 bit GOT offset for LDM */
117028f02864SThomas Preud'homme#define R_68K_TLS_LDO32     31          /* 32 bit module-relative offset */
117128f02864SThomas Preud'homme#define R_68K_TLS_LDO16     32          /* 16 bit module-relative offset */
117228f02864SThomas Preud'homme#define R_68K_TLS_LDO8      33          /* 8 bit module-relative offset */
117328f02864SThomas Preud'homme#define R_68K_TLS_IE32      34          /* 32 bit GOT offset for IE */
117428f02864SThomas Preud'homme#define R_68K_TLS_IE16      35          /* 16 bit GOT offset for IE */
117528f02864