OLD | NEW |
| (Empty) |
1 // Copyright 2010 Google, Inc. All Rights reserved | |
2 // | |
3 // Redistribution and use in source and binary forms, with or without | |
4 // modification, are permitted provided that the following conditions are | |
5 // met: | |
6 // | |
7 // * Redistributions of source code must retain the above copyright | |
8 // notice, this list of conditions and the following disclaimer. | |
9 // * Redistributions in binary form must reproduce the above | |
10 // copyright notice, this list of conditions and the following disclaimer | |
11 // in the documentation and/or other materials provided with the | |
12 // distribution. | |
13 // * Neither the name of Google Inc. nor the names of its | |
14 // contributors may be used to endorse or promote products derived from | |
15 // this software without specific prior written permission. | |
16 // | |
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | |
29 | |
30 // This file contains the structures define by ELF. | |
31 | |
32 | |
33 #ifndef ELF_READER_ELF_STRUCTS_H_ | |
34 #define ELF_READER_ELF_STRUCTS_H_ | |
35 | |
36 #include "common/types.h" | |
37 | |
38 namespace elf_reader { | |
39 | |
40 // For convienance the common parts between 32 and 64 bit versions | |
41 // of the ELF header have been broken out into seperate structures. | |
42 struct ElfHdrDef { | |
43 uint8_t e_ident[4]; | |
44 uint8_t e_class; | |
45 uint8_t e_encoding; | |
46 uint8_t e_fversion; | |
47 uint8_t e_abi; | |
48 uint8_t e_pad[8]; | |
49 uint16_t e_type; | |
50 uint16_t e_machine; | |
51 uint32_t e_version; | |
52 }; | |
53 | |
54 struct ElfObjDef { | |
55 uint32_t e_flags; | |
56 uint16_t e_ehsize; | |
57 uint16_t e_phentsize; | |
58 uint16_t e_phnum; | |
59 uint16_t e_shentsize; | |
60 uint16_t e_shnum; | |
61 uint16_t e_shstrndx; | |
62 }; | |
63 | |
64 struct ElfHdr32 { | |
65 ElfHdrDef e_def; | |
66 uint32_t e_entry; | |
67 uint32_t e_phoff; | |
68 uint32_t e_shoff; | |
69 ElfObjDef e_obj; | |
70 }; | |
71 | |
72 struct ElfHdr64 { | |
73 ElfHdrDef e_def; | |
74 uint64_t e_entry; | |
75 uint64_t e_phoff; | |
76 uint64_t e_shoff; | |
77 ElfObjDef e_obj; | |
78 }; | |
79 | |
80 struct ElfShdr32 { | |
81 uint32_t sh_name; | |
82 uint32_t sh_type; | |
83 uint32_t sh_flags; | |
84 uint32_t sh_addr; | |
85 uint32_t sh_offset; | |
86 uint32_t sh_size; | |
87 uint32_t sh_link; | |
88 uint32_t sh_info; | |
89 uint32_t sh_addralign; | |
90 uint32_t sh_entsize; | |
91 }; | |
92 | |
93 struct ElfShdr64 { | |
94 uint32_t sh_name; | |
95 uint32_t sh_type; | |
96 uint64_t sh_flags; | |
97 uint64_t sh_addr; | |
98 uint64_t sh_offset; | |
99 uint64_t sh_size; | |
100 uint32_t sh_link; | |
101 uint32_t sh_info; | |
102 uint64_t sh_addralign; | |
103 uint64_t sh_entsize; | |
104 }; | |
105 | |
106 struct ElfPhdr32 { | |
107 uint32_t p_type; | |
108 uint32_t p_offset; | |
109 uint32_t p_vaddr; | |
110 uint32_t p_paddr; | |
111 uint32_t p_filesz; | |
112 uint32_t p_memsz; | |
113 uint32_t p_flags; | |
114 uint32_t p_align; | |
115 }; | |
116 | |
117 struct ElfPhdr64 { | |
118 uint32_t p_type; | |
119 uint32_t p_flags; | |
120 uint64_t p_offset; | |
121 uint64_t p_vaddr; | |
122 uint64_t p_paddr; | |
123 uint64_t p_filesz; | |
124 uint64_t p_memsz; | |
125 uint64_t p_align; | |
126 }; | |
127 | |
128 } // namespace elf_reader | |
129 | |
130 #endif // ELF_READER_ELF_STRUCTS_H_ | |
131 | |
OLD | NEW |