]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - lib/libelf/elf_types.m4
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / lib / libelf / elf_types.m4
1 /*-
2  * Copyright (c) 2006 Joseph Koshy
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 /*
30  * ELF types, defined in the "enum Elf_Type" API.
31  *
32  * The members of the list form a 3-tuple: (name, C-type-suffix, OSversion).
33  * + `name' is an Elf_Type symbol without the `ELF_T_' prefix.
34  * + `C-type-suffix' is the suffix for Elf32_ and Elf64_ type names.
35  * + `version' is the OS version the symbol first appeared in.
36  *
37  * OS revisions of note are:
38  * 600102 - The earliest (6.0-STABLE) version supported by this code.
39  * 700009 - Symbol versioning and ELF64 type changes.
40  * 700025 - More ELF types and the introduction of libelf.
41  */
42
43 define(`ELF_TYPE_LIST',
44         ``ADDR,         Addr,   600102',
45         `BYTE,          Byte,   600102',
46         `CAP,           Cap,    700025',
47         `DYN,           Dyn,    600102',
48         `EHDR,          Ehdr,   600102',
49         `HALF,          Half,   600102',
50         `LWORD,         Lword,  700025',
51         `MOVE,          Move,   700025',
52         `MOVEP,         MoveP,  700025',
53         `NOTE,          Note,   600102',
54         `OFF,           Off,    600102',
55         `PHDR,          Phdr,   600102',
56         `REL,           Rel,    600102',
57         `RELA,          Rela,   600102',
58         `SHDR,          Shdr,   600102',
59         `SWORD,         Sword,  600102',
60         `SXWORD,        Sxword, 700009',
61         `SYMINFO,       Syminfo, 700025',
62         `SYM,           Sym,    600102',
63         `VDEF,          Verdef, 700009',
64         `VNEED,         Verneed, 700009',
65         `WORD,          Word,   600102',
66         `XWORD,         Xword,  700009',
67         `NUM,           _,      _'')
68
69 /*
70  * DEFINE_STRUCT(NAME,MEMBERLIST...)
71  *
72  * Map a type name to its members.
73  *
74  * Each member-list element comprises of pairs of (field name, type),
75  * in the sequence used in the file representation of `NAME'.
76  *
77  * Each member list element comprises a pair containing a field name
78  * and a basic type.  Basic types include IDENT, HALF, WORD, LWORD,
79  * ADDR{32,64}, OFF{32,64}, SWORD, XWORD, SXWORD.
80  *
81  * The last element of a member list is the null element: `_,_'.
82  */
83
84 define(`DEFINE_STRUCT',`define(`$1_DEF',shift($@))dnl')
85
86 DEFINE_STRUCT(`Elf32_Cap',
87         ``c_tag,        WORD',
88         `c_un.c_val,    WORD',
89         `_,_'')
90
91 DEFINE_STRUCT(`Elf64_Cap',
92         ``c_tag,        XWORD',
93         `c_un.c_val,    XWORD',
94         `_,_'')
95
96 DEFINE_STRUCT(`Elf32_Dyn',
97         ``d_tag,        SWORD',
98         `d_un.d_ptr,    WORD',
99         `_,_'')
100
101 DEFINE_STRUCT(`Elf64_Dyn',
102         ``d_tag,        SXWORD',
103         `d_un.d_ptr,    XWORD',
104         `_,_'')
105
106 DEFINE_STRUCT(`Elf32_Ehdr',
107         ``e_ident,      IDENT',
108         `e_type,        HALF',
109         `e_machine,     HALF',
110         `e_version,     WORD',
111         `e_entry,       ADDR',
112         `e_phoff,       OFF',
113         `e_shoff,       OFF',
114         `e_flags,       WORD',
115         `e_ehsize,      HALF',
116         `e_phentsize,   HALF',
117         `e_phnum,       HALF',
118         `e_shentsize,   HALF',
119         `e_shnum,       HALF',
120         `e_shstrndx,    HALF',
121         `_,_'')
122
123 DEFINE_STRUCT(`Elf64_Ehdr',
124         ``e_ident,      IDENT',
125         `e_type,        HALF',
126         `e_machine,     HALF',
127         `e_version,     WORD',
128         `e_entry,       ADDR',
129         `e_phoff,       OFF',
130         `e_shoff,       OFF',
131         `e_flags,       WORD',
132         `e_ehsize,      HALF',
133         `e_phentsize,   HALF',
134         `e_phnum,       HALF',
135         `e_shentsize,   HALF',
136         `e_shnum,       HALF',
137         `e_shstrndx,    HALF',
138         `_,_'')
139
140 DEFINE_STRUCT(`Elf32_Move',
141         ``m_value,      LWORD',
142         `m_info,        WORD',
143         `m_poffset,     WORD',
144         `m_repeat,      HALF',
145         `m_stride,      HALF',
146         `_,_'')
147
148 DEFINE_STRUCT(`Elf64_Move',
149         ``m_value,      LWORD',
150         `m_info,        XWORD',
151         `m_poffset,     XWORD',
152         `m_repeat,      HALF',
153         `m_stride,      HALF',
154         `_,_'')
155
156 DEFINE_STRUCT(`Elf32_Phdr',
157         ``p_type,       WORD',
158         `p_offset,      OFF',
159         `p_vaddr,       ADDR',
160         `p_paddr,       ADDR',
161         `p_filesz,      WORD',
162         `p_memsz,       WORD',
163         `p_flags,       WORD',
164         `p_align,       WORD',
165         `_,_'')
166
167 DEFINE_STRUCT(`Elf64_Phdr',
168         ``p_type,       WORD',
169         `p_flags,       WORD',
170         `p_offset,      OFF',
171         `p_vaddr,       ADDR',
172         `p_paddr,       ADDR',
173         `p_filesz,      XWORD',
174         `p_memsz,       XWORD',
175         `p_align,       XWORD',
176         `_,_'')
177
178 DEFINE_STRUCT(`Elf32_Rel',
179         ``r_offset,     ADDR',
180         `r_info,        WORD',
181         `_,_'')
182
183 DEFINE_STRUCT(`Elf64_Rel',
184         ``r_offset,     ADDR',
185         `r_info,        XWORD',
186         `_,_'')
187
188 DEFINE_STRUCT(`Elf32_Rela',
189         ``r_offset,     ADDR',
190         `r_info,        WORD',
191         `r_addend,      SWORD',
192         `_,_'')
193
194 DEFINE_STRUCT(`Elf64_Rela',
195         ``r_offset,     ADDR',
196         `r_info,        XWORD',
197         `r_addend,      SXWORD',
198         `_,_'')
199
200 DEFINE_STRUCT(`Elf32_Shdr',
201         ``sh_name,      WORD',
202         `sh_type,       WORD',
203         `sh_flags,      WORD',
204         `sh_addr,       ADDR',
205         `sh_offset,     OFF',
206         `sh_size,       WORD',
207         `sh_link,       WORD',
208         `sh_info,       WORD',
209         `sh_addralign,  WORD',
210         `sh_entsize,    WORD',
211         `_,_'')
212
213 DEFINE_STRUCT(`Elf64_Shdr',
214         ``sh_name,      WORD',
215         `sh_type,       WORD',
216         `sh_flags,      XWORD',
217         `sh_addr,       ADDR',
218         `sh_offset,     OFF',
219         `sh_size,       XWORD',
220         `sh_link,       WORD',
221         `sh_info,       WORD',
222         `sh_addralign,  XWORD',
223         `sh_entsize,    XWORD',
224         `_,_'')
225
226 DEFINE_STRUCT(`Elf32_Sym',
227         ``st_name,      WORD',
228         `st_value,      ADDR',
229         `st_size,       WORD',
230         `st_info,       BYTE',
231         `st_other,      BYTE',
232         `st_shndx,      HALF',
233         `_,_'')
234
235 DEFINE_STRUCT(`Elf64_Sym',
236         ``st_name,      WORD',
237         `st_info,       BYTE',
238         `st_other,      BYTE',
239         `st_shndx,      HALF',
240         `st_value,      ADDR',
241         `st_size,       XWORD',
242         `_,_'')
243
244 DEFINE_STRUCT(`Elf32_Syminfo',
245         ``si_boundto,   HALF',
246         `si_flags,      HALF',
247         `_,_'')
248
249 DEFINE_STRUCT(`Elf64_Syminfo',
250         ``si_boundto,   HALF',
251         `si_flags,      HALF',
252         `_,_'')
253
254 DEFINE_STRUCT(`Elf32_Verdaux',
255         ``vda_name,     WORD',
256         `vda_next,      WORD',
257         `_,_'')
258
259 DEFINE_STRUCT(`Elf64_Verdaux',
260         ``vda_name,     WORD',
261         `vda_next,      WORD',
262         `_,_'')
263
264 DEFINE_STRUCT(`Elf32_Verdef',
265         ``vd_version,   HALF',
266         `vd_flags,      HALF',
267         `vd_ndx,        HALF',
268         `vd_cnt,        HALF',
269         `vd_hash,       WORD',
270         `vd_aux,        WORD',
271         `vd_next,       WORD',
272         `_,_'')
273
274 DEFINE_STRUCT(`Elf64_Verdef',
275         ``vd_version,   HALF',
276         `vd_flags,      HALF',
277         `vd_ndx,        HALF',
278         `vd_cnt,        HALF',
279         `vd_hash,       WORD',
280         `vd_aux,        WORD',
281         `vd_next,       WORD',
282         `_,_'')
283
284 DEFINE_STRUCT(`Elf32_Verneed',
285         ``vn_version,   HALF',
286         `vn_cnt,        HALF',
287         `vn_file,       WORD',
288         `vn_aux,        WORD',
289         `vn_next,       WORD',
290         `_,_'')
291
292 DEFINE_STRUCT(`Elf64_Verneed',
293         ``vn_version,   HALF',
294         `vn_cnt,        HALF',
295         `vn_file,       WORD',
296         `vn_aux,        WORD',
297         `vn_next,       WORD',
298         `_,_'')
299
300 DEFINE_STRUCT(`Elf32_Vernaux',
301         ``vna_hash,     WORD',
302         `vna_flags,     HALF',
303         `vna_other,     HALF',
304         `vna_name,      WORD',
305         `vna_next,      WORD',
306         `_,_'')
307
308 DEFINE_STRUCT(`Elf64_Vernaux',
309         ``vna_hash,     WORD',
310         `vna_flags,     HALF',
311         `vna_other,     HALF',
312         `vna_name,      WORD',
313         `vna_next,      WORD',
314         `_,_'')