]>
Commit | Line | Data |
---|---|---|
f51461c8 LG |
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 | |
2e351cbe | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
f51461c8 LG |
6 | \r |
7 | \r | |
8 | **/\r | |
9 | /*-\r | |
10 | * Copyright (c) 1996-1998 John D. Polstra.\r | |
11 | * All rights reserved.\r | |
12 | *\r | |
13 | * Redistribution and use in source and binary forms, with or without\r | |
14 | * modification, are permitted provided that the following conditions\r | |
15 | * are met:\r | |
16 | * 1. Redistributions of source code must retain the above copyright\r | |
17 | * notice, this list of conditions and the following disclaimer.\r | |
18 | * 2. Redistributions in binary form must reproduce the above copyright\r | |
19 | * notice, this list of conditions and the following disclaimer in the\r | |
20 | * documentation and/or other materials provided with the distribution.\r | |
21 | *\r | |
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\r | |
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r | |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r | |
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\r | |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r | |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r | |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r | |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r | |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r | |
32 | * SUCH DAMAGE.\r | |
33 | *\r | |
34 | * $FreeBSD: src/sys/sys/elf32.h,v 1.8.14.2 2007/12/03 21:30:36 marius Exp $\r | |
35 | */\r | |
36 | \r | |
37 | #ifndef _SYS_ELF32_H_\r | |
38 | #define _SYS_ELF32_H_ 1\r | |
39 | \r | |
40 | \r | |
41 | /*\r | |
42 | * ELF definitions common to all 32-bit architectures.\r | |
43 | */\r | |
44 | \r | |
f7496d71 LG |
45 | typedef UINT32 Elf32_Addr;\r |
46 | typedef UINT16 Elf32_Half;\r | |
47 | typedef UINT32 Elf32_Off;\r | |
48 | typedef INT32 Elf32_Sword;\r | |
49 | typedef UINT32 Elf32_Word;\r | |
50 | typedef UINT64 Elf32_Lword;\r | |
f51461c8 | 51 | \r |
f7496d71 | 52 | typedef Elf32_Word Elf32_Hashelt;\r |
f51461c8 LG |
53 | \r |
54 | /* Non-standard class-dependent datatype used for abstraction. */\r | |
f7496d71 LG |
55 | typedef Elf32_Word Elf32_Size;\r |
56 | typedef Elf32_Sword Elf32_Ssize;\r | |
f51461c8 LG |
57 | \r |
58 | /*\r | |
59 | * ELF header.\r | |
60 | */\r | |
61 | \r | |
62 | typedef struct {\r | |
f7496d71 LG |
63 | unsigned char e_ident[EI_NIDENT]; /* File identification. */\r |
64 | Elf32_Half e_type; /* File type. */\r | |
65 | Elf32_Half e_machine; /* Machine architecture. */\r | |
66 | Elf32_Word e_version; /* ELF format version. */\r | |
67 | Elf32_Addr e_entry; /* Entry point. */\r | |
68 | Elf32_Off e_phoff; /* Program header file offset. */\r | |
69 | Elf32_Off e_shoff; /* Section header file offset. */\r | |
70 | Elf32_Word e_flags; /* Architecture-specific flags. */\r | |
71 | Elf32_Half e_ehsize; /* Size of ELF header in bytes. */\r | |
72 | Elf32_Half e_phentsize; /* Size of program header entry. */\r | |
73 | Elf32_Half e_phnum; /* Number of program header entries. */\r | |
74 | Elf32_Half e_shentsize; /* Size of section header entry. */\r | |
75 | Elf32_Half e_shnum; /* Number of section header entries. */\r | |
76 | Elf32_Half e_shstrndx; /* Section name strings section. */\r | |
f51461c8 LG |
77 | } Elf32_Ehdr;\r |
78 | \r | |
79 | /*\r | |
80 | * Section header.\r | |
81 | */\r | |
82 | \r | |
83 | typedef struct {\r | |
f7496d71 LG |
84 | Elf32_Word sh_name; /* Section name (index into the\r |
85 | section header string table). */\r | |
86 | Elf32_Word sh_type; /* Section type. */\r | |
87 | Elf32_Word sh_flags; /* Section flags. */\r | |
88 | Elf32_Addr sh_addr; /* Address in memory image. */\r | |
89 | Elf32_Off sh_offset; /* Offset in file. */\r | |
90 | Elf32_Word sh_size; /* Size in bytes. */\r | |
91 | Elf32_Word sh_link; /* Index of a related section. */\r | |
92 | Elf32_Word sh_info; /* Depends on section type. */\r | |
93 | Elf32_Word sh_addralign; /* Alignment in bytes. */\r | |
94 | Elf32_Word sh_entsize; /* Size of each entry in section. */\r | |
f51461c8 LG |
95 | } Elf32_Shdr;\r |
96 | \r | |
97 | /*\r | |
98 | * Program header.\r | |
99 | */\r | |
100 | \r | |
101 | typedef struct {\r | |
f7496d71 LG |
102 | Elf32_Word p_type; /* Entry type. */\r |
103 | Elf32_Off p_offset; /* File offset of contents. */\r | |
104 | Elf32_Addr p_vaddr; /* Virtual address in memory image. */\r | |
105 | Elf32_Addr p_paddr; /* Physical address (not used). */\r | |
106 | Elf32_Word p_filesz; /* Size of contents in file. */\r | |
107 | Elf32_Word p_memsz; /* Size of contents in memory. */\r | |
108 | Elf32_Word p_flags; /* Access permission flags. */\r | |
109 | Elf32_Word p_align; /* Alignment in memory and file. */\r | |
f51461c8 LG |
110 | } Elf32_Phdr;\r |
111 | \r | |
112 | /*\r | |
113 | * Dynamic structure. The ".dynamic" section contains an array of them.\r | |
114 | */\r | |
115 | \r | |
116 | typedef struct {\r | |
f7496d71 LG |
117 | Elf32_Sword d_tag; /* Entry type. */\r |
118 | union {\r | |
119 | Elf32_Word d_val; /* Integer value. */\r | |
120 | Elf32_Addr d_ptr; /* Address value. */\r | |
121 | } d_un;\r | |
f51461c8 LG |
122 | } Elf32_Dyn;\r |
123 | \r | |
124 | /*\r | |
125 | * Relocation entries.\r | |
126 | */\r | |
127 | \r | |
128 | /* Relocations that don't need an addend field. */\r | |
129 | typedef struct {\r | |
f7496d71 LG |
130 | Elf32_Addr r_offset; /* Location to be relocated. */\r |
131 | Elf32_Word r_info; /* Relocation type and symbol index. */\r | |
f51461c8 LG |
132 | } Elf32_Rel;\r |
133 | \r | |
134 | /* Relocations that need an addend field. */\r | |
135 | typedef struct {\r | |
f7496d71 LG |
136 | Elf32_Addr r_offset; /* Location to be relocated. */\r |
137 | Elf32_Word r_info; /* Relocation type and symbol index. */\r | |
138 | Elf32_Sword r_addend; /* Addend. */\r | |
f51461c8 LG |
139 | } Elf32_Rela;\r |
140 | \r | |
141 | /* Macros for accessing the fields of r_info. */\r | |
f7496d71 LG |
142 | #define ELF32_R_SYM(info) ((info) >> 8)\r |
143 | #define ELF32_R_TYPE(info) ((unsigned char)(info))\r | |
f51461c8 LG |
144 | \r |
145 | /* Macro for constructing r_info from field values. */\r | |
f7496d71 | 146 | #define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type))\r |
f51461c8 LG |
147 | \r |
148 | /*\r | |
f7496d71 | 149 | * Note entry header\r |
f51461c8 LG |
150 | */\r |
151 | typedef Elf_Note Elf32_Nhdr;\r | |
152 | \r | |
153 | /*\r | |
f7496d71 | 154 | * Move entry\r |
f51461c8 LG |
155 | */\r |
156 | typedef struct {\r | |
f7496d71 LG |
157 | Elf32_Lword m_value; /* symbol value */\r |
158 | Elf32_Word m_info; /* size + index */\r | |
159 | Elf32_Word m_poffset; /* symbol offset */\r | |
160 | Elf32_Half m_repeat; /* repeat count */\r | |
161 | Elf32_Half m_stride; /* stride info */\r | |
f51461c8 LG |
162 | } Elf32_Move;\r |
163 | \r | |
164 | /*\r | |
f7496d71 | 165 | * The macros compose and decompose values for Move.r_info\r |
f51461c8 | 166 | *\r |
f7496d71 LG |
167 | * sym = ELF32_M_SYM(M.m_info)\r |
168 | * size = ELF32_M_SIZE(M.m_info)\r | |
169 | * M.m_info = ELF32_M_INFO(sym, size)\r | |
f51461c8 | 170 | */\r |
f7496d71 LG |
171 | #define ELF32_M_SYM(info) ((info)>>8)\r |
172 | #define ELF32_M_SIZE(info) ((unsigned char)(info))\r | |
173 | #define ELF32_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size))\r | |
f51461c8 LG |
174 | \r |
175 | /*\r | |
f7496d71 | 176 | * Hardware/Software capabilities entry\r |
f51461c8 LG |
177 | */\r |
178 | typedef struct {\r | |
f7496d71 LG |
179 | Elf32_Word c_tag; /* how to interpret value */\r |
180 | union {\r | |
181 | Elf32_Word c_val;\r | |
182 | Elf32_Addr c_ptr;\r | |
183 | } c_un;\r | |
f51461c8 LG |
184 | } Elf32_Cap;\r |
185 | \r | |
186 | /*\r | |
187 | * Symbol table entries.\r | |
188 | */\r | |
189 | \r | |
190 | typedef struct {\r | |
f7496d71 LG |
191 | Elf32_Word st_name; /* String table index of name. */\r |
192 | Elf32_Addr st_value; /* Symbol value. */\r | |
193 | Elf32_Word st_size; /* Size of associated object. */\r | |
194 | unsigned char st_info; /* Type and binding information. */\r | |
195 | unsigned char st_other; /* Reserved (not used). */\r | |
196 | Elf32_Half st_shndx; /* Section index of symbol. */\r | |
f51461c8 LG |
197 | } Elf32_Sym;\r |
198 | \r | |
199 | /* Macros for accessing the fields of st_info. */\r | |
f7496d71 LG |
200 | #define ELF32_ST_BIND(info) ((info) >> 4)\r |
201 | #define ELF32_ST_TYPE(info) ((info) & 0xf)\r | |
f51461c8 LG |
202 | \r |
203 | /* Macro for constructing st_info from field values. */\r | |
f7496d71 | 204 | #define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))\r |
f51461c8 LG |
205 | \r |
206 | /* Macro for accessing the fields of st_other. */\r | |
f7496d71 | 207 | #define ELF32_ST_VISIBILITY(oth) ((oth) & 0x3)\r |
f51461c8 LG |
208 | \r |
209 | /* Structures used by Sun & GNU symbol versioning. */\r | |
210 | typedef struct\r | |
211 | {\r | |
f7496d71 LG |
212 | Elf32_Half vd_version;\r |
213 | Elf32_Half vd_flags;\r | |
214 | Elf32_Half vd_ndx;\r | |
215 | Elf32_Half vd_cnt;\r | |
216 | Elf32_Word vd_hash;\r | |
217 | Elf32_Word vd_aux;\r | |
218 | Elf32_Word vd_next;\r | |
f51461c8 LG |
219 | } Elf32_Verdef;\r |
220 | \r | |
221 | typedef struct\r | |
222 | {\r | |
f7496d71 LG |
223 | Elf32_Word vda_name;\r |
224 | Elf32_Word vda_next;\r | |
f51461c8 LG |
225 | } Elf32_Verdaux;\r |
226 | \r | |
227 | typedef struct\r | |
228 | {\r | |
f7496d71 LG |
229 | Elf32_Half vn_version;\r |
230 | Elf32_Half vn_cnt;\r | |
231 | Elf32_Word vn_file;\r | |
232 | Elf32_Word vn_aux;\r | |
233 | Elf32_Word vn_next;\r | |
f51461c8 LG |
234 | } Elf32_Verneed;\r |
235 | \r | |
236 | typedef struct\r | |
237 | {\r | |
f7496d71 LG |
238 | Elf32_Word vna_hash;\r |
239 | Elf32_Half vna_flags;\r | |
240 | Elf32_Half vna_other;\r | |
241 | Elf32_Word vna_name;\r | |
242 | Elf32_Word vna_next;\r | |
f51461c8 LG |
243 | } Elf32_Vernaux;\r |
244 | \r | |
245 | typedef Elf32_Half Elf32_Versym;\r | |
246 | \r | |
247 | typedef struct {\r | |
f7496d71 LG |
248 | Elf32_Half si_boundto; /* direct bindings - symbol bound to */\r |
249 | Elf32_Half si_flags; /* per symbol flags */\r | |
f51461c8 LG |
250 | } Elf32_Syminfo;\r |
251 | \r | |
252 | #endif /* !_SYS_ELF32_H_ */\r |