Git init
[external/libelf.git] / lib / ext_types.h
1 /*
2 ext_types.h - external representation of ELF data types.
3 Copyright (C) 1995 - 1998 Michael Riepe
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20 /* @(#) $Id: ext_types.h,v 1.9 2008/05/23 08:15:34 michael Exp $ */
21
22 #ifndef _EXT_TYPES_H
23 #define _EXT_TYPES_H
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
28
29 /*
30  * Scalar data types
31  */
32 typedef unsigned char __ext_Elf32_Addr  [ELF32_FSZ_ADDR];
33 typedef unsigned char __ext_Elf32_Half  [ELF32_FSZ_HALF];
34 typedef unsigned char __ext_Elf32_Off   [ELF32_FSZ_OFF];
35 typedef unsigned char __ext_Elf32_Sword [ELF32_FSZ_SWORD];
36 typedef unsigned char __ext_Elf32_Word  [ELF32_FSZ_WORD];
37
38 #if __LIBELF64
39
40 typedef unsigned char __ext_Elf32_Lword [8];
41
42 typedef unsigned char __ext_Elf64_Addr  [ELF64_FSZ_ADDR];
43 typedef unsigned char __ext_Elf64_Half  [ELF64_FSZ_HALF];
44 typedef unsigned char __ext_Elf64_Off   [ELF64_FSZ_OFF];
45 typedef unsigned char __ext_Elf64_Sword [ELF64_FSZ_SWORD];
46 typedef unsigned char __ext_Elf64_Word  [ELF64_FSZ_WORD];
47 typedef unsigned char __ext_Elf64_Sxword[ELF64_FSZ_SXWORD];
48 typedef unsigned char __ext_Elf64_Xword [ELF64_FSZ_XWORD];
49
50 typedef unsigned char __ext_Elf64_Lword [8];
51
52 #endif /* __LIBELF64 */
53
54 /*
55  * ELF header
56  */
57 typedef struct {
58     unsigned char       e_ident[EI_NIDENT];
59     __ext_Elf32_Half    e_type;
60     __ext_Elf32_Half    e_machine;
61     __ext_Elf32_Word    e_version;
62     __ext_Elf32_Addr    e_entry;
63     __ext_Elf32_Off     e_phoff;
64     __ext_Elf32_Off     e_shoff;
65     __ext_Elf32_Word    e_flags;
66     __ext_Elf32_Half    e_ehsize;
67     __ext_Elf32_Half    e_phentsize;
68     __ext_Elf32_Half    e_phnum;
69     __ext_Elf32_Half    e_shentsize;
70     __ext_Elf32_Half    e_shnum;
71     __ext_Elf32_Half    e_shstrndx;
72 } __ext_Elf32_Ehdr;
73
74 #if __LIBELF64
75 typedef struct {
76     unsigned char       e_ident[EI_NIDENT];
77     __ext_Elf64_Half    e_type;
78     __ext_Elf64_Half    e_machine;
79     __ext_Elf64_Word    e_version;
80     __ext_Elf64_Addr    e_entry;
81     __ext_Elf64_Off     e_phoff;
82     __ext_Elf64_Off     e_shoff;
83     __ext_Elf64_Word    e_flags;
84     __ext_Elf64_Half    e_ehsize;
85     __ext_Elf64_Half    e_phentsize;
86     __ext_Elf64_Half    e_phnum;
87     __ext_Elf64_Half    e_shentsize;
88     __ext_Elf64_Half    e_shnum;
89     __ext_Elf64_Half    e_shstrndx;
90 } __ext_Elf64_Ehdr;
91 #endif /* __LIBELF64 */
92
93 /*
94  * Section header
95  */
96 typedef struct {
97     __ext_Elf32_Word    sh_name;
98     __ext_Elf32_Word    sh_type;
99     __ext_Elf32_Word    sh_flags;
100     __ext_Elf32_Addr    sh_addr;
101     __ext_Elf32_Off     sh_offset;
102     __ext_Elf32_Word    sh_size;
103     __ext_Elf32_Word    sh_link;
104     __ext_Elf32_Word    sh_info;
105     __ext_Elf32_Word    sh_addralign;
106     __ext_Elf32_Word    sh_entsize;
107 } __ext_Elf32_Shdr;
108
109 #if __LIBELF64
110 typedef struct {
111     __ext_Elf64_Word    sh_name;
112     __ext_Elf64_Word    sh_type;
113     __ext_Elf64_Xword   sh_flags;
114     __ext_Elf64_Addr    sh_addr;
115     __ext_Elf64_Off     sh_offset;
116     __ext_Elf64_Xword   sh_size;
117     __ext_Elf64_Word    sh_link;
118     __ext_Elf64_Word    sh_info;
119     __ext_Elf64_Xword   sh_addralign;
120     __ext_Elf64_Xword   sh_entsize;
121 } __ext_Elf64_Shdr;
122 #endif /* __LIBELF64 */
123
124 /*
125  * Symbol table
126  */
127 typedef struct {
128     __ext_Elf32_Word    st_name;
129     __ext_Elf32_Addr    st_value;
130     __ext_Elf32_Word    st_size;
131     unsigned char       st_info;
132     unsigned char       st_other;
133     __ext_Elf32_Half    st_shndx;
134 } __ext_Elf32_Sym;
135
136 #if __LIBELF64
137 typedef struct {
138     __ext_Elf64_Word    st_name;
139     unsigned char       st_info;
140     unsigned char       st_other;
141     __ext_Elf64_Half    st_shndx;
142     __ext_Elf64_Addr    st_value;
143     __ext_Elf64_Xword   st_size;
144 } __ext_Elf64_Sym;
145 #endif /* __LIBELF64 */
146
147 /*
148  * Relocation
149  */
150 typedef struct {
151     __ext_Elf32_Addr    r_offset;
152     __ext_Elf32_Word    r_info;
153 } __ext_Elf32_Rel;
154
155 typedef struct {
156     __ext_Elf32_Addr    r_offset;
157     __ext_Elf32_Word    r_info;
158     __ext_Elf32_Sword   r_addend;
159 } __ext_Elf32_Rela;
160
161 #if __LIBELF64
162 typedef struct {
163     __ext_Elf64_Addr    r_offset;
164 #if __LIBELF64_IRIX
165     __ext_Elf64_Word    r_sym;
166     unsigned char       r_ssym;
167     unsigned char       r_type3;
168     unsigned char       r_type2;
169     unsigned char       r_type;
170 #else /* __LIBELF64_IRIX */
171     __ext_Elf64_Xword   r_info;
172 #endif /* __LIBELF64_IRIX */
173 } __ext_Elf64_Rel;
174
175 typedef struct {
176     __ext_Elf64_Addr    r_offset;
177 #if __LIBELF64_IRIX
178     __ext_Elf64_Word    r_sym;
179     unsigned char       r_ssym;
180     unsigned char       r_type3;
181     unsigned char       r_type2;
182     unsigned char       r_type;
183 #else /* __LIBELF64_IRIX */
184     __ext_Elf64_Xword   r_info;
185 #endif /* __LIBELF64_IRIX */
186     __ext_Elf64_Sxword  r_addend;
187 } __ext_Elf64_Rela;
188 #endif /* __LIBELF64 */
189
190 /*
191  * Program header
192  */
193 typedef struct {
194     __ext_Elf32_Word    p_type;
195     __ext_Elf32_Off     p_offset;
196     __ext_Elf32_Addr    p_vaddr;
197     __ext_Elf32_Addr    p_paddr;
198     __ext_Elf32_Word    p_filesz;
199     __ext_Elf32_Word    p_memsz;
200     __ext_Elf32_Word    p_flags;
201     __ext_Elf32_Word    p_align;
202 } __ext_Elf32_Phdr;
203
204 #if __LIBELF64
205 typedef struct {
206     __ext_Elf64_Word    p_type;
207     __ext_Elf64_Word    p_flags;
208     __ext_Elf64_Off     p_offset;
209     __ext_Elf64_Addr    p_vaddr;
210     __ext_Elf64_Addr    p_paddr;
211     __ext_Elf64_Xword   p_filesz;
212     __ext_Elf64_Xword   p_memsz;
213     __ext_Elf64_Xword   p_align;
214 } __ext_Elf64_Phdr;
215 #endif /* __LIBELF64 */
216
217 /*
218  * Dynamic structure
219  */
220 typedef struct {
221     __ext_Elf32_Sword   d_tag;
222     union {
223         __ext_Elf32_Word        d_val;
224         __ext_Elf32_Addr        d_ptr;
225     } d_un;
226 } __ext_Elf32_Dyn;
227
228 #if __LIBELF64
229 typedef struct {
230     __ext_Elf64_Sxword  d_tag;
231     union {
232         __ext_Elf64_Xword       d_val;
233         __ext_Elf64_Addr        d_ptr;
234     } d_un;
235 } __ext_Elf64_Dyn;
236 #endif /* __LIBELF64 */
237
238 /*
239  * Version definitions
240  */
241 typedef struct {
242     __ext_Elf32_Half    vd_version;
243     __ext_Elf32_Half    vd_flags;
244     __ext_Elf32_Half    vd_ndx;
245     __ext_Elf32_Half    vd_cnt;
246     __ext_Elf32_Word    vd_hash;
247     __ext_Elf32_Word    vd_aux;
248     __ext_Elf32_Word    vd_next;
249 } __ext_Elf32_Verdef;
250
251 typedef struct {
252     __ext_Elf32_Word    vda_name;
253     __ext_Elf32_Word    vda_next;
254 } __ext_Elf32_Verdaux;
255
256 typedef struct {
257     __ext_Elf32_Half    vn_version;
258     __ext_Elf32_Half    vn_cnt;
259     __ext_Elf32_Word    vn_file;
260     __ext_Elf32_Word    vn_aux;
261     __ext_Elf32_Word    vn_next;
262 } __ext_Elf32_Verneed;
263
264 typedef struct {
265     __ext_Elf32_Word    vna_hash;
266     __ext_Elf32_Half    vna_flags;
267     __ext_Elf32_Half    vna_other;
268     __ext_Elf32_Word    vna_name;
269     __ext_Elf32_Word    vna_next;
270 } __ext_Elf32_Vernaux;
271
272 #if __LIBELF64
273
274 typedef struct {
275     __ext_Elf64_Half    vd_version;
276     __ext_Elf64_Half    vd_flags;
277     __ext_Elf64_Half    vd_ndx;
278     __ext_Elf64_Half    vd_cnt;
279     __ext_Elf64_Word    vd_hash;
280     __ext_Elf64_Word    vd_aux;
281     __ext_Elf64_Word    vd_next;
282 } __ext_Elf64_Verdef;
283
284 typedef struct {
285     __ext_Elf64_Word    vda_name;
286     __ext_Elf64_Word    vda_next;
287 } __ext_Elf64_Verdaux;
288
289 typedef struct {
290     __ext_Elf64_Half    vn_version;
291     __ext_Elf64_Half    vn_cnt;
292     __ext_Elf64_Word    vn_file;
293     __ext_Elf64_Word    vn_aux;
294     __ext_Elf64_Word    vn_next;
295 } __ext_Elf64_Verneed;
296
297 typedef struct {
298     __ext_Elf64_Word    vna_hash;
299     __ext_Elf64_Half    vna_flags;
300     __ext_Elf64_Half    vna_other;
301     __ext_Elf64_Word    vna_name;
302     __ext_Elf64_Word    vna_next;
303 } __ext_Elf64_Vernaux;
304
305 #endif /* __LIBELF64 */
306
307 /*
308  * Move section
309  */
310 #if __LIBELF64
311
312 typedef struct {
313     __ext_Elf32_Lword   m_value;
314     __ext_Elf32_Word    m_info;
315     __ext_Elf32_Word    m_poffset;
316     __ext_Elf32_Half    m_repeat;
317     __ext_Elf32_Half    m_stride;
318 } __ext_Elf32_Move;
319
320 typedef struct {
321     __ext_Elf64_Lword   m_value;
322     __ext_Elf64_Xword   m_info;
323     __ext_Elf64_Xword   m_poffset;
324     __ext_Elf64_Half    m_repeat;
325     __ext_Elf64_Half    m_stride;
326 } __ext_Elf64_Move;
327
328 #endif /* __LIBELF64 */
329
330 #ifdef __cplusplus
331 }
332 #endif /* __cplusplus */
333
334 #endif /* _EXT_TYPES_H */