xref: /haiku/headers/private/storage/ElfX.h (revision 7749d0bb0c358a3279b1b9cc76d8376e900130a5)
1 /*
2  * Copyright 2002-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 // No header guard: The file is included twice by <Elf.h> and must not be
7 // included elsewhere. The _ELFX_BITS macro must be define before inclusion.
8 
9 
10 #undef ElfX
11 
12 #if _ELFX_BITS == 32
13 #	define ElfX(x)	Elf32_##x
14 #elif _ELFX_BITS == 64
15 #	define ElfX(x)	Elf64_##x
16 #endif
17 
18 
19 // object file header
20 typedef struct {
21 	unsigned char	e_ident[EI_NIDENT];
22 	ElfX(Half)		e_type;
23 	ElfX(Half)		e_machine;
24 	ElfX(Word)		e_version;
25 	ElfX(Addr)		e_entry;
26 	ElfX(Off)		e_phoff;
27 	ElfX(Off)		e_shoff;
28 	ElfX(Word)		e_flags;
29 	ElfX(Half)		e_ehsize;
30 	ElfX(Half)		e_phentsize;
31 	ElfX(Half)		e_phnum;
32 	ElfX(Half)		e_shentsize;
33 	ElfX(Half)		e_shnum;
34 	ElfX(Half)		e_shstrndx;
35 } ElfX(Ehdr);
36 
37 // program header
38 typedef struct {
39 	ElfX(Word)	p_type;
40 #if _ELFX_BITS == 64
41 	ElfX(Word)	p_flags;
42 #endif
43 	ElfX(Off)	p_offset;
44 	ElfX(Addr)	p_vaddr;
45 	ElfX(Addr)	p_paddr;
46 	ElfX(Xword)	p_filesz;
47 	ElfX(Xword)	p_memsz;
48 #if _ELFX_BITS == 32
49 	ElfX(Word)	p_flags;
50 #endif
51 	ElfX(Xword)	p_align;
52 } ElfX(Phdr);
53 
54 // section header
55 typedef struct {
56 	ElfX(Word)	sh_name;
57 	ElfX(Word)	sh_type;
58 	ElfX(Xword)	sh_flags;
59 	ElfX(Addr)	sh_addr;
60 	ElfX(Off)	sh_offset;
61 	ElfX(Xword)	sh_size;
62 	ElfX(Word)	sh_link;
63 	ElfX(Word)	sh_info;
64 	ElfX(Xword)	sh_addralign;
65 	ElfX(Xword)	sh_entsize;
66 } ElfX(Shdr);
67 
68 #undef ElfX
69