1 /* Abstract description of component ELF types. 2 Copyright (C) 1998, 1999, 2000, 2002, 2004 Red Hat, Inc. 3 Written by Ulrich Drepper <drepper (at) redhat.com>, 1998. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, version 2. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software Foundation, 16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 18 /* ELF header. */ 19 #define Ehdr(Bits, Ext) \ 20 START (Bits, Ehdr, Ext##Ehdr) \ 21 TYPE_EXTRA (unsigned char e_ident[EI_NIDENT];) \ 22 TYPE_XLATE (memmove (tdest->e_ident, tsrc->e_ident, EI_NIDENT);) \ 23 TYPE_NAME (ElfW2(Bits, Ext##Half), e_type) \ 24 TYPE_NAME (ElfW2(Bits, Ext##Half), e_machine) \ 25 TYPE_NAME (ElfW2(Bits, Ext##Word), e_version) \ 26 TYPE_NAME (ElfW2(Bits, Ext##Addr), e_entry) \ 27 TYPE_NAME (ElfW2(Bits, Ext##Off), e_phoff) \ 28 TYPE_NAME (ElfW2(Bits, Ext##Off), e_shoff) \ 29 TYPE_NAME (ElfW2(Bits, Ext##Word), e_flags) \ 30 TYPE_NAME (ElfW2(Bits, Ext##Half), e_ehsize) \ 31 TYPE_NAME (ElfW2(Bits, Ext##Half), e_phentsize) \ 32 TYPE_NAME (ElfW2(Bits, Ext##Half), e_phnum) \ 33 TYPE_NAME (ElfW2(Bits, Ext##Half), e_shentsize) \ 34 TYPE_NAME (ElfW2(Bits, Ext##Half), e_shnum) \ 35 TYPE_NAME (ElfW2(Bits, Ext##Half), e_shstrndx) \ 36 END (Bits, Ext##Ehdr) 37 38 #define Ehdr32(Ext) \ 39 Ehdr(32, Ext) 40 #define Ehdr64(Ext) \ 41 Ehdr(64, Ext) 42 43 44 /* Program header. */ 45 #define Phdr32(Ext) \ 46 START (32, Phdr, Ext##Phdr) \ 47 TYPE_NAME (ElfW2(32, Ext##Word), p_type) \ 48 TYPE_NAME (ElfW2(32, Ext##Off), p_offset) \ 49 TYPE_NAME (ElfW2(32, Ext##Addr), p_vaddr) \ 50 TYPE_NAME (ElfW2(32, Ext##Addr), p_paddr) \ 51 TYPE_NAME (ElfW2(32, Ext##Word), p_filesz) \ 52 TYPE_NAME (ElfW2(32, Ext##Word), p_memsz) \ 53 TYPE_NAME (ElfW2(32, Ext##Word), p_flags) \ 54 TYPE_NAME (ElfW2(32, Ext##Word), p_align) \ 55 END (32, Ext##Phdr) 56 #define Phdr64(Ext) \ 57 START (64, Phdr, Ext##Phdr) \ 58 TYPE_NAME (ElfW2(64, Ext##Word), p_type) \ 59 TYPE_NAME (ElfW2(64, Ext##Word), p_flags) \ 60 TYPE_NAME (ElfW2(64, Ext##Off), p_offset) \ 61 TYPE_NAME (ElfW2(64, Ext##Addr), p_vaddr) \ 62 TYPE_NAME (ElfW2(64, Ext##Addr), p_paddr) \ 63 TYPE_NAME (ElfW2(64, Ext##Xword), p_filesz) \ 64 TYPE_NAME (ElfW2(64, Ext##Xword), p_memsz) \ 65 TYPE_NAME (ElfW2(64, Ext##Xword), p_align) \ 66 END (64, Ext##Phdr) 67 68 69 /* Section header. */ 70 #define Shdr32(Ext) \ 71 START (32, Shdr, Ext##Shdr) \ 72 TYPE_NAME (ElfW2(32, Ext##Word), sh_name) \ 73 TYPE_NAME (ElfW2(32, Ext##Word), sh_type) \ 74 TYPE_NAME (ElfW2(32, Ext##Word), sh_flags) \ 75 TYPE_NAME (ElfW2(32, Ext##Addr), sh_addr) \ 76 TYPE_NAME (ElfW2(32, Ext##Off), sh_offset) \ 77 TYPE_NAME (ElfW2(32, Ext##Word), sh_size) \ 78 TYPE_NAME (ElfW2(32, Ext##Word), sh_link) \ 79 TYPE_NAME (ElfW2(32, Ext##Word), sh_info) \ 80 TYPE_NAME (ElfW2(32, Ext##Word), sh_addralign) \ 81 TYPE_NAME (ElfW2(32, Ext##Word), sh_entsize) \ 82 END (32, Ext##Shdr) 83 #define Shdr64(Ext) \ 84 START (64, Shdr, Ext##Shdr) \ 85 TYPE_NAME (ElfW2(64, Ext##Word), sh_name) \ 86 TYPE_NAME (ElfW2(64, Ext##Word), sh_type) \ 87 TYPE_NAME (ElfW2(64, Ext##Xword), sh_flags) \ 88 TYPE_NAME (ElfW2(64, Ext##Addr), sh_addr) \ 89 TYPE_NAME (ElfW2(64, Ext##Off), sh_offset) \ 90 TYPE_NAME (ElfW2(64, Ext##Xword), sh_size) \ 91 TYPE_NAME (ElfW2(64, Ext##Word), sh_link) \ 92 TYPE_NAME (ElfW2(64, Ext##Word), sh_info) \ 93 TYPE_NAME (ElfW2(64, Ext##Xword), sh_addralign) \ 94 TYPE_NAME (ElfW2(64, Ext##Xword), sh_entsize) \ 95 END (64, Ext##Shdr) 96 97 98 /* Symbol table. */ 99 #define Sym32(Ext) \ 100 START (32, Sym, Ext##Sym) \ 101 TYPE_NAME (ElfW2(32, Ext##Word), st_name) \ 102 TYPE_NAME (ElfW2(32, Ext##Addr), st_value) \ 103 TYPE_NAME (ElfW2(32, Ext##Word), st_size) \ 104 TYPE_EXTRA (unsigned char st_info;) \ 105 TYPE_XLATE (tdest->st_info = tsrc->st_info;) \ 106 TYPE_EXTRA (unsigned char st_other;) \ 107 TYPE_XLATE (tdest->st_other = tsrc->st_other;) \ 108 TYPE_NAME (ElfW2(32, Ext##Half), st_shndx) \ 109 END (32, Ext##Sym) 110 #define Sym64(Ext) \ 111 START (64, Sym, Ext##Sym) \ 112 TYPE_NAME (ElfW2(64, Ext##Word), st_name) \ 113 TYPE_EXTRA (unsigned char st_info;) \ 114 TYPE_XLATE (tdest->st_info = tsrc->st_info;) \ 115 TYPE_EXTRA (unsigned char st_other;) \ 116 TYPE_XLATE (tdest->st_other = tsrc->st_other;) \ 117 TYPE_NAME (ElfW2(64, Ext##Half), st_shndx) \ 118 TYPE_NAME (ElfW2(64, Ext##Addr), st_value) \ 119 TYPE_NAME (ElfW2(64, Ext##Xword), st_size) \ 120 END (64, Ext##Sym) 121 122 123 /* Relocation. */ 124 #define Rel32(Ext) \ 125 START (32, Rel, Ext##Rel) \ 126 TYPE_NAME (ElfW2(32, Ext##Addr), r_offset) \ 127 TYPE_NAME (ElfW2(32, Ext##Word), r_info) \ 128 END (32, Ext##Rel) 129 #define Rel64(Ext) \ 130 START (64, Rel, Ext##Rel) \ 131 TYPE_NAME (ElfW2(64, Ext##Addr), r_offset) \ 132 TYPE_NAME (ElfW2(64, Ext##Xword), r_info) \ 133 END (64, Ext##Rel) 134 135 #define Rela32(Ext) \ 136 START (32, Rela, Ext##Rela) \ 137 TYPE_NAME (ElfW2(32, Ext##Addr), r_offset) \ 138 TYPE_NAME (ElfW2(32, Ext##Word), r_info) \ 139 TYPE_NAME (ElfW2(32, Ext##Sword), r_addend) \ 140 END (32, Ext##Rela) 141 #define Rela64(Ext) \ 142 START (64, Rela, Ext##Rela) \ 143 TYPE_NAME (ElfW2(64, Ext##Addr), r_offset) \ 144 TYPE_NAME (ElfW2(64, Ext##Xword), r_info) \ 145 TYPE_NAME (ElfW2(64, Ext##Sxword), r_addend) \ 146 END (64, Ext##Rela) 147 148 149 /* Note entry header. */ 150 #define Note(Bits, Ext) \ 151 START (Bits, Nhdr, Ext##Nhdr) \ 152 TYPE_NAME (ElfW2(Bits, Ext##Word), n_namesz) \ 153 TYPE_NAME (ElfW2(Bits, Ext##Word), n_descsz) \ 154 TYPE_NAME (ElfW2(Bits, Ext##Word), n_type) \ 155 END (Bits, Ext##Nhdr) 156 157 #define Note32(Ext) \ 158 Note (32, Ext) 159 #define Note64(Ext) \ 160 Note (64, Ext) 161 162 163 /* Dynamic section data. */ 164 #define Dyn32(Ext) \ 165 START (32, Dyn, Ext##Dyn) \ 166 TYPE_NAME (ElfW2(32, Ext##Sword), d_tag) \ 167 TYPE_EXTRA (union {) \ 168 TYPE_EXTRA (ElfW2(32, Ext##Word) d_val;) \ 169 TYPE_EXTRA (ElfW2(32, Ext##Addr) d_ptr;) \ 170 TYPE_XLATE (Elf32_cvt_Addr1 (&tdest->d_un.d_val, &tsrc->d_un.d_val);) \ 171 TYPE_EXTRA (ElfW2(32, Ext##Off) d_off;) \ 172 TYPE_EXTRA (} d_un;) \ 173 END (32, Ext##Dyn) 174 #define Dyn64(Ext) \ 175 START (64, Dyn, Ext##Dyn) \ 176 TYPE_NAME (ElfW2(64, Ext##Xword), d_tag) \ 177 TYPE_EXTRA (union {) \ 178 TYPE_EXTRA (ElfW2(64, Ext##Xword) d_val;) \ 179 TYPE_EXTRA (ElfW2(64, Ext##Addr) d_ptr;) \ 180 TYPE_XLATE (Elf64_cvt_Addr1 (&tdest->d_un.d_val, &tsrc->d_un.d_val);) \ 181 TYPE_EXTRA (} d_un;) \ 182 END (64, Ext##Dyn) 183 184 185 #ifndef GENERATE_CONVERSION 186 /* Version definitions. */ 187 # define Verdef(Bits, Ext) \ 188 START (Bits, Verdef, Ext##Verdef) \ 189 TYPE_NAME (ElfW2(Bits, Ext##Half), vd_version) \ 190 TYPE_NAME (ElfW2(Bits, Ext##Half), vd_flags) \ 191 TYPE_NAME (ElfW2(Bits, Ext##Half), vd_ndx) \ 192 TYPE_NAME (ElfW2(Bits, Ext##Half), vd_cnt) \ 193 TYPE_NAME (ElfW2(Bits, Ext##Word), vd_hash) \ 194 TYPE_NAME (ElfW2(Bits, Ext##Word), vd_aux) \ 195 TYPE_NAME (ElfW2(Bits, Ext##Word), vd_next) \ 196 END (Bits, Ext##Verdef) 197 198 # define Verdef32(Ext) \ 199 Verdef (32, Ext) 200 # define Verdef64(Ext) \ 201 Verdef (64, Ext) 202 203 # define Verdaux(Bits, Ext) \ 204 START (Bits, Verdaux, Ext##Verdaux) \ 205 TYPE_NAME (ElfW2(Bits, Ext##Word), vda_name) \ 206 TYPE_NAME (ElfW2(Bits, Ext##Word), vda_next) \ 207 END (Bits, Ext##Verdaux) 208 209 # define Verdaux32(Ext) \ 210 Verdaux (32, Ext) 211 # define Verdaux64(Ext) \ 212 Verdaux (64, Ext) 213 214 /* Required versions. */ 215 # define Verneed(Bits, Ext) \ 216 START (Bits, Verneed, Ext##Verneed) \ 217 TYPE_NAME (ElfW2(Bits, Ext##Half), vn_version) \ 218 TYPE_NAME (ElfW2(Bits, Ext##Half), vn_cnt) \ 219 TYPE_NAME (ElfW2(Bits, Ext##Word), vn_file) \ 220 TYPE_NAME (ElfW2(Bits, Ext##Word), vn_aux) \ 221 TYPE_NAME (ElfW2(Bits, Ext##Word), vn_next) \ 222 END (Bits, Ext##Verneed) 223 224 # define Verneed32(Ext) \ 225 Verneed (32, Ext) 226 # define Verneed64(Ext) \ 227 Verneed (64, Ext) 228 229 # define Vernaux(Bits, Ext) \ 230 START (Bits, Vernaux, Ext##Vernaux) \ 231 TYPE_NAME (ElfW2(Bits, Ext##Word), vna_hash) \ 232 TYPE_NAME (ElfW2(Bits, Ext##Half), vna_flags) \ 233 TYPE_NAME (ElfW2(Bits, Ext##Half), vna_other) \ 234 TYPE_NAME (ElfW2(Bits, Ext##Word), vna_name) \ 235 TYPE_NAME (ElfW2(Bits, Ext##Word), vna_next) \ 236 END (Bits, Ext##Vernaux) 237 238 # define Vernaux32(Ext) \ 239 Vernaux (32, Ext) 240 # define Vernaux64(Ext) \ 241 Vernaux (64, Ext) 242 #endif 243 244 /* Symbol information. */ 245 #define Syminfo(Bits, Ext) \ 246 START (Bits, Syminfo, Ext##Syminfo) \ 247 TYPE_NAME (ElfW2(Bits, Ext##Half), si_boundto) \ 248 TYPE_NAME (ElfW2(Bits, Ext##Half), si_flags) \ 249 END (Bits, Ext##Syminfo) 250 251 #define Syminfo32(Ext) \ 252 Syminfo (32, Ext) 253 #define Syminfo64(Ext) \ 254 Syminfo (64, Ext) 255 256 /* Move information. */ 257 #define Move(Bits, Ext) \ 258 START (Bits, Move, Ext##Move) \ 259 TYPE_NAME (ElfW2(Bits, Ext##Xword), m_value) \ 260 TYPE_NAME (ElfW2(Bits, Ext##Xword), m_info) \ 261 TYPE_NAME (ElfW2(Bits, Ext##Xword), m_poffset) \ 262 TYPE_NAME (ElfW2(Bits, Ext##Half), m_repeat) \ 263 TYPE_NAME (ElfW2(Bits, Ext##Half), m_stride) \ 264 END (Bits, Ext##Move) 265 266 #define Move32(Ext) \ 267 Move (32, Ext) 268 #define Move64(Ext) \ 269 Move (64, Ext) 270 271 #define Lib(Bits, Ext) \ 272 START (Bits, Lib, Ext##Lib) \ 273 TYPE_NAME (ElfW2(Bits, Ext##Word), l_name) \ 274 TYPE_NAME (ElfW2(Bits, Ext##Word), l_time_stamp) \ 275 TYPE_NAME (ElfW2(Bits, Ext##Word), l_checksum) \ 276 TYPE_NAME (ElfW2(Bits, Ext##Word), l_version) \ 277 TYPE_NAME (ElfW2(Bits, Ext##Word), l_flags) \ 278 END (Bits, Ext##Lib) 279 280 #define Lib32(Ext) \ 281 Lib (32, Ext) 282 #define Lib64(Ext) \ 283 Lib (64, Ext) 284