- add sources.
[platform/framework/web/crosswalk.git] / src / courgette / types_elf.h
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COURGETTE_ELF_TYPES_H_
6 #define COURGETTE_ELF_TYPES_H_
7
8 //
9 // This header defines various types from the ELF file spec, but no code
10 // related to using them.
11 //
12
13 typedef uint32 Elf32_Addr;  // Unsigned program address
14 typedef uint16 Elf32_Half;  // Unsigned medium integer
15 typedef uint32 Elf32_Off;  // Unsigned file offset
16 typedef int32 Elf32_Sword;  // Signed large integer
17 typedef uint32 Elf32_Word;  // Unsigned large integer
18
19
20 // The header at the top of the file
21 struct Elf32_Ehdr {
22   unsigned char  e_ident[16];
23   Elf32_Half     e_type;
24   Elf32_Half     e_machine;
25   Elf32_Word     e_version;
26   Elf32_Addr     e_entry;
27   Elf32_Off      e_phoff;
28   Elf32_Off      e_shoff;
29   Elf32_Word     e_flags;
30   Elf32_Half     e_ehsize;
31   Elf32_Half     e_phentsize;
32   Elf32_Half     e_phnum;
33   Elf32_Half     e_shentsize;
34   Elf32_Half     e_shnum;
35   Elf32_Half     e_shstrndx;
36 };
37
38 // values for header->e_type
39 enum e_type_values {
40   ET_NONE = 0,  // No file type
41   ET_REL = 1,  // Relocatable file
42   ET_EXEC = 2,  // Executable file
43   ET_DYN = 3,  // Shared object file
44   ET_CORE = 4,  // Core file
45   ET_LOPROC = 0xff00,  // Processor-specific
46   ET_HIPROC = 0xfff  // Processor-specific
47 };
48
49 // values for header->e_machine
50 enum e_machine_values {
51   EM_NONE = 0,  // No machine
52   EM_386 = 3,  // Intel Architecture
53   EM_ARM = 40,  // ARM Architecture
54   EM_x86_64 = 62,  // Intel x86-64 Architecture
55   // Other values skipped
56 };
57
58 // A section header in the section header table
59 struct Elf32_Shdr {
60   Elf32_Word   sh_name;
61   Elf32_Word   sh_type;
62   Elf32_Word   sh_flags;
63   Elf32_Addr   sh_addr;
64   Elf32_Off    sh_offset;
65   Elf32_Word   sh_size;
66   Elf32_Word   sh_link;
67   Elf32_Word   sh_info;
68   Elf32_Word   sh_addralign;
69   Elf32_Word   sh_entsize;
70 };
71
72 // Values for the section type field in a section header
73 enum sh_type_values {
74   SHT_NULL = 0,
75   SHT_PROGBITS = 1,
76   SHT_SYMTAB = 2,
77   SHT_STRTAB = 3,
78   SHT_RELA = 4,
79   SHT_HASH = 5,
80   SHT_DYNAMIC = 6,
81   SHT_NOTE = 7,
82   SHT_NOBITS = 8,
83   SHT_REL = 9,
84   SHT_SHLIB = 10,
85   SHT_DYNSYM = 11,
86   SHT_INIT_ARRAY = 14,
87   SHT_FINI_ARRAY = 15,
88   SHT_LOPROC = 0x70000000,
89   SHT_HIPROC = 0x7fffffff,
90   SHT_LOUSER = 0x80000000,
91   SHT_HIUSER = 0xffffffff,
92 };
93
94 struct Elf32_Phdr {
95   Elf32_Word    p_type;
96   Elf32_Off     p_offset;
97   Elf32_Addr    p_vaddr;
98   Elf32_Addr    p_paddr;
99   Elf32_Word    p_filesz;
100   Elf32_Word    p_memsz;
101   Elf32_Word    p_flags;
102   Elf32_Word    p_align;
103 };
104
105 // Values for the segment type field in a program segment header
106 enum ph_type_values {
107   PT_NULL = 0,
108   PT_LOAD = 1,
109   PT_DYNAMIC = 2,
110   PT_INTERP = 3,
111   PT_NOTE = 4,
112   PT_SHLIB = 5,
113   PT_PHDR = 6,
114   PT_LOPROC = 0x70000000,
115   PT_HIPROC = 0x7fffffff
116 };
117
118 struct Elf32_Rel {
119   Elf32_Addr    r_offset;
120   Elf32_Word    r_info;
121 };
122
123 struct Elf32_Rela {
124   Elf32_Addr    r_offset;
125   Elf32_Word    r_info;
126   Elf32_Sword   r_addend;
127 };
128
129 enum elf32_rel_386_type_values {
130   R_386_NONE = 0,
131   R_386_32 = 1,
132   R_386_PC32 = 2,
133   R_386_GOT32 = 3,
134   R_386_PLT32 = 4,
135   R_386_COPY = 5,
136   R_386_GLOB_DAT = 6,
137   R_386_JMP_SLOT = 7,
138   R_386_RELATIVE = 8,
139   R_386_GOTOFF = 9,
140   R_386_GOTPC = 10,
141   R_386_TLS_TPOFF = 14,
142 };
143
144 enum elf32_rel_arm_type_values {
145   R_ARM_RELATIVE = 23,
146 };
147
148 #endif  // COURGETTE_ELF_TYPES_H_