/[gxemul]/trunk/src/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 /trunk/src/include/exec_elf.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (show annotations)
Mon Oct 8 16:18:00 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 23288 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.707 2005/04/27 16:37:33 debug Exp $
20050408	Some minor updates to the wdc. Linux now doesn't complain
		anymore if a disk is non-present.
20050409	Various minor fixes (a bintrans bug, and some other things).
		The wdc seems to work with Playstation2 emulation, but there
		is a _long_ annoying delay when disks are detected.
		Fixing a really important bintrans bug (when devices and RAM
		are mixed within 4KB pages), which was triggered with
		NetBSD/playstation2 kernels.
20050410	Adding a dummy dev_ps2_ether (just so that NetBSD doesn't
		complain as much during bootup).
		Symbols starting with '$' are now ignored.
		Renaming dev_ps2_ohci.c to dev_ohci.c, etc.
20050411	Moving the bintrans-cache-isolation check from cpu_mips.c to
		cpu_mips_coproc.c. (I thought this would give a speedup, but
		it's not noticable.)
		Better playstation2 sbus interrupt code.
		Skip ahead many ticks if the count register is read manually.
		(This increases the speed of delay-loops that simply read
		the count register.)
20050412	Updates to the playstation2 timer/interrupt code.
		Some other minor updates.
20050413	NetBSD/cobalt runs from a disk image :-) including userland;
		updating the documentation on how to install NetBSD/cobalt
		using NetBSD/pmax (!).
		Some minor bintrans updates (no real speed improvement) and
		other minor updates (playstation2 now uses the -o options).
20050414	Adding a dummy x86 (and AMD64) mode.
20050415	Adding some (32-bit and 16-bit) x86 instructions.
		Adding some initial support for non-SCSI, non-IDE floppy
		images. (The x86 mode can boot from these, more or less.)
		Moving the devices/ and include/ directories to src/devices/
		and src/include/, respectively.
20050416	Continuing on the x86 stuff. (Adding pc_bios.c and some simple
		support for software interrupts in 16-bit mode.)
20050417	Ripping out most of the x86 instruction decoding stuff, trying
		to rewrite it in a cleaner way.
		Disabling some of the least working CPU families in the
		configure script (sparc, x86, alpha, hppa), so that they are
		not enabled by default.
20050418	Trying to fix the bug which caused problems when turning on
		and off bintrans interactively, by flushing the bintrans cache
		whenever bintrans is manually (re)enabled.
20050419	Adding the 'lswi' ppc instruction.
		Minor updates to the x86 instruction decoding.
20050420	Renaming x86 register name indices from R_xx to X86_R_xx (this
		makes building on Tru64 nicer).
20050422	Adding a check for duplicate MIPS TLB entries on tlbwr/tlbwi.
20050427	Adding screenshots to guestoses.html.
		Some minor fixes and testing for the next release.

==============  RELEASE 0.3.2  ==============


