/* [<][>][^][v][top][bottom][index][help] */
1 /*
2 * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
3 * The President and Fellows of Harvard College.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30 #ifndef _ELF_H_
31 #define _ELF_H_
32
33
34 /*
35 * Simplified ELF definitions for OS/161 and System/161.
36 *
37 * Restrictions:
38 * 32-bit only
39 * No support for .o files or linker structures
40 * Does not define all the random symbols a standard elf header would.
41 */
42
43 /* Get MD bits */
44 #include <machine/elf.h>
45
46
47 /*
48 * ELF file header. This appears at the very beginning of an ELF file.
49 */
50 #define ELF_NIDENT 16
51 typedef struct {
52 unsigned char e_ident[ELF_NIDENT]; /* magic number et al. */
53 uint16_t e_type; /* type of file this is */
54 uint16_t e_machine; /* processor type file is for */
55 uint32_t e_version; /* ELF version */
56 uint32_t e_entry; /* address of program entry point */
57 uint32_t e_phoff; /* location in file of phdrs */
58 uint32_t e_shoff; /* ignore */
59 uint32_t e_flags; /* ignore */
60 uint16_t e_ehsize; /* actual size of file header */
61 uint16_t e_phentsize; /* actual size of phdr */
62 uint16_t e_phnum; /* number of phdrs */
63 uint16_t e_shentsize; /* ignore */
64 uint16_t e_shnum; /* ignore */
65 uint16_t e_shstrndx; /* ignore */
66 } Elf32_Ehdr;
67
68 /* Offsets for the 1-byte fields within e_ident[] */
69 #define EI_MAG0 0 /* '\177' */
70 #define EI_MAG1 1 /* 'E' */
71 #define EI_MAG2 2 /* 'L' */
72 #define EI_MAG3 3 /* 'F' */
73 #define EI_CLASS 4 /* File class - always ELFCLASS32 */
74 #define EI_DATA 5 /* Data encoding - ELFDATA2LSB or ELFDATA2MSB*/
75 #define EI_VERSION 6 /* ELF version - EV_CURRENT*/
76 #define EI_OSABI 7 /* OS/syscall ABI identification */
77 #define EI_ABIVERSION 8 /* syscall ABI version */
78 #define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/
79
80 /* Values for these fields */
81
82 /* For e_ident[EI_MAG0..3] */
83 #define ELFMAG0 0x7f
84 #define ELFMAG1 'E'
85 #define ELFMAG2 'L'
86 #define ELFMAG3 'F'
87
88 /* For e_ident[EI_CLASS] */
89 #define ELFCLASSNONE 0 /* Invalid class */
90 #define ELFCLASS32 1 /* 32-bit objects */
91 #define ELFCLASS64 2 /* 64-bit objects */
92
93 /* e_ident[EI_DATA] */
94 #define ELFDATANONE 0 /* Invalid data encoding */
95 #define ELFDATA2LSB 1 /* 2's complement values, LSB first */
96 #define ELFDATA2MSB 2 /* 2's complement values, MSB first */
97
98 /* e_ident[EI_VERSION] */
99 #define EV_NONE 0 /* Invalid version */
100 #define EV_CURRENT 1 /* Current version */
101
102 /* e_ident[EI_OSABI] */
103 #define ELFOSABI_SYSV 0 /* UNIX System V ABI */
104 #define ELFOSABI_HPUX 1 /* HP-UX operating system */
105 #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
106
107
108 /*
109 * Values for e_type
110 */
111 #define ET_NONE 0 /* No file type */
112 #define ET_REL 1 /* Relocatable file */
113 #define ET_EXEC 2 /* Executable file */
114 #define ET_DYN 3 /* Shared object file */
115 #define ET_CORE 4 /* Core file */
116 #define ET_NUM 5
117
118 /*
119 * Values for e_machine
120 */
121 #define EM_NONE 0 /* No machine */
122 #define EM_M32 1 /* AT&T WE 32100 */
123 #define EM_SPARC 2 /* SPARC */
124 #define EM_386 3 /* Intel 80386 */
125 #define EM_68K 4 /* Motorola 68000 */
126 #define EM_88K 5 /* Motorola 88000 */
127 #define EM_486 6 /* Intel 80486 */
128 #define EM_860 7 /* Intel 80860 */
129 #define EM_MIPS 8 /* MIPS I Architecture */
130 #define EM_S370 9 /* Amdahl UTS on System/370 */
131 #define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */
132 #define EM_RS6000 11 /* IBM RS/6000 XXX reserved */
133 #define EM_PARISC 15 /* Hewlett-Packard PA-RISC */
134 #define EM_NCUBE 16 /* NCube XXX reserved */
135 #define EM_VPP500 17 /* Fujitsu VPP500 */
136 #define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
137 #define EM_960 19 /* Intel 80960 */
138 #define EM_PPC 20 /* PowerPC */
139 #define EM_V800 36 /* NEC V800 */
140 #define EM_FR20 37 /* Fujitsu FR20 */
141 #define EM_RH32 38 /* TRW RH-32 */
142 #define EM_RCE 39 /* Motorola RCE */
143 #define EM_ARM 40 /* Advanced RISC Machines ARM */
144 #define EM_ALPHA 41 /* DIGITAL Alpha */
145 #define EM_SH 42 /* Hitachi Super-H */
146 #define EM_SPARCV9 43 /* SPARC Version 9 */
147 #define EM_TRICORE 44 /* Siemens Tricore */
148 #define EM_ARC 45 /* Argonaut RISC Core */
149 #define EM_H8_300 46 /* Hitachi H8/300 */
150 #define EM_H8_300H 47 /* Hitachi H8/300H */
151 #define EM_H8S 48 /* Hitachi H8S */
152 #define EM_H8_500 49 /* Hitachi H8/500 */
153 #define EM_IA_64 50 /* Intel Merced Processor */
154 #define EM_MIPS_X 51 /* Stanford MIPS-X */
155 #define EM_COLDFIRE 52 /* Motorola Coldfire */
156 #define EM_68HC12 53 /* Motorola MC68HC12 */
157 #define EM_VAX 75 /* DIGITAL VAX */
158 #define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */
159 #define EM_NUM 36903
160
161
162 /*
163 * "Program Header" - runtime segment header.
164 * There are Ehdr.e_phnum of these located at one position within the file.
165 *
166 * Note: if p_memsz > p_filesz, the leftover space should be zero-filled.
167 */
168 typedef struct {
169 uint32_t p_type; /* Type of segment */
170 uint32_t p_offset; /* Location of data within file */
171 uint32_t p_vaddr; /* Virtual address */
172 uint32_t p_paddr; /* Ignore */
173 uint32_t p_filesz; /* Size of data within file */
174 uint32_t p_memsz; /* Size of data to be loaded into memory*/
175 uint32_t p_flags; /* Flags */
176 uint32_t p_align; /* Required alignment - can ignore */
177 } Elf32_Phdr;
178
179 /* values for p_type */
180 #define PT_NULL 0 /* Program header table entry unused */
181 #define PT_LOAD 1 /* Loadable program segment */
182 #define PT_DYNAMIC 2 /* Dynamic linking information */
183 #define PT_INTERP 3 /* Program interpreter */
184 #define PT_NOTE 4 /* Auxiliary information */
185 #define PT_SHLIB 5 /* Reserved, unspecified semantics */
186 #define PT_PHDR 6 /* Entry for header table itself */
187 #define PT_NUM 7
188 #define PT_MIPS_REGINFO 0x70000000
189
190 /* values for p_flags */
191 #define PF_R 0x4 /* Segment is readable */
192 #define PF_W 0x2 /* Segment is writable */
193 #define PF_X 0x1 /* Segment is executable */
194
195
196 typedef Elf32_Ehdr Elf_Ehdr;
197 typedef Elf32_Phdr Elf_Phdr;
198
199
200 #endif /* _ELF_H_ */