]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - lib/libelf/elf_types.m4
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.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         `GNUHASH,       -,      800062',
50         `HALF,          Half,   600102',
51         `LWORD,         Lword,  700025',
52         `MOVE,          Move,   700025',
53         `MOVEP,         MoveP,  700025',
54         `NOTE,          Note,   600102',
55         `OFF,           Off,    600102',
56         `PHDR,          Phdr,   600102',
57         `REL,           Rel,    600102',
58         `RELA,          Rela,   600102',
59         `SHDR,          Shdr,   600102',
60         `SWORD,         Sword,  600102',
61         `SXWORD,        Sxword, 700009',
62         `SYMINFO,       Syminfo, 700025',
63         `SYM,           Sym,    600102',
64         `VDEF,          Verdef, 700009',
65         `VNEED,         Verneed, 700009',
66         `WORD,          Word,   600102',
67         `XWORD,         Xword,  700009',
68         `NUM,           _,      _'')
69
70 /*
71  * DEFINE_STRUCT(NAME,MEMBERLIST...)
72  *
73  * Map a type name to its members.
74  *
75  * Each member-list element comprises of pairs of (field name, type),
76  * in the sequence used in the file representation of `NAME'.
77  *
78  * Each member list element comprises a pair containing a field name
79  * and a basic type.  Basic types include IDENT, HALF, WORD, LWORD,
80  * ADDR{32,64}, OFF{32,64}, SWORD, XWORD, SXWORD.
81  *
82  * The last element of a member list is the null element: `_,_'.
83  */
84
85 define(`DEFINE_STRUCT',`define(`$1_DEF',shift($@))dnl')
86
87 DEFINE_STRUCT(`Elf32_Cap',
88         ``c_tag,        WORD',
89         `c_un.c_val,    WORD',
90         `_,_'')
91
92 DEFINE_STRUCT(`Elf64_Cap',
93         ``c_tag,        XWORD',
94         `c_un.c_val,    XWORD',
95         `_,_'')
96
97 DEFINE_STRUCT(`Elf32_Dyn',
98         ``d_tag,        SWORD',
99         `d_un.d_ptr,    WORD',
100         `_,_'')
101
102 DEFINE_STRUCT(`Elf64_Dyn',
103         ``d_tag,        SXWORD',
104         `d_un.d_ptr,    XWORD',
105         `_,_'')
106
107 DEFINE_STRUCT(`Elf32_Ehdr',
108         ``e_ident,      IDENT',
109         `e_type,        HALF',
110         `e_machine,     HALF',
111         `e_version,     WORD',
112         `e_entry,       ADDR',
113         `e_phoff,       OFF',
114         `e_shoff,       OFF',
115         `e_flags,       WORD',
116         `e_ehsize,      HALF',
117         `e_phentsize,   HALF',
118         `e_phnum,       HALF',
119         `e_shentsize,   HALF',
120         `e_shnum,       HALF',
121         `e_shstrndx,    HALF',
122         `_,_'')
123
124 DEFINE_STRUCT(`Elf64_Ehdr',
125         ``e_ident,      IDENT',
126         `e_type,        HALF',
127         `e_machine,     HALF',
128         `e_version,     WORD',
129         `e_entry,       ADDR',
130         `e_phoff,       OFF',
131         `e_shoff,       OFF',
132         `e_flags,       WORD',
133         `e_ehsize,      HALF',
134         `e_phentsize,   HALF',
135         `e_phnum,       HALF',
136         `e_shentsize,   HALF',
137         `e_shnum,       HALF',
138         `e_shstrndx,    HALF',
139         `_,_'')
140
141 DEFINE_STRUCT(`Elf32_Move',
142         ``m_value,      LWORD',
143         `m_info,        WORD',
144         `m_poffset,     WORD',
145         `m_repeat,      HALF',
146         `m_stride,      HALF',
147         `_,_'')
148
149 DEFINE_STRUCT(`Elf64_Move',
150         ``m_value,      LWORD',
151         `m_info,        XWORD',
152         `m_poffset,     XWORD',
153         `m_repeat,      HALF',
154         `m_stride,      HALF',
155         `_,_'')
156
157 DEFINE_STRUCT(`Elf32_Phdr',
158         ``p_type,       WORD',
159         `p_offset,      OFF',
160         `p_vaddr,       ADDR',
161         `p_paddr,       ADDR',
162         `p_filesz,      WORD',
163         `p_memsz,       WORD',
164         `p_flags,       WORD',
165         `p_align,       WORD',
166         `_,_'')
167
168 DEFINE_STRUCT(`Elf64_Phdr',
169         ``p_type,       WORD',
170         `p_flags,       WORD',
171         `p_offset,      OFF',
172         `p_vaddr,       ADDR',
173         `p_paddr,       ADDR',
174         `p_filesz,      XWORD',
175         `p_memsz,       XWORD',
176         `p_align,       XWORD',
177         `_,_'')
178
179 DEFINE_STRUCT(`Elf32_Rel',
180         ``r_offset,     ADDR',
181         `r_info,        WORD',
182         `_,_'')
183
184 DEFINE_STRUCT(`Elf64_Rel',
185         ``r_offset,     ADDR',
186         `r_info,        XWORD',
187         `_,_'')
188
189 DEFINE_STRUCT(`Elf32_Rela',
190         ``r_offset,     ADDR',
191         `r_info,        WORD',
192         `r_addend,      SWORD',
193         `_,_'')
194
195 DEFINE_STRUCT(`Elf64_Rela',
196         ``r_offset,     ADDR',
197         `r_info,        XWORD',
198         `r_addend,      SXWORD',
199         `_,_'')
200
201 DEFINE_STRUCT(`Elf32_Shdr',
202         ``sh_name,      WORD',
203         `sh_type,       WORD',
204         `sh_flags,      WORD',
205         `sh_addr,       ADDR',
206         `sh_offset,     OFF',
207         `sh_size,       WORD',
208         `sh_link,       WORD',
209         `sh_info,       WORD',
210         `sh_addralign,  WORD',
211         `sh_entsize,    WORD',
212         `_,_'')
213
214 DEFINE_STRUCT(`Elf64_Shdr',
215         ``sh_name,      WORD',
216         `sh_type,       WORD',
217         `sh_flags,      XWORD',
218         `sh_addr,       ADDR',
219         `sh_offset,     OFF',
220         `sh_size,       XWORD',
221         `sh_link,       WORD',
222         `sh_info,       WORD',
223         `sh_addralign,  XWORD',
224         `sh_entsize,    XWORD',
225         `_,_'')
226
227 DEFINE_STRUCT(`Elf32_Sym',
228         ``st_name,      WORD',
229         `st_value,      ADDR',
230         `st_size,       WORD',
231         `st_info,       BYTE',
232         `st_other,      BYTE',
233         `st_shndx,      HALF',
234         `_,_'')
235
236 DEFINE_STRUCT(`Elf64_Sym',
237         ``st_name,      WORD',
238         `st_info,       BYTE',
239         `st_other,      BYTE',
240         `st_shndx,      HALF',
241         `st_value,      ADDR',
242         `st_size,       XWORD',
243         `_,_'')
244
245 DEFINE_STRUCT(`Elf32_Syminfo',
246         ``si_boundto,   HALF',
247         `si_flags,      HALF',
248         `_,_'')
249
250 DEFINE_STRUCT(`Elf64_Syminfo',
251         ``si_boundto,   HALF',
252         `si_flags,      HALF',
253         `_,_'')
254
255 DEFINE_STRUCT(`Elf32_Verdaux',
256         ``vda_name,     WORD',
257         `vda_next,      WORD',
258         `_,_'')
259
260 DEFINE_STRUCT(`Elf64_Verdaux',
261         ``vda_name,     WORD',
262         `vda_next,      WORD',
263         `_,_'')
264
265 DEFINE_STRUCT(`Elf32_Verdef',
266         ``vd_version,   HALF',
267         `vd_flags,      HALF',
268         `vd_ndx,        HALF',
269         `vd_cnt,        HALF',
270         `vd_hash,       WORD',
271         `vd_aux,        WORD',
272         `vd_next,       WORD',
273         `_,_'')
274
275 DEFINE_STRUCT(`Elf64_Verdef',
276         ``vd_version,   HALF',
277         `vd_flags,      HALF',
278         `vd_ndx,        HALF',
279         `vd_cnt,        HALF',
280         `vd_hash,       WORD',
281         `vd_aux,        WORD',
282         `vd_next,       WORD',
283         `_,_'')
284
285 DEFINE_STRUCT(`Elf32_Verneed',
286         ``vn_version,   HALF',
287         `vn_cnt,        HALF',
288         `vn_file,       WORD',
289         `vn_aux,        WORD',
290         `vn_next,       WORD',
291         `_,_'')
292
293 DEFINE_STRUCT(`Elf64_Verneed',
294         ``vn_version,   HALF',
295         `vn_cnt,        HALF',
296         `vn_file,       WORD',
297         `vn_aux,        WORD',
298         `vn_next,       WORD',
299         `_,_'')
300
301 DEFINE_STRUCT(`Elf32_Vernaux',
302         ``vna_hash,     WORD',
303         `vna_flags,     HALF',
304         `vna_other,     HALF',
305         `vna_name,      WORD',
306         `vna_next,      WORD',
307         `_,_'')
308
309 DEFINE_STRUCT(`Elf64_Vernaux',
310         ``vna_hash,     WORD',
311         `vna_flags,     HALF',
312         `vna_other,     HALF',
313         `vna_name,      WORD',
314         `vna_next,      WORD',
315         `_,_'')