Rev 938 | Rev 1425 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 938 | Rev 952 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2006 Sergey Bondari |
2 | * Copyright (C) 2006 Sergey Bondari |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #ifndef __ELF_H__ |
29 | #ifndef __ELF_H__ |
30 | #define __ELF_H__ |
30 | #define __ELF_H__ |
31 | 31 | ||
32 | #include <arch/elf.h> |
32 | #include <arch/elf.h> |
33 | #include <arch/types.h> |
33 | #include <arch/types.h> |
34 | #include <mm/as.h> |
34 | #include <mm/as.h> |
35 | 35 | ||
36 | /** |
36 | /** |
37 | * current ELF version |
37 | * current ELF version |
38 | */ |
38 | */ |
39 | #define EV_CURRENT 1 |
39 | #define EV_CURRENT 1 |
40 | 40 | ||
41 | /** |
41 | /** |
42 | * ELF types |
42 | * ELF types |
43 | */ |
43 | */ |
44 | #define ET_NONE 0 /* No type */ |
44 | #define ET_NONE 0 /* No type */ |
45 | #define ET_REL 1 /* Relocatable file */ |
45 | #define ET_REL 1 /* Relocatable file */ |
46 | #define ET_EXEC 2 /* Executable */ |
46 | #define ET_EXEC 2 /* Executable */ |
47 | #define ET_DYN 3 /* Shared object */ |
47 | #define ET_DYN 3 /* Shared object */ |
48 | #define ET_CORE 4 /* Core */ |
48 | #define ET_CORE 4 /* Core */ |
49 | #define ET_LOPROC 0xff00 /* Processor specific */ |
49 | #define ET_LOPROC 0xff00 /* Processor specific */ |
50 | #define ET_HIPROC 0xffff /* Processor specific */ |
50 | #define ET_HIPROC 0xffff /* Processor specific */ |
51 | 51 | ||
52 | /** |
52 | /** |
53 | * ELF machine types |
53 | * ELF machine types |
54 | */ |
54 | */ |
55 | #define EM_NO 0 /* No machine */ |
55 | #define EM_NO 0 /* No machine */ |
56 | #define EM_SPARC 2 /* SPARC */ |
56 | #define EM_SPARC 2 /* SPARC */ |
57 | #define EM_386 3 /* i386 */ |
57 | #define EM_386 3 /* i386 */ |
58 | #define EM_MIPS 8 /* MIPS RS3000 */ |
58 | #define EM_MIPS 8 /* MIPS RS3000 */ |
59 | #define EM_MIPS_RS3_LE 10 /* MIPS RS3000 LE */ |
59 | #define EM_MIPS_RS3_LE 10 /* MIPS RS3000 LE */ |
60 | #define EM_PPC 20 /* PPC32 */ |
60 | #define EM_PPC 20 /* PPC32 */ |
61 | #define EM_PPC64 21 /* PPC64 */ |
61 | #define EM_PPC64 21 /* PPC64 */ |
62 | #define EM_SPARCV9 43 /* SPARC64 */ |
62 | #define EM_SPARCV9 43 /* SPARC64 */ |
63 | #define EM_IA_64 50 /* IA-64 */ |
63 | #define EM_IA_64 50 /* IA-64 */ |
64 | #define EM_X86_64 62 /* AMD64/EMT64 */ |
64 | #define EM_X86_64 62 /* AMD64/EMT64 */ |
65 | 65 | ||
66 | /** |
66 | /** |
67 | * ELF identification indexes |
67 | * ELF identification indexes |
68 | */ |
68 | */ |
69 | #define EI_MAG0 0 |
69 | #define EI_MAG0 0 |
70 | #define EI_MAG1 1 |
70 | #define EI_MAG1 1 |
71 | #define EI_MAG2 2 |
71 | #define EI_MAG2 2 |
72 | #define EI_MAG3 3 |
72 | #define EI_MAG3 3 |
73 | #define EI_CLASS 4 /* File class */ |
73 | #define EI_CLASS 4 /* File class */ |
74 | #define EI_DATA 5 /* Data encoding */ |
74 | #define EI_DATA 5 /* Data encoding */ |
75 | #define EI_VERSION 6 /* File version */ |
75 | #define EI_VERSION 6 /* File version */ |
76 | #define EI_OSABI 7 |
76 | #define EI_OSABI 7 |
77 | #define EI_ABIVERSION 8 |
77 | #define EI_ABIVERSION 8 |
78 | #define EI_PAD 9 /* Start of padding bytes */ |
78 | #define EI_PAD 9 /* Start of padding bytes */ |
79 | #define EI_NIDENT 16 /* ELF identification table size */ |
79 | #define EI_NIDENT 16 /* ELF identification table size */ |
80 | 80 | ||
81 | /** |
81 | /** |
82 | * ELF magic number |
82 | * ELF magic number |
83 | */ |
83 | */ |
84 | #define ELFMAG0 0x7f |
84 | #define ELFMAG0 0x7f |
85 | #define ELFMAG1 'E' |
85 | #define ELFMAG1 'E' |
86 | #define ELFMAG2 'L' |
86 | #define ELFMAG2 'L' |
87 | #define ELFMAG3 'F' |
87 | #define ELFMAG3 'F' |
88 | 88 | ||
89 | /** |
89 | /** |
90 | * ELF file classes |
90 | * ELF file classes |
91 | */ |
91 | */ |
92 | #define ELFCLASSNONE 0 |
92 | #define ELFCLASSNONE 0 |
93 | #define ELFCLASS32 1 |
93 | #define ELFCLASS32 1 |
94 | #define ELFCLASS64 2 |
94 | #define ELFCLASS64 2 |
95 | 95 | ||
96 | /** |
96 | /** |
97 | * ELF data encoding types |
97 | * ELF data encoding types |
98 | */ |
98 | */ |
99 | #define ELFDATANONE 0 |
99 | #define ELFDATANONE 0 |
100 | #define ELFDATA2LSB 1 /* Least significant byte first (little endian) */ |
100 | #define ELFDATA2LSB 1 /* Least significant byte first (little endian) */ |
101 | #define ELFDATA2MSB 2 /* Most signigicant byte first (big endian) */ |
101 | #define ELFDATA2MSB 2 /* Most signigicant byte first (big endian) */ |
102 | 102 | ||
103 | /** |
103 | /** |
104 | * ELF error return codes |
104 | * ELF error return codes |
105 | */ |
105 | */ |
106 | #define EE_OK 0 /* No error */ |
106 | #define EE_OK 0 /* No error */ |
107 | #define EE_INVALID 1 /* Invalid ELF image */ |
107 | #define EE_INVALID 1 /* Invalid ELF image */ |
108 | #define EE_MEMORY 2 /* Cannot allocate address space */ |
108 | #define EE_MEMORY 2 /* Cannot allocate address space */ |
109 | #define EE_INCOMPATIBLE 3 /* ELF image is not compatible with current architecture */ |
109 | #define EE_INCOMPATIBLE 3 /* ELF image is not compatible with current architecture */ |
110 | #define EE_UNSUPPORTED 4 /* Non-supported ELF (e.g. dynamic ELFs) */ |
110 | #define EE_UNSUPPORTED 4 /* Non-supported ELF (e.g. dynamic ELFs) */ |
111 | #define EE_IRRECOVERABLE 5 |
111 | #define EE_IRRECOVERABLE 5 |
112 | 112 | ||
113 | /** |
113 | /** |
114 | * ELF section types |
114 | * ELF section types |
115 | */ |
115 | */ |
116 | #define SHT_NULL 0 |
116 | #define SHT_NULL 0 |
117 | #define SHT_PROGBITS 1 |
117 | #define SHT_PROGBITS 1 |
118 | #define SHT_SYMTAB 2 |
118 | #define SHT_SYMTAB 2 |
119 | #define SHT_STRTAB 3 |
119 | #define SHT_STRTAB 3 |
120 | #define SHT_RELA 4 |
120 | #define SHT_RELA 4 |
121 | #define SHT_HASH 5 |
121 | #define SHT_HASH 5 |
122 | #define SHT_DYNAMIC 6 |
122 | #define SHT_DYNAMIC 6 |
123 | #define SHT_NOTE 7 |
123 | #define SHT_NOTE 7 |
124 | #define SHT_NOBITS 8 |
124 | #define SHT_NOBITS 8 |
125 | #define SHT_REL 9 |
125 | #define SHT_REL 9 |
126 | #define SHT_SHLIB 10 |
126 | #define SHT_SHLIB 10 |
127 | #define SHT_DYNSYM 11 |
127 | #define SHT_DYNSYM 11 |
128 | #define SHT_LOOS 0x60000000 |
128 | #define SHT_LOOS 0x60000000 |
129 | #define SHT_HIOS 0x6fffffff |
129 | #define SHT_HIOS 0x6fffffff |
130 | #define SHT_LOPROC 0x70000000 |
130 | #define SHT_LOPROC 0x70000000 |
131 | #define SHT_HIPROC 0x7fffffff |
131 | #define SHT_HIPROC 0x7fffffff |
132 | #define SHT_LOUSER 0x80000000 |
132 | #define SHT_LOUSER 0x80000000 |
133 | #define SHT_HIUSER 0xffffffff |
133 | #define SHT_HIUSER 0xffffffff |
134 | 134 | ||
135 | /** |
135 | /** |
136 | * ELF section flags |
136 | * ELF section flags |
137 | */ |
137 | */ |
138 | #define SHF_WRITE 0x1 |
138 | #define SHF_WRITE 0x1 |
139 | #define SHF_ALLOC 0x2 |
139 | #define SHF_ALLOC 0x2 |
140 | #define SHF_EXECINSTR 0x4 |
140 | #define SHF_EXECINSTR 0x4 |
141 | #define SHF_MASKPROC 0xf0000000 |
141 | #define SHF_MASKPROC 0xf0000000 |
142 | 142 | ||
143 | /** |
143 | /** |
144 | * Symbol binding |
144 | * Symbol binding |
145 | */ |
145 | */ |
146 | #define STB_LOCAL 0 |
146 | #define STB_LOCAL 0 |
147 | #define STB_GLOBAL 1 |
147 | #define STB_GLOBAL 1 |
148 | #define STB_WEAK 2 |
148 | #define STB_WEAK 2 |
149 | #define STB_LOPROC 13 |
149 | #define STB_LOPROC 13 |
150 | #define STB_HIPROC 15 |
150 | #define STB_HIPROC 15 |
151 | 151 | ||
152 | /** |
152 | /** |
153 | * Symbol types |
153 | * Symbol types |
154 | */ |
154 | */ |
155 | #define STT_NOTYPE 0 |
155 | #define STT_NOTYPE 0 |
156 | #define STT_OBJECT 1 |
156 | #define STT_OBJECT 1 |
157 | #define STT_FUNC 2 |
157 | #define STT_FUNC 2 |
158 | #define STT_SECTION 3 |
158 | #define STT_SECTION 3 |
159 | #define STT_FILE 4 |
159 | #define STT_FILE 4 |
160 | #define STT_LOPROC 13 |
160 | #define STT_LOPROC 13 |
161 | #define STT_HIPROC 15 |
161 | #define STT_HIPROC 15 |
162 | 162 | ||
163 | /** |
163 | /** |
164 | * Program segment types |
164 | * Program segment types |
165 | */ |
165 | */ |
166 | #define PT_NULL 0 |
166 | #define PT_NULL 0 |
167 | #define PT_LOAD 1 |
167 | #define PT_LOAD 1 |
168 | #define PT_DYNAMIC 2 |
168 | #define PT_DYNAMIC 2 |
169 | #define PT_INTERP 3 |
169 | #define PT_INTERP 3 |
170 | #define PT_NOTE 4 |
170 | #define PT_NOTE 4 |
171 | #define PT_SHLIB 5 |
171 | #define PT_SHLIB 5 |
172 | #define PT_PHDR 6 |
172 | #define PT_PHDR 6 |
173 | #define PT_LOPROC 0x70000000 |
173 | #define PT_LOPROC 0x70000000 |
174 | #define PT_HIPROC 0x7fffffff |
174 | #define PT_HIPROC 0x7fffffff |
175 | 175 | ||
176 | /** |
176 | /** |
177 | * Program segment attributes. |
177 | * Program segment attributes. |
178 | */ |
178 | */ |
179 | #define PF_X 1 |
179 | #define PF_X 1 |
180 | #define PF_W 2 |
180 | #define PF_W 2 |
181 | #define PF_R 4 |
181 | #define PF_R 4 |
182 | 182 | ||
183 | /** |
183 | /** |
184 | * ELF data types |
184 | * ELF data types |
185 | * |
185 | * |
186 | * These types are found to be identical in both 32-bit and 64-bit |
186 | * These types are found to be identical in both 32-bit and 64-bit |
187 | * ELF object file specifications. They are the only types used |
187 | * ELF object file specifications. They are the only types used |
188 | * in ELF header. |
188 | * in ELF header. |
189 | */ |
189 | */ |
190 | typedef __u64 elf_xword; |
190 | typedef __u64 elf_xword; |
191 | typedef __s64 elf_sxword; |
191 | typedef __s64 elf_sxword; |
192 | typedef __u32 elf_word; |
192 | typedef __u32 elf_word; |
193 | typedef __s32 elf_sword; |
193 | typedef __s32 elf_sword; |
194 | typedef __u16 elf_half; |
194 | typedef __u16 elf_half; |
195 | 195 | ||
196 | /** |
196 | /** |
197 | * 32-bit ELF data types. |
197 | * 32-bit ELF data types. |
198 | * |
198 | * |
199 | * These types are specific for 32-bit format. |
199 | * These types are specific for 32-bit format. |
200 | */ |
200 | */ |
201 | typedef __u32 elf32_addr; |
201 | typedef __u32 elf32_addr; |
202 | typedef __u32 elf32_off; |
202 | typedef __u32 elf32_off; |
203 | 203 | ||
204 | /** |
204 | /** |
205 | * 64-bit ELF data types. |
205 | * 64-bit ELF data types. |
206 | * |
206 | * |
207 | * These types are specific for 64-bit format. |
207 | * These types are specific for 64-bit format. |
208 | */ |
208 | */ |
209 | typedef __u64 elf64_addr; |
209 | typedef __u64 elf64_addr; |
210 | typedef __u64 elf64_off; |
210 | typedef __u64 elf64_off; |
211 | 211 | ||
212 | /** ELF header */ |
212 | /** ELF header */ |
213 | struct elf32_header { |
213 | struct elf32_header { |
214 | __u8 e_ident[EI_NIDENT]; |
214 | __u8 e_ident[EI_NIDENT]; |
215 | elf_half e_type; |
215 | elf_half e_type; |
216 | elf_half e_machine; |
216 | elf_half e_machine; |
217 | elf_word e_version; |
217 | elf_word e_version; |
218 | elf32_addr e_entry; |
218 | elf32_addr e_entry; |
219 | elf32_off e_phoff; |
219 | elf32_off e_phoff; |
220 | elf32_off e_shoff; |
220 | elf32_off e_shoff; |
221 | elf_word e_flags; |
221 | elf_word e_flags; |
222 | elf_half e_ehsize; |
222 | elf_half e_ehsize; |
223 | elf_half e_phentsize; |
223 | elf_half e_phentsize; |
224 | elf_half e_phnum; |
224 | elf_half e_phnum; |
225 | elf_half e_shentsize; |
225 | elf_half e_shentsize; |
226 | elf_half e_shnum; |
226 | elf_half e_shnum; |
227 | elf_half e_shstrndx; |
227 | elf_half e_shstrndx; |
228 | }; |
228 | }; |
229 | struct elf64_header { |
229 | struct elf64_header { |
230 | __u8 e_ident[EI_NIDENT]; |
230 | __u8 e_ident[EI_NIDENT]; |
231 | elf_half e_type; |
231 | elf_half e_type; |
232 | elf_half e_machine; |
232 | elf_half e_machine; |
233 | elf_word e_version; |
233 | elf_word e_version; |
234 | elf64_addr e_entry; |
234 | elf64_addr e_entry; |
235 | elf64_off e_phoff; |
235 | elf64_off e_phoff; |
236 | elf64_off e_shoff; |
236 | elf64_off e_shoff; |
237 | elf_word e_flags; |
237 | elf_word e_flags; |
238 | elf_half e_ehsize; |
238 | elf_half e_ehsize; |
239 | elf_half e_phentsize; |
239 | elf_half e_phentsize; |
240 | elf_half e_phnum; |
240 | elf_half e_phnum; |
241 | elf_half e_shentsize; |
241 | elf_half e_shentsize; |
242 | elf_half e_shnum; |
242 | elf_half e_shnum; |
243 | elf_half e_shstrndx; |
243 | elf_half e_shstrndx; |
244 | }; |
244 | }; |
245 | 245 | ||
246 | /* |
246 | /* |
- | 247 | * ELF segment header. |
|
- | 248 | * Segments headers are also known as program headers. |
|
- | 249 | */ |
|
- | 250 | struct elf32_segment_header { |
|
- | 251 | elf_word p_type; |
|
- | 252 | elf32_off p_offset; |
|
- | 253 | elf32_addr p_vaddr; |
|
- | 254 | elf32_addr p_paddr; |
|
- | 255 | elf_word p_filesz; |
|
- | 256 | elf_word p_memsz; |
|
- | 257 | elf_word p_flags; |
|
- | 258 | elf_word p_align; |
|
- | 259 | }; |
|
- | 260 | struct elf64_segment_header { |
|
- | 261 | elf_word p_type; |
|
- | 262 | elf_word p_flags; |
|
- | 263 | elf64_off p_offset; |
|
- | 264 | elf64_addr p_vaddr; |
|
- | 265 | elf64_addr p_paddr; |
|
- | 266 | elf_xword p_filesz; |
|
- | 267 | elf_xword p_memsz; |
|
- | 268 | elf_xword p_align; |
|
- | 269 | }; |
|
- | 270 | ||
- | 271 | /* |
|
247 | * ELF section header |
272 | * ELF section header |
248 | */ |
273 | */ |
249 | struct elf32_section_header { |
274 | struct elf32_section_header { |
250 | elf_word sh_name; |
275 | elf_word sh_name; |
251 | elf_word sh_type; |
276 | elf_word sh_type; |
252 | elf_word sh_flags; |
277 | elf_word sh_flags; |
253 | elf32_addr sh_addr; |
278 | elf32_addr sh_addr; |
254 | elf32_off sh_offset; |
279 | elf32_off sh_offset; |
255 | elf_word sh_size; |
280 | elf_word sh_size; |
256 | elf_word sh_link; |
281 | elf_word sh_link; |
257 | elf_word sh_info; |
282 | elf_word sh_info; |
258 | elf_word sh_addralign; |
283 | elf_word sh_addralign; |
259 | elf_word sh_entsize; |
284 | elf_word sh_entsize; |
260 | }; |
285 | }; |
261 | struct elf64_section_header { |
286 | struct elf64_section_header { |
262 | elf_word sh_name; |
287 | elf_word sh_name; |
263 | elf_word sh_type; |
288 | elf_word sh_type; |
264 | elf_xword sh_flags; |
289 | elf_xword sh_flags; |
265 | elf64_addr sh_addr; |
290 | elf64_addr sh_addr; |
266 | elf64_off sh_offset; |
291 | elf64_off sh_offset; |
267 | elf_xword sh_size; |
292 | elf_xword sh_size; |
268 | elf_word sh_link; |
293 | elf_word sh_link; |
269 | elf_word sh_info; |
294 | elf_word sh_info; |
270 | elf_xword sh_addralign; |
295 | elf_xword sh_addralign; |
271 | elf_xword sh_entsize; |
296 | elf_xword sh_entsize; |
272 | }; |
297 | }; |
273 | 298 | ||
274 | /* |
299 | /* |
275 | * ELF symbol table entry |
300 | * ELF symbol table entry |
276 | */ |
301 | */ |
277 | struct elf32_symbol { |
302 | struct elf32_symbol { |
278 | elf_word st_name; |
303 | elf_word st_name; |
279 | elf32_addr st_value; |
304 | elf32_addr st_value; |
280 | elf_word st_size; |
305 | elf_word st_size; |
281 | __u8 st_info; |
306 | __u8 st_info; |
282 | __u8 st_other; |
307 | __u8 st_other; |
283 | elf_half st_shndx; |
308 | elf_half st_shndx; |
284 | }; |
309 | }; |
285 | struct elf64_symbol { |
310 | struct elf64_symbol { |
286 | elf_word st_name; |
311 | elf_word st_name; |
287 | __u8 st_info; |
312 | __u8 st_info; |
288 | __u8 st_other; |
313 | __u8 st_other; |
289 | elf_half st_shndx; |
314 | elf_half st_shndx; |
290 | elf64_addr st_value; |
315 | elf64_addr st_value; |
291 | elf_xword st_size; |
316 | elf_xword st_size; |
292 | }; |
317 | }; |
293 | 318 | ||
294 | /* |
- | |
295 | * ELF program header entry |
- | |
296 | */ |
- | |
297 | struct elf32_ph_entry { |
- | |
298 | elf_word p_type; |
- | |
299 | elf32_off p_offset; |
- | |
300 | elf32_addr p_vaddr; |
- | |
301 | elf32_addr p_paddr; |
- | |
302 | elf_word p_filesz; |
- | |
303 | elf_word p_memsz; |
- | |
304 | elf_word p_flags; |
- | |
305 | elf_word p_align; |
- | |
306 | }; |
- | |
307 | struct elf64_ph_entry { |
- | |
308 | elf_word p_type; |
- | |
309 | elf_word p_flags; |
- | |
310 | elf64_off p_offset; |
- | |
311 | elf64_addr p_vaddr; |
- | |
312 | elf64_addr p_paddr; |
- | |
313 | elf_xword p_filesz; |
- | |
314 | elf_xword p_memsz; |
- | |
315 | elf_xword p_align; |
- | |
316 | }; |
- | |
317 | - | ||
318 | #ifdef __32_BITS__ |
319 | #ifdef __32_BITS__ |
319 | typedef struct elf32_header elf_header_t; |
320 | typedef struct elf32_header elf_header_t; |
- | 321 | typedef struct elf32_segment_header elf_segment_header_t; |
|
320 | typedef struct elf32_section_header elf_section_header_t; |
322 | typedef struct elf32_section_header elf_section_header_t; |
321 | typedef struct elf32_symbol elf_symbol_t; |
323 | typedef struct elf32_symbol elf_symbol_t; |
322 | typedef struct elf32_ph_entry elf_ph_entry_t; |
- | |
323 | #endif |
324 | #endif |
324 | #ifdef __64_BITS__ |
325 | #ifdef __64_BITS__ |
325 | typedef struct elf64_header elf_header_t; |
326 | typedef struct elf64_header elf_header_t; |
- | 327 | typedef struct elf64_segment_header elf_segment_header_t; |
|
326 | typedef struct elf64_section_header elf_section_header_t; |
328 | typedef struct elf64_section_header elf_section_header_t; |
327 | typedef struct elf64_symbol elf_symbol_t; |
329 | typedef struct elf64_symbol elf_symbol_t; |
328 | typedef struct elf64_ph_entry elf_ph_entry_t; |
- | |
329 | #endif |
330 | #endif |
330 | 331 | ||
331 | extern int elf_load(elf_header_t *header, as_t * as); |
332 | extern int elf_load(elf_header_t *header, as_t * as); |
332 | extern char *elf_error(int rc); |
333 | extern char *elf_error(int rc); |
333 | 334 | ||
334 | #endif |
335 | #endif |
335 | 336 |