1 /* gxemul: $Id: exec_elf.h,v 1.5 2005/04/14 21:01:52 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_AMD64 62 /* AMD64 (GXemul addition) */
219 #define EM_VAX 75 /* DIGITAL VAX */
220 #define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */
221 #define EM_NUM 36903
222
223 /*
224 * Program Header
225 */
226 typedef struct {
227 Elf32_Word p_type; /* entry type */
228 Elf32_Off p_offset; /* offset */
229 Elf32_Addr p_vaddr; /* virtual address */
230 Elf32_Addr p_paddr; /* physical address */
231 Elf32_Word p_filesz; /* file size */
232 Elf32_Word p_memsz; /* memory size */
233 Elf32_Word p_flags; /* flags */
234 Elf32_Word p_align; /* memory & file alignment */
235 } Elf32_Phdr;
236
237 typedef struct {
238 Elf64_Half p_type; /* entry type */
239 Elf64_Half p_flags; /* flags */
240 Elf64_Off p_offset; /* offset */
241 Elf64_Addr p_vaddr; /* virtual address */
242 Elf64_Addr p_paddr; /* physical address */
243 Elf64_Xword p_filesz; /* file size */
244 Elf64_Xword p_memsz; /* memory size */
245 Elf64_Xword p_align; /* memory & file alignment */
246 } Elf64_Phdr;
247
248 /* p_type */
249 #define PT_NULL 0 /* Program header table entry unused */
250 #define PT_LOAD 1 /* Loadable program segment */
251 #define PT_DYNAMIC 2 /* Dynamic linking information */
252 #define PT_INTERP 3 /* Program interpreter */
253 #define PT_NOTE 4 /* Auxiliary information */
254 #define PT_SHLIB 5 /* Reserved, unspecified semantics */
255 #define PT_PHDR 6 /* Entry for header table itself */
256 #define PT_NUM 7
257
258 /* p_flags */
259 #define PF_R 0x4 /* Segment is readable */
260 #define PF_W 0x2 /* Segment is writable */
261 #define PF_X 0x1 /* Segment is executable */
262
263 #define PF_MASKOS 0x0ff00000 /* Opersting system specific values */
264 #define PF_MASKPROC 0xf0000000 /* Processor-specific values */
265
266 #define PT_LOPROC 0x70000000 /* Processor-specific range */
267 #define PT_HIPROC 0x7fffffff
268
269 #define PT_MIPS_REGINFO 0x70000000
270
271 /*
272 * Section Headers
273 */
274 typedef struct {
275 Elf32_Word sh_name; /* section name (.shstrtab index) */
276 Elf32_Word sh_type; /* section type */
277 Elf32_Word sh_flags; /* section flags */
278 Elf32_Addr sh_addr; /* virtual address */
279 Elf32_Off sh_offset; /* file offset */
280 Elf32_Word sh_size; /* section size */
281 Elf32_Word sh_link; /* link to another */
282 Elf32_Word sh_info; /* misc info */
283 Elf32_Word sh_addralign; /* memory alignment */
284 Elf32_Word sh_entsize; /* table entry size */
285 } Elf32_Shdr;
286
287 typedef struct {
288 Elf64_Half sh_name; /* section name (.shstrtab index) */
289 Elf64_Half sh_type; /* section type */
290 Elf64_Xword sh_flags; /* section flags */
291 Elf64_Addr sh_addr; /* virtual address */
292 Elf64_Off sh_offset; /* file offset */
293 Elf64_Xword sh_size; /* section size */
294 Elf64_Half sh_link; /* link to another */
295 Elf64_Half sh_info; /* misc info */
296 Elf64_Xword sh_addralign; /* memory alignment */
297 Elf64_Xword sh_entsize; /* table entry size */
298 } Elf64_Shdr;
299
300 /* sh_type */
301 #define SHT_NULL 0
302 #define SHT_PROGBITS 1
303 #define SHT_SYMTAB 2
304 #define SHT_STRTAB 3
305 #define SHT_RELA 4
306 #define SHT_HASH 5
307 #define SHT_DYNAMIC 6
308 #define SHT_NOTE 7
309 #define SHT_NOBITS 8
310 #define SHT_REL 9
311 #define SHT_SHLIB 10
312 #define SHT_DYNSYM 11
313 #define SHT_NUM 12
314
315 #define SHT_LOOS 0x60000000 /* Operating system specific range */
316 #define SHT_HIOS 0x6fffffff
317 #define SHT_LOPROC 0x70000000 /* Processor-specific range */
318 #define SHT_HIPROC 0x7fffffff
319 #define SHT_LOUSER 0x80000000 /* Application-specific range */
320 #define SHT_HIUSER 0xffffffff
321
322 /* sh_flags */
323 #define SHF_WRITE 0x1 /* Section contains writable data */
324 #define SHF_ALLOC 0x2 /* Section occupies memory */
325 #define SHF_EXECINSTR 0x4 /* Section contains executable insns */
326
327 #define SHF_MASKOS 0x0f000000 /* Operating system specific values */
328 #define SHF_MASKPROC 0xf0000000 /* Processor-specific values */
329
330 /*
331 * Symbol Table
332 */
333 typedef struct {
334 Elf32_Word st_name; /* Symbol name (.symtab index) */
335 Elf32_Word st_value; /* value of symbol */
336 Elf32_Word st_size; /* size of symbol */
337 Elf_Byte st_info; /* type / binding attrs */
338 Elf_Byte st_other; /* unused */
339 Elf32_Half st_shndx; /* section index of symbol */
340 } Elf32_Sym;
341
342 typedef struct {
343 Elf64_Half st_name; /* Symbol name (.symtab index) */
344 Elf_Byte st_info; /* type / binding attrs */
345 Elf_Byte st_other; /* unused */
346 Elf64_Quarter st_shndx; /* section index of symbol */
347 Elf64_Addr st_value; /* value of symbol */
348 Elf64_Xword st_size; /* size of symbol */
349 } Elf64_Sym;
350
351 /* Symbol Table index of the undefined symbol */
352 #define ELF_SYM_UNDEFINED 0
353
354 /* st_info: Symbol Bindings */
355 #define STB_LOCAL 0 /* local symbol */
356 #define STB_GLOBAL 1 /* global symbol */
357 #define STB_WEAK 2 /* weakly defined global symbol */
358 #define STB_NUM 3
359
360 #define STB_LOOS 10 /* Operating system specific range */
361 #define STB_HIOS 12
362 #define STB_LOPROC 13 /* Processor-specific range */
363 #define STB_HIPROC 15
364
365 /* st_info: Symbol Types */
366 #define STT_NOTYPE 0 /* Type not specified */
367 #define STT_OBJECT 1 /* Associated with a data object */
368 #define STT_FUNC 2 /* Associated with a function */
369 #define STT_SECTION 3 /* Associated with a section */
370 #define STT_FILE 4 /* Associated with a file name */
371 #define STT_NUM 5
372
373 #define STT_LOOS 10 /* Operating system specific range */
374 #define STT_HIOS 12
375 #define STT_LOPROC 13 /* Processor-specific range */
376 #define STT_HIPROC 15
377
378 /* st_info utility macros */
379 #define ELF32_ST_BIND(info) ((Elf32_Word)(info) >> 4)
380 #define ELF32_ST_TYPE(info) ((Elf32_Word)(info) & 0xf)
381 #define ELF32_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | ((type) & 0xf)))
382
383 #define ELF64_ST_BIND(info) ((Elf64_Xword)(info) >> 4)
384 #define ELF64_ST_TYPE(info) ((Elf64_Xword)(info) & 0xf)
385 #define ELF64_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | ((type) & 0xf)))
386
387 /*
388 * Special section indexes
389 */
390 #define SHN_UNDEF 0 /* Undefined section */
391
392 #define SHN_LORESERVE 0xff00 /* Reserved range */
393 #define SHN_ABS 0xfff1 /* Absolute symbols */
394 #define SHN_COMMON 0xfff2 /* Common symbols */
395 #define SHN_HIRESERVE 0xffff
396
397 #define SHN_LOPROC 0xff00 /* Processor-specific range */
398 #define SHN_HIPROC 0xff1f
399 #define SHN_LOOS 0xff20 /* Operating system specific range */
400 #define SHN_HIOS 0xff3f
401
402 #define SHN_MIPS_ACOMMON 0xff00
403 #define SHN_MIPS_TEXT 0xff01
404 #define SHN_MIPS_DATA 0xff02
405 #define SHN_MIPS_SCOMMON 0xff03
406
407 /*
408 * Relocation Entries
409 */
410 typedef struct {
411 Elf32_Word r_offset; /* where to do it */
412 Elf32_Word r_info; /* index & type of relocation */
413 } Elf32_Rel;
414
415 typedef struct {
416 Elf32_Word r_offset; /* where to do it */
417 Elf32_Word r_info; /* index & type of relocation */
418 Elf32_Sword r_addend; /* adjustment value */
419 } Elf32_Rela;
420
421 /* r_info utility macros */
422 #define ELF32_R_SYM(info) ((info) >> 8)
423 #define ELF32_R_TYPE(info) ((info) & 0xff)
424 #define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type))
425
426 typedef struct {
427 Elf64_Addr r_offset; /* where to do it */
428 Elf64_Xword r_info; /* index & type of relocation */
429 } Elf64_Rel;
430
431 typedef struct {
432 Elf64_Addr r_offset; /* where to do it */
433 Elf64_Xword r_info; /* index & type of relocation */
434 Elf64_Sxword r_addend; /* adjustment value */
435 } Elf64_Rela;
436
437 /* r_info utility macros */
438 #define ELF64_R_SYM(info) ((info) >> 32)
439 #define ELF64_R_TYPE(info) ((info) & 0xffffffff)
440 #define ELF64_R_INFO(sym,type) (((sym) << 32) + (type))
441
442 /*
443 * Dynamic Section structure array
444 */
445 typedef struct {
446 Elf32_Word d_tag; /* entry tag value */
447 union {
448 Elf32_Addr d_ptr;
449 Elf32_Word d_val;
450 } d_un;
451 } Elf32_Dyn;
452
453 typedef struct {
454 Elf64_Xword d_tag; /* entry tag value */
455 union {
456 Elf64_Addr d_ptr;
457 Elf64_Xword d_val;
458 } d_un;
459 } Elf64_Dyn;
460
461 /* d_tag */
462 #define DT_NULL 0 /* Marks end of dynamic array */
463 #define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */
464 #define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */
465 #define DT_PLTGOT 3 /* Address of PLT and/or GOT */
466 #define DT_HASH 4 /* Address of symbol hash table */
467 #define DT_STRTAB 5 /* Address of string table */
468 #define DT_SYMTAB 6 /* Address of symbol table */
469 #define DT_RELA 7 /* Address of Rela relocation table */
470 #define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */
471 #define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */
472 #define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */
473 #define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */
474 #define DT_INIT 12 /* Address of initialization function */
475 #define DT_FINI 13 /* Address of termination function */
476 #define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */
477 #define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */
478 #define DT_SYMBOLIC 16 /* Start symbol search within local object */
479 #define DT_REL 17 /* Address of Rel relocation table */
480 #define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */
481 #define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */
482 #define DT_PLTREL 20 /* Type of PLT relocation entries */
483 #define DT_DEBUG 21 /* Used for debugging; unspecified */
484 #define DT_TEXTREL 22 /* Relocations might modify non-writable seg */
485 #define DT_JMPREL 23 /* Address of relocations associated with PLT */
486 #define DT_BIND_NOW 24 /* Process all relocations at load-time */
487 #define DT_INIT_ARRAY 25 /* Address of initialization function array */
488 #define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */
489 #define DT_INIT_ARRAYSZ 27 /* Address of termination function array */
490 #define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/
491 #define DT_NUM 29
492
493 #define DT_LOOS 0x60000000 /* Operating system specific range */
494 #define DT_HIOS 0x6fffffff
495 #define DT_LOPROC 0x70000000 /* Processor-specific range */
496 #define DT_HIPROC 0x7fffffff
497
498 /*
499 * Auxiliary Vectors
500 */
501 typedef struct {
502 Elf32_Word a_type; /* 32-bit id */
503 Elf32_Word a_v; /* 32-bit id */
504 } Aux32Info;
505
506 typedef struct {
507 Elf64_Half a_type; /* 32-bit id */
508 Elf64_Xword a_v; /* 64-bit id */
509 } Aux64Info;
510
511 /* a_type */
512 #define AT_NULL 0 /* Marks end of array */
513 #define AT_IGNORE 1 /* No meaning, a_un is undefined */
514 #define AT_EXECFD 2 /* Open file descriptor of object file */
515 #define AT_PHDR 3 /* &phdr[0] */
516 #define AT_PHENT 4 /* sizeof(phdr[0]) */
517 #define AT_PHNUM 5 /* # phdr entries */
518 #define AT_PAGESZ 6 /* PAGESIZE */
519 #define AT_BASE 7 /* Interpreter base addr */
520 #define AT_FLAGS 8 /* Processor flags */
521 #define AT_ENTRY 9 /* Entry address of executable */
522 #define AT_DCACHEBSIZE 10 /* Data cache block size */
523 #define AT_ICACHEBSIZE 11 /* Instruction cache block size */
524 #define AT_UCACHEBSIZE 12 /* Unified cache block size */
525
526 /* Vendor specific */
527 #define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */
528
529 #define AT_SUN_UID 2000 /* euid */
530 #define AT_SUN_RUID 2001 /* ruid */
531 #define AT_SUN_GID 2002 /* egid */
532 #define AT_SUN_RGID 2003 /* rgid */
533
534 /* Solaris kernel specific */
535 #define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */
536 #define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */
537 #define AT_SUN_LDNAME 2006 /* dynamic linker's name */
538 #define AT_SUN_LPGSIZE 2007 /* large pagesize */
539
540 /* Other information */
541 #define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */
542 #define AT_SUN_HWCAP 2009 /* process hardware capabilities */
543 #define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */
544 #define AT_SUN_CPU 2011 /* cpu name */
545 /* ibcs2 emulation band aid */
546 #define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */
547 #define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */
548 /* Executable's fully resolved name */
549 #define AT_SUN_EXECNAME 2014
550
551 /*
552 * Note Headers
553 */
554 typedef struct {
555 Elf32_Word n_namesz;
556 Elf32_Word n_descsz;
557 Elf32_Word n_type;
558 } Elf32_Nhdr;
559
560 typedef struct {
561 Elf64_Half n_namesz;
562 Elf64_Half n_descsz;
563 Elf64_Half n_type;
564 } Elf64_Nhdr;
565
566 #define ELF_NOTE_TYPE_OSVERSION 1
567
568 /* NetBSD-specific note type: OS Version. desc is 4-byte NetBSD integer. */
569 #define ELF_NOTE_NETBSD_TYPE_OSVERSION ELF_NOTE_TYPE_OSVERSION
570
571 /* NetBSD-specific note type: Emulation name. desc is emul name string. */
572 #define ELF_NOTE_NETBSD_TYPE_EMULNAME 2
573
574 /* NetBSD-specific note name and description sizes */
575 #define ELF_NOTE_NETBSD_NAMESZ 7
576 #define ELF_NOTE_NETBSD_DESCSZ 4
577 /* NetBSD-specific note name */
578 #define ELF_NOTE_NETBSD_NAME "NetBSD\0\0"
579
580 /* GNU-specific note name and description sizes */
581 #define ELF_NOTE_GNU_NAMESZ 4
582 #define ELF_NOTE_GNU_DESCSZ 4
583 /* GNU-specific note name */
584 #define ELF_NOTE_GNU_NAME "GNU\0"
585
586 /* GNU-specific OS/version value stuff */
587 #define ELF_NOTE_GNU_OSMASK (u_int32_t)0xff000000
588 #define ELF_NOTE_GNU_OSLINUX (u_int32_t)0x01000000
589 #define ELF_NOTE_GNU_OSMACH (u_int32_t)0x00000000
590
591 #if defined(ELFSIZE)
592 #define CONCAT(x,y) __CONCAT(x,y)
593 #define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
594 #define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
595 #define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE))
596 #define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
597 #endif
598
599 /* #include <machine/elf_machdep.h> */
600
601 #if defined(ELFSIZE) && (ELFSIZE == 32)
602 #define Elf_Ehdr Elf32_Ehdr
603 #define Elf_Phdr Elf32_Phdr
604 #define Elf_Shdr Elf32_Shdr
605 #define Elf_Sym Elf32_Sym
606 #define Elf_Rel Elf32_Rel
607 #define Elf_Rela Elf32_Rela
608 #define Elf_Dyn Elf32_Dyn
609 #define Elf_Word Elf32_Word
610 #define Elf_Sword Elf32_Sword
611 #define Elf_Addr Elf32_Addr
612 #define Elf_Off Elf32_Off
613 #define Elf_Nhdr Elf32_Nhdr
614
615 #define ELF_R_SYM ELF32_R_SYM
616 #define ELF_R_TYPE ELF32_R_TYPE
617 #define ELFCLASS ELFCLASS32
618
619 #define ELF_ST_BIND ELF32_ST_BIND
620 #define ELF_ST_TYPE ELF32_ST_TYPE
621 #define ELF_ST_INFO ELF32_ST_INFO
622
623 #define AuxInfo Aux32Info
624 #elif defined(ELFSIZE) && (ELFSIZE == 64)
625 #define Elf_Ehdr Elf64_Ehdr
626 #define Elf_Phdr Elf64_Phdr
627 #define Elf_Shdr Elf64_Shdr
628 #define Elf_Sym Elf64_Sym
629 #define Elf_Rel Elf64_Rel
630 #define Elf_Rela Elf64_Rela
631 #define Elf_Dyn Elf64_Dyn
632 #define Elf_Word Elf64_Word
633 #define Elf_Sword Elf64_Sword
634 #define Elf_Addr Elf64_Addr
635 #define Elf_Off Elf64_Off
636 #define Elf_Nhdr Elf64_Nhdr
637
638 #define ELF_R_SYM ELF64_R_SYM
639 #define ELF_R_TYPE ELF64_R_TYPE
640 #define ELFCLASS ELFCLASS64
641
642 #define ELF_ST_BIND ELF64_ST_BIND
643 #define ELF_ST_TYPE ELF64_ST_TYPE
644 #define ELF_ST_INFO ELF64_ST_INFO
645
646 #define AuxInfo Aux64Info
647 #endif
648
649 #ifdef _KERNEL
650
651 #define ELF_AUX_ENTRIES 8 /* Size of aux array passed to loader */
652 #define ELF32_NO_ADDR (~(Elf32_Addr)0) /* Indicates addr. not yet filled in */
653 #define ELF64_NO_ADDR (~(Elf64_Addr)0) /* Indicates addr. not yet filled in */
654
655 #if defined(ELFSIZE) && (ELFSIZE == 64)
656 #define ELF_NO_ADDR ELF64_NO_ADDR
657 #elif defined(ELFSIZE) && (ELFSIZE == 32)
658 #define ELF_NO_ADDR ELF32_NO_ADDR
659 #endif
660
661 #if defined(ELFSIZE)
662 struct elf_args {
663 Elf_Addr arg_entry; /* program entry point */
664 Elf_Addr arg_interp; /* Interpreter load address */
665 Elf_Addr arg_phaddr; /* program header address */
666 Elf_Addr arg_phentsize; /* Size of program header */
667 Elf_Addr arg_phnum; /* Number of program headers */
668 };
669 #endif
670
671 #ifndef _LKM
672 #include "opt_execfmt.h"
673 #endif
674
675 #ifdef EXEC_ELF32
676 int exec_elf32_makecmds __P((struct proc *, struct exec_package *));
677 int elf32_read_from __P((struct proc *, struct vnode *, u_long,
678 caddr_t, int));
679 void *elf32_copyargs __P((struct exec_package *, struct ps_strings *,
680 void *, void *));
681 #endif
682
683 #ifdef EXEC_ELF64
684 int exec_elf64_makecmds __P((struct proc *, struct exec_package *));
685 int elf64_read_from __P((struct proc *, struct vnode *, u_long,
686 caddr_t, int));
687 void *elf64_copyargs __P((struct exec_package *, struct ps_strings *,
688 void *, void *));
689 #endif
690
691 /* common */
692 int exec_elf_setup_stack __P((struct proc *, struct exec_package *));
693
694 #endif /* _KERNEL */
695
696 #endif /* __EXEC_ELF_H */
697

  ViewVC Help
Powered by ViewVC 1.1.26