OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 | |
6 // This file contains the structures define by ELF. | |
7 | |
8 | |
9 #ifndef ELF_READER_ELF_STRUCTS_H_ | |
10 #define ELF_READER_ELF_STRUCTS_H_ | |
11 | |
12 #include "common/types.h" | |
13 | |
14 namespace elf_reader { | |
15 | |
16 // For convienance the common parts between 32 and 64 bit versions | |
17 // of the ELF header have been broken out into seperate structures. | |
18 struct ElfHdrDef { | |
19 uint8_t e_ident[4]; | |
20 uint8_t e_class; | |
21 uint8_t e_encoding; | |
22 uint8_t e_fversion; | |
23 uint8_t e_abi; | |
24 uint8_t e_pad[8]; | |
25 uint16_t e_type; | |
26 uint16_t e_machine; | |
27 uint32_t e_version; | |
28 }; | |
29 | |
30 struct ElfObjDef { | |
31 uint32_t e_flags; | |
32 uint16_t e_ehsize; | |
33 uint16_t e_phentsize; | |
34 uint16_t e_phnum; | |
35 uint16_t e_shentsize; | |
36 uint16_t e_shnum; | |
37 uint16_t e_shstrndx; | |
38 }; | |
39 | |
40 struct ElfHdr32 { | |
41 ElfHdrDef e_def; | |
42 uint32_t e_entry; | |
43 uint32_t e_phoff; | |
44 uint32_t e_shoff; | |
45 ElfObjDef e_obj; | |
46 }; | |
47 | |
48 struct ElfHdr64 { | |
49 ElfHdrDef e_def; | |
50 uint64_t e_entry; | |
51 uint64_t e_phoff; | |
52 uint64_t e_shoff; | |
53 ElfObjDef e_obj; | |
54 }; | |
55 | |
56 struct ElfShdr32 { | |
57 uint32_t sh_name; | |
58 uint32_t sh_type; | |
59 uint32_t sh_flags; | |
60 uint32_t sh_addr; | |
61 uint32_t sh_offset; | |
62 uint32_t sh_size; | |
63 uint32_t sh_link; | |
64 uint32_t sh_info; | |
65 uint32_t sh_addralign; | |
66 uint32_t sh_entsize; | |
67 }; | |
68 | |
69 struct ElfShdr64 { | |
70 uint32_t sh_name; | |
71 uint32_t sh_type; | |
72 uint64_t sh_flags; | |
73 uint64_t sh_addr; | |
74 uint64_t sh_offset; | |
75 uint64_t sh_size; | |
76 uint32_t sh_link; | |
77 uint32_t sh_info; | |
78 uint64_t sh_addralign; | |
79 uint64_t sh_entsize; | |
80 }; | |
81 | |
82 struct ElfPhdr32 { | |
83 uint32_t p_type; | |
84 uint32_t p_offset; | |
85 uint32_t p_vaddr; | |
86 uint32_t p_paddr; | |
87 uint32_t p_filesz; | |
88 uint32_t p_memsz; | |
89 uint32_t p_flags; | |
90 uint32_t p_align; | |
91 }; | |
92 | |
93 struct ElfPhdr64 { | |
94 uint32_t p_type; | |
95 uint32_t p_flags; | |
96 uint64_t p_offset; | |
97 uint64_t p_vaddr; | |
98 uint64_t p_paddr; | |
99 uint64_t p_filesz; | |
100 uint64_t p_memsz; | |
101 uint64_t p_align; | |
102 }; | |
103 | |
104 } // namespace elf_reader | |
105 | |
106 #endif // ELF_READER_ELF_STRUCTS_H_ | |
107 | |
OLD | NEW |