loader: remove shouting from ORB's variable name
[hvf.git] / include / binfmt_elf.h
blob48387f043cdb9a8abe1275694199546c4055e9e1
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 #define STB_LOCAL 0
96 #define STB_GLOBAL 1
97 #define STB_WEAK 2
98 #define STB_LOOS 10
99 #define STB_HIOS 12
100 #define STB_LOPROC 13
101 #define STB_HIPROC 15
103 #define STT_NOTYPE 0
104 #define STT_OBJECT 1
105 #define STT_FUNC 2
106 #define STT_SECTION 3
107 #define STT_FILE 4
108 #define STT_LOOS 10
109 #define STT_HIOS 12
110 #define STT_LOPROC 13
111 #define STT_HIPROC 15
113 typedef u32 Elf32_Addr;
114 typedef u32 Elf32_Off;
115 typedef u16 Elf32_Half;
116 typedef u32 Elf32_Word;
117 typedef s32 Elf32_Sword;
119 typedef u64 Elf64_Addr;
120 typedef u64 Elf64_Off;
121 typedef u16 Elf64_Half;
122 typedef u32 Elf64_Word;
123 typedef s32 Elf64_Sword;
124 typedef u64 Elf64_Xword;
125 typedef s64 Elf64_Sxword;
128 * ELF file header
130 typedef struct {
131 unsigned char e_ident[EI_NIDENT]; /* ELF identification */
132 Elf32_Half e_type; /* Object file type */
133 Elf32_Half e_machine; /* Machine type */
134 Elf32_Word e_version; /* Object file version */
135 Elf32_Addr e_entry; /* Entry point address */
136 Elf32_Off e_phoff; /* Program header offset */
137 Elf32_Off e_shoff; /* Section header offset */
138 Elf32_Word e_flags; /* Processor-specific flags */
139 Elf32_Half e_ehsize; /* ELF header size */
140 Elf32_Half e_phentsize; /* Size of program header entry */
141 Elf32_Half e_phnum; /* Number of program header entries */
142 Elf32_Half e_shentsize; /* Size of section header entries */
143 Elf32_Half e_shnum; /* Number of section header entries */
144 Elf32_Half e_shstrndx; /* Section name string table index */
145 } Elf32_Ehdr;
147 typedef struct {
148 unsigned char e_ident[EI_NIDENT]; /* ELF identification */
149 Elf64_Half e_type; /* Object file type */
150 Elf64_Half e_machine; /* Machine type */
151 Elf64_Word e_version; /* Object file version */
152 Elf64_Addr e_entry; /* Entry point address */
153 Elf64_Off e_phoff; /* Program header offset */
154 Elf64_Off e_shoff; /* Section header offset */
155 Elf64_Word e_flags; /* Processor-specific flags */
156 Elf64_Half e_ehsize; /* ELF header size */
157 Elf64_Half e_phentsize; /* Size of program header entry */
158 Elf64_Half e_phnum; /* Number of program header entries */
159 Elf64_Half e_shentsize; /* Size of section header entries */
160 Elf64_Half e_shnum; /* Number of section header entries */
161 Elf64_Half e_shstrndx; /* Section name string table index */
162 } Elf64_Ehdr;
164 /* combined header for easy pointer casting */
165 typedef union {
166 Elf32_Ehdr s390;
167 Elf64_Ehdr z;
168 } Elf_Ehdr;
171 * ELF section header
173 typedef struct {
174 Elf32_Word sh_name; /* Section name */
175 Elf32_Word sh_type; /* Section type */
176 Elf32_Word sh_flags; /* Section attributes */
177 Elf32_Addr sh_addr; /* Virtual address in memory */
178 Elf32_Off sh_offset; /* Offset in file */
179 Elf32_Word sh_size; /* Size of section */
180 Elf32_Word sh_link; /* Link to other section */
181 Elf32_Word sh_info; /* Misc information */
182 Elf32_Word sh_addralign; /* Address alignment boundary */
183 Elf32_Word sh_entsize; /* Size of entries, if section has table */
184 } Elf32_Shdr;
186 typedef struct {
187 Elf64_Word sh_name; /* Section name */
188 Elf64_Word sh_type; /* Section type */
189 Elf64_Xword sh_flags; /* Section attributes */
190 Elf64_Addr sh_addr; /* Virtual address in memory */
191 Elf64_Off sh_offset; /* Offset in file */
192 Elf64_Xword sh_size; /* Size of section */
193 Elf64_Word sh_link; /* Link to other section */
194 Elf64_Word sh_info; /* Misc information */
195 Elf64_Xword sh_addralign; /* Address alignment boundary */
196 Elf64_Xword sh_entsize; /* Size of entries, if section has table */
197 } Elf64_Shdr;
199 /* combined header for easy pointer casting */
200 typedef union {
201 Elf32_Shdr s390;
202 Elf64_Shdr z;
203 } Elf_Shdr;
206 * ELF program header
208 typedef struct {
209 Elf32_Word p_type; /* Segment type */
210 Elf32_Off p_offset; /* Segment file offset */
211 Elf32_Addr p_vaddr; /* Segment virt. addr */
212 Elf32_Addr p_paddr; /* <undefined> */
213 Elf32_Word p_filesz; /* Segment size in file */
214 Elf32_Word p_memsz; /* Segment size in mem */
215 Elf32_Word p_flags; /* Segment flags */
216 Elf32_Word p_align; /* Segment alignment */
217 } Elf32_Phdr;
219 typedef struct {
220 Elf64_Word p_type; /* Segment type */
221 Elf64_Word p_flags; /* Segment file offset */
222 Elf64_Off p_offset; /* Segment virt. addr */
223 Elf64_Addr p_vaddr; /* <undefined> */
224 Elf64_Addr p_paddr; /* Segment size in file */
225 Elf64_Xword p_filesz; /* Segment size in mem */
226 Elf64_Xword p_memsz; /* Segment flags */
227 Elf64_Xword p_align; /* Segment alignment */
228 } Elf64_Phdr;
230 /* combined header for easy pointer casting */
231 typedef union {
232 Elf32_Phdr s390;
233 Elf64_Phdr z;
234 } Elf_Phdr;
237 * ELF symbol table entries
239 typedef struct {
240 Elf64_Word st_name; /* Symbol name */
241 unsigned char st_info; /* Type and Binding attributes */
242 unsigned char st_other; /* Reserved */
243 Elf64_Half st_shndx; /* Section table index */
244 Elf64_Addr st_value; /* Symbol value */
245 Elf64_Xword st_size; /* Size of object */
246 } Elf64_Sym;
248 #endif