hvf: use yacc & re2c to generate a system config parser
[hvf.git] / include / binfmt_elf.h
blobd5b765bccce12e269cee871eb0aa8c683576ac97
1 /*
2 * (C) Copyright 2007-2010 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * This file is released under the GPLv2. See the COPYING file for more
5 * details.
6 */
8 #ifndef __BINFMT_ELF_H
9 #define __BINFMT_ELF_H
11 #define EI_MAG0 0
12 #define EI_MAG1 1
13 #define EI_MAG2 2
14 #define EI_MAG3 3
15 #define EI_CLASS 4
16 #define EI_DATA 5
17 #define EI_VERSION 6
18 #define EI_OSABI 7
19 #define EI_ABIVERSION 8
20 #define EI_PAD 9
21 #define EI_NIDENT 16
23 #define ELFMAG0 0x7f
24 #define ELFMAG1 'E'
25 #define ELFMAG2 'L'
26 #define ELFMAG3 'F'
28 #define ELFCLASSNONE 0
29 #define ELFCLASS32 1
30 #define ELFCLASS64 2
32 #define ELFDATANONE 0
33 #define ELFDATA2LSB 1
34 #define ELFDATA2MSB 2
36 #define EV_CURRENT 1
38 #define ELFOSABI_NONE 0
40 #define ET_NONE 0
41 #define ET_REL 1
42 #define ET_EXEC 2
43 #define ET_DYN 3
44 #define ET_CORE 4
45 #define ET_LOOS 0xfe00
46 #define ET_HIOS 0xfeff
47 #define ET_LOPROC 0xff00
48 #define ET_HIPROC 0xffff
50 #define EM_S390 22
52 #define SHT_NULL 0
53 #define SHT_PROGBITS 1
54 #define SHT_SYMTAB 2
55 #define SHT_STRTAB 3
56 #define SHT_RELA 4
57 #define SHT_HASH 5
58 #define SHT_DYNAMIC 6
59 #define SHT_NOTE 7
60 #define SHT_NOBITS 8
61 #define SHT_REL 9
62 #define SHT_SHLIB 10
63 #define SHT_DYNSYM 11
64 #define SHT_INIT_ARRAY 14
65 #define SHT_FINI_ARRAY 15
66 #define SHT_PREINI_ARRAY 16
67 #define SHT_GROUP 17
68 #define SHT_SYMTAB_SHNDX 18
69 #define SHT_LOOS 0x60000000
70 #define SHT_HIOS 0x6fffffff
71 #define SHT_LOPROC 0x70000000
72 #define SHT_HIPROC 0x7fffffff
73 #define SHT_LOUSER 0x80000000
74 #define SHT_HIUSER 0xffffffff
76 #define PT_NULL 0
77 #define PT_LOAD 1
78 #define PT_DYNAMIC 2
79 #define PT_INTERP 3
80 #define PT_NOTE 4
81 #define PT_SHLIB 5
82 #define PT_PHDR 6
83 #define PT_TLS 7
84 #define PT_LOOS 0x60000000
85 #define PT_HIOS 0x6fffffff
86 #define PT_LOPROC 0x70000000
87 #define PT_HIPROC 0x7fffffff
89 #define PF_X 0x1
90 #define PF_W 0x2
91 #define PF_R 0x4
92 #define PF_MASKOS 0x0ff00000
93 #define PF_MAKSPROC 0xf0000000
95 typedef u32 Elf32_Addr;
96 typedef u32 Elf32_Off;
97 typedef u16 Elf32_Half;
98 typedef u32 Elf32_Word;
99 typedef s32 Elf32_Sword;
101 typedef u64 Elf64_Addr;
102 typedef u64 Elf64_Off;
103 typedef u16 Elf64_Half;
104 typedef u32 Elf64_Word;
105 typedef s32 Elf64_Sword;
106 typedef u64 Elf64_Xword;
107 typedef s64 Elf64_Sxword;
110 * ELF file header
112 typedef struct {
113 unsigned char e_ident[EI_NIDENT]; /* ELF identification */
114 Elf32_Half e_type; /* Object file type */
115 Elf32_Half e_machine; /* Machine type */
116 Elf32_Word e_version; /* Object file version */
117 Elf32_Addr e_entry; /* Entry point address */
118 Elf32_Off e_phoff; /* Program header offset */
119 Elf32_Off e_shoff; /* Section header offset */
120 Elf32_Word e_flags; /* Processor-specific flags */
121 Elf32_Half e_ehsize; /* ELF header size */
122 Elf32_Half e_phentsize; /* Size of program header entry */
123 Elf32_Half e_phnum; /* Number of program header entries */
124 Elf32_Half e_shentsize; /* Size of section header entries */
125 Elf32_Half e_shnum; /* Number of section header entries */
126 Elf32_Half e_shstrndx; /* Section name string table index */
127 } Elf32_Ehdr;
129 typedef struct {
130 unsigned char e_ident[EI_NIDENT]; /* ELF identification */
131 Elf64_Half e_type; /* Object file type */
132 Elf64_Half e_machine; /* Machine type */
133 Elf64_Word e_version; /* Object file version */
134 Elf64_Addr e_entry; /* Entry point address */
135 Elf64_Off e_phoff; /* Program header offset */
136 Elf64_Off e_shoff; /* Section header offset */
137 Elf64_Word e_flags; /* Processor-specific flags */
138 Elf64_Half e_ehsize; /* ELF header size */
139 Elf64_Half e_phentsize; /* Size of program header entry */
140 Elf64_Half e_phnum; /* Number of program header entries */
141 Elf64_Half e_shentsize; /* Size of section header entries */
142 Elf64_Half e_shnum; /* Number of section header entries */
143 Elf64_Half e_shstrndx; /* Section name string table index */
144 } Elf64_Ehdr;
146 /* combined header for easy pointer casting */
147 typedef union {
148 Elf32_Ehdr s390;
149 Elf64_Ehdr z;
150 } Elf_Ehdr;
153 * ELF section header
155 typedef struct {
156 Elf32_Word sh_name; /* Section name */
157 Elf32_Word sh_type; /* Section type */
158 Elf32_Word sh_flags; /* Section attributes */
159 Elf32_Addr sh_addr; /* Virtual address in memory */
160 Elf32_Off sh_offset; /* Offset in file */
161 Elf32_Word sh_size; /* Size of section */
162 Elf32_Word sh_link; /* Link to other section */
163 Elf32_Word sh_info; /* Misc information */
164 Elf32_Word sh_addralign; /* Address alignment boundary */
165 Elf32_Word sh_entsize; /* Size of entries, if section has table */
166 } Elf32_Shdr;
168 typedef struct {
169 Elf64_Word sh_name; /* Section name */
170 Elf64_Word sh_type; /* Section type */
171 Elf64_Xword sh_flags; /* Section attributes */
172 Elf64_Addr sh_addr; /* Virtual address in memory */
173 Elf64_Off sh_offset; /* Offset in file */
174 Elf64_Xword sh_size; /* Size of section */
175 Elf64_Word sh_link; /* Link to other section */
176 Elf64_Word sh_info; /* Misc information */
177 Elf64_Xword sh_addralign; /* Address alignment boundary */
178 Elf64_Xword sh_entsize; /* Size of entries, if section has table */
179 } Elf64_Shdr;
181 /* combined header for easy pointer casting */
182 typedef union {
183 Elf32_Shdr s390;
184 Elf64_Shdr z;
185 } Elf_Shdr;
188 * ELF program header
190 typedef struct {
191 Elf32_Word p_type; /* Segment type */
192 Elf32_Off p_offset; /* Segment file offset */
193 Elf32_Addr p_vaddr; /* Segment virt. addr */
194 Elf32_Addr p_paddr; /* <undefined> */
195 Elf32_Word p_filesz; /* Segment size in file */
196 Elf32_Word p_memsz; /* Segment size in mem */
197 Elf32_Word p_flags; /* Segment flags */
198 Elf32_Word p_align; /* Segment alignment */
199 } Elf32_Phdr;
201 typedef struct {
202 Elf64_Word p_type; /* Segment type */
203 Elf64_Word p_flags; /* Segment file offset */
204 Elf64_Off p_offset; /* Segment virt. addr */
205 Elf64_Addr p_vaddr; /* <undefined> */
206 Elf64_Addr p_paddr; /* Segment size in file */
207 Elf64_Xword p_filesz; /* Segment size in mem */
208 Elf64_Xword p_memsz; /* Segment flags */
209 Elf64_Xword p_align; /* Segment alignment */
210 } Elf64_Phdr;
212 /* combined header for easy pointer casting */
213 typedef union {
214 Elf32_Phdr s390;
215 Elf64_Phdr z;
216 } Elf_Phdr;
218 #endif