1 /* Abstract description of component ELF types. 2 Copyright (C) 1998, 1999, 2000, 2002, 2004, 2007 Red Hat, Inc. 3 This file is part of Red Hat elfutils. 4 Written by Ulrich Drepper <drepper (at) redhat.com>, 1998. 5 6 Red Hat elfutils is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by the 8 Free Software Foundation; version 2 of the License. 9 10 Red Hat elfutils is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License along 16 with Red Hat elfutils; if not, write to the Free Software Foundation, 17 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. 18 19 In addition, as a special exception, Red Hat, Inc. gives You the 20 additional right to link the code of Red Hat elfutils with code licensed 21 under any Open Source Initiative certified open source license 22 (http://www.opensource.org/licenses/index.php) which requires the 23 distribution of source code with any binary distribution and to 24 distribute linked combinations of the two. Non-GPL Code permitted under 25 this exception must only link to the code of Red Hat elfutils through 26 those well defined interfaces identified in the file named EXCEPTION 27 found in the source code files (the "Approved Interfaces"). The files 28 of Non-GPL Code may instantiate templates or use macros or inline 29 functions from the Approved Interfaces without causing the resulting 30 work to be covered by the GNU General Public License. Only Red Hat, 31 Inc. may make changes or additions to the list of Approved Interfaces. 32 Red Hat's grant of this exception is conditioned upon your not adding 33 any new exceptions. If you wish to add a new Approved Interface or 34 exception, please contact Red Hat. You must obey the GNU General Public 35 License in all respects for all of the Red Hat elfutils code and other 36 code used in conjunction with Red Hat elfutils except the Non-GPL Code 37 covered by this exception. If you modify this file, you may extend this 38 exception to your version of the file, but you are not obligated to do 39 so. If you do not wish to provide this exception without modification, 40 you must delete this exception statement from your version and license 41 this file solely under the GPL without exception. 42 43 Red Hat elfutils is an included package of the Open Invention Network. 44 An included package of the Open Invention Network is a package for which 45 Open Invention Network licensees cross-license their patents. No patent 46 license is granted, either expressly or impliedly, by designation as an 47 included package. Should you wish to participate in the Open Invention 48 Network licensing program, please visit www.openinventionnetwork.com 49 <http://www.openinventionnetwork.com>. */ 50 51 /* ELF header. */ 52 #define Ehdr(Bits, Ext) \ 53 START (Bits, Ehdr, Ext##Ehdr) \ 54 TYPE_EXTRA (unsigned char e_ident[EI_NIDENT];) \ 55 TYPE_XLATE (memmove (tdest->e_ident, tsrc->e_ident, EI_NIDENT);) \ 56 TYPE_NAME (ElfW2(Bits, Ext##Half), e_type) \ 57 TYPE_NAME (ElfW2(Bits, Ext##Half), e_machine) \ 58 TYPE_NAME (ElfW2(Bits, Ext##Word), e_version) \ 59 TYPE_NAME (ElfW2(Bits, Ext##Addr), e_entry) \ 60 TYPE_NAME (ElfW2(Bits, Ext##Off), e_phoff) \ 61 TYPE_NAME (ElfW2(Bits, Ext##Off), e_shoff) \ 62 TYPE_NAME (ElfW2(Bits, Ext##Word), e_flags) \ 63 TYPE_NAME (ElfW2(Bits, Ext##Half), e_ehsize) \ 64 TYPE_NAME (ElfW2(Bits, Ext##Half), e_phentsize) \ 65 TYPE_NAME (ElfW2(Bits, Ext##Half), e_phnum) \ 66 TYPE_NAME (ElfW2(Bits, Ext##Half), e_shentsize) \ 67 TYPE_NAME (ElfW2(Bits, Ext##Half), e_shnum) \ 68 TYPE_NAME (ElfW2(Bits, Ext##Half), e_shstrndx) \ 69 END (Bits, Ext##Ehdr) 70 71 #define Ehdr32(Ext) \ 72 Ehdr(32, Ext) 73 #define Ehdr64(Ext) \ 74 Ehdr(64, Ext) 75 76 77 /* Program header. */ 78 #define Phdr32(Ext) \ 79 START (32, Phdr, Ext##Phdr) \ 80 TYPE_NAME (ElfW2(32, Ext##Word), p_type) \ 81 TYPE_NAME (ElfW2(32, Ext##Off), p_offset) \ 82 TYPE_NAME (ElfW2(32, Ext##Addr), p_vaddr) \ 83 TYPE_NAME (ElfW2(32, Ext##Addr), p_paddr) \ 84 TYPE_NAME (ElfW2(32, Ext##Word), p_filesz) \ 85 TYPE_NAME (ElfW2(32, Ext##Word), p_memsz) \ 86 TYPE_NAME (ElfW2(32, Ext##Word), p_flags) \ 87 TYPE_NAME (ElfW2(32, Ext##Word), p_align) \ 88 END (32, Ext##Phdr) 89 #define Phdr64(Ext) \ 90 START (64, Phdr, Ext##Phdr) \ 91 TYPE_NAME (ElfW2(64, Ext##Word), p_type) \ 92 TYPE_NAME (ElfW2(64, Ext##Word), p_flags) \ 93 TYPE_NAME (ElfW2(64, Ext##Off), p_offset) \ 94 TYPE_NAME (ElfW2(64, Ext##Addr), p_vaddr) \ 95 TYPE_NAME (ElfW2(64, Ext##Addr), p_paddr) \ 96 TYPE_NAME (ElfW2(64, Ext##Xword), p_filesz) \ 97 TYPE_NAME (ElfW2(64, Ext##Xword), p_memsz) \ 98 TYPE_NAME (ElfW2(64, Ext##Xword), p_align) \ 99 END (64, Ext##Phdr) 100 101 102 /* Section header. */ 103 #define Shdr32(Ext) \ 104 START (32, Shdr, Ext##Shdr) \ 105 TYPE_NAME (ElfW2(32, Ext##Word), sh_name) \ 106 TYPE_NAME (ElfW2(32, Ext##Word), sh_type) \ 107 TYPE_NAME (ElfW2(32, Ext##Word), sh_flags) \ 108 TYPE_NAME (ElfW2(32, Ext##Addr), sh_addr) \ 109 TYPE_NAME (ElfW2(32, Ext##Off), sh_offset) \ 110 TYPE_NAME (ElfW2(32, Ext##Word), sh_size) \ 111 TYPE_NAME (ElfW2(32, Ext##Word), sh_link) \ 112 TYPE_NAME (ElfW2(32, Ext##Word), sh_info) \ 113 TYPE_NAME (ElfW2(32, Ext##Word), sh_addralign) \ 114 TYPE_NAME (ElfW2(32, Ext##Word), sh_entsize) \ 115 END (32, Ext##Shdr) 116 #define Shdr64(Ext) \ 117 START (64, Shdr, Ext##Shdr) \ 118 TYPE_NAME (ElfW2(64, Ext##Word), sh_name) \ 119 TYPE_NAME (ElfW2(64, Ext##Word), sh_type) \ 120 TYPE_NAME (ElfW2(64, Ext##Xword), sh_flags) \ 121 TYPE_NAME (ElfW2(64, Ext##Addr), sh_addr) \ 122 TYPE_NAME (ElfW2(64, Ext##Off), sh_offset) \ 123 TYPE_NAME (ElfW2(64, Ext##Xword), sh_size) \ 124 TYPE_NAME (ElfW2(64, Ext##Word), sh_link) \ 125 TYPE_NAME (ElfW2(64, Ext##Word), sh_info) \ 126 TYPE_NAME (ElfW2(64, Ext##Xword), sh_addralign) \ 127 TYPE_NAME (ElfW2(64, Ext##Xword), sh_entsize) \ 128 END (64, Ext##Shdr) 129 130 131 /* Symbol table. */ 132 #define Sym32(Ext) \ 133 START (32, Sym, Ext##Sym) \ 134 TYPE_NAME (ElfW2(32, Ext##Word), st_name) \ 135 TYPE_NAME (ElfW2(32, Ext##Addr), st_value) \ 136 TYPE_NAME (ElfW2(32, Ext##Word), st_size) \ 137 TYPE_EXTRA (unsigned char st_info;) \ 138 TYPE_XLATE (tdest->st_info = tsrc->st_info;) \ 139 TYPE_EXTRA (unsigned char st_other;) \ 140 TYPE_XLATE (tdest->st_other = tsrc->st_other;) \ 141 TYPE_NAME (ElfW2(32, Ext##Half), st_shndx) \ 142 END (32, Ext##Sym) 143 #define Sym64(Ext) \ 144 START (64, Sym, Ext##Sym) \ 145 TYPE_NAME (ElfW2(64, Ext##Word), st_name) \ 146 TYPE_EXTRA (unsigned char st_info;) \ 147 TYPE_XLATE (tdest->st_info = tsrc->st_info;) \ 148 TYPE_EXTRA (unsigned char st_other;) \ 149 TYPE_XLATE (tdest->st_other = tsrc->st_other;) \ 150 TYPE_NAME (ElfW2(64, Ext##Half), st_shndx) \ 151 TYPE_NAME (ElfW2(64, Ext##Addr), st_value) \ 152 TYPE_NAME (ElfW2(64, Ext##Xword), st_size) \ 153 END (64, Ext##Sym) 154 155 156 /* Relocation. */ 157 #define Rel32(Ext) \ 158 START (32, Rel, Ext##Rel) \ 159 TYPE_NAME (ElfW2(32, Ext##Addr), r_offset) \ 160 TYPE_NAME (ElfW2(32, Ext##Word), r_info) \ 161 END (32, Ext##Rel) 162 #define Rel64(Ext) \ 163 START (64, Rel, Ext##Rel) \ 164 TYPE_NAME (ElfW2(64, Ext##Addr), r_offset) \ 165 TYPE_NAME (ElfW2(64, Ext##Xword), r_info) \ 166 END (64, Ext##Rel) 167 168 #define Rela32(Ext) \ 169 START (32, Rela, Ext##Rela) \ 170 TYPE_NAME (ElfW2(32, Ext##Addr), r_offset) \ 171 TYPE_NAME (ElfW2(32, Ext##Word), r_info) \ 172 TYPE_NAME (ElfW2(32, Ext##Sword), r_addend) \ 173 END (32, Ext##Rela) 174 #define Rela64(Ext) \ 175 START (64, Rela, Ext##Rela) \ 176 TYPE_NAME (ElfW2(64, Ext##Addr), r_offset) \ 177 TYPE_NAME (ElfW2(64, Ext##Xword), r_info) \ 178 TYPE_NAME (ElfW2(64, Ext##Sxword), r_addend) \ 179 END (64, Ext##Rela) 180 181 182 /* Note entry header. */ 183 #define Note(Bits, Ext) \ 184 START (Bits, Nhdr, Ext##Nhdr) \ 185 TYPE_NAME (ElfW2(Bits, Ext##Word), n_namesz) \ 186 TYPE_NAME (ElfW2(Bits, Ext##Word), n_descsz) \ 187 TYPE_NAME (ElfW2(Bits, Ext##Word), n_type) \ 188 END (Bits, Ext##Nhdr) 189 190 #define Note32(Ext) \ 191 Note (32, Ext) 192 #define Note64(Ext) \ 193 Note (64, Ext) 194 195 196 /* Dynamic section data. */ 197 #define Dyn32(Ext) \ 198 START (32, Dyn, Ext##Dyn) \ 199 TYPE_NAME (ElfW2(32, Ext##Sword), d_tag) \ 200 TYPE_EXTRA (union {) \ 201 TYPE_EXTRA (ElfW2(32, Ext##Word) d_val;) \ 202 TYPE_EXTRA (ElfW2(32, Ext##Addr) d_ptr;) \ 203 TYPE_XLATE (Elf32_cvt_Addr1 (&tdest->d_un.d_val, &tsrc->d_un.d_val);) \ 204 TYPE_EXTRA (ElfW2(32, Ext##Off) d_off;) \ 205 TYPE_EXTRA (} d_un;) \ 206 END (32, Ext##Dyn) 207 #define Dyn64(Ext) \ 208 START (64, Dyn, Ext##Dyn) \ 209 TYPE_NAME (ElfW2(64, Ext##Xword), d_tag) \ 210 TYPE_EXTRA (union {) \ 211 TYPE_EXTRA (ElfW2(64, Ext##Xword) d_val;) \ 212 TYPE_EXTRA (ElfW2(64, Ext##Addr) d_ptr;) \ 213 TYPE_XLATE (Elf64_cvt_Addr1 (&tdest->d_un.d_val, &tsrc->d_un.d_val);) \ 214 TYPE_EXTRA (} d_un;) \ 215 END (64, Ext##Dyn) 216 217 218 #ifndef GENERATE_CONVERSION 219 /* Version definitions. */ 220 # define Verdef(Bits, Ext) \ 221 START (Bits, Verdef, Ext##Verdef) \ 222 TYPE_NAME (ElfW2(Bits, Ext##Half), vd_version) \ 223 TYPE_NAME (ElfW2(Bits, Ext##Half), vd_flags) \ 224 TYPE_NAME (ElfW2(Bits, Ext##Half), vd_ndx) \ 225 TYPE_NAME (ElfW2(Bits, Ext##Half), vd_cnt) \ 226 TYPE_NAME (ElfW2(Bits, Ext##Word), vd_hash) \ 227 TYPE_NAME (ElfW2(Bits, Ext##Word), vd_aux) \ 228 TYPE_NAME (ElfW2(Bits, Ext##Word), vd_next) \ 229 END (Bits, Ext##Verdef) 230 231 # define Verdef32(Ext) \ 232 Verdef (32, Ext) 233 # define Verdef64(Ext) \ 234 Verdef (64, Ext) 235 236 # define Verdaux(Bits, Ext) \ 237 START (Bits, Verdaux, Ext##Verdaux) \ 238 TYPE_NAME (ElfW2(Bits, Ext##Word), vda_name) \ 239 TYPE_NAME (ElfW2(Bits, Ext##Word), vda_next) \ 240 END (Bits, Ext##Verdaux) 241 242 # define Verdaux32(Ext) \ 243 Verdaux (32, Ext) 244 # define Verdaux64(Ext) \ 245 Verdaux (64, Ext) 246 247 /* Required versions. */ 248 # define Verneed(Bits, Ext) \ 249 START (Bits, Verneed, Ext##Verneed) \ 250 TYPE_NAME (ElfW2(Bits, Ext##Half), vn_version) \ 251 TYPE_NAME (ElfW2(Bits, Ext##Half), vn_cnt) \ 252 TYPE_NAME (ElfW2(Bits, Ext##Word), vn_file) \ 253 TYPE_NAME (ElfW2(Bits, Ext##Word), vn_aux) \ 254 TYPE_NAME (ElfW2(Bits, Ext##Word), vn_next) \ 255 END (Bits, Ext##Verneed) 256 257 # define Verneed32(Ext) \ 258 Verneed (32, Ext) 259 # define Verneed64(Ext) \ 260 Verneed (64, Ext) 261 262 # define Vernaux(Bits, Ext) \ 263 START (Bits, Vernaux, Ext##Vernaux) \ 264 TYPE_NAME (ElfW2(Bits, Ext##Word), vna_hash) \ 265 TYPE_NAME (ElfW2(Bits, Ext##Half), vna_flags) \ 266 TYPE_NAME (ElfW2(Bits, Ext##Half), vna_other) \ 267 TYPE_NAME (ElfW2(Bits, Ext##Word), vna_name) \ 268 TYPE_NAME (ElfW2(Bits, Ext##Word), vna_next) \ 269 END (Bits, Ext##Vernaux) 270 271 # define Vernaux32(Ext) \ 272 Vernaux (32, Ext) 273 # define Vernaux64(Ext) \ 274 Vernaux (64, Ext) 275 #endif 276 277 /* Symbol information. */ 278 #define Syminfo(Bits, Ext) \ 279 START (Bits, Syminfo, Ext##Syminfo) \ 280 TYPE_NAME (ElfW2(Bits, Ext##Half), si_boundto) \ 281 TYPE_NAME (ElfW2(Bits, Ext##Half), si_flags) \ 282 END (Bits, Ext##Syminfo) 283 284 #define Syminfo32(Ext) \ 285 Syminfo (32, Ext) 286 #define Syminfo64(Ext) \ 287 Syminfo (64, Ext) 288 289 /* Move information. */ 290 #define Move(Bits, Ext) \ 291 START (Bits, Move, Ext##Move) \ 292 TYPE_NAME (ElfW2(Bits, Ext##Xword), m_value) \ 293 TYPE_NAME (ElfW2(Bits, Ext##Xword), m_info) \ 294 TYPE_NAME (ElfW2(Bits, Ext##Xword), m_poffset) \ 295 TYPE_NAME (ElfW2(Bits, Ext##Half), m_repeat) \ 296 TYPE_NAME (ElfW2(Bits, Ext##Half), m_stride) \ 297 END (Bits, Ext##Move) 298 299 #define Move32(Ext) \ 300 Move (32, Ext) 301 #define Move64(Ext) \ 302 Move (64, Ext) 303 304 #define Lib(Bits, Ext) \ 305 START (Bits, Lib, Ext##Lib) \ 306 TYPE_NAME (ElfW2(Bits, Ext##Word), l_name) \ 307 TYPE_NAME (ElfW2(Bits, Ext##Word), l_time_stamp) \ 308 TYPE_NAME (ElfW2(Bits, Ext##Word), l_checksum) \ 309 TYPE_NAME (ElfW2(Bits, Ext##Word), l_version) \ 310 TYPE_NAME (ElfW2(Bits, Ext##Word), l_flags) \ 311 END (Bits, Ext##Lib) 312 313 #define Lib32(Ext) \ 314 Lib (32, Ext) 315 #define Lib64(Ext) \ 316 Lib (64, Ext) 317 318 #define auxv_t32(Ext) \ 319 START (32, auxv_t, Ext##auxv_t) \ 320 TYPE_NAME (ElfW2(32, Ext##Word), a_type) \ 321 TYPE_EXTRA (union {) \ 322 TYPE_EXTRA (ElfW2(32, Ext##Word) a_val;) \ 323 TYPE_XLATE (Elf32_cvt_Addr1 (&tdest->a_un.a_val, &tsrc->a_un.a_val);) \ 324 TYPE_EXTRA (} a_un;) \ 325 END (32, Ext##auxv_t) 326 #define auxv_t64(Ext) \ 327 START (64, auxv_t, Ext##auxv_t) \ 328 TYPE_NAME (ElfW2(64, Ext##Xword), a_type) \ 329 TYPE_EXTRA (union {) \ 330 TYPE_EXTRA (ElfW2(64, Ext##Xword) a_val;) \ 331 TYPE_XLATE (Elf64_cvt_Addr1 (&tdest->a_un.a_val, &tsrc->a_un.a_val);) \ 332 TYPE_EXTRA (} a_un;) \ 333 END (64, Ext##auxv_t) 334