FreeNOS
ELFHeader.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIBEXEC_ELFHEADER_H
19 #define __LIBEXEC_ELFHEADER_H
20 
21 #include <Types.h>
22 
37 #define ELF_INDEX_MAGIC0 0
38 
40 #define ELF_INDEX_MAGIC1 1
41 
43 #define ELF_INDEX_MAGIC2 2
44 
46 #define ELF_INDEX_MAGIC3 3
47 
49 #define ELF_INDEX_CLASS 4
50 
52 #define ELF_INDEX_DATA 5
53 
55 #define ELF_INDEX_VERSION 6
56 
58 #define ELF_INDEX_PAD 7
59 
61 #define ELF_INDEX_NIDENT 16
62 
73 #define ELF_MAGIC0 0x7f
74 
76 #define ELF_MAGIC1 'E'
77 
79 #define ELF_MAGIC2 'L'
80 
82 #define ELF_MAGIC3 'F'
83 
94 #define ELF_CLASS_NONE 0
95 
97 #define ELF_CLASS_32 1
98 
100 #define ELF_CLASS_64 2
101 
112 #define ELF_DATA_NONE 0
113 
115 #define ELF_DATA_2LSB 1
116 
118 #define ELF_DATA_2MSB 2
119 
130 #define ELF_TYPE_NONE 0
131 
133 #define ELF_TYPE_REL 1
134 
136 #define ELF_TYPE_EXEC 2
137 
139 #define ELF_TYPE_DYN 3
140 
142 #define ELF_TYPE_CORE 4
143 
145 #define ELF_TYPE_NUM 5
146 
148 #define ELF_TYPE_LOPROC 0xff00
149 
151 #define ELF_TYPE_HIPROC 0xffff
152 
163 #define ELF_MACHINE_NONE 0
164 
166 #define ELF_MACHINE_M32 1
167 
169 #define ELF_MACHINE_SPARC 2
170 
172 #define ELF_MACHINE_386 3
173 
175 #define ELF_MACHINE_68K 4
176 
178 #define ELF_MACHINE_88K 5
179 
181 #define ELF_MACHINE_860 7
182 
184 #define ELF_MACHINE_MIPS_RS3 8
185 
187 #define ELF_MACHINE_MIPS_RS4 10
188 
199 #define ELF_VERSION_NONE 0
200 
202 #define ELF_VERSION_CURRENT 1
203 
211 typedef struct ELFHeader
212 {
215 
218 
221 
224 
227 
230 
231  /* Section header table file offset */
233 
234  /* Processor-specific flags. */
236 
239 
242 
245 
248 
251 
254 }
255 ELFHeader;
256 
263 #define ELF_SEGMENT_NULL 0
264 
266 #define ELF_SEGMENT_LOAD 1
267 
269 #define ELF_SEGMENT_DYNAMIC 2
270 
272 #define ELF_SEGMENT_INTERP 3
273 
275 #define ELF_SEGMENT_NOTE 4
276 
278 #define ELF_SEGMENT_SHLIB 5
279 
281 #define ELF_SEGMENT_SELF 6
282 
284 #define ELF_SEGMENT_LOPROC 0x70000000
285 
287 #define ELF_SEGMENT_HIPROC 0x7fffffff
288 
296 typedef struct ELFSegment
297 {
300 
303 
306 
309 
312 
315 
318 
321 }
322 ELFSegment;
323 
329 #endif /* __LIBEXEC_ELFHEADER_H */
ELFHeader::entry
u32 entry
Entry point virtual address.
Definition: ELFHeader.h:226
Types.h
ELFSegment
ELF program segment in the executable file.
Definition: ELFHeader.h:296
ELFHeader::ident
u8 ident[ELF_INDEX_NIDENT]
Magic number and other info.
Definition: ELFHeader.h:214
ELFHeader::flags
u32 flags
Definition: ELFHeader.h:235
ELFHeader::programHeaderOffset
u32 programHeaderOffset
Program header table file offset.
Definition: ELFHeader.h:229
ELFHeader
struct ELFHeader ELFHeader
Describes an ELF executable and must be placed at the beginning of executable programs.
ELFSegment::fileSize
u32 fileSize
Segment file image size.
Definition: ELFHeader.h:311
ELFHeader::machine
u16 machine
Physical machine architecture.
Definition: ELFHeader.h:220
ELFHeader::version
u32 version
Object file version.
Definition: ELFHeader.h:223
ELFHeader::sectionHeaderOffset
u32 sectionHeaderOffset
Definition: ELFHeader.h:232
ELFSegment::flags
u32 flags
Optional segment flags.
Definition: ELFHeader.h:317
ELFHeader::programHeaderEntryCount
u16 programHeaderEntryCount
Program header table entry count.
Definition: ELFHeader.h:244
ELFSegment::offset
u32 offset
Offset in the file of this segment.
Definition: ELFHeader.h:302
ELFHeader::sectionHeaderStringsIndex
u16 sectionHeaderStringsIndex
Section header string table index.
Definition: ELFHeader.h:253
ELFHeader
Describes an ELF executable and must be placed at the beginning of executable programs.
Definition: ELFHeader.h:211
ELFSegment
struct ELFSegment ELFSegment
ELF program segment in the executable file.
ELFHeader::headerSize
u16 headerSize
ELF header size in bytes.
Definition: ELFHeader.h:238
u16
unsigned short u16
Unsigned 16-bit number.
Definition: Types.h:56
ELFHeader::sectionHeaderEntrySize
u16 sectionHeaderEntrySize
Section header table entry size.
Definition: ELFHeader.h:247
ELFSegment::alignment
u32 alignment
Memory alignment when loaded into memory.
Definition: ELFHeader.h:320
u32
unsigned int u32
Unsigned 32-bit number.
Definition: Types.h:53
ELFSegment::physicalAddress
u32 physicalAddress
Physical address start.
Definition: ELFHeader.h:308
ELFHeader::type
u16 type
Object file type.
Definition: ELFHeader.h:217
u8
unsigned char u8
Unsigned 8-bit number.
Definition: Types.h:59
ELFHeader::programHeaderEntrySize
u16 programHeaderEntrySize
Program header table entry size.
Definition: ELFHeader.h:241
ELFSegment::type
u32 type
Segment type.
Definition: ELFHeader.h:299
ELFHeader::sectionHeaderEntryCount
u16 sectionHeaderEntryCount
Section header table entry count.
Definition: ELFHeader.h:250
ELFSegment::memorySize
u32 memorySize
Segment memory image size.
Definition: ELFHeader.h:314
ELF_INDEX_NIDENT
#define ELF_INDEX_NIDENT
Number of bytes in the ELF identity field.
Definition: ELFHeader.h:61
ELFSegment::virtualAddress
u32 virtualAddress
Virtual address start.
Definition: ELFHeader.h:305