1164190Sjkoshy/*- 2164190Sjkoshy * Copyright (c) 2006 Joseph Koshy 3164190Sjkoshy * All rights reserved. 4164190Sjkoshy * 5164190Sjkoshy * Redistribution and use in source and binary forms, with or without 6164190Sjkoshy * modification, are permitted provided that the following conditions 7164190Sjkoshy * are met: 8164190Sjkoshy * 1. Redistributions of source code must retain the above copyright 9164190Sjkoshy * notice, this list of conditions and the following disclaimer. 10164190Sjkoshy * 2. Redistributions in binary form must reproduce the above copyright 11164190Sjkoshy * notice, this list of conditions and the following disclaimer in the 12164190Sjkoshy * documentation and/or other materials provided with the distribution. 13164190Sjkoshy * 14164190Sjkoshy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15164190Sjkoshy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16164190Sjkoshy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17164190Sjkoshy * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18164190Sjkoshy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19164190Sjkoshy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20164190Sjkoshy * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21164190Sjkoshy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22164190Sjkoshy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23164190Sjkoshy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24164190Sjkoshy * SUCH DAMAGE. 25164190Sjkoshy * 26164190Sjkoshy * $FreeBSD: releng/10.2/lib/libelf/elf_types.m4 210341 2010-07-21 10:57:22Z kaiw $ 27164190Sjkoshy */ 28164190Sjkoshy 29164190Sjkoshy/* 30164190Sjkoshy * ELF types, defined in the "enum Elf_Type" API. 31165317Sjkoshy * 32165317Sjkoshy * The members of the list form a 3-tuple: (name, C-type-suffix, OSversion). 33165317Sjkoshy * + `name' is an Elf_Type symbol without the `ELF_T_' prefix. 34165317Sjkoshy * + `C-type-suffix' is the suffix for Elf32_ and Elf64_ type names. 35165317Sjkoshy * + `version' is the OS version the symbol first appeared in. 36165317Sjkoshy * 37165317Sjkoshy * OS revisions of note are: 38165317Sjkoshy * 600102 - The earliest (6.0-STABLE) version supported by this code. 39165317Sjkoshy * 700009 - Symbol versioning and ELF64 type changes. 40165317Sjkoshy * 700025 - More ELF types and the introduction of libelf. 41164190Sjkoshy */ 42164190Sjkoshy 43164190Sjkoshydefine(`ELF_TYPE_LIST', 44165317Sjkoshy ``ADDR, Addr, 600102', 45165317Sjkoshy `BYTE, Byte, 600102', 46165317Sjkoshy `CAP, Cap, 700025', 47165317Sjkoshy `DYN, Dyn, 600102', 48165317Sjkoshy `EHDR, Ehdr, 600102', 49210341Skaiw `GNUHASH, -, 800062', 50165317Sjkoshy `HALF, Half, 600102', 51165317Sjkoshy `LWORD, Lword, 700025', 52165317Sjkoshy `MOVE, Move, 700025', 53165317Sjkoshy `MOVEP, MoveP, 700025', 54165317Sjkoshy `NOTE, Note, 600102', 55165317Sjkoshy `OFF, Off, 600102', 56165317Sjkoshy `PHDR, Phdr, 600102', 57165317Sjkoshy `REL, Rel, 600102', 58165317Sjkoshy `RELA, Rela, 600102', 59165317Sjkoshy `SHDR, Shdr, 600102', 60165317Sjkoshy `SWORD, Sword, 600102', 61165317Sjkoshy `SXWORD, Sxword, 700009', 62165317Sjkoshy `SYMINFO, Syminfo, 700025', 63165317Sjkoshy `SYM, Sym, 600102', 64165317Sjkoshy `VDEF, Verdef, 700009', 65165317Sjkoshy `VNEED, Verneed, 700009', 66165317Sjkoshy `WORD, Word, 600102', 67165317Sjkoshy `XWORD, Xword, 700009', 68165317Sjkoshy `NUM, _, _'') 69164190Sjkoshy 70164190Sjkoshy/* 71164190Sjkoshy * DEFINE_STRUCT(NAME,MEMBERLIST...) 72164190Sjkoshy * 73164190Sjkoshy * Map a type name to its members. 74164190Sjkoshy * 75164190Sjkoshy * Each member-list element comprises of pairs of (field name, type), 76164190Sjkoshy * in the sequence used in the file representation of `NAME'. 77164190Sjkoshy * 78164190Sjkoshy * Each member list element comprises a pair containing a field name 79164190Sjkoshy * and a basic type. Basic types include IDENT, HALF, WORD, LWORD, 80164190Sjkoshy * ADDR{32,64}, OFF{32,64}, SWORD, XWORD, SXWORD. 81164190Sjkoshy * 82164190Sjkoshy * The last element of a member list is the null element: `_,_'. 83164190Sjkoshy */ 84164190Sjkoshy 85164190Sjkoshydefine(`DEFINE_STRUCT',`define(`$1_DEF',shift($@))dnl') 86164190Sjkoshy 87164190SjkoshyDEFINE_STRUCT(`Elf32_Cap', 88164190Sjkoshy ``c_tag, WORD', 89164190Sjkoshy `c_un.c_val, WORD', 90164190Sjkoshy `_,_'') 91164190Sjkoshy 92164190SjkoshyDEFINE_STRUCT(`Elf64_Cap', 93164190Sjkoshy ``c_tag, XWORD', 94164190Sjkoshy `c_un.c_val, XWORD', 95164190Sjkoshy `_,_'') 96164190Sjkoshy 97164190SjkoshyDEFINE_STRUCT(`Elf32_Dyn', 98164190Sjkoshy ``d_tag, SWORD', 99164190Sjkoshy `d_un.d_ptr, WORD', 100164190Sjkoshy `_,_'') 101164190Sjkoshy 102164190SjkoshyDEFINE_STRUCT(`Elf64_Dyn', 103164190Sjkoshy ``d_tag, SXWORD', 104164190Sjkoshy `d_un.d_ptr, XWORD', 105164190Sjkoshy `_,_'') 106164190Sjkoshy 107164190SjkoshyDEFINE_STRUCT(`Elf32_Ehdr', 108164190Sjkoshy ``e_ident, IDENT', 109164190Sjkoshy `e_type, HALF', 110164190Sjkoshy `e_machine, HALF', 111164190Sjkoshy `e_version, WORD', 112164190Sjkoshy `e_entry, ADDR', 113164190Sjkoshy `e_phoff, OFF', 114164190Sjkoshy `e_shoff, OFF', 115164190Sjkoshy `e_flags, WORD', 116164190Sjkoshy `e_ehsize, HALF', 117164190Sjkoshy `e_phentsize, HALF', 118164190Sjkoshy `e_phnum, HALF', 119164190Sjkoshy `e_shentsize, HALF', 120164190Sjkoshy `e_shnum, HALF', 121164190Sjkoshy `e_shstrndx, HALF', 122164190Sjkoshy `_,_'') 123164190Sjkoshy 124164190SjkoshyDEFINE_STRUCT(`Elf64_Ehdr', 125164190Sjkoshy ``e_ident, IDENT', 126164190Sjkoshy `e_type, HALF', 127164190Sjkoshy `e_machine, HALF', 128164190Sjkoshy `e_version, WORD', 129164190Sjkoshy `e_entry, ADDR', 130164190Sjkoshy `e_phoff, OFF', 131164190Sjkoshy `e_shoff, OFF', 132164190Sjkoshy `e_flags, WORD', 133164190Sjkoshy `e_ehsize, HALF', 134164190Sjkoshy `e_phentsize, HALF', 135164190Sjkoshy `e_phnum, HALF', 136164190Sjkoshy `e_shentsize, HALF', 137164190Sjkoshy `e_shnum, HALF', 138164190Sjkoshy `e_shstrndx, HALF', 139164190Sjkoshy `_,_'') 140164190Sjkoshy 141164190SjkoshyDEFINE_STRUCT(`Elf32_Move', 142164190Sjkoshy ``m_value, LWORD', 143164190Sjkoshy `m_info, WORD', 144164190Sjkoshy `m_poffset, WORD', 145164190Sjkoshy `m_repeat, HALF', 146164190Sjkoshy `m_stride, HALF', 147164190Sjkoshy `_,_'') 148164190Sjkoshy 149164190SjkoshyDEFINE_STRUCT(`Elf64_Move', 150164190Sjkoshy ``m_value, LWORD', 151164190Sjkoshy `m_info, XWORD', 152164190Sjkoshy `m_poffset, XWORD', 153164190Sjkoshy `m_repeat, HALF', 154164190Sjkoshy `m_stride, HALF', 155164190Sjkoshy `_,_'') 156164190Sjkoshy 157164190SjkoshyDEFINE_STRUCT(`Elf32_Phdr', 158164190Sjkoshy ``p_type, WORD', 159164190Sjkoshy `p_offset, OFF', 160164190Sjkoshy `p_vaddr, ADDR', 161164190Sjkoshy `p_paddr, ADDR', 162164190Sjkoshy `p_filesz, WORD', 163164190Sjkoshy `p_memsz, WORD', 164164190Sjkoshy `p_flags, WORD', 165164190Sjkoshy `p_align, WORD', 166164190Sjkoshy `_,_'') 167164190Sjkoshy 168164190SjkoshyDEFINE_STRUCT(`Elf64_Phdr', 169164190Sjkoshy ``p_type, WORD', 170164190Sjkoshy `p_flags, WORD', 171164190Sjkoshy `p_offset, OFF', 172164190Sjkoshy `p_vaddr, ADDR', 173164190Sjkoshy `p_paddr, ADDR', 174164190Sjkoshy `p_filesz, XWORD', 175164190Sjkoshy `p_memsz, XWORD', 176164190Sjkoshy `p_align, XWORD', 177164190Sjkoshy `_,_'') 178164190Sjkoshy 179164190SjkoshyDEFINE_STRUCT(`Elf32_Rel', 180164190Sjkoshy ``r_offset, ADDR', 181164190Sjkoshy `r_info, WORD', 182164190Sjkoshy `_,_'') 183164190Sjkoshy 184164190SjkoshyDEFINE_STRUCT(`Elf64_Rel', 185164190Sjkoshy ``r_offset, ADDR', 186164190Sjkoshy `r_info, XWORD', 187164190Sjkoshy `_,_'') 188164190Sjkoshy 189164190SjkoshyDEFINE_STRUCT(`Elf32_Rela', 190164190Sjkoshy ``r_offset, ADDR', 191164190Sjkoshy `r_info, WORD', 192164190Sjkoshy `r_addend, SWORD', 193164190Sjkoshy `_,_'') 194164190Sjkoshy 195164190SjkoshyDEFINE_STRUCT(`Elf64_Rela', 196164190Sjkoshy ``r_offset, ADDR', 197164190Sjkoshy `r_info, XWORD', 198164190Sjkoshy `r_addend, SXWORD', 199164190Sjkoshy `_,_'') 200164190Sjkoshy 201164190SjkoshyDEFINE_STRUCT(`Elf32_Shdr', 202164190Sjkoshy ``sh_name, WORD', 203164190Sjkoshy `sh_type, WORD', 204164190Sjkoshy `sh_flags, WORD', 205164190Sjkoshy `sh_addr, ADDR', 206164190Sjkoshy `sh_offset, OFF', 207164190Sjkoshy `sh_size, WORD', 208164190Sjkoshy `sh_link, WORD', 209164190Sjkoshy `sh_info, WORD', 210164190Sjkoshy `sh_addralign, WORD', 211164190Sjkoshy `sh_entsize, WORD', 212164190Sjkoshy `_,_'') 213164190Sjkoshy 214164190SjkoshyDEFINE_STRUCT(`Elf64_Shdr', 215164190Sjkoshy ``sh_name, WORD', 216164190Sjkoshy `sh_type, WORD', 217164190Sjkoshy `sh_flags, XWORD', 218164190Sjkoshy `sh_addr, ADDR', 219164190Sjkoshy `sh_offset, OFF', 220164190Sjkoshy `sh_size, XWORD', 221164190Sjkoshy `sh_link, WORD', 222164190Sjkoshy `sh_info, WORD', 223164190Sjkoshy `sh_addralign, XWORD', 224164190Sjkoshy `sh_entsize, XWORD', 225164190Sjkoshy `_,_'') 226164190Sjkoshy 227164190SjkoshyDEFINE_STRUCT(`Elf32_Sym', 228164190Sjkoshy ``st_name, WORD', 229164190Sjkoshy `st_value, ADDR', 230164190Sjkoshy `st_size, WORD', 231164190Sjkoshy `st_info, BYTE', 232164190Sjkoshy `st_other, BYTE', 233164190Sjkoshy `st_shndx, HALF', 234164190Sjkoshy `_,_'') 235164190Sjkoshy 236164190SjkoshyDEFINE_STRUCT(`Elf64_Sym', 237164190Sjkoshy ``st_name, WORD', 238164190Sjkoshy `st_info, BYTE', 239164190Sjkoshy `st_other, BYTE', 240164190Sjkoshy `st_shndx, HALF', 241164190Sjkoshy `st_value, ADDR', 242164190Sjkoshy `st_size, XWORD', 243164190Sjkoshy `_,_'') 244164190Sjkoshy 245164190SjkoshyDEFINE_STRUCT(`Elf32_Syminfo', 246164190Sjkoshy ``si_boundto, HALF', 247164190Sjkoshy `si_flags, HALF', 248164190Sjkoshy `_,_'') 249164190Sjkoshy 250164190SjkoshyDEFINE_STRUCT(`Elf64_Syminfo', 251164190Sjkoshy ``si_boundto, HALF', 252164190Sjkoshy `si_flags, HALF', 253164190Sjkoshy `_,_'') 254164190Sjkoshy 255164190SjkoshyDEFINE_STRUCT(`Elf32_Verdaux', 256164190Sjkoshy ``vda_name, WORD', 257164190Sjkoshy `vda_next, WORD', 258164190Sjkoshy `_,_'') 259164190Sjkoshy 260164190SjkoshyDEFINE_STRUCT(`Elf64_Verdaux', 261164190Sjkoshy ``vda_name, WORD', 262164190Sjkoshy `vda_next, WORD', 263164190Sjkoshy `_,_'') 264164190Sjkoshy 265164190SjkoshyDEFINE_STRUCT(`Elf32_Verdef', 266164190Sjkoshy ``vd_version, HALF', 267164190Sjkoshy `vd_flags, HALF', 268164190Sjkoshy `vd_ndx, HALF', 269164190Sjkoshy `vd_cnt, HALF', 270164190Sjkoshy `vd_hash, WORD', 271164190Sjkoshy `vd_aux, WORD', 272164190Sjkoshy `vd_next, WORD', 273164190Sjkoshy `_,_'') 274164190Sjkoshy 275164190SjkoshyDEFINE_STRUCT(`Elf64_Verdef', 276164190Sjkoshy ``vd_version, HALF', 277164190Sjkoshy `vd_flags, HALF', 278164190Sjkoshy `vd_ndx, HALF', 279164190Sjkoshy `vd_cnt, HALF', 280164190Sjkoshy `vd_hash, WORD', 281164190Sjkoshy `vd_aux, WORD', 282164190Sjkoshy `vd_next, WORD', 283164190Sjkoshy `_,_'') 284164190Sjkoshy 285164190SjkoshyDEFINE_STRUCT(`Elf32_Verneed', 286164190Sjkoshy ``vn_version, HALF', 287164190Sjkoshy `vn_cnt, HALF', 288164190Sjkoshy `vn_file, WORD', 289164190Sjkoshy `vn_aux, WORD', 290164190Sjkoshy `vn_next, WORD', 291164190Sjkoshy `_,_'') 292164190Sjkoshy 293164190SjkoshyDEFINE_STRUCT(`Elf64_Verneed', 294164190Sjkoshy ``vn_version, HALF', 295164190Sjkoshy `vn_cnt, HALF', 296164190Sjkoshy `vn_file, WORD', 297164190Sjkoshy `vn_aux, WORD', 298164190Sjkoshy `vn_next, WORD', 299164190Sjkoshy `_,_'') 300164190Sjkoshy 301164190SjkoshyDEFINE_STRUCT(`Elf32_Vernaux', 302164190Sjkoshy ``vna_hash, WORD', 303164190Sjkoshy `vna_flags, HALF', 304164190Sjkoshy `vna_other, HALF', 305164190Sjkoshy `vna_name, WORD', 306164190Sjkoshy `vna_next, WORD', 307164190Sjkoshy `_,_'') 308164190Sjkoshy 309164190SjkoshyDEFINE_STRUCT(`Elf64_Vernaux', 310164190Sjkoshy ``vna_hash, WORD', 311164190Sjkoshy `vna_flags, HALF', 312164190Sjkoshy `vna_other, HALF', 313164190Sjkoshy `vna_name, WORD', 314164190Sjkoshy `vna_next, WORD', 315164190Sjkoshy `_,_'') 316