OSDN Git Service

Check in released NDK version r4.
[android-x86/prebuilt.git] / ndk / android-ndk-r4 / darwin / platforms / android-8 / arch-x86 / usr / include / linux / elf.h
1 /****************************************************************************
2  ****************************************************************************
3  ***
4  ***   This header was automatically generated from a Linux kernel header
5  ***   of the same name, to make information necessary for userspace to
6  ***   call into the kernel available to libc.  It contains only constants,
7  ***   structures, and macros generated from the original header, and thus,
8  ***   contains no copyrightable information.
9  ***
10  ****************************************************************************
11  ****************************************************************************/
12 #ifndef _LINUX_ELF_H
13 #define _LINUX_ELF_H
14
15 #include <linux/types.h>
16 #include <linux/auxvec.h>
17 #include <linux/elf-em.h>
18 #include <asm/elf.h>
19
20 #ifndef elf_read_implies_exec
21
22 #define elf_read_implies_exec(ex, have_pt_gnu_stack) 0
23 #endif
24
25 typedef __u32 Elf32_Addr;
26 typedef __u16 Elf32_Half;
27 typedef __u32 Elf32_Off;
28 typedef __s32 Elf32_Sword;
29 typedef __u32 Elf32_Word;
30
31 typedef __u64 Elf64_Addr;
32 typedef __u16 Elf64_Half;
33 typedef __s16 Elf64_SHalf;
34 typedef __u64 Elf64_Off;
35 typedef __s32 Elf64_Sword;
36 typedef __u32 Elf64_Word;
37 typedef __u64 Elf64_Xword;
38 typedef __s64 Elf64_Sxword;
39
40 #define PT_NULL 0
41 #define PT_LOAD 1
42 #define PT_DYNAMIC 2
43 #define PT_INTERP 3
44 #define PT_NOTE 4
45 #define PT_SHLIB 5
46 #define PT_PHDR 6
47 #define PT_TLS 7  
48 #define PT_LOOS 0x60000000  
49 #define PT_HIOS 0x6fffffff  
50 #define PT_LOPROC 0x70000000
51 #define PT_HIPROC 0x7fffffff
52 #define PT_GNU_EH_FRAME 0x6474e550
53
54 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
55
56 #define ET_NONE 0
57 #define ET_REL 1
58 #define ET_EXEC 2
59 #define ET_DYN 3
60 #define ET_CORE 4
61 #define ET_LOPROC 0xff00
62 #define ET_HIPROC 0xffff
63
64 #define DT_NULL 0
65 #define DT_NEEDED 1
66 #define DT_PLTRELSZ 2
67 #define DT_PLTGOT 3
68 #define DT_HASH 4
69 #define DT_STRTAB 5
70 #define DT_SYMTAB 6
71 #define DT_RELA 7
72 #define DT_RELASZ 8
73 #define DT_RELAENT 9
74 #define DT_STRSZ 10
75 #define DT_SYMENT 11
76 #define DT_INIT 12
77 #define DT_FINI 13
78 #define DT_SONAME 14
79 #define DT_RPATH 15
80 #define DT_SYMBOLIC 16
81 #define DT_REL 17
82 #define DT_RELSZ 18
83 #define DT_RELENT 19
84 #define DT_PLTREL 20
85 #define DT_DEBUG 21
86 #define DT_TEXTREL 22
87 #define DT_JMPREL 23
88 #define DT_LOPROC 0x70000000
89 #define DT_HIPROC 0x7fffffff
90
91 #define STB_LOCAL 0
92 #define STB_GLOBAL 1
93 #define STB_WEAK 2
94
95 #define STT_NOTYPE 0
96 #define STT_OBJECT 1
97 #define STT_FUNC 2
98 #define STT_SECTION 3
99 #define STT_FILE 4
100 #define STT_COMMON 5
101 #define STT_TLS 6
102
103 #define ELF_ST_BIND(x) ((x) >> 4)
104 #define ELF_ST_TYPE(x) (((unsigned int) x) & 0xf)
105 #define ELF32_ST_BIND(x) ELF_ST_BIND(x)
106 #define ELF32_ST_TYPE(x) ELF_ST_TYPE(x)
107 #define ELF64_ST_BIND(x) ELF_ST_BIND(x)
108 #define ELF64_ST_TYPE(x) ELF_ST_TYPE(x)
109
110 typedef struct dynamic{
111  Elf32_Sword d_tag;
112  union{
113  Elf32_Sword d_val;
114  Elf32_Addr d_ptr;
115  } d_un;
116 } Elf32_Dyn;
117
118 typedef struct {
119  Elf64_Sxword d_tag;
120  union {
121  Elf64_Xword d_val;
122  Elf64_Addr d_ptr;
123  } d_un;
124 } Elf64_Dyn;
125
126 #define ELF32_R_SYM(x) ((x) >> 8)
127 #define ELF32_R_TYPE(x) ((x) & 0xff)
128
129 #define ELF64_R_SYM(i) ((i) >> 32)
130 #define ELF64_R_TYPE(i) ((i) & 0xffffffff)
131
132 typedef struct elf32_rel {
133  Elf32_Addr r_offset;
134  Elf32_Word r_info;
135 } Elf32_Rel;
136
137 typedef struct elf64_rel {
138  Elf64_Addr r_offset;
139  Elf64_Xword r_info;
140 } Elf64_Rel;
141
142 typedef struct elf32_rela{
143  Elf32_Addr r_offset;
144  Elf32_Word r_info;
145  Elf32_Sword r_addend;
146 } Elf32_Rela;
147
148 typedef struct elf64_rela {
149  Elf64_Addr r_offset;
150  Elf64_Xword r_info;
151  Elf64_Sxword r_addend;
152 } Elf64_Rela;
153
154 typedef struct elf32_sym{
155  Elf32_Word st_name;
156  Elf32_Addr st_value;
157  Elf32_Word st_size;
158  unsigned char st_info;
159  unsigned char st_other;
160  Elf32_Half st_shndx;
161 } Elf32_Sym;
162
163 typedef struct elf64_sym {
164  Elf64_Word st_name;
165  unsigned char st_info;
166  unsigned char st_other;
167  Elf64_Half st_shndx;
168  Elf64_Addr st_value;
169  Elf64_Xword st_size;
170 } Elf64_Sym;
171
172 #define EI_NIDENT 16
173
174 typedef struct elf32_hdr{
175  unsigned char e_ident[EI_NIDENT];
176  Elf32_Half e_type;
177  Elf32_Half e_machine;
178  Elf32_Word e_version;
179  Elf32_Addr e_entry;
180  Elf32_Off e_phoff;
181  Elf32_Off e_shoff;
182  Elf32_Word e_flags;
183  Elf32_Half e_ehsize;
184  Elf32_Half e_phentsize;
185  Elf32_Half e_phnum;
186  Elf32_Half e_shentsize;
187  Elf32_Half e_shnum;
188  Elf32_Half e_shstrndx;
189 } Elf32_Ehdr;
190
191 typedef struct elf64_hdr {
192  unsigned char e_ident[16];
193  Elf64_Half e_type;
194  Elf64_Half e_machine;
195  Elf64_Word e_version;
196  Elf64_Addr e_entry;
197  Elf64_Off e_phoff;
198  Elf64_Off e_shoff;
199  Elf64_Word e_flags;
200  Elf64_Half e_ehsize;
201  Elf64_Half e_phentsize;
202  Elf64_Half e_phnum;
203  Elf64_Half e_shentsize;
204  Elf64_Half e_shnum;
205  Elf64_Half e_shstrndx;
206 } Elf64_Ehdr;
207
208 #define PF_R 0x4
209 #define PF_W 0x2
210 #define PF_X 0x1
211
212 typedef struct elf32_phdr{
213  Elf32_Word p_type;
214  Elf32_Off p_offset;
215  Elf32_Addr p_vaddr;
216  Elf32_Addr p_paddr;
217  Elf32_Word p_filesz;
218  Elf32_Word p_memsz;
219  Elf32_Word p_flags;
220  Elf32_Word p_align;
221 } Elf32_Phdr;
222
223 typedef struct elf64_phdr {
224  Elf64_Word p_type;
225  Elf64_Word p_flags;
226  Elf64_Off p_offset;
227  Elf64_Addr p_vaddr;
228  Elf64_Addr p_paddr;
229  Elf64_Xword p_filesz;
230  Elf64_Xword p_memsz;
231  Elf64_Xword p_align;
232 } Elf64_Phdr;
233
234 #define SHT_NULL 0
235 #define SHT_PROGBITS 1
236 #define SHT_SYMTAB 2
237 #define SHT_STRTAB 3
238 #define SHT_RELA 4
239 #define SHT_HASH 5
240 #define SHT_DYNAMIC 6
241 #define SHT_NOTE 7
242 #define SHT_NOBITS 8
243 #define SHT_REL 9
244 #define SHT_SHLIB 10
245 #define SHT_DYNSYM 11
246 #define SHT_NUM 12
247 #define SHT_LOPROC 0x70000000
248 #define SHT_HIPROC 0x7fffffff
249 #define SHT_LOUSER 0x80000000
250 #define SHT_HIUSER 0xffffffff
251
252 #define SHF_WRITE 0x1
253 #define SHF_ALLOC 0x2
254 #define SHF_EXECINSTR 0x4
255 #define SHF_MASKPROC 0xf0000000
256
257 #define SHN_UNDEF 0
258 #define SHN_LORESERVE 0xff00
259 #define SHN_LOPROC 0xff00
260 #define SHN_HIPROC 0xff1f
261 #define SHN_ABS 0xfff1
262 #define SHN_COMMON 0xfff2
263 #define SHN_HIRESERVE 0xffff
264
265 typedef struct {
266  Elf32_Word sh_name;
267  Elf32_Word sh_type;
268  Elf32_Word sh_flags;
269  Elf32_Addr sh_addr;
270  Elf32_Off sh_offset;
271  Elf32_Word sh_size;
272  Elf32_Word sh_link;
273  Elf32_Word sh_info;
274  Elf32_Word sh_addralign;
275  Elf32_Word sh_entsize;
276 } Elf32_Shdr;
277
278 typedef struct elf64_shdr {
279  Elf64_Word sh_name;
280  Elf64_Word sh_type;
281  Elf64_Xword sh_flags;
282  Elf64_Addr sh_addr;
283  Elf64_Off sh_offset;
284  Elf64_Xword sh_size;
285  Elf64_Word sh_link;
286  Elf64_Word sh_info;
287  Elf64_Xword sh_addralign;
288  Elf64_Xword sh_entsize;
289 } Elf64_Shdr;
290
291 #define EI_MAG0 0  
292 #define EI_MAG1 1
293 #define EI_MAG2 2
294 #define EI_MAG3 3
295 #define EI_CLASS 4
296 #define EI_DATA 5
297 #define EI_VERSION 6
298 #define EI_OSABI 7
299 #define EI_PAD 8
300
301 #define ELFMAG0 0x7f  
302 #define ELFMAG1 'E'
303 #define ELFMAG2 'L'
304 #define ELFMAG3 'F'
305 #define ELFMAG "\177ELF"
306 #define SELFMAG 4
307
308 #define ELFCLASSNONE 0  
309 #define ELFCLASS32 1
310 #define ELFCLASS64 2
311 #define ELFCLASSNUM 3
312
313 #define ELFDATANONE 0  
314 #define ELFDATA2LSB 1
315 #define ELFDATA2MSB 2
316
317 #define EV_NONE 0  
318 #define EV_CURRENT 1
319 #define EV_NUM 2
320
321 #define ELFOSABI_NONE 0
322 #define ELFOSABI_LINUX 3
323
324 #ifndef ELF_OSABI
325 #define ELF_OSABI ELFOSABI_NONE
326 #endif
327
328 #define NT_PRSTATUS 1
329 #define NT_PRFPREG 2
330 #define NT_PRPSINFO 3
331 #define NT_TASKSTRUCT 4
332 #define NT_AUXV 6
333 #define NT_PRXFPREG 0x46e62b7f  
334
335 typedef struct elf32_note {
336  Elf32_Word n_namesz;
337  Elf32_Word n_descsz;
338  Elf32_Word n_type;
339 } Elf32_Nhdr;
340
341 typedef struct elf64_note {
342  Elf64_Word n_namesz;
343  Elf64_Word n_descsz;
344  Elf64_Word n_type;
345 } Elf64_Nhdr;
346
347 #if ELF_CLASS == ELFCLASS32
348
349 #define elfhdr elf32_hdr
350 #define elf_phdr elf32_phdr
351 #define elf_note elf32_note
352
353 #else
354
355 #define elfhdr elf64_hdr
356 #define elf_phdr elf64_phdr
357 #define elf_note elf64_note
358
359 #endif
360
361 #endif