]>
Commit | Line | Data |
---|---|---|
ced216f8 HL |
1 | /** @file\r |
2 | Ported ELF include files from FreeBSD\r | |
3 | \r | |
4 | Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | /*-\r | |
15 | * Copyright (c) 1996-1998 John D. Polstra.\r | |
16 | * All rights reserved.\r | |
17 | *\r | |
18 | * Redistribution and use in source and binary forms, with or without\r | |
19 | * modification, are permitted provided that the following conditions\r | |
20 | * are met:\r | |
21 | * 1. Redistributions of source code must retain the above copyright\r | |
22 | * notice, this list of conditions and the following disclaimer.\r | |
23 | * 2. Redistributions in binary form must reproduce the above copyright\r | |
24 | * notice, this list of conditions and the following disclaimer in the\r | |
25 | * documentation and/or other materials provided with the distribution.\r | |
26 | *\r | |
27 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\r | |
28 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r | |
29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r | |
30 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\r | |
31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r | |
32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r | |
33 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r | |
34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r | |
36 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r | |
37 | * SUCH DAMAGE.\r | |
38 | *\r | |
39 | * $FreeBSD: src/sys/sys/elf64.h,v 1.10.14.2 2007/12/03 21:30:36 marius Exp $\r | |
40 | */\r | |
41 | \r | |
42 | #ifndef _SYS_ELF64_H_\r | |
43 | #define _SYS_ELF64_H_ 1\r | |
44 | \r | |
45 | \r | |
46 | /*\r | |
47 | * ELF definitions common to all 64-bit architectures.\r | |
48 | */\r | |
49 | \r | |
50 | typedef UINT64 Elf64_Addr;\r | |
51 | typedef UINT16 Elf64_Half;\r | |
52 | typedef UINT64 Elf64_Off;\r | |
53 | typedef INT32 Elf64_Sword;\r | |
54 | typedef INT64 Elf64_Sxword;\r | |
55 | typedef UINT32 Elf64_Word;\r | |
56 | typedef UINT64 Elf64_Lword;\r | |
57 | typedef UINT64 Elf64_Xword;\r | |
58 | \r | |
59 | /*\r | |
60 | * Types of dynamic symbol hash table bucket and chain elements.\r | |
61 | *\r | |
62 | * This is inconsistent among 64 bit architectures, so a machine dependent\r | |
63 | * typedef is required.\r | |
64 | */\r | |
65 | \r | |
66 | typedef Elf64_Word Elf64_Hashelt;\r | |
67 | \r | |
68 | /* Non-standard class-dependent datatype used for abstraction. */\r | |
69 | typedef Elf64_Xword Elf64_Size;\r | |
70 | typedef Elf64_Sxword Elf64_Ssize;\r | |
71 | \r | |
72 | /*\r | |
73 | * ELF header.\r | |
74 | */\r | |
75 | \r | |
76 | typedef struct {\r | |
77 | unsigned char e_ident[EI_NIDENT]; /* File identification. */\r | |
78 | Elf64_Half e_type; /* File type. */\r | |
79 | Elf64_Half e_machine; /* Machine architecture. */\r | |
80 | Elf64_Word e_version; /* ELF format version. */\r | |
81 | Elf64_Addr e_entry; /* Entry point. */\r | |
82 | Elf64_Off e_phoff; /* Program header file offset. */\r | |
83 | Elf64_Off e_shoff; /* Section header file offset. */\r | |
84 | Elf64_Word e_flags; /* Architecture-specific flags. */\r | |
85 | Elf64_Half e_ehsize; /* Size of ELF header in bytes. */\r | |
86 | Elf64_Half e_phentsize; /* Size of program header entry. */\r | |
87 | Elf64_Half e_phnum; /* Number of program header entries. */\r | |
88 | Elf64_Half e_shentsize; /* Size of section header entry. */\r | |
89 | Elf64_Half e_shnum; /* Number of section header entries. */\r | |
90 | Elf64_Half e_shstrndx; /* Section name strings section. */\r | |
91 | } Elf64_Ehdr;\r | |
92 | \r | |
93 | /*\r | |
94 | * Section header.\r | |
95 | */\r | |
96 | \r | |
97 | typedef struct {\r | |
98 | Elf64_Word sh_name; /* Section name (index into the\r | |
99 | section header string table). */\r | |
100 | Elf64_Word sh_type; /* Section type. */\r | |
101 | Elf64_Xword sh_flags; /* Section flags. */\r | |
102 | Elf64_Addr sh_addr; /* Address in memory image. */\r | |
103 | Elf64_Off sh_offset; /* Offset in file. */\r | |
104 | Elf64_Xword sh_size; /* Size in bytes. */\r | |
105 | Elf64_Word sh_link; /* Index of a related section. */\r | |
106 | Elf64_Word sh_info; /* Depends on section type. */\r | |
107 | Elf64_Xword sh_addralign; /* Alignment in bytes. */\r | |
108 | Elf64_Xword sh_entsize; /* Size of each entry in section. */\r | |
109 | } Elf64_Shdr;\r | |
110 | \r | |
111 | /*\r | |
112 | * Program header.\r | |
113 | */\r | |
114 | \r | |
115 | typedef struct {\r | |
116 | Elf64_Word p_type; /* Entry type. */\r | |
117 | Elf64_Word p_flags; /* Access permission flags. */\r | |
118 | Elf64_Off p_offset; /* File offset of contents. */\r | |
119 | Elf64_Addr p_vaddr; /* Virtual address in memory image. */\r | |
120 | Elf64_Addr p_paddr; /* Physical address (not used). */\r | |
121 | Elf64_Xword p_filesz; /* Size of contents in file. */\r | |
122 | Elf64_Xword p_memsz; /* Size of contents in memory. */\r | |
123 | Elf64_Xword p_align; /* Alignment in memory and file. */\r | |
124 | } Elf64_Phdr;\r | |
125 | \r | |
126 | /*\r | |
127 | * Dynamic structure. The ".dynamic" section contains an array of them.\r | |
128 | */\r | |
129 | \r | |
130 | typedef struct {\r | |
131 | Elf64_Sxword d_tag; /* Entry type. */\r | |
132 | union {\r | |
133 | Elf64_Xword d_val; /* Integer value. */\r | |
134 | Elf64_Addr d_ptr; /* Address value. */\r | |
135 | } d_un;\r | |
136 | } Elf64_Dyn;\r | |
137 | \r | |
138 | /*\r | |
139 | * Relocation entries.\r | |
140 | */\r | |
141 | \r | |
142 | /* Relocations that don't need an addend field. */\r | |
143 | typedef struct {\r | |
144 | Elf64_Addr r_offset; /* Location to be relocated. */\r | |
145 | Elf64_Xword r_info; /* Relocation type and symbol index. */\r | |
146 | } Elf64_Rel;\r | |
147 | \r | |
148 | /* Relocations that need an addend field. */\r | |
149 | typedef struct {\r | |
150 | Elf64_Addr r_offset; /* Location to be relocated. */\r | |
151 | Elf64_Xword r_info; /* Relocation type and symbol index. */\r | |
152 | Elf64_Sxword r_addend; /* Addend. */\r | |
153 | } Elf64_Rela;\r | |
154 | \r | |
155 | /* Macros for accessing the fields of r_info. */\r | |
156 | #define ELF64_R_SYM(info) ((info) >> 32)\r | |
157 | #define ELF64_R_TYPE(info) ((info) & 0xffffffffL)\r | |
158 | \r | |
159 | /* Macro for constructing r_info from field values. */\r | |
160 | #define ELF64_R_INFO(sym, type) (((sym) << 32) + ((type) & 0xffffffffL))\r | |
161 | \r | |
162 | #define ELF64_R_TYPE_DATA(info) (((Elf64_Xword)(info)<<32)>>40)\r | |
163 | #define ELF64_R_TYPE_ID(info) (((Elf64_Xword)(info)<<56)>>56)\r | |
164 | #define ELF64_R_TYPE_INFO(data, type) \\r | |
165 | (((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type))\r | |
166 | \r | |
167 | /*\r | |
168 | * Note entry header\r | |
169 | */\r | |
170 | typedef Elf_Note Elf64_Nhdr;\r | |
171 | \r | |
172 | /*\r | |
173 | * Move entry\r | |
174 | */\r | |
175 | typedef struct {\r | |
176 | Elf64_Lword m_value; /* symbol value */\r | |
177 | Elf64_Xword m_info; /* size + index */\r | |
178 | Elf64_Xword m_poffset; /* symbol offset */\r | |
179 | Elf64_Half m_repeat; /* repeat count */\r | |
180 | Elf64_Half m_stride; /* stride info */\r | |
181 | } Elf64_Move;\r | |
182 | \r | |
183 | #define ELF64_M_SYM(info) ((info)>>8)\r | |
184 | #define ELF64_M_SIZE(info) ((unsigned char)(info))\r | |
185 | #define ELF64_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size))\r | |
186 | \r | |
187 | /*\r | |
188 | * Hardware/Software capabilities entry\r | |
189 | */\r | |
190 | typedef struct {\r | |
191 | Elf64_Xword c_tag; /* how to interpret value */\r | |
192 | union {\r | |
193 | Elf64_Xword c_val;\r | |
194 | Elf64_Addr c_ptr;\r | |
195 | } c_un;\r | |
196 | } Elf64_Cap;\r | |
197 | \r | |
198 | /*\r | |
199 | * Symbol table entries.\r | |
200 | */\r | |
201 | \r | |
202 | typedef struct {\r | |
203 | Elf64_Word st_name; /* String table index of name. */\r | |
204 | unsigned char st_info; /* Type and binding information. */\r | |
205 | unsigned char st_other; /* Reserved (not used). */\r | |
206 | Elf64_Half st_shndx; /* Section index of symbol. */\r | |
207 | Elf64_Addr st_value; /* Symbol value. */\r | |
208 | Elf64_Xword st_size; /* Size of associated object. */\r | |
209 | } Elf64_Sym;\r | |
210 | \r | |
211 | /* Macros for accessing the fields of st_info. */\r | |
212 | #define ELF64_ST_BIND(info) ((info) >> 4)\r | |
213 | #define ELF64_ST_TYPE(info) ((info) & 0xf)\r | |
214 | \r | |
215 | /* Macro for constructing st_info from field values. */\r | |
216 | #define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))\r | |
217 | \r | |
218 | /* Macro for accessing the fields of st_other. */\r | |
219 | #define ELF64_ST_VISIBILITY(oth) ((oth) & 0x3)\r | |
220 | \r | |
221 | /* Structures used by Sun & GNU-style symbol versioning. */\r | |
222 | typedef struct {\r | |
223 | Elf64_Half vd_version;\r | |
224 | Elf64_Half vd_flags;\r | |
225 | Elf64_Half vd_ndx;\r | |
226 | Elf64_Half vd_cnt;\r | |
227 | Elf64_Word vd_hash;\r | |
228 | Elf64_Word vd_aux;\r | |
229 | Elf64_Word vd_next;\r | |
230 | } Elf64_Verdef;\r | |
231 | \r | |
232 | typedef struct {\r | |
233 | Elf64_Word vda_name;\r | |
234 | Elf64_Word vda_next;\r | |
235 | } Elf64_Verdaux;\r | |
236 | \r | |
237 | typedef struct {\r | |
238 | Elf64_Half vn_version;\r | |
239 | Elf64_Half vn_cnt;\r | |
240 | Elf64_Word vn_file;\r | |
241 | Elf64_Word vn_aux;\r | |
242 | Elf64_Word vn_next;\r | |
243 | } Elf64_Verneed;\r | |
244 | \r | |
245 | typedef struct {\r | |
246 | Elf64_Word vna_hash;\r | |
247 | Elf64_Half vna_flags;\r | |
248 | Elf64_Half vna_other;\r | |
249 | Elf64_Word vna_name;\r | |
250 | Elf64_Word vna_next;\r | |
251 | } Elf64_Vernaux;\r | |
252 | \r | |
253 | typedef Elf64_Half Elf64_Versym;\r | |
254 | \r | |
255 | typedef struct {\r | |
256 | Elf64_Half si_boundto; /* direct bindings - symbol bound to */\r | |
257 | Elf64_Half si_flags; /* per symbol flags */\r | |
258 | } Elf64_Syminfo;\r | |
259 | \r | |
260 | #endif /* !_SYS_ELF64_H_ */\r |