/[gxemul]/upstream/0.3.1/include/exec_elf.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /upstream/0.3.1/include/exec_elf.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations)
Mon Oct 8 16:17:52 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 23236 byte(s)
0.3.1
1 /* gxemul: $Id: exec_elf.h,v 1.4 2005/03/05 12:34:02 debug Exp $ */
2
3 #ifndef __EXEC_ELF_H
4 #define __EXEC_ELF_H
5
6 #include <inttypes.h>
7
8 /* $NetBSD: exec_elf.h,v 1.37.4.2 2001/05/01 12:05:43 he Exp $ */
9
10 /*-
11 * Copyright (c) 1994 The NetBSD Foundation, Inc.
12 * All rights reserved.
13 *
14 * This code is derived from software contributed to The NetBSD Foundation
15 * by Christos Zoulas.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 * 3. All advertising materials mentioning features or use of this software
26 * must display the following acknowledgement:
27 * This product includes software developed by the NetBSD
28 * Foundation, Inc. and its contributors.
29 * 4. Neither the name of The NetBSD Foundation nor the names of its
30 * contributors may be used to endorse or promote products derived
31 * from this software without specific prior written permission.
32 *
33 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
34 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
35 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
36 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
37 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
38 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
39 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
40 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
41 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
42 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
43 * POSSIBILITY OF SUCH DAMAGE.
44 */
45
46
47 typedef uint8_t Elf_Byte;
48
49 typedef uint32_t Elf32_Addr;
50 #define ELF32_FSZ_ADDR 4
51 typedef uint32_t Elf32_Off;
52 #define ELF32_FSZ_OFF 4
53 typedef int32_t Elf32_Sword;
54 #define ELF32_FSZ_SWORD 4
55 typedef uint32_t Elf32_Word;
56 #define ELF32_FSZ_WORD 4
57 typedef uint16_t Elf32_Half;
58 #define ELF32_FSZ_HALF 2
59
60 typedef uint64_t Elf64_Addr;
61 #define ELF64_FSZ_ADDR 8
62 typedef uint64_t Elf64_Off;
63 #define ELF64_FSZ_OFF 8
64 typedef int32_t Elf64_Shalf;
65 #define ELF64_FSZ_SHALF 4
66 #ifdef __sparc_v9__
67 /* #error weird */
68 typedef int32_t Elf64_Sword;
69 #define ELF64_FSZ_SWORD 4
70 typedef uint32_t Elf64_Word;
71 #define ELF64_FSZ_WORD 4
72 #else
73 typedef int64_t Elf64_Sword;
74 #define ELF64_FSZ_SWORD 8
75 typedef uint64_t Elf64_Word;
76 #define ELF64_FSZ_WORD 8
77 #endif
78 typedef int64_t Elf64_Sxword;
79 #define ELF64_FSZ_XWORD 8
80 typedef uint64_t Elf64_Xword;
81 #define ELF64_FSZ_XWORD 8
82 typedef uint32_t Elf64_Half;
83 #define ELF64_FSZ_HALF 4
84 typedef uint16_t Elf64_Quarter;
85 #define ELF64_FSZ_QUARTER 2
86
87 /*
88 * ELF Header
89 */
90 #define ELF_NIDENT 16
91
92 typedef struct {
93 unsigned char e_ident[ELF_NIDENT]; /* Id bytes */
94 Elf32_Half e_type; /* file type */
95 Elf32_Half e_machine; /* machine type */
96 Elf32_Word e_version; /* version number */
97 Elf32_Addr e_entry; /* entry point */
98 Elf32_Off e_phoff; /* Program hdr offset */
99 Elf32_Off e_shoff; /* Section hdr offset */
100 Elf32_Word e_flags; /* Processor flags */
101 Elf32_Half e_ehsize; /* sizeof ehdr */
102 Elf32_Half e_phentsize; /* Program header entry size */
103 Elf32_Half e_phnum; /* Number of program headers */
104 Elf32_Half e_shentsize; /* Section header entry size */
105 Elf32_Half e_shnum; /* Number of section headers */
106 Elf32_Half e_shstrndx; /* String table index */
107 } Elf32_Ehdr;
108
109 typedef struct {
110 unsigned char e_ident[ELF_NIDENT]; /* Id bytes */
111 Elf64_Quarter e_type; /* file type */
112 Elf64_Quarter e_machine; /* machine type */
113 Elf64_Half e_version; /* version number */
114 Elf64_Addr e_entry; /* entry point */
115 Elf64_Off e_phoff; /* Program hdr offset */
116 Elf64_Off e_shoff; /* Section hdr offset */
117 Elf64_Half e_flags; /* Processor flags */
118 Elf64_Quarter e_ehsize; /* sizeof ehdr */
119 Elf64_Quarter e_phentsize; /* Program header entry size */
120 Elf64_Quarter e_phnum; /* Number of program headers */
121 Elf64_Quarter e_shentsize; /* Section header entry size */
122 Elf64_Quarter e_shnum; /* Number of section headers */
123 Elf64_Quarter e_shstrndx; /* String table index */
124 } Elf64_Ehdr;
125
126 /* e_ident offsets */
127 #define EI_MAG0 0 /* '\177' */
128 #define EI_MAG1 1 /* 'E' */
129 #define EI_MAG2 2 /* 'L' */
130 #define EI_MAG3 3 /* 'F' */
131 #define EI_CLASS 4 /* File class */
132 #define EI_DATA 5 /* Data encoding */
133 #define EI_VERSION 6 /* File version */
134 #define EI_OSABI 7 /* Operating system/ABI identification */
135 #define EI_ABIVERSION 8 /* ABI version */
136 #define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/
137
138 /* e_ident[ELFMAG0,ELFMAG3] */
139 #define ELFMAG0 0x7f
140 #define ELFMAG1 'E'
141 #define ELFMAG2 'L'
142 #define ELFMAG3 'F'
143 #define ELFMAG "\177ELF"
144 #define SELFMAG 4
145
146 /* e_ident[EI_CLASS] */
147 #define ELFCLASSNONE 0 /* Invalid class */
148 #define ELFCLASS32 1 /* 32-bit objects */
149 #define ELFCLASS64 2 /* 64-bit objects */
150 #define ELFCLASSNUM 3
151
152 /* e_ident[EI_DATA] */
153 #define ELFDATANONE 0 /* Invalid data encoding */
154 #define ELFDATA2LSB 1 /* 2's complement values, LSB first */
155 #define ELFDATA2MSB 2 /* 2's complement values, MSB first */
156
157 /* e_ident[EI_VERSION] */
158 #define EV_NONE 0 /* Invalid version */
159 #define EV_CURRENT 1 /* Current version */
160 #define EV_NUM 2
161
162 /* e_ident[EI_OSABI] */
163 #define ELFOSABI_SYSV 0 /* UNIX System V ABI */
164 #define ELFOSABI_HPUX 1 /* HP-UX operating system */
165 #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
166
167 /* e_type */
168 #define ET_NONE 0 /* No file type */
169 #define ET_REL 1 /* Relocatable file */
170 #define ET_EXEC 2 /* Executable file */
171 #define ET_DYN 3 /* Shared object file */
172 #define ET_CORE 4 /* Core file */
173 #define ET_NUM 5
174
175 #define ET_LOOS 0xfe00 /* Operating system specific range */
176 #define ET_HIOS 0xfeff
177 #define ET_LOPROC 0xff00 /* Processor-specific range */
178 #define ET_HIPROC 0xffff
179
180 /* e_machine */
181 #define EM_NONE 0 /* No machine */
182 #define EM_M32 1 /* AT&T WE 32100 */
183 #define EM_SPARC 2 /* SPARC */
184 #define EM_386 3 /* Intel 80386 */
185 #define EM_68K 4 /* Motorola 68000 */
186 #define EM_88K 5 /* Motorola 88000 */
187 #define EM_486 6 /* Intel 80486 */
188 #define EM_860 7 /* Intel 80860 */
189 #define EM_MIPS 8 /* MIPS I Architecture */
190 #define EM_S370 9 /* Amdahl UTS on System/370 */
191 #define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */
192 #define EM_RS6000 11 /* IBM RS/6000 XXX reserved */
193 #define EM_PARISC 15 /* Hewlett-Packard PA-RISC */
194 #define EM_NCUBE 16 /* NCube XXX reserved */
195 #define EM_VPP500 17 /* Fujitsu VPP500 */
196 #define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
197 #define EM_960 19 /* Intel 80960 */
198 #define EM_PPC 20 /* PowerPC */
199 #define EM_PPC64 21 /* PowerPC 64-bit (gxemul addition) */
200 #define EM_V800 36 /* NEC V800 */
201 #define EM_FR20 37 /* Fujitsu FR20 */
202 #define EM_RH32 38 /* TRW RH-32 */
203 #define EM_RCE 39 /* Motorola RCE */
204 #define EM_ARM 40 /* Advanced RISC Machines ARM */
205 #define EM_ALPHA 41 /* DIGITAL Alpha */
206 #define EM_SH 42 /* Hitachi Super-H */
207 #define EM_SPARCV9 43 /* SPARC Version 9 */
208 #define EM_TRICORE 44 /* Siemens Tricore */
209 #define EM_ARC 45 /* Argonaut RISC Core */
210 #define EM_H8_300 46 /* Hitachi H8/300 */
211 #define EM_H8_300H 47 /* Hitachi H8/300H */
212 #define EM_H8S 48 /* Hitachi H8S */
213 #define EM_H8_500 49 /* Hitachi H8/500 */
214 #define EM_IA_64 50 /* Intel Merced Processor */
215 #define EM_MIPS_X 51 /* Stanford MIPS-X */
216 #define EM_COLDFIRE 52 /* Motorola Coldfire */
217 #define EM_68HC12 53 /* Motorola MC68HC12 */
218 #define EM_VAX 75 /* DIGITAL VAX */
219 #define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */
220 #define EM_NUM 36903
221
222 /*
223 * Program Header
224 */
225 typedef struct {
226 Elf32_Word p_type; /* entry type */
227 Elf32_Off p_offset; /* offset */
228 Elf32_Addr p_vaddr; /* virtual address */
229 Elf32_Addr p_paddr; /* physical address */
230 Elf32_Word p_filesz; /* file size */
231 Elf32_Word p_memsz; /* memory size */
232 Elf32_Word p_flags; /* flags */
233 Elf32_Word p_align; /* memory & file alignment */
234 } Elf32_Phdr;
235
236 typedef struct {
237 Elf64_Half p_type; /* entry type */
238 Elf64_Half p_flags; /* flags */
239 Elf64_Off p_offset; /* offset */
240 Elf64_Addr p_vaddr; /* virtual address */
241 Elf64_Addr p_paddr; /* physical address */
242 Elf64_Xword p_filesz; /* file size */
243 Elf64_Xword p_memsz; /* memory size */
244 Elf64_Xword p_align; /* memory & file alignment */
245 } Elf64_Phdr;
246
247 /* p_type */
248 #define PT_NULL 0 /* Program header table entry unused */
249 #define PT_LOAD 1 /* Loadable program segment */
250 #define PT_DYNAMIC 2 /* Dynamic linking information */
251 #define PT_INTERP 3 /* Program interpreter */
252 #define PT_NOTE 4 /* Auxiliary information */
253 #define PT_SHLIB 5 /* Reserved, unspecified semantics */
254 #define PT_PHDR 6 /* Entry for header table itself */
255 #define PT_NUM 7
256
257 /* p_flags */
258 #define PF_R 0x4 /* Segment is readable */
259 #define PF_W 0x2 /* Segment is writable */
260 #define PF_X 0x1 /* Segment is executable */
261
262 #define PF_MASKOS 0x0ff00000 /* Opersting system specific values */
263 #define PF_MASKPROC 0xf0000000 /* Processor-specific values */
264
265 #define PT_LOPROC 0x70000000 /* Processor-specific range */
266 #define PT_HIPROC 0x7fffffff
267
268 #define PT_MIPS_REGINFO 0x70000000
269
270 /*
271 * Section Headers
272 */
273 typedef struct {
274 Elf32_Word sh_name; /* section name (.shstrtab index) */
275 Elf32_Word sh_type; /* section type */
276 Elf32_Word sh_flags; /* section flags */
277 Elf32_Addr sh_addr; /* virtual address */
278 Elf32_Off sh_offset; /* file offset */
279 Elf32_Word sh_size; /* section size */
280 Elf32_Word sh_link; /* link to another */
281 Elf32_Word sh_info; /* misc info */
282 Elf32_Word sh_addralign; /* memory alignment */
283 Elf32_Word sh_entsize; /* table entry size */
284 } Elf32_Shdr;
285
286 typedef struct {
287 Elf64_Half sh_name; /* section name (.shstrtab index) */
288 Elf64_Half sh_type; /* section type */
289 Elf64_Xword sh_flags; /* section flags */
290 Elf64_Addr sh_addr; /* virtual address */
291 Elf64_Off sh_offset; /* file offset */
292 Elf64_Xword sh_size; /* section size */
293 Elf64_Half sh_link; /* link to another */
294 Elf64_Half sh_info; /* misc info */
295 Elf64_Xword sh_addralign; /* memory alignment */
296 Elf64_Xword sh_entsize; /* table entry size */
297 } Elf64_Shdr;
298
299 /* sh_type */
300 #define SHT_NULL 0
301 #define SHT_PROGBITS 1
302 #define SHT_SYMTAB 2
303 #define SHT_STRTAB 3
304 #define SHT_RELA 4
305 #define SHT_HASH 5
306 #define SHT_DYNAMIC 6
307 #define SHT_NOTE 7
308 #define SHT_NOBITS 8
309 #define SHT_REL 9
310 #define SHT_SHLIB 10
311 #define SHT_DYNSYM 11
312 #define SHT_NUM 12
313
314 #define SHT_LOOS 0x60000000 /* Operating system specific range */
315 #define SHT_HIOS 0x6fffffff
316 #define SHT_LOPROC 0x70000000 /* Processor-specific range */
317 #define SHT_HIPROC 0x7fffffff
318 #define SHT_LOUSER 0x80000000 /* Application-specific range */
319 #define SHT_HIUSER 0xffffffff
320
321 /* sh_flags */
322 #define SHF_WRITE 0x1 /* Section contains writable data */
323 #define SHF_ALLOC 0x2 /* Section occupies memory */
324 #define SHF_EXECINSTR 0x4 /* Section contains executable insns */
325
326 #define SHF_MASKOS 0x0f000000 /* Operating system specific values */
327 #define SHF_MASKPROC 0xf0000000 /* Processor-specific values */
328
329 /*
330 * Symbol Table
331 */
332 typedef struct {
333 Elf32_Word st_name; /* Symbol name (.symtab index) */
334 Elf32_Word st_value; /* value of symbol */
335 Elf32_Word st_size; /* size of symbol */
336 Elf_Byte st_info; /* type / binding attrs */
337 Elf_Byte st_other; /* unused */
338 Elf32_Half st_shndx; /* section index of symbol */
339 } Elf32_Sym;
340
341 typedef struct {
342 Elf64_Half st_name; /* Symbol name (.symtab index) */
343 Elf_Byte st_info; /* type / binding attrs */
344 Elf_Byte st_other; /* unused */
345 Elf64_Quarter st_shndx; /* section index of symbol */
346 Elf64_Addr st_value; /* value of symbol */
347 Elf64_Xword st_size; /* size of symbol */
348 } Elf64_Sym;
349
350 /* Symbol Table index of the undefined symbol */
351 #define ELF_SYM_UNDEFINED 0
352
353 /* st_info: Symbol Bindings */
354 #define STB_LOCAL 0 /* local symbol */
355 #define STB_GLOBAL 1 /* global symbol */
356 #define STB_WEAK 2 /* weakly defined global symbol */
357 #define STB_NUM 3
358
359 #define STB_LOOS 10 /* Operating system specific range */
360 #define STB_HIOS 12
361 #define STB_LOPROC 13 /* Processor-specific range */
362 #define STB_HIPROC 15
363
364 /* st_info: Symbol Types */
365 #define STT_NOTYPE 0 /* Type not specified */
366 #define STT_OBJECT 1 /* Associated with a data object */
367 #define STT_FUNC 2 /* Associated with a function */
368 #define STT_SECTION 3 /* Associated with a section */
369 #define STT_FILE 4 /* Associated with a file name */
370 #define STT_NUM 5
371
372 #define STT_LOOS 10 /* Operating system specific range */
373 #define STT_HIOS 12
374 #define STT_LOPROC 13 /* Processor-specific range */
375 #define STT_HIPROC 15
376
377 /* st_info utility macros */
378 #define ELF32_ST_BIND(info) ((Elf32_Word)(info) >> 4)
379 #define ELF32_ST_TYPE(info) ((Elf32_Word)(info) & 0xf)
380 #define ELF32_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | ((type) & 0xf)))
381
382 #define ELF64_ST_BIND(info) ((Elf64_Xword)(info) >> 4)
383 #define ELF64_ST_TYPE(info) ((Elf64_Xword)(info) & 0xf)
384 #define ELF64_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | ((type) & 0xf)))
385
386 /*
387 * Special section indexes
388 */
389 #define SHN_UNDEF 0 /* Undefined section */
390
391 #define SHN_LORESERVE 0xff00 /* Reserved range */
392 #define SHN_ABS 0xfff1 /* Absolute symbols */
393 #define SHN_COMMON 0xfff2 /* Common symbols */
394 #define SHN_HIRESERVE 0xffff
395
396 #define SHN_LOPROC 0xff00 /* Processor-specific range */
397 #define SHN_HIPROC 0xff1f
398 #define SHN_LOOS 0xff20 /* Operating system specific range */
399 #define SHN_HIOS 0xff3f
400
401 #define SHN_MIPS_ACOMMON 0xff00
402 #define SHN_MIPS_TEXT 0xff01
403 #define SHN_MIPS_DATA 0xff02
404 #define SHN_MIPS_SCOMMON 0xff03
405
406 /*
407 * Relocation Entries
408 */
409 typedef struct {
410 Elf32_Word r_offset; /* where to do it */
411 Elf32_Word r_info; /* index & type of relocation */
412 } Elf32_Rel;
413
414 typedef struct {
415 Elf32_Word r_offset; /* where to do it */
416 Elf32_Word r_info; /* index & type of relocation */
417 Elf32_Sword r_addend; /* adjustment value */
418 } Elf32_Rela;
419
420 /* r_info utility macros */
421 #define ELF32_R_SYM(info) ((info) >> 8)
422 #define ELF32_R_TYPE(info) ((info) & 0xff)
423 #define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type))
424
425 typedef struct {
426 Elf64_Addr r_offset; /* where to do it */
427 Elf64_Xword r_info; /* index & type of relocation */
428 } Elf64_Rel;
429
430 typedef struct {
431 Elf64_Addr r_offset; /* where to do it */
432 Elf64_Xword r_info; /* index & type of relocation */
433 Elf64_Sxword r_addend; /* adjustment value */
434 } Elf64_Rela;
435
436 /* r_info utility macros */
437 #define ELF64_R_SYM(info) ((info) >> 32)
438 #define ELF64_R_TYPE(info) ((info) & 0xffffffff)
439 #define ELF64_R_INFO(sym,type) (((sym) << 32) + (type))
440
441 /*
442 * Dynamic Section structure array
443 */
444 typedef struct {
445 Elf32_Word d_tag; /* entry tag value */
446 union {
447 Elf32_Addr d_ptr;
448 Elf32_Word d_val;
449 } d_un;
450 } Elf32_Dyn;
451
452 typedef struct {
453 Elf64_Xword d_tag; /* entry tag value */
454 union {
455 Elf64_Addr d_ptr;
456 Elf64_Xword d_val;
457 } d_un;
458 } Elf64_Dyn;
459
460 /* d_tag */
461 #define DT_NULL 0 /* Marks end of dynamic array */
462 #define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */
463 #define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */
464 #define DT_PLTGOT 3 /* Address of PLT and/or GOT */
465 #define DT_HASH 4 /* Address of symbol hash table */
466 #define DT_STRTAB 5 /* Address of string table */
467 #define DT_SYMTAB 6 /* Address of symbol table */
468 #define DT_RELA 7 /* Address of Rela relocation table */
469 #define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */
470 #define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */
471 #define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */
472 #define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */
473 #define DT_INIT 12 /* Address of initialization function */
474 #define DT_FINI 13 /* Address of termination function */
475 #define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */
476 #define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */
477 #define DT_SYMBOLIC 16 /* Start symbol search within local object */
478 #define DT_REL 17 /* Address of Rel relocation table */
479 #define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */
480 #define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */
481 #define DT_PLTREL 20 /* Type of PLT relocation entries */
482 #define DT_DEBUG 21 /* Used for debugging; unspecified */
483 #define DT_TEXTREL 22 /* Relocations might modify non-writable seg */
484 #define DT_JMPREL 23 /* Address of relocations associated with PLT */
485 #define DT_BIND_NOW 24 /* Process all relocations at load-time */
486 #define DT_INIT_ARRAY 25 /* Address of initialization function array */
487 #define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */
488 #define DT_INIT_ARRAYSZ 27 /* Address of termination function array */
489 #define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/
490 #define DT_NUM 29
491
492 #define DT_LOOS 0x60000000 /* Operating system specific range */
493 #define DT_HIOS 0x6fffffff
494 #define DT_LOPROC 0x70000000 /* Processor-specific range */
495 #define DT_HIPROC 0x7fffffff
496
497 /*
498 * Auxiliary Vectors
499 */
500 typedef struct {
501 Elf32_Word a_type; /* 32-bit id */
502 Elf32_Word a_v; /* 32-bit id */
503 } Aux32Info;
504
505 typedef struct {
506 Elf64_Half a_type; /* 32-bit id */
507 Elf64_Xword a_v; /* 64-bit id */
508 } Aux64Info;
509
510 /* a_type */
511 #define AT_NULL 0 /* Marks end of array */
512 #define AT_IGNORE 1 /* No meaning, a_un is undefined */
513 #define AT_EXECFD 2 /* Open file descriptor of object file */
514 #define AT_PHDR 3 /* &phdr[0] */
515 #define AT_PHENT 4 /* sizeof(phdr[0]) */
516 #define AT_PHNUM 5 /* # phdr entries */
517 #define AT_PAGESZ 6 /* PAGESIZE */
518 #define AT_BASE 7 /* Interpreter base addr */
519 #define AT_FLAGS 8 /* Processor flags */
520 #define AT_ENTRY 9 /* Entry address of executable */
521 #define AT_DCACHEBSIZE 10 /* Data cache block size */
522 #define AT_ICACHEBSIZE 11 /* Instruction cache block size */
523 #define AT_UCACHEBSIZE 12 /* Unified cache block size */
524
525 /* Vendor specific */
526 #define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */
527
528 #define AT_SUN_UID 2000 /* euid */
529 #define AT_SUN_RUID 2001 /* ruid */
530 #define AT_SUN_GID 2002 /* egid */
531 #define AT_SUN_RGID 2003 /* rgid */
532
533 /* Solaris kernel specific */
534 #define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */
535 #define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */
536 #define AT_SUN_LDNAME 2006 /* dynamic linker's name */
537 #define AT_SUN_LPGSIZE 2007 /* large pagesize */
538
539 /* Other information */
540 #define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */
541 #define AT_SUN_HWCAP 2009 /* process hardware capabilities */
542 #define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */
543 #define AT_SUN_CPU 2011 /* cpu name */
544 /* ibcs2 emulation band aid */
545 #define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */
546 #define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */
547 /* Executable's fully resolved name */
548 #define AT_SUN_EXECNAME 2014
549
550 /*
551 * Note Headers
552 */
553 typedef struct {
554 Elf32_Word n_namesz;
555 Elf32_Word n_descsz;
556 Elf32_Word n_type;
557 } Elf32_Nhdr;
558
559 typedef struct {
560 Elf64_Half n_namesz;
561 Elf64_Half n_descsz;
562 Elf64_Half n_type;
563 } Elf64_Nhdr;
564
565 #define ELF_NOTE_TYPE_OSVERSION 1
566
567 /* NetBSD-specific note type: OS Version. desc is 4-byte NetBSD integer. */
568 #define ELF_NOTE_NETBSD_TYPE_OSVERSION ELF_NOTE_TYPE_OSVERSION
569
570 /* NetBSD-specific note type: Emulation name. desc is emul name string. */
571 #define ELF_NOTE_NETBSD_TYPE_EMULNAME 2
572
573 /* NetBSD-specific note name and description sizes */
574 #define ELF_NOTE_NETBSD_NAMESZ 7
575 #define ELF_NOTE_NETBSD_DESCSZ 4
576 /* NetBSD-specific note name */
577 #define ELF_NOTE_NETBSD_NAME "NetBSD\0\0"
578
579 /* GNU-specific note name and description sizes */
580 #define ELF_NOTE_GNU_NAMESZ 4
581 #define ELF_NOTE_GNU_DESCSZ 4
582 /* GNU-specific note name */
583 #define ELF_NOTE_GNU_NAME "GNU\0"
584
585 /* GNU-specific OS/version value stuff */
586 #define ELF_NOTE_GNU_OSMASK (u_int32_t)0xff000000
587 #define ELF_NOTE_GNU_OSLINUX (u_int32_t)0x01000000
588 #define ELF_NOTE_GNU_OSMACH (u_int32_t)0x00000000
589
590 #if defined(ELFSIZE)
591 #define CONCAT(x,y) __CONCAT(x,y)
592 #define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
593 #define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
594 #define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE))
595 #define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
596 #endif
597
598 /* #include <machine/elf_machdep.h> */
599
600 #if defined(ELFSIZE) && (ELFSIZE == 32)
601 #define Elf_Ehdr Elf32_Ehdr
602 #define Elf_Phdr Elf32_Phdr
603 #define Elf_Shdr Elf32_Shdr
604 #define Elf_Sym Elf32_Sym
605 #define Elf_Rel Elf32_Rel
606 #define Elf_Rela Elf32_Rela
607 #define Elf_Dyn Elf32_Dyn
608 #define Elf_Word Elf32_Word
609 #define Elf_Sword Elf32_Sword
610 #define Elf_Addr Elf32_Addr
611 #define Elf_Off Elf32_Off
612 #define Elf_Nhdr Elf32_Nhdr
613
614 #define ELF_R_SYM ELF32_R_SYM
615 #define ELF_R_TYPE ELF32_R_TYPE
616 #define ELFCLASS ELFCLASS32
617
618 #define ELF_ST_BIND ELF32_ST_BIND
619 #define ELF_ST_TYPE ELF32_ST_TYPE
620 #define ELF_ST_INFO ELF32_ST_INFO
621
622 #define AuxInfo Aux32Info
623 #elif defined(ELFSIZE) && (ELFSIZE == 64)
624 #define Elf_Ehdr Elf64_Ehdr
625 #define Elf_Phdr Elf64_Phdr
626 #define Elf_Shdr Elf64_Shdr
627 #define Elf_Sym Elf64_Sym
628 #define Elf_Rel Elf64_Rel
629 #define Elf_Rela Elf64_Rela
630 #define Elf_Dyn Elf64_Dyn
631 #define Elf_Word Elf64_Word
632 #define Elf_Sword Elf64_Sword
633 #define Elf_Addr Elf64_Addr
634 #define Elf_Off Elf64_Off
635 #define Elf_Nhdr Elf64_Nhdr
636
637 #define ELF_R_SYM ELF64_R_SYM
638 #define ELF_R_TYPE ELF64_R_TYPE
639 #define ELFCLASS ELFCLASS64
640
641 #define ELF_ST_BIND ELF64_ST_BIND
642 #define ELF_ST_TYPE ELF64_ST_TYPE
643 #define ELF_ST_INFO ELF64_ST_INFO
644
645 #define AuxInfo Aux64Info
646 #endif
647
648 #ifdef _KERNEL
649
650 #define ELF_AUX_ENTRIES 8 /* Size of aux array passed to loader */
651 #define ELF32_NO_ADDR (~(Elf32_Addr)0) /* Indicates addr. not yet filled in */
652 #define ELF64_NO_ADDR (~(Elf64_Addr)0) /* Indicates addr. not yet filled in */
653
654 #if defined(ELFSIZE) && (ELFSIZE == 64)
655 #define ELF_NO_ADDR ELF64_NO_ADDR
656 #elif defined(ELFSIZE) && (ELFSIZE == 32)
657 #define ELF_NO_ADDR ELF32_NO_ADDR
658 #endif
659
660 #if defined(ELFSIZE)
661 struct elf_args {
662 Elf_Addr arg_entry; /* program entry point */
663 Elf_Addr arg_interp; /* Interpreter load address */
664 Elf_Addr arg_phaddr; /* program header address */
665 Elf_Addr arg_phentsize; /* Size of program header */
666 Elf_Addr arg_phnum; /* Number of program headers */
667 };
668 #endif
669
670 #ifndef _LKM
671 #include "opt_execfmt.h"
672 #endif
673
674 #ifdef EXEC_ELF32
675 int exec_elf32_makecmds __P((struct proc *, struct exec_package *));
676 int elf32_read_from __P((struct proc *, struct vnode *, u_long,
677 caddr_t, int));
678 void *elf32_copyargs __P((struct exec_package *, struct ps_strings *,
679 void *, void *));
680 #endif
681
682 #ifdef EXEC_ELF64
683 int exec_elf64_makecmds __P((struct proc *, struct exec_package *));
684 int elf64_read_from __P((struct proc *, struct vnode *, u_long,
685 caddr_t, int));
686 void *elf64_copyargs __P((struct exec_package *, struct ps_strings *,
687 void *, void *));
688 #endif
689
690 /* common */
691 int exec_elf_setup_stack __P((struct proc *, struct exec_package *));
692
693 #endif /* _KERNEL */
694
695 #endif /* __EXEC_ELF_H */
696

  ViewVC Help
Powered by ViewVC 1.1.26