125b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* This file defines standard ELF types, structures, and macros.
225b3c049e70834cf33790a28643ab058b507b35cBen Cheng   Copyright (C) 1995-2003,2004,2005,2006,2007,2008,2009,2010
325b3c049e70834cf33790a28643ab058b507b35cBen Cheng	Free Software Foundation, Inc.
425b3c049e70834cf33790a28643ab058b507b35cBen Cheng   This file is part of the GNU C Library.
525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
625b3c049e70834cf33790a28643ab058b507b35cBen Cheng   The GNU C Library is free software; you can redistribute it and/or
725b3c049e70834cf33790a28643ab058b507b35cBen Cheng   modify it under the terms of the GNU Lesser General Public
825b3c049e70834cf33790a28643ab058b507b35cBen Cheng   License as published by the Free Software Foundation; either
925b3c049e70834cf33790a28643ab058b507b35cBen Cheng   version 2.1 of the License, or (at your option) any later version.
1025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
1125b3c049e70834cf33790a28643ab058b507b35cBen Cheng   The GNU C Library is distributed in the hope that it will be useful,
1225b3c049e70834cf33790a28643ab058b507b35cBen Cheng   but WITHOUT ANY WARRANTY; without even the implied warranty of
1325b3c049e70834cf33790a28643ab058b507b35cBen Cheng   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1425b3c049e70834cf33790a28643ab058b507b35cBen Cheng   Lesser General Public License for more details.
1525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
1625b3c049e70834cf33790a28643ab058b507b35cBen Cheng   You should have received a copy of the GNU Lesser General Public
1725b3c049e70834cf33790a28643ab058b507b35cBen Cheng   License along with the GNU C Library; if not, write to the Free
1825b3c049e70834cf33790a28643ab058b507b35cBen Cheng   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1925b3c049e70834cf33790a28643ab058b507b35cBen Cheng   02111-1307 USA.  */
2025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
2125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#ifndef _ELF_H
2225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	_ELF_H 1
2325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
24cd981789b391a786af52d66854a4a1650709889cBen Cheng#ifndef __APPLE__
2525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#include <features.h>
26cd981789b391a786af52d66854a4a1650709889cBen Cheng#endif
2725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
2825b3c049e70834cf33790a28643ab058b507b35cBen Cheng__BEGIN_DECLS
2925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
3025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Standard ELF types.  */
3125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
3225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#include <stdint.h>
3325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
3425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Type for a 16-bit quantity.  */
3525b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef uint16_t Elf32_Half;
3625b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef uint16_t Elf64_Half;
3725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
3825b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Types for signed and unsigned 32-bit quantities.  */
3925b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef uint32_t Elf32_Word;
4025b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef	int32_t  Elf32_Sword;
4125b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef uint32_t Elf64_Word;
4225b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef	int32_t  Elf64_Sword;
4325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
4425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Types for signed and unsigned 64-bit quantities.  */
4525b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef uint64_t Elf32_Xword;
4625b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef	int64_t  Elf32_Sxword;
4725b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef uint64_t Elf64_Xword;
4825b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef	int64_t  Elf64_Sxword;
4925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
5025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Type of addresses.  */
5125b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef uint32_t Elf32_Addr;
5225b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef uint64_t Elf64_Addr;
5325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
5425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Type of file offsets.  */
5525b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef uint32_t Elf32_Off;
5625b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef uint64_t Elf64_Off;
5725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
5825b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Type for section indices, which are 16-bit quantities.  */
5925b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef uint16_t Elf32_Section;
6025b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef uint16_t Elf64_Section;
6125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
6225b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Type for version symbol information.  */
6325b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef Elf32_Half Elf32_Versym;
6425b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef Elf64_Half Elf64_Versym;
6525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
6625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
6725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* The ELF file header.  This appears at the start of every ELF file.  */
6825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
6925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EI_NIDENT (16)
7025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
7125b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
7225b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
7325b3c049e70834cf33790a28643ab058b507b35cBen Cheng  unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
7425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	e_type;			/* Object file type */
7525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	e_machine;		/* Architecture */
7625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	e_version;		/* Object file version */
7725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Addr	e_entry;		/* Entry point virtual address */
7825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Off	e_phoff;		/* Program header table file offset */
7925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Off	e_shoff;		/* Section header table file offset */
8025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	e_flags;		/* Processor-specific flags */
8125b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	e_ehsize;		/* ELF header size in bytes */
8225b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	e_phentsize;		/* Program header table entry size */
8325b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	e_phnum;		/* Program header table entry count */
8425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	e_shentsize;		/* Section header table entry size */
8525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	e_shnum;		/* Section header table entry count */
8625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	e_shstrndx;		/* Section header string table index */
8725b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Ehdr;
8825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
8925b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
9025b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
9125b3c049e70834cf33790a28643ab058b507b35cBen Cheng  unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
9225b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	e_type;			/* Object file type */
9325b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	e_machine;		/* Architecture */
9425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	e_version;		/* Object file version */
9525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Addr	e_entry;		/* Entry point virtual address */
9625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Off	e_phoff;		/* Program header table file offset */
9725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Off	e_shoff;		/* Section header table file offset */
9825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	e_flags;		/* Processor-specific flags */
9925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	e_ehsize;		/* ELF header size in bytes */
10025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	e_phentsize;		/* Program header table entry size */
10125b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	e_phnum;		/* Program header table entry count */
10225b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	e_shentsize;		/* Section header table entry size */
10325b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	e_shnum;		/* Section header table entry count */
10425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	e_shstrndx;		/* Section header string table index */
10525b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Ehdr;
10625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
10725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Fields in the e_ident array.  The EI_* macros are indices into the
10825b3c049e70834cf33790a28643ab058b507b35cBen Cheng   array.  The macros under each EI_* macro are the values the byte
10925b3c049e70834cf33790a28643ab058b507b35cBen Cheng   may have.  */
11025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
11125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EI_MAG0		0		/* File identification byte 0 index */
11225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFMAG0		0x7f		/* Magic number byte 0 */
11325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
11425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EI_MAG1		1		/* File identification byte 1 index */
11525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFMAG1		'E'		/* Magic number byte 1 */
11625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
11725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EI_MAG2		2		/* File identification byte 2 index */
11825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFMAG2		'L'		/* Magic number byte 2 */
11925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
12025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EI_MAG3		3		/* File identification byte 3 index */
12125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFMAG3		'F'		/* Magic number byte 3 */
12225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
12325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Conglomeration of the identification bytes, for easy testing as a word.  */
12425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	ELFMAG		"\177ELF"
12525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	SELFMAG		4
12625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
12725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EI_CLASS	4		/* File class byte index */
12825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFCLASSNONE	0		/* Invalid class */
12925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFCLASS32	1		/* 32-bit objects */
13025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFCLASS64	2		/* 64-bit objects */
13125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFCLASSNUM	3
13225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
13325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EI_DATA		5		/* Data encoding byte index */
13425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFDATANONE	0		/* Invalid data encoding */
13525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFDATA2LSB	1		/* 2's complement, little endian */
13625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFDATA2MSB	2		/* 2's complement, big endian */
13725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFDATANUM	3
13825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
13925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EI_VERSION	6		/* File version byte index */
14025b3c049e70834cf33790a28643ab058b507b35cBen Cheng					/* Value must be EV_CURRENT */
14125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
14225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EI_OSABI	7		/* OS ABI identification */
14325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_NONE		0	/* UNIX System V ABI */
14425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_SYSV		0	/* Alias.  */
14525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_HPUX		1	/* HP-UX */
14625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_NETBSD		2	/* NetBSD.  */
14725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_LINUX		3	/* Linux.  */
14825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_SOLARIS	6	/* Sun Solaris.  */
14925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_AIX		7	/* IBM AIX.  */
15025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_IRIX		8	/* SGI Irix.  */
15125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_FREEBSD	9	/* FreeBSD.  */
15225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_TRU64		10	/* Compaq TRU64 UNIX.  */
15325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_MODESTO	11	/* Novell Modesto.  */
15425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_OPENBSD	12	/* OpenBSD.  */
15525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_ARM_AEABI	64	/* ARM EABI */
15625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_ARM		97	/* ARM */
15725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELFOSABI_STANDALONE	255	/* Standalone (embedded) application */
15825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
15925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EI_ABIVERSION	8		/* ABI version */
16025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
16125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EI_PAD		9		/* Byte index of padding bytes */
16225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
16325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for e_type (object file type).  */
16425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
16525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ET_NONE		0		/* No file type */
16625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ET_REL		1		/* Relocatable file */
16725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ET_EXEC		2		/* Executable file */
16825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ET_DYN		3		/* Shared object file */
16925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ET_CORE		4		/* Core file */
17025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	ET_NUM		5		/* Number of defined types */
17125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ET_LOOS		0xfe00		/* OS-specific range start */
17225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ET_HIOS		0xfeff		/* OS-specific range end */
17325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ET_LOPROC	0xff00		/* Processor-specific range start */
17425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ET_HIPROC	0xffff		/* Processor-specific range end */
17525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
17625b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for e_machine (architecture).  */
17725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
17825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_NONE		 0		/* No machine */
17925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_M32		 1		/* AT&T WE 32100 */
18025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_SPARC	 2		/* SUN SPARC */
18125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_386		 3		/* Intel 80386 */
18225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_68K		 4		/* Motorola m68k family */
18325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_88K		 5		/* Motorola m88k family */
18425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_860		 7		/* Intel 80860 */
18525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_MIPS		 8		/* MIPS R3000 big-endian */
18625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_S370		 9		/* IBM System/370 */
18725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_MIPS_RS3_LE	10		/* MIPS R3000 little-endian */
18825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
18925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_PARISC	15		/* HPPA */
19025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_VPP500	17		/* Fujitsu VPP500 */
19125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_SPARC32PLUS	18		/* Sun's "v8plus" */
19225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_960		19		/* Intel 80960 */
19325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_PPC		20		/* PowerPC */
19425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_PPC64	21		/* PowerPC 64-bit */
19525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_S390		22		/* IBM S390 */
19625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
19725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_V800		36		/* NEC V800 series */
19825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_FR20		37		/* Fujitsu FR20 */
19925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_RH32		38		/* TRW RH-32 */
20025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_RCE		39		/* Motorola RCE */
20125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_ARM		40		/* ARM */
20225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_FAKE_ALPHA	41		/* Digital Alpha */
20325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_SH		42		/* Hitachi SH */
20425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_SPARCV9	43		/* SPARC v9 64-bit */
20525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_TRICORE	44		/* Siemens Tricore */
20625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_ARC		45		/* Argonaut RISC Core */
20725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_H8_300	46		/* Hitachi H8/300 */
20825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_H8_300H	47		/* Hitachi H8/300H */
20925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_H8S		48		/* Hitachi H8S */
21025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_H8_500	49		/* Hitachi H8/500 */
21125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_IA_64	50		/* Intel Merced */
21225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_MIPS_X	51		/* Stanford MIPS-X */
21325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_COLDFIRE	52		/* Motorola Coldfire */
21425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_68HC12	53		/* Motorola M68HC12 */
21525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_MMA		54		/* Fujitsu MMA Multimedia Accelerator*/
21625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_PCP		55		/* Siemens PCP */
21725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_NCPU		56		/* Sony nCPU embeeded RISC */
21825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_NDR1		57		/* Denso NDR1 microprocessor */
21925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_STARCORE	58		/* Motorola Start*Core processor */
22025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_ME16		59		/* Toyota ME16 processor */
22125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_ST100	60		/* STMicroelectronic ST100 processor */
22225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_TINYJ	61		/* Advanced Logic Corp. Tinyj emb.fam*/
22325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_X86_64	62		/* AMD x86-64 architecture */
22425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_PDSP		63		/* Sony DSP Processor */
22525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
22625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_FX66		66		/* Siemens FX66 microcontroller */
22725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_ST9PLUS	67		/* STMicroelectronics ST9+ 8/16 mc */
22825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_ST7		68		/* STmicroelectronics ST7 8 bit mc */
22925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_68HC16	69		/* Motorola MC68HC16 microcontroller */
23025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_68HC11	70		/* Motorola MC68HC11 microcontroller */
23125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_68HC08	71		/* Motorola MC68HC08 microcontroller */
23225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_68HC05	72		/* Motorola MC68HC05 microcontroller */
23325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_SVX		73		/* Silicon Graphics SVx */
23425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_ST19		74		/* STMicroelectronics ST19 8 bit mc */
23525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_VAX		75		/* Digital VAX */
23625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_CRIS		76		/* Axis Communications 32-bit embedded processor */
23725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_JAVELIN	77		/* Infineon Technologies 32-bit embedded processor */
23825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_FIREPATH	78		/* Element 14 64-bit DSP Processor */
23925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_ZSP		79		/* LSI Logic 16-bit DSP Processor */
24025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_MMIX		80		/* Donald Knuth's educational 64-bit processor */
24125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_HUANY	81		/* Harvard University machine-independent object files */
24225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_PRISM	82		/* SiTera Prism */
24325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_AVR		83		/* Atmel AVR 8-bit microcontroller */
24425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_FR30		84		/* Fujitsu FR30 */
24525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_D10V		85		/* Mitsubishi D10V */
24625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_D30V		86		/* Mitsubishi D30V */
24725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_V850		87		/* NEC v850 */
24825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_M32R		88		/* Mitsubishi M32R */
24925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_MN10300	89		/* Matsushita MN10300 */
25025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_MN10200	90		/* Matsushita MN10200 */
25125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_PJ		91		/* picoJava */
25225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_OPENRISC	92		/* OpenRISC 32-bit embedded processor */
25325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_ARC_A5	93		/* ARC Cores Tangent-A5 */
25425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_XTENSA	94		/* Tensilica Xtensa Architecture */
25525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_NUM		95
25625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
2575ed9caeeaedc12e756d8779073bce6f5db06574fMohamad Ayyash#define EM_AARCH64	183		/* ARM 64-bit */
2585ed9caeeaedc12e756d8779073bce6f5db06574fMohamad Ayyash
25925b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* If it is necessary to assign new unofficial EM_* values, please
26025b3c049e70834cf33790a28643ab058b507b35cBen Cheng   pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
26125b3c049e70834cf33790a28643ab058b507b35cBen Cheng   chances of collision with official or non-GNU unofficial values.  */
26225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
26325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EM_ALPHA	0x9026
26425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
26525b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for e_version (version).  */
26625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
26725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EV_NONE		0		/* Invalid ELF version */
26825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EV_CURRENT	1		/* Current version */
26925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EV_NUM		2
27025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
27125b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Section header.  */
27225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
27325b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
27425b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
27525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	sh_name;		/* Section name (string tbl index) */
27625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	sh_type;		/* Section type */
27725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	sh_flags;		/* Section flags */
27825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Addr	sh_addr;		/* Section virtual addr at execution */
27925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Off	sh_offset;		/* Section file offset */
28025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	sh_size;		/* Section size in bytes */
28125b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	sh_link;		/* Link to another section */
28225b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	sh_info;		/* Additional section information */
28325b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	sh_addralign;		/* Section alignment */
28425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	sh_entsize;		/* Entry size if section holds table */
28525b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Shdr;
28625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
28725b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
28825b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
28925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	sh_name;		/* Section name (string tbl index) */
29025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	sh_type;		/* Section type */
29125b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Xword	sh_flags;		/* Section flags */
29225b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Addr	sh_addr;		/* Section virtual addr at execution */
29325b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Off	sh_offset;		/* Section file offset */
29425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Xword	sh_size;		/* Section size in bytes */
29525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	sh_link;		/* Link to another section */
29625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	sh_info;		/* Additional section information */
29725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Xword	sh_addralign;		/* Section alignment */
29825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Xword	sh_entsize;		/* Entry size if section holds table */
29925b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Shdr;
30025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
30125b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Special section indices.  */
30225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
30325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHN_UNDEF	0		/* Undefined section */
30425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHN_LORESERVE	0xff00		/* Start of reserved indices */
30525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHN_LOPROC	0xff00		/* Start of processor-specific */
30625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHN_BEFORE	0xff00		/* Order section before all others
30725b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   (Solaris).  */
30825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHN_AFTER	0xff01		/* Order section after all others
30925b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   (Solaris).  */
31025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHN_HIPROC	0xff1f		/* End of processor-specific */
31125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHN_LOOS	0xff20		/* Start of OS-specific */
31225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHN_HIOS	0xff3f		/* End of OS-specific */
31325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHN_ABS		0xfff1		/* Associated symbol is absolute */
31425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHN_COMMON	0xfff2		/* Associated symbol is common */
31525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHN_XINDEX	0xffff		/* Index is in extra table.  */
31625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHN_HIRESERVE	0xffff		/* End of reserved indices */
31725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
31825b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for sh_type (section type).  */
31925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
32025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_NULL	  0		/* Section header table entry unused */
32125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_PROGBITS	  1		/* Program data */
32225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_SYMTAB	  2		/* Symbol table */
32325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_STRTAB	  3		/* String table */
32425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_RELA	  4		/* Relocation entries with addends */
32525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_HASH	  5		/* Symbol hash table */
32625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_DYNAMIC	  6		/* Dynamic linking information */
32725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_NOTE	  7		/* Notes */
32825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_NOBITS	  8		/* Program space with no data (bss) */
32925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_REL		  9		/* Relocation entries, no addends */
33025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_SHLIB	  10		/* Reserved */
33125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_DYNSYM	  11		/* Dynamic linker symbol table */
33225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_INIT_ARRAY	  14		/* Array of constructors */
33325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_FINI_ARRAY	  15		/* Array of destructors */
33425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_PREINIT_ARRAY 16		/* Array of pre-constructors */
33525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_GROUP	  17		/* Section group */
33625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_SYMTAB_SHNDX  18		/* Extended section indeces */
33725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	SHT_NUM		  19		/* Number of defined types.  */
33825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_LOOS	  0x60000000	/* Start OS-specific.  */
33925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_GNU_ATTRIBUTES 0x6ffffff5	/* Object attributes.  */
34025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_GNU_HASH	  0x6ffffff6	/* GNU-style hash table.  */
34125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_GNU_LIBLIST	  0x6ffffff7	/* Prelink library list */
34225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_CHECKSUM	  0x6ffffff8	/* Checksum for DSO content.  */
34325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_LOSUNW	  0x6ffffffa	/* Sun-specific low bound.  */
34425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_SUNW_move	  0x6ffffffa
34525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_SUNW_COMDAT   0x6ffffffb
34625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_SUNW_syminfo  0x6ffffffc
34725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_GNU_verdef	  0x6ffffffd	/* Version definition section.  */
34825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_GNU_verneed	  0x6ffffffe	/* Version needs section.  */
34925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_GNU_versym	  0x6fffffff	/* Version symbol table.  */
35025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_HISUNW	  0x6fffffff	/* Sun-specific high bound.  */
35125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_HIOS	  0x6fffffff	/* End OS-specific type */
35225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_LOPROC	  0x70000000	/* Start of processor-specific */
35325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_HIPROC	  0x7fffffff	/* End of processor-specific */
35425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_LOUSER	  0x80000000	/* Start of application-specific */
35525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHT_HIUSER	  0x8fffffff	/* End of application-specific */
35625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
35725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for sh_flags (section flags).  */
35825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
35925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_WRITE	     (1 << 0)	/* Writable */
36025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_ALLOC	     (1 << 1)	/* Occupies memory during execution */
36125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_EXECINSTR	     (1 << 2)	/* Executable */
36225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_MERGE	     (1 << 4)	/* Might be merged */
36325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_STRINGS	     (1 << 5)	/* Contains nul-terminated strings */
36425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_INFO_LINK	     (1 << 6)	/* `sh_info' contains SHT index */
36525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_LINK_ORDER	     (1 << 7)	/* Preserve order after combining */
36625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_OS_NONCONFORMING (1 << 8)	/* Non-standard OS specific handling
36725b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   required */
36825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_GROUP	     (1 << 9)	/* Section is member of a group.  */
36925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_TLS		     (1 << 10)	/* Section hold thread-local data.  */
37025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_MASKOS	     0x0ff00000	/* OS-specific.  */
37125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_MASKPROC	     0xf0000000	/* Processor-specific */
37225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_ORDERED	     (1 << 30)	/* Special ordering requirement
37325b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   (Solaris).  */
37425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SHF_EXCLUDE	     (1 << 31)	/* Section is excluded unless
37525b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   referenced or allocated (Solaris).*/
37625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
37725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Section group handling.  */
37825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define GRP_COMDAT	0x1		/* Mark group as COMDAT.  */
37925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
38025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Symbol table entry.  */
38125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
38225b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
38325b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
38425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	st_name;		/* Symbol name (string tbl index) */
38525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Addr	st_value;		/* Symbol value */
38625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	st_size;		/* Symbol size */
38725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  unsigned char	st_info;		/* Symbol type and binding */
38825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  unsigned char	st_other;		/* Symbol visibility */
38925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Section	st_shndx;		/* Section index */
39025b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Sym;
39125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
39225b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
39325b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
39425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	st_name;		/* Symbol name (string tbl index) */
39525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  unsigned char	st_info;		/* Symbol type and binding */
39625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  unsigned char st_other;		/* Symbol visibility */
39725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Section	st_shndx;		/* Section index */
39825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Addr	st_value;		/* Symbol value */
39925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Xword	st_size;		/* Symbol size */
40025b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Sym;
40125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
40225b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* The syminfo section if available contains additional information about
40325b3c049e70834cf33790a28643ab058b507b35cBen Cheng   every dynamic symbol.  */
40425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
40525b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
40625b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
40725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half si_boundto;		/* Direct bindings, symbol bound to */
40825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half si_flags;			/* Per symbol flags */
40925b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Syminfo;
41025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
41125b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
41225b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
41325b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half si_boundto;		/* Direct bindings, symbol bound to */
41425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half si_flags;			/* Per symbol flags */
41525b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Syminfo;
41625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
41725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Possible values for si_boundto.  */
41825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SYMINFO_BT_SELF		0xffff	/* Symbol bound to self */
41925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SYMINFO_BT_PARENT	0xfffe	/* Symbol bound to parent */
42025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SYMINFO_BT_LOWRESERVE	0xff00	/* Beginning of reserved entries */
42125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
42225b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Possible bitmasks for si_flags.  */
42325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SYMINFO_FLG_DIRECT	0x0001	/* Direct bound symbol */
42425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SYMINFO_FLG_PASSTHRU	0x0002	/* Pass-thru symbol for translator */
42525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SYMINFO_FLG_COPY	0x0004	/* Symbol is a copy-reloc */
42625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SYMINFO_FLG_LAZYLOAD	0x0008	/* Symbol bound to object to be lazy
42725b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   loaded */
42825b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Syminfo version values.  */
42925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SYMINFO_NONE		0
43025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SYMINFO_CURRENT		1
43125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define SYMINFO_NUM		2
43225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
43325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
43425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* How to extract and insert information held in the st_info field.  */
43525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
43625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF32_ST_BIND(val)		(((unsigned char) (val)) >> 4)
43725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF32_ST_TYPE(val)		((val) & 0xf)
43825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF32_ST_INFO(bind, type)	(((bind) << 4) + ((type) & 0xf))
43925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
44025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field.  */
44125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF64_ST_BIND(val)		ELF32_ST_BIND (val)
44225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF64_ST_TYPE(val)		ELF32_ST_TYPE (val)
44325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF64_ST_INFO(bind, type)	ELF32_ST_INFO ((bind), (type))
44425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
44525b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for ST_BIND subfield of st_info (symbol binding).  */
44625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
44725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STB_LOCAL	0		/* Local symbol */
44825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STB_GLOBAL	1		/* Global symbol */
44925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STB_WEAK	2		/* Weak symbol */
45025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	STB_NUM		3		/* Number of defined types.  */
45125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STB_LOOS	10		/* Start of OS-specific */
45225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STB_GNU_UNIQUE	10		/* Unique symbol.  */
45325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STB_HIOS	12		/* End of OS-specific */
45425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STB_LOPROC	13		/* Start of processor-specific */
45525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STB_HIPROC	15		/* End of processor-specific */
45625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
45725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
45825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
45925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STT_NOTYPE	0		/* Symbol type is unspecified */
46025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STT_OBJECT	1		/* Symbol is a data object */
46125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STT_FUNC	2		/* Symbol is a code object */
46225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STT_SECTION	3		/* Symbol associated with a section */
46325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STT_FILE	4		/* Symbol's name is file name */
46425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STT_COMMON	5		/* Symbol is a common data object */
46525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STT_TLS		6		/* Symbol is thread-local data object*/
46625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	STT_NUM		7		/* Number of defined types.  */
46725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STT_LOOS	10		/* Start of OS-specific */
46825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STT_GNU_IFUNC	10		/* Symbol is indirect code object */
46925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STT_HIOS	12		/* End of OS-specific */
47025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STT_LOPROC	13		/* Start of processor-specific */
47125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STT_HIPROC	15		/* End of processor-specific */
47225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
47325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
47425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Symbol table indices are found in the hash buckets and chain table
47525b3c049e70834cf33790a28643ab058b507b35cBen Cheng   of a symbol hash table section.  This special index value indicates
47625b3c049e70834cf33790a28643ab058b507b35cBen Cheng   the end of a chain, meaning no further symbols are found in that bucket.  */
47725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
47825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STN_UNDEF	0		/* End of a chain.  */
47925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
48025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
48125b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* How to extract and insert information held in the st_other field.  */
48225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
48325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF32_ST_VISIBILITY(o)	((o) & 0x03)
48425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
48525b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* For ELF64 the definitions are the same.  */
48625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF64_ST_VISIBILITY(o)	ELF32_ST_VISIBILITY (o)
48725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
48825b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Symbol visibility specification encoded in the st_other field.  */
48925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STV_DEFAULT	0		/* Default symbol visibility rules */
49025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STV_INTERNAL	1		/* Processor specific hidden class */
49125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STV_HIDDEN	2		/* Sym unavailable in other modules */
49225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define STV_PROTECTED	3		/* Not preemptible, not exported */
49325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
49425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
49525b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Relocation table entry without addend (in section of type SHT_REL).  */
49625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
49725b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
49825b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
49925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Addr	r_offset;		/* Address */
50025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	r_info;			/* Relocation type and symbol index */
50125b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Rel;
50225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
50325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* I have seen two different definitions of the Elf64_Rel and
50425b3c049e70834cf33790a28643ab058b507b35cBen Cheng   Elf64_Rela structures, so we'll leave them out until Novell (or
50525b3c049e70834cf33790a28643ab058b507b35cBen Cheng   whoever) gets their act together.  */
50625b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* The following, at least, is used on Sparc v9, MIPS, and Alpha.  */
50725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
50825b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
50925b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
51025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Addr	r_offset;		/* Address */
51125b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Xword	r_info;			/* Relocation type and symbol index */
51225b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Rel;
51325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
51425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Relocation table entry with addend (in section of type SHT_RELA).  */
51525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
51625b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
51725b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
51825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Addr	r_offset;		/* Address */
51925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	r_info;			/* Relocation type and symbol index */
52025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Sword	r_addend;		/* Addend */
52125b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Rela;
52225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
52325b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
52425b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
52525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Addr	r_offset;		/* Address */
52625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Xword	r_info;			/* Relocation type and symbol index */
52725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Sxword	r_addend;		/* Addend */
52825b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Rela;
52925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
53025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* How to extract and insert information held in the r_info field.  */
53125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
53225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF32_R_SYM(val)		((val) >> 8)
53325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF32_R_TYPE(val)		((val) & 0xff)
53425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF32_R_INFO(sym, type)		(((sym) << 8) + ((type) & 0xff))
53525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
53625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF64_R_SYM(i)			((i) >> 32)
53725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF64_R_TYPE(i)			((i) & 0xffffffff)
53825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF64_R_INFO(sym,type)		((((Elf64_Xword) (sym)) << 32) + (type))
53925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
54025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Program segment header.  */
54125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
54225b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
54325b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
54425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	p_type;			/* Segment type */
54525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Off	p_offset;		/* Segment file offset */
54625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Addr	p_vaddr;		/* Segment virtual address */
54725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Addr	p_paddr;		/* Segment physical address */
54825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	p_filesz;		/* Segment size in file */
54925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	p_memsz;		/* Segment size in memory */
55025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	p_flags;		/* Segment flags */
55125b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	p_align;		/* Segment alignment */
55225b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Phdr;
55325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
55425b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
55525b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
55625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	p_type;			/* Segment type */
55725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	p_flags;		/* Segment flags */
55825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Off	p_offset;		/* Segment file offset */
55925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Addr	p_vaddr;		/* Segment virtual address */
56025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Addr	p_paddr;		/* Segment physical address */
56125b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Xword	p_filesz;		/* Segment size in file */
56225b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Xword	p_memsz;		/* Segment size in memory */
56325b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Xword	p_align;		/* Segment alignment */
56425b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Phdr;
56525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
56625b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Special value for e_phnum.  This indicates that the real number of
56725b3c049e70834cf33790a28643ab058b507b35cBen Cheng   program headers is too large to fit into e_phnum.  Instead the real
56825b3c049e70834cf33790a28643ab058b507b35cBen Cheng   value is in the field sh_info of section 0.  */
56925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
57025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PN_XNUM		0xffff
57125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
57225b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for p_type (segment type).  */
57325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
57425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	PT_NULL		0		/* Program header table entry unused */
57525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_LOAD		1		/* Loadable program segment */
57625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_DYNAMIC	2		/* Dynamic linking information */
57725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_INTERP	3		/* Program interpreter */
57825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_NOTE		4		/* Auxiliary information */
57925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_SHLIB	5		/* Reserved */
58025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_PHDR		6		/* Entry for header table itself */
58125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_TLS		7		/* Thread-local storage segment */
58225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	PT_NUM		8		/* Number of defined types */
58325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_LOOS		0x60000000	/* Start of OS-specific */
58425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_GNU_EH_FRAME	0x6474e550	/* GCC .eh_frame_hdr segment */
58525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_GNU_STACK	0x6474e551	/* Indicates stack executability */
58625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_GNU_RELRO	0x6474e552	/* Read-only after relocation */
58725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_LOSUNW	0x6ffffffa
58825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_SUNWBSS	0x6ffffffa	/* Sun Specific segment */
58925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_SUNWSTACK	0x6ffffffb	/* Stack segment */
59025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_HISUNW	0x6fffffff
59125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_HIOS		0x6fffffff	/* End of OS-specific */
59225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_LOPROC	0x70000000	/* Start of processor-specific */
59325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PT_HIPROC	0x7fffffff	/* End of processor-specific */
59425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
59525b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for p_flags (segment flags).  */
59625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
59725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PF_X		(1 << 0)	/* Segment is executable */
59825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PF_W		(1 << 1)	/* Segment is writable */
59925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PF_R		(1 << 2)	/* Segment is readable */
60025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PF_MASKOS	0x0ff00000	/* OS-specific */
60125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define PF_MASKPROC	0xf0000000	/* Processor-specific */
60225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
60325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for note segment descriptor types for core files. */
60425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
60525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_PRSTATUS	1		/* Contains copy of prstatus struct */
60625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_FPREGSET	2		/* Contains copy of fpregset struct */
60725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_PRPSINFO	3		/* Contains copy of prpsinfo struct */
60825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_PRXREG	4		/* Contains copy of prxregset struct */
60925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_TASKSTRUCT	4		/* Contains copy of task structure */
61025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_PLATFORM	5		/* String from sysinfo(SI_PLATFORM) */
61125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_AUXV		6		/* Contains copy of auxv array */
61225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_GWINDOWS	7		/* Contains copy of gwindows struct */
61325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_ASRS		8		/* Contains copy of asrset struct */
61425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_PSTATUS	10		/* Contains copy of pstatus struct */
61525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_PSINFO	13		/* Contains copy of psinfo struct */
61625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_PRCRED	14		/* Contains copy of prcred struct */
61725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_UTSNAME	15		/* Contains copy of utsname struct */
61825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_LWPSTATUS	16		/* Contains copy of lwpstatus struct */
61925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_LWPSINFO	17		/* Contains copy of lwpinfo struct */
62025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_PRFPXREG	20		/* Contains copy of fprxregset struct */
62125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_PRXFPREG	0x46e62b7f	/* Contains copy of user_fxsr_struct */
62225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_PPC_VMX	0x100		/* PowerPC Altivec/VMX registers */
62325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_PPC_SPE	0x101		/* PowerPC SPE/EVR registers */
62425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_PPC_VSX	0x102		/* PowerPC VSX registers */
62525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_386_TLS	0x200		/* i386 TLS slots (struct user_desc) */
62625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_386_IOPERM	0x201		/* x86 io permission bitmap (1=deny) */
62725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_X86_XSTATE	0x202		/* x86 extended state using xsave */
62825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
62925b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for the note segment descriptor types for object files.  */
63025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
63125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_VERSION	1		/* Contains a version string.  */
63225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
63325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
63425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Dynamic section entry.  */
63525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
63625b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
63725b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
63825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Sword	d_tag;			/* Dynamic entry type */
63925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  union
64025b3c049e70834cf33790a28643ab058b507b35cBen Cheng    {
64125b3c049e70834cf33790a28643ab058b507b35cBen Cheng      Elf32_Word d_val;			/* Integer value */
64225b3c049e70834cf33790a28643ab058b507b35cBen Cheng      Elf32_Addr d_ptr;			/* Address value */
64325b3c049e70834cf33790a28643ab058b507b35cBen Cheng    } d_un;
64425b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Dyn;
64525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
64625b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
64725b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
64825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Sxword	d_tag;			/* Dynamic entry type */
64925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  union
65025b3c049e70834cf33790a28643ab058b507b35cBen Cheng    {
65125b3c049e70834cf33790a28643ab058b507b35cBen Cheng      Elf64_Xword d_val;		/* Integer value */
65225b3c049e70834cf33790a28643ab058b507b35cBen Cheng      Elf64_Addr d_ptr;			/* Address value */
65325b3c049e70834cf33790a28643ab058b507b35cBen Cheng    } d_un;
65425b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Dyn;
65525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
65625b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for d_tag (dynamic entry type).  */
65725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
65825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_NULL		0		/* Marks end of dynamic section */
65925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_NEEDED	1		/* Name of needed library */
66025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_PLTRELSZ	2		/* Size in bytes of PLT relocs */
66125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_PLTGOT	3		/* Processor defined value */
66225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_HASH		4		/* Address of symbol hash table */
66325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_STRTAB	5		/* Address of string table */
66425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_SYMTAB	6		/* Address of symbol table */
66525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_RELA		7		/* Address of Rela relocs */
66625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_RELASZ	8		/* Total size of Rela relocs */
66725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_RELAENT	9		/* Size of one Rela reloc */
66825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_STRSZ	10		/* Size of string table */
66925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_SYMENT	11		/* Size of one symbol table entry */
67025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_INIT		12		/* Address of init function */
67125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_FINI		13		/* Address of termination function */
67225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_SONAME	14		/* Name of shared object */
67325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_RPATH	15		/* Library search path (deprecated) */
67425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_SYMBOLIC	16		/* Start symbol search here */
67525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_REL		17		/* Address of Rel relocs */
67625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_RELSZ	18		/* Total size of Rel relocs */
67725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_RELENT	19		/* Size of one Rel reloc */
67825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_PLTREL	20		/* Type of reloc in PLT */
67925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_DEBUG	21		/* For debugging; unspecified */
68025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_TEXTREL	22		/* Reloc might modify .text */
68125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_JMPREL	23		/* Address of PLT relocs */
68225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DT_BIND_NOW	24		/* Process relocations of object */
68325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DT_INIT_ARRAY	25		/* Array with addresses of init fct */
68425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DT_FINI_ARRAY	26		/* Array with addresses of fini fct */
68525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DT_INIT_ARRAYSZ	27		/* Size in bytes of DT_INIT_ARRAY */
68625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DT_FINI_ARRAYSZ	28		/* Size in bytes of DT_FINI_ARRAY */
68725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_RUNPATH	29		/* Library search path */
68825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_FLAGS	30		/* Flags for the object being loaded */
68925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_ENCODING	32		/* Start of encoded range */
69025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_PREINIT_ARRAY 32		/* Array with addresses of preinit fct*/
69125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_PREINIT_ARRAYSZ 33		/* size in bytes of DT_PREINIT_ARRAY */
69225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DT_NUM		34		/* Number used */
69325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_LOOS		0x6000000d	/* Start of OS-specific */
69425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_HIOS		0x6ffff000	/* End of OS-specific */
69525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_LOPROC	0x70000000	/* Start of processor-specific */
69625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_HIPROC	0x7fffffff	/* End of processor-specific */
69725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DT_PROCNUM	DT_MIPS_NUM	/* Most used by any processor */
69825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
69925b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
70025b3c049e70834cf33790a28643ab058b507b35cBen Cheng   Dyn.d_un.d_val field of the Elf*_Dyn structure.  This follows Sun's
70125b3c049e70834cf33790a28643ab058b507b35cBen Cheng   approach.  */
70225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_VALRNGLO	0x6ffffd00
70325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_GNU_PRELINKED 0x6ffffdf5	/* Prelinking timestamp */
70425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_GNU_CONFLICTSZ 0x6ffffdf6	/* Size of conflict section */
70525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_GNU_LIBLISTSZ 0x6ffffdf7	/* Size of library list */
70625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_CHECKSUM	0x6ffffdf8
70725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_PLTPADSZ	0x6ffffdf9
70825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_MOVEENT	0x6ffffdfa
70925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_MOVESZ	0x6ffffdfb
71025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_FEATURE_1	0x6ffffdfc	/* Feature selection (DTF_*).  */
71125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_POSFLAG_1	0x6ffffdfd	/* Flags for DT_* entries, effecting
71225b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   the following DT_* entry.  */
71325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_SYMINSZ	0x6ffffdfe	/* Size of syminfo table (in bytes) */
71425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_SYMINENT	0x6ffffdff	/* Entry size of syminfo */
71525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_VALRNGHI	0x6ffffdff
71625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_VALTAGIDX(tag)	(DT_VALRNGHI - (tag))	/* Reverse order! */
71725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_VALNUM 12
71825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
71925b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
72025b3c049e70834cf33790a28643ab058b507b35cBen Cheng   Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
72125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
72225b3c049e70834cf33790a28643ab058b507b35cBen Cheng   If any adjustment is made to the ELF object after it has been
72325b3c049e70834cf33790a28643ab058b507b35cBen Cheng   built these entries will need to be adjusted.  */
72425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_ADDRRNGLO	0x6ffffe00
72525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_GNU_HASH	0x6ffffef5	/* GNU-style hash table.  */
72625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_TLSDESC_PLT	0x6ffffef6
72725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_TLSDESC_GOT	0x6ffffef7
72825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_GNU_CONFLICT	0x6ffffef8	/* Start of conflict section */
72925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_GNU_LIBLIST	0x6ffffef9	/* Library list */
73025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_CONFIG	0x6ffffefa	/* Configuration information.  */
73125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_DEPAUDIT	0x6ffffefb	/* Dependency auditing.  */
73225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_AUDIT	0x6ffffefc	/* Object auditing.  */
73325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DT_PLTPAD	0x6ffffefd	/* PLT padding.  */
73425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DT_MOVETAB	0x6ffffefe	/* Move table.  */
73525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_SYMINFO	0x6ffffeff	/* Syminfo table.  */
73625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_ADDRRNGHI	0x6ffffeff
73725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_ADDRTAGIDX(tag)	(DT_ADDRRNGHI - (tag))	/* Reverse order! */
73825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_ADDRNUM 11
73925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
74025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* The versioning entry types.  The next are defined as part of the
74125b3c049e70834cf33790a28643ab058b507b35cBen Cheng   GNU extension.  */
74225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_VERSYM	0x6ffffff0
74325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
74425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_RELACOUNT	0x6ffffff9
74525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_RELCOUNT	0x6ffffffa
74625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
74725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* These were chosen by Sun.  */
74825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_FLAGS_1	0x6ffffffb	/* State flags, see DF_1_* below.  */
74925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DT_VERDEF	0x6ffffffc	/* Address of version definition
75025b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   table */
75125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DT_VERDEFNUM	0x6ffffffd	/* Number of version definitions */
75225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DT_VERNEED	0x6ffffffe	/* Address of table with needed
75325b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   versions */
75425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DT_VERNEEDNUM	0x6fffffff	/* Number of needed versions */
75525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_VERSIONTAGIDX(tag)	(DT_VERNEEDNUM - (tag))	/* Reverse order! */
75625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_VERSIONTAGNUM 16
75725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
75825b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Sun added these machine-independent extensions in the "processor-specific"
75925b3c049e70834cf33790a28643ab058b507b35cBen Cheng   range.  Be compatible.  */
76025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_AUXILIARY    0x7ffffffd      /* Shared object to load before self */
76125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_FILTER       0x7fffffff      /* Shared object to get values from */
76225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_EXTRATAGIDX(tag)	((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
76325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DT_EXTRANUM	3
76425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
76525b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Values of `d_un.d_val' in the DT_FLAGS entry.  */
76625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_ORIGIN	0x00000001	/* Object may use DF_ORIGIN */
76725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_SYMBOLIC	0x00000002	/* Symbol resolutions starts here */
76825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_TEXTREL	0x00000004	/* Object contains text relocations */
76925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_BIND_NOW	0x00000008	/* No lazy binding for this object */
77025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_STATIC_TLS	0x00000010	/* Module uses the static TLS model */
77125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
77225b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
77325b3c049e70834cf33790a28643ab058b507b35cBen Cheng   entry in the dynamic section.  */
77425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_NOW	0x00000001	/* Set RTLD_NOW for this object.  */
77525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_GLOBAL	0x00000002	/* Set RTLD_GLOBAL for this object.  */
77625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_GROUP	0x00000004	/* Set RTLD_GROUP for this object.  */
77725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_NODELETE	0x00000008	/* Set RTLD_NODELETE for this object.*/
77825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_LOADFLTR	0x00000010	/* Trigger filtee loading at runtime.*/
77925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_INITFIRST	0x00000020	/* Set RTLD_INITFIRST for this object*/
78025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_NOOPEN	0x00000040	/* Set RTLD_NOOPEN for this object.  */
78125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_ORIGIN	0x00000080	/* $ORIGIN must be handled.  */
78225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_DIRECT	0x00000100	/* Direct binding enabled.  */
78325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_TRANS	0x00000200
78425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_INTERPOSE	0x00000400	/* Object is used to interpose.  */
78525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_NODEFLIB	0x00000800	/* Ignore default lib search path.  */
78625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_NODUMP	0x00001000	/* Object can't be dldump'ed.  */
78725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_CONFALT	0x00002000	/* Configuration alternative created.*/
78825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_1_ENDFILTEE	0x00004000	/* Filtee terminates filters search. */
78925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DF_1_DISPRELDNE	0x00008000	/* Disp reloc applied at build time. */
79025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	DF_1_DISPRELPND	0x00010000	/* Disp reloc applied at run-time.  */
79125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
79225b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Flags for the feature selection in DT_FEATURE_1.  */
79325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DTF_1_PARINIT	0x00000001
79425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DTF_1_CONFEXP	0x00000002
79525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
79625b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry.  */
79725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_P1_LAZYLOAD	0x00000001	/* Lazyload following object.  */
79825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define DF_P1_GROUPPERM	0x00000002	/* Symbols from next object are not
79925b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   generally available.  */
80025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
80125b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Version definition sections.  */
80225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
80325b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
80425b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
80525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	vd_version;		/* Version revision */
80625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	vd_flags;		/* Version information */
80725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	vd_ndx;			/* Version Index */
80825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	vd_cnt;			/* Number of associated aux entries */
80925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	vd_hash;		/* Version name hash value */
81025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	vd_aux;			/* Offset in bytes to verdaux array */
81125b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	vd_next;		/* Offset in bytes to next verdef
81225b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   entry */
81325b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Verdef;
81425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
81525b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
81625b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
81725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	vd_version;		/* Version revision */
81825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	vd_flags;		/* Version information */
81925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	vd_ndx;			/* Version Index */
82025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	vd_cnt;			/* Number of associated aux entries */
82125b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	vd_hash;		/* Version name hash value */
82225b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	vd_aux;			/* Offset in bytes to verdaux array */
82325b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	vd_next;		/* Offset in bytes to next verdef
82425b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   entry */
82525b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Verdef;
82625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
82725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
82825b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for vd_version (version revision).  */
82925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define VER_DEF_NONE	0		/* No version */
83025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define VER_DEF_CURRENT	1		/* Current version */
83125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define VER_DEF_NUM	2		/* Given version number */
83225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
83325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for vd_flags (version information flags).  */
83425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define VER_FLG_BASE	0x1		/* Version definition of file itself */
83525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define VER_FLG_WEAK	0x2		/* Weak version identifier */
83625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
83725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Versym symbol index values.  */
83825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	VER_NDX_LOCAL		0	/* Symbol is local.  */
83925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	VER_NDX_GLOBAL		1	/* Symbol is global.  */
84025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	VER_NDX_LORESERVE	0xff00	/* Beginning of reserved entries.  */
84125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	VER_NDX_ELIMINATE	0xff01	/* Symbol is to be eliminated.  */
84225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
84325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Auxialiary version information.  */
84425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
84525b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
84625b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
84725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	vda_name;		/* Version or dependency names */
84825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	vda_next;		/* Offset in bytes to next verdaux
84925b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   entry */
85025b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Verdaux;
85125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
85225b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
85325b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
85425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	vda_name;		/* Version or dependency names */
85525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	vda_next;		/* Offset in bytes to next verdaux
85625b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   entry */
85725b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Verdaux;
85825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
85925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
86025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Version dependency section.  */
86125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
86225b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
86325b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
86425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	vn_version;		/* Version of structure */
86525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	vn_cnt;			/* Number of associated aux entries */
86625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	vn_file;		/* Offset of filename for this
86725b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   dependency */
86825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	vn_aux;			/* Offset in bytes to vernaux array */
86925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	vn_next;		/* Offset in bytes to next verneed
87025b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   entry */
87125b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Verneed;
87225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
87325b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
87425b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
87525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	vn_version;		/* Version of structure */
87625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	vn_cnt;			/* Number of associated aux entries */
87725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	vn_file;		/* Offset of filename for this
87825b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   dependency */
87925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	vn_aux;			/* Offset in bytes to vernaux array */
88025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	vn_next;		/* Offset in bytes to next verneed
88125b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   entry */
88225b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Verneed;
88325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
88425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
88525b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for vn_version (version revision).  */
88625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define VER_NEED_NONE	 0		/* No version */
88725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define VER_NEED_CURRENT 1		/* Current version */
88825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define VER_NEED_NUM	 2		/* Given version number */
88925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
89025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Auxiliary needed version information.  */
89125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
89225b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
89325b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
89425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	vna_hash;		/* Hash value of dependency name */
89525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	vna_flags;		/* Dependency specific information */
89625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half	vna_other;		/* Unused */
89725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	vna_name;		/* Dependency name string offset */
89825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word	vna_next;		/* Offset in bytes to next vernaux
89925b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   entry */
90025b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Vernaux;
90125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
90225b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
90325b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
90425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	vna_hash;		/* Hash value of dependency name */
90525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	vna_flags;		/* Dependency specific information */
90625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half	vna_other;		/* Unused */
90725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	vna_name;		/* Dependency name string offset */
90825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word	vna_next;		/* Offset in bytes to next vernaux
90925b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   entry */
91025b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Vernaux;
91125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
91225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
91325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for vna_flags.  */
91425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define VER_FLG_WEAK	0x2		/* Weak version identifier */
91525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
91625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
91725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Auxiliary vector.  */
91825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
91925b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* This vector is normally only used by the program interpreter.  The
92025b3c049e70834cf33790a28643ab058b507b35cBen Cheng   usual definition in an ABI supplement uses the name auxv_t.  The
92125b3c049e70834cf33790a28643ab058b507b35cBen Cheng   vector is not usually defined in a standard <elf.h> file, but it
92225b3c049e70834cf33790a28643ab058b507b35cBen Cheng   can't hurt.  We rename it to avoid conflicts.  The sizes of these
92325b3c049e70834cf33790a28643ab058b507b35cBen Cheng   types are an arrangement between the exec server and the program
92425b3c049e70834cf33790a28643ab058b507b35cBen Cheng   interpreter, so we don't fully specify them here.  */
92525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
92625b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
92725b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
92825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  uint32_t a_type;		/* Entry type */
92925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  union
93025b3c049e70834cf33790a28643ab058b507b35cBen Cheng    {
93125b3c049e70834cf33790a28643ab058b507b35cBen Cheng      uint32_t a_val;		/* Integer value */
93225b3c049e70834cf33790a28643ab058b507b35cBen Cheng      /* We use to have pointer elements added here.  We cannot do that,
93325b3c049e70834cf33790a28643ab058b507b35cBen Cheng	 though, since it does not work when using 32-bit definitions
93425b3c049e70834cf33790a28643ab058b507b35cBen Cheng	 on 64-bit platforms and vice versa.  */
93525b3c049e70834cf33790a28643ab058b507b35cBen Cheng    } a_un;
93625b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_auxv_t;
93725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
93825b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
93925b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
94025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  uint64_t a_type;		/* Entry type */
94125b3c049e70834cf33790a28643ab058b507b35cBen Cheng  union
94225b3c049e70834cf33790a28643ab058b507b35cBen Cheng    {
94325b3c049e70834cf33790a28643ab058b507b35cBen Cheng      uint64_t a_val;		/* Integer value */
94425b3c049e70834cf33790a28643ab058b507b35cBen Cheng      /* We use to have pointer elements added here.  We cannot do that,
94525b3c049e70834cf33790a28643ab058b507b35cBen Cheng	 though, since it does not work when using 32-bit definitions
94625b3c049e70834cf33790a28643ab058b507b35cBen Cheng	 on 64-bit platforms and vice versa.  */
94725b3c049e70834cf33790a28643ab058b507b35cBen Cheng    } a_un;
94825b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_auxv_t;
94925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
95025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Legal values for a_type (entry type).  */
95125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
95225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_NULL		0		/* End of vector */
95325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_IGNORE	1		/* Entry should be ignored */
95425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_EXECFD	2		/* File descriptor of program */
95525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_PHDR		3		/* Program headers for program */
95625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_PHENT	4		/* Size of program header entry */
95725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_PHNUM	5		/* Number of program headers */
95825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_PAGESZ	6		/* System page size */
95925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_BASE		7		/* Base address of interpreter */
96025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_FLAGS	8		/* Flags */
96125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_ENTRY	9		/* Entry point of program */
96225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_NOTELF	10		/* Program is not ELF */
96325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_UID		11		/* Real uid */
96425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_EUID		12		/* Effective uid */
96525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_GID		13		/* Real gid */
96625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_EGID		14		/* Effective gid */
96725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_CLKTCK	17		/* Frequency of times() */
96825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
96925b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Some more special a_type values describing the hardware.  */
97025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_PLATFORM	15		/* String identifying platform.  */
97125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_HWCAP	16		/* Machine dependent hints about
97225b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   processor capabilities.  */
97325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
97425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* This entry gives some information about the FPU initialization
97525b3c049e70834cf33790a28643ab058b507b35cBen Cheng   performed by the kernel.  */
97625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_FPUCW	18		/* Used FPU control word.  */
97725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
97825b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Cache block sizes.  */
97925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_DCACHEBSIZE	19		/* Data cache block size.  */
98025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_ICACHEBSIZE	20		/* Instruction cache block size.  */
98125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_UCACHEBSIZE	21		/* Unified cache block size.  */
98225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
98325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* A special ignored value for PPC, used by the kernel to control the
98425b3c049e70834cf33790a28643ab058b507b35cBen Cheng   interpretation of the AUXV. Must be > 16.  */
98525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_IGNOREPPC	22		/* Entry should be ignored.  */
98625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
98725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define	AT_SECURE	23		/* Boolean, was exec setuid-like?  */
98825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
98925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_BASE_PLATFORM 24		/* String identifying real platforms.*/
99025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
99125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_RANDOM	25		/* Address of 16 random bytes.  */
99225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
99325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_EXECFN	31		/* Filename of executable.  */
99425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
99525b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Pointer to the global system page used for system calls and other
99625b3c049e70834cf33790a28643ab058b507b35cBen Cheng   nice things.  */
99725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_SYSINFO	32
99825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_SYSINFO_EHDR	33
99925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
100025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Shapes of the caches.  Bits 0-3 contains associativity; bits 4-7 contains
100125b3c049e70834cf33790a28643ab058b507b35cBen Cheng   log2 of line size; mask those to get cache size.  */
100225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_L1I_CACHESHAPE	34
100325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_L1D_CACHESHAPE	35
100425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_L2_CACHESHAPE	36
100525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define AT_L3_CACHESHAPE	37
100625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
100725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Note section contents.  Each entry in the note section begins with
100825b3c049e70834cf33790a28643ab058b507b35cBen Cheng   a header of a fixed form.  */
100925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
101025b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
101125b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
101225b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word n_namesz;			/* Length of the note's name.  */
101325b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word n_descsz;			/* Length of the note's descriptor.  */
101425b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word n_type;			/* Type of the note.  */
101525b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Nhdr;
101625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
101725b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
101825b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
101925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word n_namesz;			/* Length of the note's name.  */
102025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word n_descsz;			/* Length of the note's descriptor.  */
102125b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Word n_type;			/* Type of the note.  */
102225b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Nhdr;
102325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
102425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Known names of notes.  */
102525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
102625b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Solaris entries in the note section have this name.  */
102725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF_NOTE_SOLARIS	"SUNW Solaris"
102825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
102925b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Note entries for GNU systems have this name.  */
103025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF_NOTE_GNU		"GNU"
103125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
103225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
103325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Defined types of notes for Solaris.  */
103425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
103525b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Value of descriptor (one word) is desired pagesize for the binary.  */
103625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF_NOTE_PAGESIZE_HINT	1
103725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
103825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
103925b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Defined note types for GNU systems.  */
104025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
104125b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* ABI information.  The descriptor consists of words:
104225b3c049e70834cf33790a28643ab058b507b35cBen Cheng   word 0: OS descriptor
104325b3c049e70834cf33790a28643ab058b507b35cBen Cheng   word 1: major version of the ABI
104425b3c049e70834cf33790a28643ab058b507b35cBen Cheng   word 2: minor version of the ABI
104525b3c049e70834cf33790a28643ab058b507b35cBen Cheng   word 3: subminor version of the ABI
104625b3c049e70834cf33790a28643ab058b507b35cBen Cheng*/
104725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_GNU_ABI_TAG	1
104825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF_NOTE_ABI	NT_GNU_ABI_TAG /* Old name.  */
104925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
105025b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Known OSes.  These values can appear in word 0 of an
105125b3c049e70834cf33790a28643ab058b507b35cBen Cheng   NT_GNU_ABI_TAG note section entry.  */
105225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF_NOTE_OS_LINUX	0
105325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF_NOTE_OS_GNU		1
105425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF_NOTE_OS_SOLARIS2	2
105525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF_NOTE_OS_FREEBSD	3
105625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
105725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Synthetic hwcap information.  The descriptor begins with two words:
105825b3c049e70834cf33790a28643ab058b507b35cBen Cheng   word 0: number of entries
105925b3c049e70834cf33790a28643ab058b507b35cBen Cheng   word 1: bitmask of enabled entries
106025b3c049e70834cf33790a28643ab058b507b35cBen Cheng   Then follow variable-length entries, one byte followed by a
106125b3c049e70834cf33790a28643ab058b507b35cBen Cheng   '\0'-terminated hwcap name string.  The byte gives the bit
106225b3c049e70834cf33790a28643ab058b507b35cBen Cheng   number to test if enabled, (1U << bit) & bitmask.  */
106325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_GNU_HWCAP	2
106425b3c049e70834cf33790a28643ab058b507b35cBen Cheng
106525b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Build ID bits as generated by ld --build-id.
106625b3c049e70834cf33790a28643ab058b507b35cBen Cheng   The descriptor consists of any nonzero number of bytes.  */
106725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_GNU_BUILD_ID	3
106825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
106925b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Version note generated by GNU gold containing a version string.  */
107025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define NT_GNU_GOLD_VERSION	4
107125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
107225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
107325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Move records.  */
107425b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
107525b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
107625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Xword m_value;		/* Symbol value.  */
107725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word m_info;		/* Size and index.  */
107825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Word m_poffset;		/* Symbol offset.  */
107925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half m_repeat;		/* Repeat count.  */
108025b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf32_Half m_stride;		/* Stride info.  */
108125b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf32_Move;
108225b3c049e70834cf33790a28643ab058b507b35cBen Cheng
108325b3c049e70834cf33790a28643ab058b507b35cBen Chengtypedef struct
108425b3c049e70834cf33790a28643ab058b507b35cBen Cheng{
108525b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Xword m_value;		/* Symbol value.  */
108625b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Xword m_info;		/* Size and index.  */
108725b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Xword m_poffset;	/* Symbol offset.  */
108825b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half m_repeat;		/* Repeat count.  */
108925b3c049e70834cf33790a28643ab058b507b35cBen Cheng  Elf64_Half m_stride;		/* Stride info.  */
109025b3c049e70834cf33790a28643ab058b507b35cBen Cheng} Elf64_Move;
109125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
109225b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Macro to construct move records.  */
109325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF32_M_SYM(info)	((info) >> 8)
109425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF32_M_SIZE(info)	((unsigned char) (info))
109525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF32_M_INFO(sym, size)	(((sym) << 8) + (unsigned char) (size))
109625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
109725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF64_M_SYM(info)	ELF32_M_SYM (info)
109825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF64_M_SIZE(info)	ELF32_M_SIZE (info)
109925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define ELF64_M_INFO(sym, size)	ELF32_M_INFO (sym, size)
110025b3c049e70834cf33790a28643ab058b507b35cBen Cheng
110125b3c049e70834cf33790a28643ab058b507b35cBen Cheng
110225b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Motorola 68k specific definitions.  */
110325b3c049e70834cf33790a28643ab058b507b35cBen Cheng
110425b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Values for Elf32_Ehdr.e_flags.  */
110525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define EF_CPU32	0x00810000
110625b3c049e70834cf33790a28643ab058b507b35cBen Cheng
110725b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* m68k relocs.  */
110825b3c049e70834cf33790a28643ab058b507b35cBen Cheng
110925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_NONE	0		/* No reloc */
111025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_32	1		/* Direct 32 bit  */
111125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_16	2		/* Direct 16 bit  */
111225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_8		3		/* Direct 8 bit  */
111325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_PC32	4		/* PC relative 32 bit */
111425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_PC16	5		/* PC relative 16 bit */
111525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_PC8	6		/* PC relative 8 bit */
111625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_GOT32	7		/* 32 bit PC relative GOT entry */
111725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_GOT16	8		/* 16 bit PC relative GOT entry */
111825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_GOT8	9		/* 8 bit PC relative GOT entry */
111925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_GOT32O	10		/* 32 bit GOT offset */
112025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_GOT16O	11		/* 16 bit GOT offset */
112125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_GOT8O	12		/* 8 bit GOT offset */
112225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_PLT32	13		/* 32 bit PC relative PLT address */
112325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_PLT16	14		/* 16 bit PC relative PLT address */
112425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_PLT8	15		/* 8 bit PC relative PLT address */
112525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_PLT32O	16		/* 32 bit PLT offset */
112625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_PLT16O	17		/* 16 bit PLT offset */
112725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_PLT8O	18		/* 8 bit PLT offset */
112825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_COPY	19		/* Copy symbol at runtime */
112925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_GLOB_DAT	20		/* Create GOT entry */
113025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_JMP_SLOT	21		/* Create PLT entry */
113125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_RELATIVE	22		/* Adjust by program base */
113225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_GD32      25          /* 32 bit GOT offset for GD */
113325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_GD16      26          /* 16 bit GOT offset for GD */
113425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_GD8       27          /* 8 bit GOT offset for GD */
113525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_LDM32     28          /* 32 bit GOT offset for LDM */
113625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_LDM16     29          /* 16 bit GOT offset for LDM */
113725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_LDM8      30          /* 8 bit GOT offset for LDM */
113825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_LDO32     31          /* 32 bit module-relative offset */
113925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_LDO16     32          /* 16 bit module-relative offset */
114025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_LDO8      33          /* 8 bit module-relative offset */
114125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_IE32      34          /* 32 bit GOT offset for IE */
114225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_IE16      35          /* 16 bit GOT offset for IE */
114325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_IE8       36          /* 8 bit GOT offset for IE */
114425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_LE32      37          /* 32 bit offset relative to
114525b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   static TLS block */
114625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_LE16      38          /* 16 bit offset relative to
114725b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   static TLS block */
114825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_LE8       39          /* 8 bit offset relative to
114925b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   static TLS block */
115025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_DTPMOD32  40          /* 32 bit module number */
115125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_DTPREL32  41          /* 32 bit module-relative offset */
115225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_TLS_TPREL32   42          /* 32 bit TP-relative offset */
115325b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Keep this the last entry.  */
115425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_68K_NUM	43
115525b3c049e70834cf33790a28643ab058b507b35cBen Cheng
115625b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* Intel 80386 specific definitions.  */
115725b3c049e70834cf33790a28643ab058b507b35cBen Cheng
115825b3c049e70834cf33790a28643ab058b507b35cBen Cheng/* i386 relocs.  */
115925b3c049e70834cf33790a28643ab058b507b35cBen Cheng
116025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_NONE	   0		/* No reloc */
116125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_32	   1		/* Direct 32 bit  */
116225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_PC32	   2		/* PC relative 32 bit */
116325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_GOT32	   3		/* 32 bit GOT entry */
116425b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_PLT32	   4		/* 32 bit PLT address */
116525b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_COPY	   5		/* Copy symbol at runtime */
116625b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_GLOB_DAT	   6		/* Create GOT entry */
116725b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_JMP_SLOT	   7		/* Create PLT entry */
116825b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_RELATIVE	   8		/* Adjust by program base */
116925b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_GOTOFF	   9		/* 32 bit offset to GOT */
117025b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_GOTPC	   10		/* 32 bit PC relative offset to GOT */
117125b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_32PLT	   11
117225b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_TLS_TPOFF	   14		/* Offset in static TLS block */
117325b3c049e70834cf33790a28643ab058b507b35cBen Cheng#define R_386_TLS_IE	   15		/* Address of GOT entry for static TLS
117425b3c049e70834cf33790a28643ab058b507b35cBen Cheng					   block offset */
1175