Home | History | Annotate | Line # | Download | only in sys
exec_elf.h revision 1.1.8.1
      1  1.1.8.1      tls /*	$NetBSD: exec_elf.h,v 1.1.8.1 2014/08/20 00:04:56 tls Exp $	*/
      2      1.1  tsutsui 
      3      1.1  tsutsui /*-
      4      1.1  tsutsui  * Copyright (c) 1994 The NetBSD Foundation, Inc.
      5      1.1  tsutsui  * All rights reserved.
      6      1.1  tsutsui  *
      7      1.1  tsutsui  * This code is derived from software contributed to The NetBSD Foundation
      8      1.1  tsutsui  * by Christos Zoulas.
      9      1.1  tsutsui  *
     10      1.1  tsutsui  * Redistribution and use in source and binary forms, with or without
     11      1.1  tsutsui  * modification, are permitted provided that the following conditions
     12      1.1  tsutsui  * are met:
     13      1.1  tsutsui  * 1. Redistributions of source code must retain the above copyright
     14      1.1  tsutsui  *    notice, this list of conditions and the following disclaimer.
     15      1.1  tsutsui  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.1  tsutsui  *    notice, this list of conditions and the following disclaimer in the
     17      1.1  tsutsui  *    documentation and/or other materials provided with the distribution.
     18      1.1  tsutsui  *
     19      1.1  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20      1.1  tsutsui  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21      1.1  tsutsui  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22      1.1  tsutsui  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23      1.1  tsutsui  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24      1.1  tsutsui  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25      1.1  tsutsui  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26      1.1  tsutsui  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27      1.1  tsutsui  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28      1.1  tsutsui  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29      1.1  tsutsui  * POSSIBILITY OF SUCH DAMAGE.
     30      1.1  tsutsui  */
     31      1.1  tsutsui 
     32      1.1  tsutsui #ifndef _SYS_EXEC_ELF_H_
     33      1.1  tsutsui #define	_SYS_EXEC_ELF_H_
     34      1.1  tsutsui 
     35      1.1  tsutsui /*
     36      1.1  tsutsui  * The current ELF ABI specification is available at:
     37      1.1  tsutsui  *	http://www.sco.com/developer/gabi/
     38      1.1  tsutsui  *
     39      1.1  tsutsui  * Current header definitions are in:
     40      1.1  tsutsui  *	http://www.sco.com/developer/gabi/latest/ch4.eheader.html
     41      1.1  tsutsui  */
     42      1.1  tsutsui 
     43      1.1  tsutsui #if defined(_KERNEL) || defined(_STANDALONE)
     44      1.1  tsutsui #include <sys/types.h>
     45      1.1  tsutsui #else
     46      1.1  tsutsui #include <inttypes.h>
     47      1.1  tsutsui #endif /* _KERNEL || _STANDALONE */
     48      1.1  tsutsui 
     49      1.1  tsutsui typedef	uint8_t  	Elf_Byte;
     50      1.1  tsutsui 
     51      1.1  tsutsui typedef	uint32_t	Elf32_Addr;
     52      1.1  tsutsui #define	ELF32_FSZ_ADDR	4
     53      1.1  tsutsui typedef	uint32_t	Elf32_Off;
     54      1.1  tsutsui #define	ELF32_FSZ_OFF	4
     55      1.1  tsutsui typedef	int32_t		Elf32_Sword;
     56      1.1  tsutsui #define	ELF32_FSZ_SWORD	4
     57      1.1  tsutsui typedef	uint32_t	Elf32_Word;
     58      1.1  tsutsui #define	ELF32_FSZ_WORD	4
     59      1.1  tsutsui typedef	uint16_t	Elf32_Half;
     60      1.1  tsutsui #define	ELF32_FSZ_HALF	2
     61      1.1  tsutsui 
     62      1.1  tsutsui typedef	uint64_t	Elf64_Addr;
     63      1.1  tsutsui #define	ELF64_FSZ_ADDR	8
     64      1.1  tsutsui typedef	uint64_t	Elf64_Off;
     65      1.1  tsutsui #define	ELF64_FSZ_OFF	8
     66      1.1  tsutsui 
     67      1.1  tsutsui #ifndef ELF64_FSZ_SWORD
     68      1.1  tsutsui typedef	int32_t		Elf64_Sword;
     69      1.1  tsutsui #define	ELF64_FSZ_SWORD	4
     70      1.1  tsutsui #endif /* ELF64_FSZ_SWORD */
     71      1.1  tsutsui #ifndef ELF64_FSZ_WORD
     72      1.1  tsutsui typedef	uint32_t	Elf64_Word;
     73      1.1  tsutsui #define	ELF64_FSZ_WORD	4
     74      1.1  tsutsui #endif /* ELF64_FSZ_WORD */
     75      1.1  tsutsui 
     76      1.1  tsutsui typedef	int64_t		Elf64_Sxword;
     77      1.1  tsutsui #define	ELF64_FSZ_XWORD	8
     78      1.1  tsutsui typedef	uint64_t	Elf64_Xword;
     79      1.1  tsutsui #define	ELF64_FSZ_XWORD	8
     80      1.1  tsutsui typedef	uint16_t	Elf64_Half;
     81      1.1  tsutsui #define	ELF64_FSZ_HALF 2
     82      1.1  tsutsui 
     83      1.1  tsutsui /*
     84      1.1  tsutsui  * ELF Header
     85      1.1  tsutsui  */
     86      1.1  tsutsui #define	ELF_NIDENT	16
     87      1.1  tsutsui 
     88      1.1  tsutsui typedef struct {
     89      1.1  tsutsui 	unsigned char	e_ident[ELF_NIDENT];	/* Id bytes */
     90      1.1  tsutsui 	Elf32_Half	e_type;			/* file type */
     91      1.1  tsutsui 	Elf32_Half	e_machine;		/* machine type */
     92      1.1  tsutsui 	Elf32_Word	e_version;		/* version number */
     93      1.1  tsutsui 	Elf32_Addr	e_entry;		/* entry point */
     94      1.1  tsutsui 	Elf32_Off	e_phoff;		/* Program hdr offset */
     95      1.1  tsutsui 	Elf32_Off	e_shoff;		/* Section hdr offset */
     96      1.1  tsutsui 	Elf32_Word	e_flags;		/* Processor flags */
     97      1.1  tsutsui 	Elf32_Half      e_ehsize;		/* sizeof ehdr */
     98      1.1  tsutsui 	Elf32_Half      e_phentsize;		/* Program header entry size */
     99      1.1  tsutsui 	Elf32_Half      e_phnum;		/* Number of program headers */
    100      1.1  tsutsui 	Elf32_Half      e_shentsize;		/* Section header entry size */
    101      1.1  tsutsui 	Elf32_Half      e_shnum;		/* Number of section headers */
    102      1.1  tsutsui 	Elf32_Half      e_shstrndx;		/* String table index */
    103      1.1  tsutsui } Elf32_Ehdr;
    104      1.1  tsutsui 
    105      1.1  tsutsui typedef struct {
    106      1.1  tsutsui 	unsigned char	e_ident[ELF_NIDENT];	/* Id bytes */
    107      1.1  tsutsui 	Elf64_Half	e_type;			/* file type */
    108      1.1  tsutsui 	Elf64_Half	e_machine;		/* machine type */
    109      1.1  tsutsui 	Elf64_Word	e_version;		/* version number */
    110      1.1  tsutsui 	Elf64_Addr	e_entry;		/* entry point */
    111      1.1  tsutsui 	Elf64_Off	e_phoff;		/* Program hdr offset */
    112      1.1  tsutsui 	Elf64_Off	e_shoff;		/* Section hdr offset */
    113      1.1  tsutsui 	Elf64_Word	e_flags;		/* Processor flags */
    114      1.1  tsutsui 	Elf64_Half	e_ehsize;		/* sizeof ehdr */
    115      1.1  tsutsui 	Elf64_Half	e_phentsize;		/* Program header entry size */
    116      1.1  tsutsui 	Elf64_Half	e_phnum;		/* Number of program headers */
    117      1.1  tsutsui 	Elf64_Half	e_shentsize;		/* Section header entry size */
    118      1.1  tsutsui 	Elf64_Half	e_shnum;		/* Number of section headers */
    119      1.1  tsutsui 	Elf64_Half	e_shstrndx;		/* String table index */
    120      1.1  tsutsui } Elf64_Ehdr;
    121      1.1  tsutsui 
    122      1.1  tsutsui /* e_ident offsets */
    123      1.1  tsutsui #define	EI_MAG0		0	/* '\177' */
    124      1.1  tsutsui #define	EI_MAG1		1	/* 'E'    */
    125      1.1  tsutsui #define	EI_MAG2		2	/* 'L'    */
    126      1.1  tsutsui #define	EI_MAG3		3	/* 'F'    */
    127      1.1  tsutsui #define	EI_CLASS	4	/* File class */
    128      1.1  tsutsui #define	EI_DATA		5	/* Data encoding */
    129      1.1  tsutsui #define	EI_VERSION	6	/* File version */
    130      1.1  tsutsui #define	EI_OSABI	7	/* Operating system/ABI identification */
    131      1.1  tsutsui #define	EI_ABIVERSION	8	/* ABI version */
    132      1.1  tsutsui #define	EI_PAD		9	/* Start of padding bytes up to EI_NIDENT*/
    133      1.1  tsutsui 
    134      1.1  tsutsui /* e_ident[ELFMAG0,ELFMAG3] */
    135      1.1  tsutsui #define	ELFMAG0		0x7f
    136      1.1  tsutsui #define	ELFMAG1		'E'
    137      1.1  tsutsui #define	ELFMAG2		'L'
    138      1.1  tsutsui #define	ELFMAG3		'F'
    139      1.1  tsutsui #define	ELFMAG		"\177ELF"
    140      1.1  tsutsui #define	SELFMAG		4
    141      1.1  tsutsui 
    142      1.1  tsutsui /* e_ident[EI_CLASS] */
    143      1.1  tsutsui #define	ELFCLASSNONE	0	/* Invalid class */
    144      1.1  tsutsui #define	ELFCLASS32	1	/* 32-bit objects */
    145      1.1  tsutsui #define	ELFCLASS64	2	/* 64-bit objects */
    146      1.1  tsutsui #define	ELFCLASSNUM	3
    147      1.1  tsutsui 
    148      1.1  tsutsui /* e_ident[EI_DATA] */
    149      1.1  tsutsui #define	ELFDATANONE	0	/* Invalid data encoding */
    150      1.1  tsutsui #define	ELFDATA2LSB	1	/* 2's complement values, LSB first */
    151      1.1  tsutsui #define	ELFDATA2MSB	2	/* 2's complement values, MSB first */
    152      1.1  tsutsui 
    153      1.1  tsutsui /* e_ident[EI_VERSION] */
    154      1.1  tsutsui #define	EV_NONE		0	/* Invalid version */
    155      1.1  tsutsui #define	EV_CURRENT	1	/* Current version */
    156      1.1  tsutsui #define	EV_NUM		2
    157      1.1  tsutsui 
    158      1.1  tsutsui /* e_ident[EI_OSABI] */
    159      1.1  tsutsui #define	ELFOSABI_SYSV		0	/* UNIX System V ABI */
    160      1.1  tsutsui #define	ELFOSABI_HPUX		1	/* HP-UX operating system */
    161      1.1  tsutsui #define ELFOSABI_NETBSD		2	/* NetBSD */
    162      1.1  tsutsui #define ELFOSABI_LINUX		3	/* GNU/Linux */
    163      1.1  tsutsui #define ELFOSABI_HURD		4	/* GNU/Hurd */
    164      1.1  tsutsui #define ELFOSABI_86OPEN		5	/* 86Open */
    165      1.1  tsutsui #define ELFOSABI_SOLARIS	6	/* Solaris */
    166      1.1  tsutsui #define ELFOSABI_MONTEREY	7	/* Monterey */
    167      1.1  tsutsui #define ELFOSABI_IRIX		8	/* IRIX */
    168      1.1  tsutsui #define ELFOSABI_FREEBSD	9	/* FreeBSD */
    169      1.1  tsutsui #define ELFOSABI_TRU64		10	/* TRU64 UNIX */
    170      1.1  tsutsui #define ELFOSABI_MODESTO	11	/* Novell Modesto */
    171      1.1  tsutsui #define ELFOSABI_OPENBSD	12	/* OpenBSD */
    172      1.1  tsutsui /* Unofficial OSABIs follow */
    173      1.1  tsutsui #define ELFOSABI_ARM		97	/* ARM */
    174      1.1  tsutsui #define	ELFOSABI_STANDALONE	255	/* Standalone (embedded) application */
    175      1.1  tsutsui 
    176      1.1  tsutsui /* e_type */
    177      1.1  tsutsui #define	ET_NONE		0	/* No file type */
    178      1.1  tsutsui #define	ET_REL		1	/* Relocatable file */
    179      1.1  tsutsui #define	ET_EXEC		2	/* Executable file */
    180      1.1  tsutsui #define	ET_DYN		3	/* Shared object file */
    181      1.1  tsutsui #define	ET_CORE		4	/* Core file */
    182      1.1  tsutsui #define	ET_NUM		5
    183      1.1  tsutsui 
    184      1.1  tsutsui #define	ET_LOOS		0xfe00	/* Operating system specific range */
    185      1.1  tsutsui #define	ET_HIOS		0xfeff
    186      1.1  tsutsui #define	ET_LOPROC	0xff00	/* Processor-specific range */
    187      1.1  tsutsui #define	ET_HIPROC	0xffff
    188      1.1  tsutsui 
    189      1.1  tsutsui /* e_machine */
    190      1.1  tsutsui #define	EM_NONE		0	/* No machine */
    191      1.1  tsutsui #define	EM_M32		1	/* AT&T WE 32100 */
    192      1.1  tsutsui #define	EM_SPARC	2	/* SPARC */
    193      1.1  tsutsui #define	EM_386		3	/* Intel 80386 */
    194      1.1  tsutsui #define	EM_68K		4	/* Motorola 68000 */
    195      1.1  tsutsui #define	EM_88K		5	/* Motorola 88000 */
    196      1.1  tsutsui #define	EM_486		6	/* Intel 80486 */
    197      1.1  tsutsui #define	EM_860		7	/* Intel 80860 */
    198      1.1  tsutsui #define	EM_MIPS		8	/* MIPS I Architecture */
    199      1.1  tsutsui #define	EM_S370		9	/* Amdahl UTS on System/370 */
    200      1.1  tsutsui #define	EM_MIPS_RS3_LE	10	/* MIPS RS3000 Little-endian */
    201      1.1  tsutsui 			/* 11-14 - Reserved */
    202      1.1  tsutsui #define	EM_RS6000	11	/* IBM RS/6000 XXX reserved */
    203      1.1  tsutsui #define	EM_PARISC	15	/* Hewlett-Packard PA-RISC */
    204      1.1  tsutsui #define	EM_NCUBE	16	/* NCube XXX reserved */
    205      1.1  tsutsui #define	EM_VPP500	17	/* Fujitsu VPP500 */
    206      1.1  tsutsui #define	EM_SPARC32PLUS	18	/* Enhanced instruction set SPARC */
    207      1.1  tsutsui #define	EM_960		19	/* Intel 80960 */
    208      1.1  tsutsui #define	EM_PPC		20	/* PowerPC */
    209      1.1  tsutsui #define	EM_PPC64	21	/* 64-bit PowerPC */
    210      1.1  tsutsui 			/* 22-35 - Reserved */
    211      1.1  tsutsui #define	EM_V800		36	/* NEC V800 */
    212      1.1  tsutsui #define	EM_FR20		37	/* Fujitsu FR20 */
    213      1.1  tsutsui #define	EM_RH32		38	/* TRW RH-32 */
    214      1.1  tsutsui #define	EM_RCE		39	/* Motorola RCE */
    215      1.1  tsutsui #define	EM_ARM		40	/* Advanced RISC Machines ARM */
    216      1.1  tsutsui #define	EM_ALPHA	41	/* DIGITAL Alpha */
    217      1.1  tsutsui #define	EM_SH		42	/* Hitachi Super-H */
    218      1.1  tsutsui #define	EM_SPARCV9	43	/* SPARC Version 9 */
    219      1.1  tsutsui #define	EM_TRICORE	44	/* Siemens Tricore */
    220      1.1  tsutsui #define	EM_ARC		45	/* Argonaut RISC Core */
    221      1.1  tsutsui #define	EM_H8_300	46	/* Hitachi H8/300 */
    222      1.1  tsutsui #define	EM_H8_300H	47	/* Hitachi H8/300H */
    223      1.1  tsutsui #define	EM_H8S		48	/* Hitachi H8S */
    224      1.1  tsutsui #define	EM_H8_500	49	/* Hitachi H8/500 */
    225      1.1  tsutsui #define	EM_IA_64	50	/* Intel Merced Processor */
    226      1.1  tsutsui #define	EM_MIPS_X	51	/* Stanford MIPS-X */
    227      1.1  tsutsui #define	EM_COLDFIRE	52	/* Motorola Coldfire */
    228      1.1  tsutsui #define	EM_68HC12	53	/* Motorola MC68HC12 */
    229      1.1  tsutsui #define	EM_MMA		54	/* Fujitsu MMA Multimedia Accelerator */
    230      1.1  tsutsui #define	EM_PCP		55	/* Siemens PCP */
    231      1.1  tsutsui #define	EM_NCPU		56	/* Sony nCPU embedded RISC processor */
    232      1.1  tsutsui #define	EM_NDR1		57	/* Denso NDR1 microprocessor */
    233      1.1  tsutsui #define	EM_STARCORE	58	/* Motorola Star*Core processor */
    234      1.1  tsutsui #define	EM_ME16		59	/* Toyota ME16 processor */
    235      1.1  tsutsui #define	EM_ST100	60	/* STMicroelectronics ST100 processor */
    236      1.1  tsutsui #define	EM_TINYJ	61	/* Advanced Logic Corp. TinyJ embedded family processor */
    237      1.1  tsutsui #define	EM_X86_64	62	/* AMD x86-64 architecture */
    238      1.1  tsutsui #define	EM_PDSP		63	/* Sony DSP Processor */
    239      1.1  tsutsui 			/* 64-65 - Reserved */
    240      1.1  tsutsui #define	EM_FX66		66	/* Siemens FX66 microcontroller */
    241      1.1  tsutsui #define	EM_ST9PLUS	67	/* STMicroelectronics ST9+ 8/16 bit microcontroller */
    242      1.1  tsutsui #define	EM_ST7		68	/* STMicroelectronics ST7 8-bit microcontroller */
    243      1.1  tsutsui #define	EM_68HC16	69	/* Motorola MC68HC16 Microcontroller */
    244      1.1  tsutsui #define	EM_68HC11	70	/* Motorola MC68HC11 Microcontroller */
    245      1.1  tsutsui #define	EM_68HC08	71	/* Motorola MC68HC08 Microcontroller */
    246      1.1  tsutsui #define	EM_68HC05	72	/* Motorola MC68HC05 Microcontroller */
    247      1.1  tsutsui #define	EM_SVX		73	/* Silicon Graphics SVx */
    248      1.1  tsutsui #define	EM_ST19		74	/* STMicroelectronics ST19 8-bit CPU */
    249      1.1  tsutsui #define	EM_VAX		75	/* Digital VAX */
    250      1.1  tsutsui #define	EM_CRIS		76	/* Axis Communications 32-bit embedded processor */
    251      1.1  tsutsui #define	EM_JAVELIN	77	/* Infineon Technologies 32-bit embedded CPU */
    252      1.1  tsutsui #define	EM_FIREPATH	78	/* Element 14 64-bit DSP processor */
    253      1.1  tsutsui #define	EM_ZSP		79	/* LSI Logic's 16-bit DSP processor */
    254      1.1  tsutsui #define	EM_MMIX		80	/* Donald Knuth's educational 64-bit processor */
    255      1.1  tsutsui #define	EM_HUANY	81	/* Harvard's machine-independent format */
    256      1.1  tsutsui #define	EM_PRISM	82	/* SiTera Prism */
    257      1.1  tsutsui #define	EM_AVR		83	/* Atmel AVR 8-bit microcontroller */
    258      1.1  tsutsui #define	EM_FR30		84	/* Fujitsu FR30 */
    259      1.1  tsutsui #define	EM_D10V		85	/* Mitsubishi D10V */
    260      1.1  tsutsui #define	EM_D30V		86	/* Mitsubishi D30V */
    261      1.1  tsutsui #define	EM_V850		87	/* NEC v850 */
    262      1.1  tsutsui #define	EM_M32R		88	/* Mitsubishi M32R */
    263      1.1  tsutsui #define	EM_MN10300	89	/* Matsushita MN10300 */
    264      1.1  tsutsui #define	EM_MN10200	90	/* Matsushita MN10200 */
    265      1.1  tsutsui #define	EM_PJ		91	/* picoJava */
    266      1.1  tsutsui #define	EM_OPENRISC	92	/* OpenRISC 32-bit embedded processor */
    267      1.1  tsutsui #define	EM_ARC_A5	93	/* ARC Cores Tangent-A5 */
    268      1.1  tsutsui #define	EM_XTENSA	94	/* Tensilica Xtensa Architecture */
    269      1.1  tsutsui #define	EM_NS32K	97	/* National Semiconductor 32000 series */
    270      1.1  tsutsui 
    271      1.1  tsutsui /* Unofficial machine types follow */
    272      1.1  tsutsui #define	EM_ALPHA_EXP	36902	/* used by NetBSD/alpha; obsolete */
    273      1.1  tsutsui #define	EM_NUM		36903
    274      1.1  tsutsui 
    275      1.1  tsutsui /*
    276      1.1  tsutsui  * Program Header
    277      1.1  tsutsui  */
    278      1.1  tsutsui typedef struct {
    279      1.1  tsutsui 	Elf32_Word	p_type;		/* entry type */
    280      1.1  tsutsui 	Elf32_Off	p_offset;	/* offset */
    281      1.1  tsutsui 	Elf32_Addr	p_vaddr;	/* virtual address */
    282      1.1  tsutsui 	Elf32_Addr	p_paddr;	/* physical address */
    283      1.1  tsutsui 	Elf32_Word	p_filesz;	/* file size */
    284      1.1  tsutsui 	Elf32_Word	p_memsz;	/* memory size */
    285      1.1  tsutsui 	Elf32_Word	p_flags;	/* flags */
    286      1.1  tsutsui 	Elf32_Word	p_align;	/* memory & file alignment */
    287      1.1  tsutsui } Elf32_Phdr;
    288      1.1  tsutsui 
    289      1.1  tsutsui typedef struct {
    290      1.1  tsutsui 	Elf64_Word	p_type;		/* entry type */
    291      1.1  tsutsui 	Elf64_Word	p_flags;	/* flags */
    292      1.1  tsutsui 	Elf64_Off	p_offset;	/* offset */
    293      1.1  tsutsui 	Elf64_Addr	p_vaddr;	/* virtual address */
    294      1.1  tsutsui 	Elf64_Addr	p_paddr;	/* physical address */
    295      1.1  tsutsui 	Elf64_Xword	p_filesz;	/* file size */
    296      1.1  tsutsui 	Elf64_Xword	p_memsz;	/* memory size */
    297      1.1  tsutsui 	Elf64_Xword	p_align;	/* memory & file alignment */
    298      1.1  tsutsui } Elf64_Phdr;
    299      1.1  tsutsui 
    300      1.1  tsutsui /* p_type */
    301      1.1  tsutsui #define	PT_NULL		0		/* Program header table entry unused */
    302      1.1  tsutsui #define	PT_LOAD		1		/* Loadable program segment */
    303      1.1  tsutsui #define	PT_DYNAMIC	2		/* Dynamic linking information */
    304      1.1  tsutsui #define	PT_INTERP	3		/* Program interpreter */
    305      1.1  tsutsui #define	PT_NOTE		4		/* Auxiliary information */
    306      1.1  tsutsui #define	PT_SHLIB	5		/* Reserved, unspecified semantics */
    307      1.1  tsutsui #define	PT_PHDR		6		/* Entry for header table itself */
    308      1.1  tsutsui #define	PT_NUM		7
    309      1.1  tsutsui 
    310      1.1  tsutsui /* p_flags */
    311      1.1  tsutsui #define	PF_R		0x4	/* Segment is readable */
    312      1.1  tsutsui #define	PF_W		0x2	/* Segment is writable */
    313      1.1  tsutsui #define	PF_X		0x1	/* Segment is executable */
    314      1.1  tsutsui 
    315      1.1  tsutsui #define	PF_MASKOS	0x0ff00000	/* Opersting system specific values */
    316      1.1  tsutsui #define	PF_MASKPROC	0xf0000000	/* Processor-specific values */
    317      1.1  tsutsui 
    318      1.1  tsutsui #define	PT_LOPROC	0x70000000	/* Processor-specific range */
    319      1.1  tsutsui #define	PT_HIPROC	0x7fffffff
    320      1.1  tsutsui 
    321      1.1  tsutsui #define	PT_MIPS_REGINFO	0x70000000
    322      1.1  tsutsui 
    323      1.1  tsutsui /*
    324      1.1  tsutsui  * Section Headers
    325      1.1  tsutsui  */
    326      1.1  tsutsui typedef struct {
    327      1.1  tsutsui 	Elf32_Word	sh_name;	/* section name (.shstrtab index) */
    328      1.1  tsutsui 	Elf32_Word	sh_type;	/* section type */
    329      1.1  tsutsui 	Elf32_Word	sh_flags;	/* section flags */
    330      1.1  tsutsui 	Elf32_Addr	sh_addr;	/* virtual address */
    331      1.1  tsutsui 	Elf32_Off	sh_offset;	/* file offset */
    332      1.1  tsutsui 	Elf32_Word	sh_size;	/* section size */
    333      1.1  tsutsui 	Elf32_Word	sh_link;	/* link to another */
    334      1.1  tsutsui 	Elf32_Word	sh_info;	/* misc info */
    335      1.1  tsutsui 	Elf32_Word	sh_addralign;	/* memory alignment */
    336      1.1  tsutsui 	Elf32_Word	sh_entsize;	/* table entry size */
    337      1.1  tsutsui } Elf32_Shdr;
    338      1.1  tsutsui 
    339      1.1  tsutsui typedef struct {
    340      1.1  tsutsui 	Elf64_Word	sh_name;	/* section name (.shstrtab index) */
    341      1.1  tsutsui 	Elf64_Word	sh_type;	/* section type */
    342      1.1  tsutsui 	Elf64_Xword	sh_flags;	/* section flags */
    343      1.1  tsutsui 	Elf64_Addr	sh_addr;	/* virtual address */
    344      1.1  tsutsui 	Elf64_Off	sh_offset;	/* file offset */
    345      1.1  tsutsui 	Elf64_Xword	sh_size;	/* section size */
    346      1.1  tsutsui 	Elf64_Word	sh_link;	/* link to another */
    347      1.1  tsutsui 	Elf64_Word	sh_info;	/* misc info */
    348      1.1  tsutsui 	Elf64_Xword	sh_addralign;	/* memory alignment */
    349      1.1  tsutsui 	Elf64_Xword	sh_entsize;	/* table entry size */
    350      1.1  tsutsui } Elf64_Shdr;
    351      1.1  tsutsui 
    352      1.1  tsutsui /* sh_type */
    353      1.1  tsutsui #define	SHT_NULL	0		/* Section header table entry unused */
    354      1.1  tsutsui #define	SHT_PROGBITS	1		/* Program information */
    355      1.1  tsutsui #define	SHT_SYMTAB	2		/* Symbol table */
    356      1.1  tsutsui #define	SHT_STRTAB	3		/* String table */
    357      1.1  tsutsui #define	SHT_RELA	4		/* Relocation information w/ addend */
    358      1.1  tsutsui #define	SHT_HASH	5		/* Symbol hash table */
    359      1.1  tsutsui #define	SHT_DYNAMIC	6		/* Dynamic linking information */
    360      1.1  tsutsui #define	SHT_NOTE	7		/* Auxiliary information */
    361      1.1  tsutsui #define	SHT_NOBITS	8		/* No space allocated in file image */
    362      1.1  tsutsui #define	SHT_REL		9		/* Relocation information w/o addend */
    363      1.1  tsutsui #define	SHT_SHLIB	10		/* Reserved, unspecified semantics */
    364      1.1  tsutsui #define	SHT_DYNSYM	11		/* Symbol table for dynamic linker */
    365      1.1  tsutsui #define	SHT_NUM		12
    366      1.1  tsutsui 
    367      1.1  tsutsui #define	SHT_LOOS	0x60000000	/* Operating system specific range */
    368      1.1  tsutsui #define	SHT_HIOS	0x6fffffff
    369      1.1  tsutsui #define	SHT_LOPROC	0x70000000	/* Processor-specific range */
    370      1.1  tsutsui #define	SHT_HIPROC	0x7fffffff
    371      1.1  tsutsui #define	SHT_LOUSER	0x80000000	/* Application-specific range */
    372      1.1  tsutsui #define	SHT_HIUSER	0xffffffff
    373      1.1  tsutsui 
    374      1.1  tsutsui /* sh_flags */
    375      1.1  tsutsui #define	SHF_WRITE	0x1		/* Section contains writable data */
    376      1.1  tsutsui #define	SHF_ALLOC	0x2		/* Section occupies memory */
    377      1.1  tsutsui #define	SHF_EXECINSTR	0x4		/* Section contains executable insns */
    378      1.1  tsutsui 
    379      1.1  tsutsui #define	SHF_MASKOS	0x0f000000	/* Operating system specific values */
    380      1.1  tsutsui #define	SHF_MASKPROC	0xf0000000	/* Processor-specific values */
    381      1.1  tsutsui 
    382      1.1  tsutsui /*
    383      1.1  tsutsui  * Symbol Table
    384      1.1  tsutsui  */
    385      1.1  tsutsui typedef struct {
    386      1.1  tsutsui 	Elf32_Word	st_name;	/* Symbol name (.symtab index) */
    387      1.1  tsutsui 	Elf32_Word	st_value;	/* value of symbol */
    388      1.1  tsutsui 	Elf32_Word	st_size;	/* size of symbol */
    389      1.1  tsutsui 	Elf_Byte	st_info;	/* type / binding attrs */
    390      1.1  tsutsui 	Elf_Byte	st_other;	/* unused */
    391      1.1  tsutsui 	Elf32_Half	st_shndx;	/* section index of symbol */
    392      1.1  tsutsui } Elf32_Sym;
    393      1.1  tsutsui 
    394      1.1  tsutsui typedef struct {
    395      1.1  tsutsui 	Elf64_Word	st_name;	/* Symbol name (.symtab index) */
    396      1.1  tsutsui 	Elf_Byte	st_info;	/* type / binding attrs */
    397      1.1  tsutsui 	Elf_Byte	st_other;	/* unused */
    398      1.1  tsutsui 	Elf64_Half	st_shndx;	/* section index of symbol */
    399      1.1  tsutsui 	Elf64_Addr	st_value;	/* value of symbol */
    400      1.1  tsutsui 	Elf64_Xword	st_size;	/* size of symbol */
    401      1.1  tsutsui } Elf64_Sym;
    402      1.1  tsutsui 
    403      1.1  tsutsui /* Symbol Table index of the undefined symbol */
    404      1.1  tsutsui #define	ELF_SYM_UNDEFINED	0
    405      1.1  tsutsui 
    406      1.1  tsutsui /* st_info: Symbol Bindings */
    407      1.1  tsutsui #define	STB_LOCAL		0	/* local symbol */
    408      1.1  tsutsui #define	STB_GLOBAL		1	/* global symbol */
    409      1.1  tsutsui #define	STB_WEAK		2	/* weakly defined global symbol */
    410      1.1  tsutsui #define	STB_NUM			3
    411      1.1  tsutsui 
    412      1.1  tsutsui #define	STB_LOOS		10	/* Operating system specific range */
    413      1.1  tsutsui #define	STB_HIOS		12
    414      1.1  tsutsui #define	STB_LOPROC		13	/* Processor-specific range */
    415      1.1  tsutsui #define	STB_HIPROC		15
    416      1.1  tsutsui 
    417      1.1  tsutsui /* st_info: Symbol Types */
    418      1.1  tsutsui #define	STT_NOTYPE		0	/* Type not specified */
    419      1.1  tsutsui #define	STT_OBJECT		1	/* Associated with a data object */
    420      1.1  tsutsui #define	STT_FUNC		2	/* Associated with a function */
    421      1.1  tsutsui #define	STT_SECTION		3	/* Associated with a section */
    422      1.1  tsutsui #define	STT_FILE		4	/* Associated with a file name */
    423      1.1  tsutsui #define	STT_NUM			5
    424      1.1  tsutsui 
    425      1.1  tsutsui #define	STT_LOOS		10	/* Operating system specific range */
    426      1.1  tsutsui #define	STT_HIOS		12
    427      1.1  tsutsui #define	STT_LOPROC		13	/* Processor-specific range */
    428      1.1  tsutsui #define	STT_HIPROC		15
    429      1.1  tsutsui 
    430      1.1  tsutsui /* st_info utility macros */
    431      1.1  tsutsui #define	ELF32_ST_BIND(info)		((Elf32_Word)(info) >> 4)
    432      1.1  tsutsui #define	ELF32_ST_TYPE(info)		((Elf32_Word)(info) & 0xf)
    433      1.1  tsutsui #define	ELF32_ST_INFO(bind,type)	((Elf_Byte)(((bind) << 4) | ((type) & 0xf)))
    434      1.1  tsutsui 
    435      1.1  tsutsui #define	ELF64_ST_BIND(info)		((Elf64_Xword)(info) >> 4)
    436      1.1  tsutsui #define	ELF64_ST_TYPE(info)		((Elf64_Xword)(info) & 0xf)
    437      1.1  tsutsui #define	ELF64_ST_INFO(bind,type)	((Elf_Byte)(((bind) << 4) | ((type) & 0xf)))
    438      1.1  tsutsui 
    439      1.1  tsutsui /*
    440      1.1  tsutsui  * Special section indexes
    441      1.1  tsutsui  */
    442      1.1  tsutsui #define	SHN_UNDEF	0		/* Undefined section */
    443      1.1  tsutsui 
    444      1.1  tsutsui #define	SHN_LORESERVE	0xff00		/* Reserved range */
    445      1.1  tsutsui #define	SHN_ABS		0xfff1		/*  Absolute symbols */
    446      1.1  tsutsui #define	SHN_COMMON	0xfff2		/*  Common symbols */
    447      1.1  tsutsui #define	SHN_HIRESERVE	0xffff
    448      1.1  tsutsui 
    449      1.1  tsutsui #define	SHN_LOPROC	0xff00		/* Processor-specific range */
    450      1.1  tsutsui #define	SHN_HIPROC	0xff1f
    451      1.1  tsutsui #define	SHN_LOOS	0xff20		/* Operating system specific range */
    452      1.1  tsutsui #define	SHN_HIOS	0xff3f
    453      1.1  tsutsui 
    454      1.1  tsutsui #define	SHN_MIPS_ACOMMON 0xff00
    455      1.1  tsutsui #define	SHN_MIPS_TEXT	0xff01
    456      1.1  tsutsui #define	SHN_MIPS_DATA	0xff02
    457      1.1  tsutsui #define	SHN_MIPS_SCOMMON 0xff03
    458      1.1  tsutsui 
    459      1.1  tsutsui /*
    460      1.1  tsutsui  * Relocation Entries
    461      1.1  tsutsui  */
    462      1.1  tsutsui typedef struct {
    463      1.1  tsutsui 	Elf32_Word	r_offset;	/* where to do it */
    464      1.1  tsutsui 	Elf32_Word	r_info;		/* index & type of relocation */
    465      1.1  tsutsui } Elf32_Rel;
    466      1.1  tsutsui 
    467      1.1  tsutsui typedef struct {
    468      1.1  tsutsui 	Elf32_Word	r_offset;	/* where to do it */
    469      1.1  tsutsui 	Elf32_Word	r_info;		/* index & type of relocation */
    470      1.1  tsutsui 	Elf32_Sword	r_addend;	/* adjustment value */
    471      1.1  tsutsui } Elf32_Rela;
    472      1.1  tsutsui 
    473      1.1  tsutsui /* r_info utility macros */
    474      1.1  tsutsui #define	ELF32_R_SYM(info)	((info) >> 8)
    475      1.1  tsutsui #define	ELF32_R_TYPE(info)	((info) & 0xff)
    476      1.1  tsutsui #define	ELF32_R_INFO(sym, type)	(((sym) << 8) + (unsigned char)(type))
    477      1.1  tsutsui 
    478      1.1  tsutsui typedef struct {
    479      1.1  tsutsui 	Elf64_Addr	r_offset;	/* where to do it */
    480      1.1  tsutsui 	Elf64_Xword	r_info;		/* index & type of relocation */
    481      1.1  tsutsui } Elf64_Rel;
    482      1.1  tsutsui 
    483      1.1  tsutsui typedef struct {
    484      1.1  tsutsui 	Elf64_Addr	r_offset;	/* where to do it */
    485      1.1  tsutsui 	Elf64_Xword	r_info;		/* index & type of relocation */
    486      1.1  tsutsui 	Elf64_Sxword	r_addend;	/* adjustment value */
    487      1.1  tsutsui } Elf64_Rela;
    488      1.1  tsutsui 
    489      1.1  tsutsui /* r_info utility macros */
    490      1.1  tsutsui #define	ELF64_R_SYM(info)	((info) >> 32)
    491      1.1  tsutsui #define	ELF64_R_TYPE(info)	((info) & 0xffffffff)
    492      1.1  tsutsui #define	ELF64_R_INFO(sym,type)	(((sym) << 32) + (type))
    493      1.1  tsutsui 
    494      1.1  tsutsui /*
    495      1.1  tsutsui  * Dynamic Section structure array
    496      1.1  tsutsui  */
    497      1.1  tsutsui typedef struct {
    498      1.1  tsutsui 	Elf32_Word	d_tag;		/* entry tag value */
    499      1.1  tsutsui 	union {
    500      1.1  tsutsui 	    Elf32_Addr	d_ptr;
    501      1.1  tsutsui 	    Elf32_Word	d_val;
    502      1.1  tsutsui 	} d_un;
    503      1.1  tsutsui } Elf32_Dyn;
    504      1.1  tsutsui 
    505      1.1  tsutsui typedef struct {
    506      1.1  tsutsui 	Elf64_Xword	d_tag;		/* entry tag value */
    507      1.1  tsutsui 	union {
    508      1.1  tsutsui 	    Elf64_Addr	d_ptr;
    509      1.1  tsutsui 	    Elf64_Xword	d_val;
    510      1.1  tsutsui 	} d_un;
    511      1.1  tsutsui } Elf64_Dyn;
    512      1.1  tsutsui 
    513      1.1  tsutsui /* d_tag */
    514      1.1  tsutsui #define	DT_NULL		0	/* Marks end of dynamic array */
    515      1.1  tsutsui #define	DT_NEEDED	1	/* Name of needed library (DT_STRTAB offset) */
    516      1.1  tsutsui #define	DT_PLTRELSZ	2	/* Size, in bytes, of relocations in PLT */
    517      1.1  tsutsui #define	DT_PLTGOT	3	/* Address of PLT and/or GOT */
    518      1.1  tsutsui #define	DT_HASH		4	/* Address of symbol hash table */
    519      1.1  tsutsui #define	DT_STRTAB	5	/* Address of string table */
    520      1.1  tsutsui #define	DT_SYMTAB	6	/* Address of symbol table */
    521      1.1  tsutsui #define	DT_RELA		7	/* Address of Rela relocation table */
    522      1.1  tsutsui #define	DT_RELASZ	8	/* Size, in bytes, of DT_RELA table */
    523      1.1  tsutsui #define	DT_RELAENT	9	/* Size, in bytes, of one DT_RELA entry */
    524      1.1  tsutsui #define	DT_STRSZ	10	/* Size, in bytes, of DT_STRTAB table */
    525      1.1  tsutsui #define	DT_SYMENT	11	/* Size, in bytes, of one DT_SYMTAB entry */
    526      1.1  tsutsui #define	DT_INIT		12	/* Address of initialization function */
    527      1.1  tsutsui #define	DT_FINI		13	/* Address of termination function */
    528      1.1  tsutsui #define	DT_SONAME	14	/* Shared object name (DT_STRTAB offset) */
    529      1.1  tsutsui #define	DT_RPATH	15	/* Library search path (DT_STRTAB offset) */
    530      1.1  tsutsui #define	DT_SYMBOLIC	16	/* Start symbol search within local object */
    531      1.1  tsutsui #define	DT_REL		17	/* Address of Rel relocation table */
    532      1.1  tsutsui #define	DT_RELSZ	18	/* Size, in bytes, of DT_REL table */
    533      1.1  tsutsui #define	DT_RELENT	19	/* Size, in bytes, of one DT_REL entry */
    534      1.1  tsutsui #define	DT_PLTREL	20 	/* Type of PLT relocation entries */
    535      1.1  tsutsui #define	DT_DEBUG	21	/* Used for debugging; unspecified */
    536      1.1  tsutsui #define	DT_TEXTREL	22	/* Relocations might modify non-writable seg */
    537      1.1  tsutsui #define	DT_JMPREL	23	/* Address of relocations associated with PLT */
    538      1.1  tsutsui #define	DT_BIND_NOW	24	/* Process all relocations at load-time */
    539      1.1  tsutsui #define	DT_INIT_ARRAY	25	/* Address of initialization function array */
    540      1.1  tsutsui #define	DT_FINI_ARRAY	26	/* Size, in bytes, of DT_INIT_ARRAY array */
    541      1.1  tsutsui #define	DT_INIT_ARRAYSZ	27	/* Address of termination function array */
    542      1.1  tsutsui #define	DT_FINI_ARRAYSZ	28	/* Size, in bytes, of DT_FINI_ARRAY array*/
    543      1.1  tsutsui #define	DT_NUM		29
    544      1.1  tsutsui 
    545      1.1  tsutsui #define	DT_LOOS		0x60000000	/* Operating system specific range */
    546      1.1  tsutsui #define	DT_HIOS		0x6fffffff
    547      1.1  tsutsui #define	DT_LOPROC	0x70000000	/* Processor-specific range */
    548      1.1  tsutsui #define	DT_HIPROC	0x7fffffff
    549      1.1  tsutsui 
    550      1.1  tsutsui /*
    551      1.1  tsutsui  * Auxiliary Vectors
    552      1.1  tsutsui  */
    553      1.1  tsutsui typedef struct {
    554      1.1  tsutsui 	Elf32_Word	a_type;				/* 32-bit id */
    555      1.1  tsutsui 	Elf32_Word	a_v;				/* 32-bit id */
    556      1.1  tsutsui } Aux32Info;
    557      1.1  tsutsui 
    558      1.1  tsutsui typedef struct {
    559      1.1  tsutsui 	Elf64_Word	a_type;				/* 32-bit id */
    560      1.1  tsutsui 	Elf64_Xword	a_v;				/* 64-bit id */
    561      1.1  tsutsui } Aux64Info;
    562      1.1  tsutsui 
    563      1.1  tsutsui /* a_type */
    564      1.1  tsutsui #define	AT_NULL		0	/* Marks end of array */
    565      1.1  tsutsui #define	AT_IGNORE	1	/* No meaning, a_un is undefined */
    566      1.1  tsutsui #define	AT_EXECFD	2	/* Open file descriptor of object file */
    567      1.1  tsutsui #define	AT_PHDR		3	/* &phdr[0] */
    568      1.1  tsutsui #define	AT_PHENT	4	/* sizeof(phdr[0]) */
    569      1.1  tsutsui #define	AT_PHNUM	5	/* # phdr entries */
    570      1.1  tsutsui #define	AT_PAGESZ	6	/* PAGESIZE */
    571      1.1  tsutsui #define	AT_BASE		7	/* Interpreter base addr */
    572      1.1  tsutsui #define	AT_FLAGS	8	/* Processor flags */
    573      1.1  tsutsui #define	AT_ENTRY	9	/* Entry address of executable */
    574      1.1  tsutsui #define	AT_DCACHEBSIZE	10	/* Data cache block size */
    575      1.1  tsutsui #define	AT_ICACHEBSIZE	11	/* Instruction cache block size */
    576      1.1  tsutsui #define	AT_UCACHEBSIZE	12	/* Unified cache block size */
    577      1.1  tsutsui 
    578      1.1  tsutsui 	/* Vendor specific */
    579      1.1  tsutsui #define	AT_MIPS_NOTELF	10	/* XXX a_val != 0 -> MIPS XCOFF executable */
    580      1.1  tsutsui 
    581      1.1  tsutsui #define	AT_SUN_UID	2000	/* euid */
    582      1.1  tsutsui #define	AT_SUN_RUID	2001	/* ruid */
    583      1.1  tsutsui #define	AT_SUN_GID	2002	/* egid */
    584      1.1  tsutsui #define	AT_SUN_RGID	2003	/* rgid */
    585      1.1  tsutsui 
    586      1.1  tsutsui 	/* Solaris kernel specific */
    587      1.1  tsutsui #define	AT_SUN_LDELF	2004	/* dynamic linker's ELF header */
    588      1.1  tsutsui #define	AT_SUN_LDSHDR	2005	/* dynamic linker's section header */
    589      1.1  tsutsui #define	AT_SUN_LDNAME	2006	/* dynamic linker's name */
    590      1.1  tsutsui #define	AT_SUN_LPGSIZE	2007	/* large pagesize */
    591      1.1  tsutsui 
    592      1.1  tsutsui 	/* Other information */
    593      1.1  tsutsui #define	AT_SUN_PLATFORM	2008	/* sysinfo(SI_PLATFORM) */
    594      1.1  tsutsui #define	AT_SUN_HWCAP	2009	/* process hardware capabilities */
    595      1.1  tsutsui #define	AT_SUN_IFLUSH	2010	/* do we need to flush the instruction cache? */
    596      1.1  tsutsui #define	AT_SUN_CPU	2011	/* CPU name */
    597      1.1  tsutsui 	/* ibcs2 emulation band aid */
    598      1.1  tsutsui #define	AT_SUN_EMUL_ENTRY 2012	/* coff entry point */
    599      1.1  tsutsui #define	AT_SUN_EMUL_EXECFD 2013	/* coff file descriptor */
    600      1.1  tsutsui 	/* Executable's fully resolved name */
    601      1.1  tsutsui #define	AT_SUN_EXECNAME	2014
    602      1.1  tsutsui 
    603      1.1  tsutsui /*
    604      1.1  tsutsui  * Note Headers
    605      1.1  tsutsui  */
    606      1.1  tsutsui typedef struct {
    607      1.1  tsutsui 	Elf32_Word n_namesz;
    608      1.1  tsutsui 	Elf32_Word n_descsz;
    609      1.1  tsutsui 	Elf32_Word n_type;
    610      1.1  tsutsui } Elf32_Nhdr;
    611      1.1  tsutsui 
    612      1.1  tsutsui typedef struct {
    613      1.1  tsutsui 	Elf64_Word n_namesz;
    614      1.1  tsutsui 	Elf64_Word n_descsz;
    615      1.1  tsutsui 	Elf64_Word n_type;
    616      1.1  tsutsui } Elf64_Nhdr;
    617      1.1  tsutsui 
    618      1.1  tsutsui #define	ELF_NOTE_TYPE_ABI_TAG		1
    619      1.1  tsutsui 
    620      1.1  tsutsui /* GNU-specific note name and description sizes */
    621      1.1  tsutsui #define	ELF_NOTE_ABI_NAMESZ		4
    622      1.1  tsutsui #define	ELF_NOTE_ABI_DESCSZ		16
    623      1.1  tsutsui /* GNU-specific note name */
    624      1.1  tsutsui #define	ELF_NOTE_ABI_NAME		"GNU\0"
    625      1.1  tsutsui 
    626      1.1  tsutsui /* GNU-specific OS/version value stuff */
    627      1.1  tsutsui #define	ELF_NOTE_ABI_OS_LINUX		0
    628      1.1  tsutsui #define	ELF_NOTE_ABI_OS_HURD		1
    629      1.1  tsutsui #define	ELF_NOTE_ABI_OS_SOLARIS		2
    630      1.1  tsutsui 
    631      1.1  tsutsui /* NetBSD-specific note type: Emulation name.  desc is emul name string. */
    632      1.1  tsutsui #define	ELF_NOTE_TYPE_NETBSD_TAG	1
    633      1.1  tsutsui 
    634      1.1  tsutsui /* NetBSD-specific note name and description sizes */
    635      1.1  tsutsui #define	ELF_NOTE_NETBSD_NAMESZ		7
    636      1.1  tsutsui #define	ELF_NOTE_NETBSD_DESCSZ		4
    637      1.1  tsutsui /* NetBSD-specific note name */
    638      1.1  tsutsui #define	ELF_NOTE_NETBSD_NAME		"NetBSD\0\0"
    639      1.1  tsutsui 
    640      1.1  tsutsui /*
    641      1.1  tsutsui  * NetBSD-specific core file information.
    642      1.1  tsutsui  *
    643      1.1  tsutsui  * NetBSD ELF core files use notes to provide information about
    644      1.1  tsutsui  * the process's state.  The note name is "NetBSD-CORE" for
    645      1.1  tsutsui  * information that is global to the process, and "NetBSD-CORE@nn",
    646      1.1  tsutsui  * where "nn" is the lwpid of the LWP that the information belongs
    647      1.1  tsutsui  * to (such as register state).
    648      1.1  tsutsui  *
    649      1.1  tsutsui  * We use the following note identifiers:
    650      1.1  tsutsui  *
    651      1.1  tsutsui  *	ELF_NOTE_NETBSD_CORE_PROCINFO
    652      1.1  tsutsui  *		Note is a "netbsd_elfcore_procinfo" structure.
    653      1.1  tsutsui  *
    654      1.1  tsutsui  * We also use ptrace(2) request numbers (the ones that exist in
    655      1.1  tsutsui  * machine-dependent space) to identify register info notes.  The
    656      1.1  tsutsui  * info in such notes is in the same format that ptrace(2) would
    657      1.1  tsutsui  * export that information.
    658      1.1  tsutsui  *
    659      1.1  tsutsui  * Please try to keep the members of this structure nicely aligned,
    660      1.1  tsutsui  * and if you add elements, add them to the end and bump the version.
    661      1.1  tsutsui  */
    662      1.1  tsutsui 
    663      1.1  tsutsui #define	ELF_NOTE_NETBSD_CORE_NAME	"NetBSD-CORE"
    664      1.1  tsutsui 
    665      1.1  tsutsui #define	ELF_NOTE_NETBSD_CORE_PROCINFO	1
    666      1.1  tsutsui 
    667      1.1  tsutsui #define	NETBSD_ELFCORE_PROCINFO_VERSION	1
    668      1.1  tsutsui 
    669      1.1  tsutsui struct netbsd_elfcore_procinfo {
    670      1.1  tsutsui 	/* Version 1 fields start here. */
    671      1.1  tsutsui 	uint32_t	cpi_version;	/* netbsd_elfcore_procinfo version */
    672      1.1  tsutsui 	uint32_t	cpi_cpisize;	/* sizeof(netbsd_elfcore_procinfo) */
    673      1.1  tsutsui 	uint32_t	cpi_signo;	/* killing signal */
    674      1.1  tsutsui 	uint32_t	cpi_sigcode;	/* signal code */
    675      1.1  tsutsui 	uint32_t	cpi_sigpend[4];	/* pending signals */
    676      1.1  tsutsui 	uint32_t	cpi_sigmask[4];	/* blocked signals */
    677      1.1  tsutsui 	uint32_t	cpi_sigignore[4];/* blocked signals */
    678      1.1  tsutsui 	uint32_t	cpi_sigcatch[4];/* blocked signals */
    679      1.1  tsutsui 	int32_t		cpi_pid;	/* process ID */
    680      1.1  tsutsui 	int32_t		cpi_ppid;	/* parent process ID */
    681      1.1  tsutsui 	int32_t		cpi_pgrp;	/* process group ID */
    682      1.1  tsutsui 	int32_t		cpi_sid;	/* session ID */
    683      1.1  tsutsui 	uint32_t	cpi_ruid;	/* real user ID */
    684      1.1  tsutsui 	uint32_t	cpi_euid;	/* effective user ID */
    685      1.1  tsutsui 	uint32_t	cpi_svuid;	/* saved user ID */
    686      1.1  tsutsui 	uint32_t	cpi_rgid;	/* real group ID */
    687      1.1  tsutsui 	uint32_t	cpi_egid;	/* effective group ID */
    688      1.1  tsutsui 	uint32_t	cpi_svgid;	/* saved group ID */
    689      1.1  tsutsui 	uint32_t	cpi_nlwps;	/* number of LWPs */
    690      1.1  tsutsui 	int8_t		cpi_name[32];	/* copy of p->p_comm */
    691      1.1  tsutsui 	/* Add version 2 fields below here. */
    692      1.1  tsutsui };
    693      1.1  tsutsui 
    694      1.1  tsutsui #if defined(ELFSIZE)
    695      1.1  tsutsui #define	CONCAT(x,y)	__CONCAT(x,y)
    696      1.1  tsutsui #define	ELFNAME(x)	CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
    697      1.1  tsutsui #define	ELFNAME2(x,y)	CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
    698      1.1  tsutsui #define	ELFNAMEEND(x)	CONCAT(x,CONCAT(_elf,ELFSIZE))
    699      1.1  tsutsui #define	ELFDEFNNAME(x)	CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
    700      1.1  tsutsui #endif
    701      1.1  tsutsui 
    702      1.1  tsutsui #if defined(ELFSIZE) && (ELFSIZE == 32)
    703      1.1  tsutsui #define	Elf_Ehdr	Elf32_Ehdr
    704      1.1  tsutsui #define	Elf_Phdr	Elf32_Phdr
    705      1.1  tsutsui #define	Elf_Shdr	Elf32_Shdr
    706      1.1  tsutsui #define	Elf_Sym		Elf32_Sym
    707      1.1  tsutsui #define	Elf_Rel		Elf32_Rel
    708      1.1  tsutsui #define	Elf_Rela	Elf32_Rela
    709      1.1  tsutsui #define	Elf_Dyn		Elf32_Dyn
    710      1.1  tsutsui #define	Elf_Word	Elf32_Word
    711      1.1  tsutsui #define	Elf_Sword	Elf32_Sword
    712      1.1  tsutsui #define	Elf_Addr	Elf32_Addr
    713      1.1  tsutsui #define	Elf_Off		Elf32_Off
    714      1.1  tsutsui #define	Elf_Nhdr	Elf32_Nhdr
    715      1.1  tsutsui 
    716      1.1  tsutsui #define	ELF_R_SYM	ELF32_R_SYM
    717      1.1  tsutsui #define	ELF_R_TYPE	ELF32_R_TYPE
    718      1.1  tsutsui #define	ELFCLASS	ELFCLASS32
    719      1.1  tsutsui 
    720      1.1  tsutsui #define	ELF_ST_BIND	ELF32_ST_BIND
    721      1.1  tsutsui #define	ELF_ST_TYPE	ELF32_ST_TYPE
    722      1.1  tsutsui #define	ELF_ST_INFO	ELF32_ST_INFO
    723      1.1  tsutsui 
    724      1.1  tsutsui #define	AuxInfo		Aux32Info
    725      1.1  tsutsui #elif defined(ELFSIZE) && (ELFSIZE == 64)
    726      1.1  tsutsui #define	Elf_Ehdr	Elf64_Ehdr
    727      1.1  tsutsui #define	Elf_Phdr	Elf64_Phdr
    728      1.1  tsutsui #define	Elf_Shdr	Elf64_Shdr
    729      1.1  tsutsui #define	Elf_Sym		Elf64_Sym
    730      1.1  tsutsui #define	Elf_Rel		Elf64_Rel
    731      1.1  tsutsui #define	Elf_Rela	Elf64_Rela
    732      1.1  tsutsui #define	Elf_Dyn		Elf64_Dyn
    733      1.1  tsutsui #define	Elf_Word	Elf64_Word
    734      1.1  tsutsui #define	Elf_Sword	Elf64_Sword
    735      1.1  tsutsui #define	Elf_Addr	Elf64_Addr
    736      1.1  tsutsui #define	Elf_Off		Elf64_Off
    737      1.1  tsutsui #define	Elf_Nhdr	Elf64_Nhdr
    738      1.1  tsutsui 
    739      1.1  tsutsui #define	ELF_R_SYM	ELF64_R_SYM
    740      1.1  tsutsui #define	ELF_R_TYPE	ELF64_R_TYPE
    741      1.1  tsutsui #define	ELFCLASS	ELFCLASS64
    742      1.1  tsutsui 
    743      1.1  tsutsui #define	ELF_ST_BIND	ELF64_ST_BIND
    744      1.1  tsutsui #define	ELF_ST_TYPE	ELF64_ST_TYPE
    745      1.1  tsutsui #define	ELF_ST_INFO	ELF64_ST_INFO
    746      1.1  tsutsui 
    747      1.1  tsutsui #define	AuxInfo		Aux64Info
    748      1.1  tsutsui #endif
    749      1.1  tsutsui 
    750      1.1  tsutsui #endif /* !_SYS_EXEC_ELF_H_ */
    751