elf.h revision 186212
1186681Sed/*-
2186681Sed * Copyright (c) 1996-1997 John D. Polstra.
3186681Sed * All rights reserved.
4186681Sed *
5186681Sed * Redistribution and use in source and binary forms, with or without
6186681Sed * modification, are permitted provided that the following conditions
7186681Sed * are met:
8186681Sed * 1. Redistributions of source code must retain the above copyright
9186681Sed *    notice, this list of conditions and the following disclaimer.
10186681Sed * 2. Redistributions in binary form must reproduce the above copyright
11186681Sed *    notice, this list of conditions and the following disclaimer in the
12186681Sed *    documentation and/or other materials provided with the distribution.
13186681Sed *
14186681Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15186681Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16186681Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17186681Sed * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18186681Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19186681Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20186681Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21186681Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22186681Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23186681Sed * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24186681Sed * SUCH DAMAGE.
25186681Sed *
26186681Sed * $FreeBSD: head/sys/i386/include/elf.h 186212 2008-12-17 06:56:58Z imp $
27186681Sed */
28186681Sed
29186681Sed#ifndef _MACHINE_ELF_H_
30186681Sed#define	_MACHINE_ELF_H_ 1
31186681Sed
32186681Sed/*
33186681Sed * ELF definitions for the i386 architecture.
34186681Sed */
35186681Sed
36186681Sed#include <sys/elf32.h>	/* Definitions common to all 32 bit architectures. */
37186681Sed#if defined(__ELF_WORD_SIZE) && __ELF_WORD_SIZE == 64
38206141Sed#include <sys/elf64.h>	/* Definitions common to all 64 bit architectures. */
39186681Sed#endif
40186681Sed
41186681Sed#ifndef __ELF_WORD_SIZE
42186681Sed#define	__ELF_WORD_SIZE	32	/* Used by <sys/elf_generic.h> */
43186681Sed#endif
44221698Sed
45221698Sed#include <sys/elf_generic.h>
46221698Sed
47186681Sed#define	ELF_ARCH	EM_386
48199171Sed
49199171Sed#define	ELF_MACHINE_OK(x) ((x) == EM_386 || (x) == EM_486)
50199171Sed
51199171Sed/*
52199171Sed * Auxiliary vector entries for passing information to the interpreter.
53199171Sed *
54199171Sed * The i386 supplement to the SVR4 ABI specification names this "auxv_t",
55199171Sed * but POSIX lays claim to all symbols ending with "_t".
56199171Sed */
57186681Sed
58186681Sedtypedef struct {	/* Auxiliary vector entry on initial stack */
59186681Sed	int	a_type;			/* Entry type. */
60186681Sed	union {
61197470Sed		long	a_val;		/* Integer value. */
62197470Sed		void	*a_ptr;		/* Address. */
63197470Sed		void	(*a_fcn)(void);	/* Function pointer (not used). */
64197470Sed	} a_un;
65186681Sed} Elf32_Auxinfo;
66186681Sed
67186681Sed#if __ELF_WORD_SIZE == 64
68186681Sed/* Fake for amd64 loader support */
69186681Sedtypedef struct {
70186681Sed	int fake;
71186681Sed} Elf64_Auxinfo;
72186681Sed#endif
73186681Sed
74186681Sed__ElfType(Auxinfo);
75186681Sed
76186681Sed/* Values for a_type. */
77186681Sed#define	AT_NULL		0	/* Terminates the vector. */
78186681Sed#define	AT_IGNORE	1	/* Ignored entry. */
79186681Sed#define	AT_EXECFD	2	/* File descriptor of program to load. */
80186681Sed#define	AT_PHDR		3	/* Program header of program already loaded. */
81186681Sed#define	AT_PHENT	4	/* Size of each program header entry. */
82186681Sed#define	AT_PHNUM	5	/* Number of program header entries. */
83186681Sed#define	AT_PAGESZ	6	/* Page size in bytes. */
84186681Sed#define	AT_BASE		7	/* Interpreter's base address. */
85186681Sed#define	AT_FLAGS	8	/* Flags (unused for i386). */
86186681Sed#define	AT_ENTRY	9	/* Where interpreter should transfer control. */
87186681Sed/*
88186681Sed * The following non-standard values are used in Linux ELF binaries.
89186681Sed */
90186681Sed#define	AT_NOTELF	10	/* Program is not ELF ?? */
91186681Sed#define	AT_UID		11	/* Real uid. */
92186681Sed#define	AT_EUID		12	/* Effective uid. */
93186681Sed#define	AT_GID		13	/* Real gid. */
94186681Sed#define	AT_EGID		14	/* Effective gid. */
95186681Sed
96186681Sed#define	AT_COUNT	15	/* Count of defined aux entry types. */
97186681Sed
98186681Sed/*
99186681Sed * Relocation types.
100186681Sed */
101186681Sed
102186681Sed#define	R_386_COUNT	38	/* Count of defined relocation types. */
103186681Sed
104186681Sed/* Define "machine" characteristics */
105186681Sed#define	ELF_TARG_CLASS	ELFCLASS32
106186681Sed#define	ELF_TARG_DATA	ELFDATA2LSB
107186681Sed#define	ELF_TARG_MACH	EM_386
108186681Sed#define	ELF_TARG_VER	1
109186681Sed
110186681Sed#endif /* !_MACHINE_ELF_H_ */
111186681Sed