Expect cvtsi2ssl instead of cvtsi2ss.
[binutils.git] / elfcpp / elfcpp.h
blob64f7c6c2d11351184620f4274c1a7a8014174ec0
1 // elfcpp.h -- main header file for elfcpp -*- C++ -*-
3 // Copyright 2006, 2007, Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of elfcpp.
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public License
10 // as published by the Free Software Foundation; either version 2, or
11 // (at your option) any later version.
13 // In addition to the permissions in the GNU Library General Public
14 // License, the Free Software Foundation gives you unlimited
15 // permission to link the compiled version of this file into
16 // combinations with other programs, and to distribute those
17 // combinations without any restriction coming from the use of this
18 // file. (The Library Public License restrictions do apply in other
19 // respects; for example, they cover modification of the file, and
20 /// distribution when not linked into a combined executable.)
22 // This program is distributed in the hope that it will be useful, but
23 // WITHOUT ANY WARRANTY; without even the implied warranty of
24 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 // Library General Public License for more details.
27 // You should have received a copy of the GNU Library General Public
28 // License along with this program; if not, write to the Free Software
29 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
30 // 02110-1301, USA.
32 // This is the external interface for elfcpp.
34 #ifndef ELFCPP_H
35 #define ELFCPP_H
37 #include "elfcpp_swap.h"
39 #include <stdint.h>
41 namespace elfcpp
44 // Basic ELF types.
46 // These types are always the same size.
48 typedef uint16_t Elf_Half;
49 typedef uint32_t Elf_Word;
50 typedef int32_t Elf_Sword;
51 typedef uint64_t Elf_Xword;
52 typedef int64_t Elf_Sxword;
54 // These types vary in size depending on the ELF file class. The
55 // template parameter should be 32 or 64.
57 template<int size>
58 struct Elf_types;
60 template<>
61 struct Elf_types<32>
63 typedef uint32_t Elf_Addr;
64 typedef uint32_t Elf_Off;
65 typedef uint32_t Elf_WXword;
66 typedef int32_t Elf_Swxword;
69 template<>
70 struct Elf_types<64>
72 typedef uint64_t Elf_Addr;
73 typedef uint64_t Elf_Off;
74 typedef uint64_t Elf_WXword;
75 typedef int64_t Elf_Swxword;
78 // Offsets within the Ehdr e_ident field.
80 const int EI_MAG0 = 0;
81 const int EI_MAG1 = 1;
82 const int EI_MAG2 = 2;
83 const int EI_MAG3 = 3;
84 const int EI_CLASS = 4;
85 const int EI_DATA = 5;
86 const int EI_VERSION = 6;
87 const int EI_OSABI = 7;
88 const int EI_ABIVERSION = 8;
89 const int EI_PAD = 9;
90 const int EI_NIDENT = 16;
92 // The valid values found in Ehdr e_ident[EI_MAG0 through EI_MAG3].
94 const int ELFMAG0 = 0x7f;
95 const int ELFMAG1 = 'E';
96 const int ELFMAG2 = 'L';
97 const int ELFMAG3 = 'F';
99 // The valid values found in Ehdr e_ident[EI_CLASS].
101 enum
103 ELFCLASSNONE = 0,
104 ELFCLASS32 = 1,
105 ELFCLASS64 = 2
108 // The valid values found in Ehdr e_ident[EI_DATA].
110 enum
112 ELFDATANONE = 0,
113 ELFDATA2LSB = 1,
114 ELFDATA2MSB = 2
117 // The valid values found in Ehdr e_ident[EI_VERSION] and e_version.
119 enum
121 EV_NONE = 0,
122 EV_CURRENT = 1
125 // The valid values found in Ehdr e_ident[EI_OSABI].
127 enum ELFOSABI
129 ELFOSABI_NONE = 0,
130 ELFOSABI_HPUX = 1,
131 ELFOSABI_NETBSD = 2,
132 // ELFOSABI_LINUX is not listed in the ELF standard.
133 ELFOSABI_LINUX = 3,
134 // ELFOSABI_HURD is not listed in the ELF standard.
135 ELFOSABI_HURD = 4,
136 ELFOSABI_SOLARIS = 6,
137 ELFOSABI_AIX = 7,
138 ELFOSABI_IRIX = 8,
139 ELFOSABI_FREEBSD = 9,
140 ELFOSABI_TRU64 = 10,
141 ELFOSABI_MODESTO = 11,
142 ELFOSABI_OPENBSD = 12,
143 ELFOSABI_OPENVMS = 13,
144 ELFOSABI_NSK = 14,
145 ELFOSABI_AROS = 15,
146 // A GNU extension for the ARM.
147 ELFOSABI_ARM = 97,
148 // A GNU extension for the MSP.
149 ELFOSABI_STANDALONE = 255
152 // The valid values found in the Ehdr e_type field.
154 enum ET
156 ET_NONE = 0,
157 ET_REL = 1,
158 ET_EXEC = 2,
159 ET_DYN = 3,
160 ET_CORE = 4,
161 ET_LOOS = 0xfe00,
162 ET_HIOS = 0xfeff,
163 ET_LOPROC = 0xff00,
164 ET_HIPROC = 0xffff
167 // The valid values found in the Ehdr e_machine field.
169 enum EM
171 EM_NONE = 0,
172 EM_M32 = 1,
173 EM_SPARC = 2,
174 EM_386 = 3,
175 EM_68K = 4,
176 EM_88K = 5,
177 // 6 used to be EM_486
178 EM_860 = 7,
179 EM_MIPS = 8,
180 EM_S370 = 9,
181 EM_MIPS_RS3_LE = 10,
182 // 11 was the old Sparc V9 ABI.
183 // 12 through 14 are reserved.
184 EM_PARISC = 15,
185 // 16 is reserved.
186 // Some old PowerPC object files use 17.
187 EM_VPP500 = 17,
188 EM_SPARC32PLUS = 18,
189 EM_960 = 19,
190 EM_PPC = 20,
191 EM_PPC64 = 21,
192 EM_S390 = 22,
193 // 23 through 35 are served.
194 EM_V800 = 36,
195 EM_FR20 = 37,
196 EM_RH32 = 38,
197 EM_RCE = 39,
198 EM_ARM = 40,
199 EM_ALPHA = 41,
200 EM_SH = 42,
201 EM_SPARCV9 = 43,
202 EM_TRICORE = 44,
203 EM_ARC = 45,
204 EM_H8_300 = 46,
205 EM_H8_300H = 47,
206 EM_H8S = 48,
207 EM_H8_500 = 49,
208 EM_IA_64 = 50,
209 EM_MIPS_X = 51,
210 EM_COLDFIRE = 52,
211 EM_68HC12 = 53,
212 EM_MMA = 54,
213 EM_PCP = 55,
214 EM_NCPU = 56,
215 EM_NDR1 = 57,
216 EM_STARCORE = 58,
217 EM_ME16 = 59,
218 EM_ST100 = 60,
219 EM_TINYJ = 61,
220 EM_X86_64 = 62,
221 EM_PDSP = 63,
222 EM_PDP10 = 64,
223 EM_PDP11 = 65,
224 EM_FX66 = 66,
225 EM_ST9PLUS = 67,
226 EM_ST7 = 68,
227 EM_68HC16 = 69,
228 EM_68HC11 = 70,
229 EM_68HC08 = 71,
230 EM_68HC05 = 72,
231 EM_SVX = 73,
232 EM_ST19 = 74,
233 EM_VAX = 75,
234 EM_CRIS = 76,
235 EM_JAVELIN = 77,
236 EM_FIREPATH = 78,
237 EM_ZSP = 79,
238 EM_MMIX = 80,
239 EM_HUANY = 81,
240 EM_PRISM = 82,
241 EM_AVR = 83,
242 EM_FR30 = 84,
243 EM_D10V = 85,
244 EM_D30V = 86,
245 EM_V850 = 87,
246 EM_M32R = 88,
247 EM_MN10300 = 89,
248 EM_MN10200 = 90,
249 EM_PJ = 91,
250 EM_OPENRISC = 92,
251 EM_ARC_A5 = 93,
252 EM_XTENSA = 94,
253 EM_VIDEOCORE = 95,
254 EM_TMM_GPP = 96,
255 EM_NS32K = 97,
256 EM_TPC = 98,
257 // Some old picoJava object files use 99 (EM_PJ is correct).
258 EM_SNP1K = 99,
259 EM_ST200 = 100,
260 EM_IP2K = 101,
261 EM_MAX = 102,
262 EM_CR = 103,
263 EM_F2MC16 = 104,
264 EM_MSP430 = 105,
265 EM_BLACKFIN = 106,
266 EM_SE_C33 = 107,
267 EM_SEP = 108,
268 EM_ARCA = 109,
269 EM_UNICORE = 110,
270 EM_ALTERA_NIOS2 = 113,
271 EM_CRX = 114,
272 // The Morph MT.
273 EM_MT = 0x2530,
274 // DLX.
275 EM_DLX = 0x5aa5,
276 // FRV.
277 EM_FRV = 0x5441,
278 // Infineon Technologies 16-bit microcontroller with C166-V2 core.
279 EM_X16X = 0x4688,
280 // Xstorym16
281 EM_XSTORMY16 = 0xad45,
282 // Renesas M32C
283 EM_M32C = 0xfeb0,
284 // Vitesse IQ2000
285 EM_IQ2000 = 0xfeba,
286 // NIOS
287 EM_NIOS32 = 0xfebb
288 // Old AVR objects used 0x1057 (EM_AVR is correct).
289 // Old MSP430 objects used 0x1059 (EM_MSP430 is correct).
290 // Old FR30 objects used 0x3330 (EM_FR30 is correct).
291 // Old OpenRISC objects used 0x3426 and 0x8472 (EM_OPENRISC is correct).
292 // Old D10V objects used 0x7650 (EM_D10V is correct).
293 // Old D30V objects used 0x7676 (EM_D30V is correct).
294 // Old IP2X objects used 0x8217 (EM_IP2K is correct).
295 // Old PowerPC objects used 0x9025 (EM_PPC is correct).
296 // Old Alpha objects used 0x9026 (EM_ALPHA is correct).
297 // Old M32R objects used 0x9041 (EM_M32R is correct).
298 // Old V850 objects used 0x9080 (EM_V850 is correct).
299 // Old S/390 objects used 0xa390 (EM_S390 is correct).
300 // Old Xtensa objects used 0xabc7 (EM_XTENSA is correct).
301 // Old MN10300 objects used 0xbeef (EM_MN10300 is correct).
302 // Old MN10200 objects used 0xdead (EM_MN10200 is correct).
305 // Special section indices.
307 enum
309 SHN_UNDEF = 0,
310 SHN_LORESERVE = 0xff00,
311 SHN_LOPROC = 0xff00,
312 SHN_HIPROC = 0xff1f,
313 SHN_LOOS = 0xff20,
314 SHN_HIOS = 0xff3f,
315 SHN_ABS = 0xfff1,
316 SHN_COMMON = 0xfff2,
317 SHN_XINDEX = 0xffff,
318 SHN_HIRESERVE = 0xffff
321 // The valid values found in the Shdr sh_type field.
323 enum SHT
325 SHT_NULL = 0,
326 SHT_PROGBITS = 1,
327 SHT_SYMTAB = 2,
328 SHT_STRTAB = 3,
329 SHT_RELA = 4,
330 SHT_HASH = 5,
331 SHT_DYNAMIC = 6,
332 SHT_NOTE = 7,
333 SHT_NOBITS = 8,
334 SHT_REL = 9,
335 SHT_SHLIB = 10,
336 SHT_DYNSYM = 11,
337 SHT_INIT_ARRAY = 14,
338 SHT_FINI_ARRAY = 15,
339 SHT_PREINIT_ARRAY = 16,
340 SHT_GROUP = 17,
341 SHT_SYMTAB_SHNDX = 18,
342 SHT_LOOS = 0x60000000,
343 SHT_HIOS = 0x6fffffff,
344 SHT_LOPROC = 0x70000000,
345 SHT_HIPROC = 0x7fffffff,
346 SHT_LOUSER = 0x80000000,
347 SHT_HIUSER = 0xffffffff,
348 // The remaining values are not in the standard.
349 // List of prelink dependencies.
350 SHT_GNU_LIBLIST = 0x6ffffff7,
351 // Versions defined by file.
352 SHT_SUNW_verdef = 0x6ffffffd,
353 SHT_GNU_verdef = 0x6ffffffd,
354 // Versions needed by file.
355 SHT_SUNW_verneed = 0x6ffffffe,
356 SHT_GNU_verneed = 0x6ffffffe,
357 // Symbol versions,
358 SHT_SUNW_versym = 0x6fffffff,
359 SHT_GNU_versym = 0x6fffffff,
362 // The valid bit flags found in the Shdr sh_flags field.
364 enum SHF
366 SHF_WRITE = 0x1,
367 SHF_ALLOC = 0x2,
368 SHF_EXECINSTR = 0x4,
369 SHF_MERGE = 0x10,
370 SHF_STRINGS = 0x20,
371 SHF_INFO_LINK = 0x40,
372 SHF_LINK_ORDER = 0x80,
373 SHF_OS_NONCONFORMING = 0x100,
374 SHF_GROUP = 0x200,
375 SHF_TLS = 0x400,
376 SHF_MASKOS = 0x0ff00000,
377 SHF_MASKPROC = 0xf0000000
380 // Bit flags which appear in the first 32-bit word of the section data
381 // of a SHT_GROUP section.
383 enum
385 GRP_COMDAT = 0x1,
386 GRP_MASKOS = 0x0ff00000,
387 GRP_MASKPROC = 0xf0000000
390 // The valid values found in the Phdr p_type field.
392 enum PT
394 PT_NULL = 0,
395 PT_LOAD = 1,
396 PT_DYNAMIC = 2,
397 PT_INTERP = 3,
398 PT_NOTE = 4,
399 PT_SHLIB = 5,
400 PT_PHDR = 6,
401 PT_TLS = 7,
402 PT_LOOS = 0x60000000,
403 PT_HIOS = 0x6fffffff,
404 PT_LOPROC = 0x70000000,
405 PT_HIPROC = 0x7fffffff,
406 // The remaining values are not in the standard.
407 // Frame unwind information.
408 PT_GNU_EH_FRAME = 0x6474e550,
409 PT_SUNW_EH_FRAME = 0x6474e550,
410 // Stack flags.
411 PT_GNU_STACK = 0x6474e551,
412 // Read only after relocation.
413 PT_GNU_RELRO = 0x6474e552
416 // The valid bit flags found in the Phdr p_flags field.
418 enum PF
420 PF_X = 0x1,
421 PF_W = 0x2,
422 PF_R = 0x4,
423 PF_MASKOS = 0x0ff00000,
424 PF_MASKPROC = 0xf0000000
427 // Symbol binding from Sym st_info field.
429 enum STB
431 STB_LOCAL = 0,
432 STB_GLOBAL = 1,
433 STB_WEAK = 2,
434 STB_LOOS = 10,
435 STB_HIOS = 12,
436 STB_LOPROC = 13,
437 STB_HIPROC = 15
440 // Symbol types from Sym st_info field.
442 enum STT
444 STT_NOTYPE = 0,
445 STT_OBJECT = 1,
446 STT_FUNC = 2,
447 STT_SECTION = 3,
448 STT_FILE = 4,
449 STT_COMMON = 5,
450 STT_TLS = 6,
451 STT_LOOS = 10,
452 STT_HIOS = 12,
453 STT_LOPROC = 13,
454 STT_HIPROC = 15
457 inline STB
458 elf_st_bind(unsigned char info)
460 return static_cast<STB>(info >> 4);
463 inline STT
464 elf_st_type(unsigned char info)
466 return static_cast<STT>(info & 0xf);
469 inline unsigned char
470 elf_st_info(STB bind, STT type)
472 return ((static_cast<unsigned char>(bind) << 4)
473 + (static_cast<unsigned char>(type) & 0xf));
476 // Symbol visibility from Sym st_other field.
478 enum STV
480 STV_DEFAULT = 0,
481 STV_INTERNAL = 1,
482 STV_HIDDEN = 2,
483 STV_PROTECTED = 3
486 inline STV
487 elf_st_visibility(unsigned char other)
489 return static_cast<STV>(other & 0x3);
492 inline unsigned char
493 elf_st_nonvis(unsigned char other)
495 return static_cast<STV>(other >> 2);
498 inline unsigned char
499 elf_st_other(STV vis, unsigned char nonvis)
501 return ((nonvis << 2)
502 + (static_cast<unsigned char>(vis) & 3));
505 // Reloc information from Rel/Rela r_info field.
507 template<int size>
508 unsigned int
509 elf_r_sym(typename Elf_types<size>::Elf_WXword);
511 template<>
512 inline unsigned int
513 elf_r_sym<32>(Elf_Word v)
515 return v >> 8;
518 template<>
519 inline unsigned int
520 elf_r_sym<64>(Elf_Xword v)
522 return v >> 32;
525 template<int size>
526 unsigned int
527 elf_r_type(typename Elf_types<size>::Elf_WXword);
529 template<>
530 inline unsigned int
531 elf_r_type<32>(Elf_Word v)
533 return v & 0xff;
536 template<>
537 inline unsigned int
538 elf_r_type<64>(Elf_Xword v)
540 return v & 0xffffffff;
543 template<int size>
544 typename Elf_types<size>::Elf_WXword
545 elf_r_info(unsigned int s, unsigned int t);
547 template<>
548 inline Elf_Word
549 elf_r_info<32>(unsigned int s, unsigned int t)
551 return (s << 8) + (t & 0xff);
554 template<>
555 inline Elf_Xword
556 elf_r_info<64>(unsigned int s, unsigned int t)
558 return (static_cast<Elf_Xword>(s) << 32) + (t & 0xffffffff);
561 // Dynamic tags found in the PT_DYNAMIC segment.
563 enum DT
565 DT_NULL = 0,
566 DT_NEEDED = 1,
567 DT_PLTRELSZ = 2,
568 DT_PLTGOT = 3,
569 DT_HASH = 4,
570 DT_STRTAB = 5,
571 DT_SYMTAB = 6,
572 DT_RELA = 7,
573 DT_RELASZ = 8,
574 DT_RELAENT = 9,
575 DT_STRSZ = 10,
576 DT_SYMENT = 11,
577 DT_INIT = 12,
578 DT_FINI = 13,
579 DT_SONAME = 14,
580 DT_RPATH = 15,
581 DT_SYMBOLIC = 16,
582 DT_REL = 17,
583 DT_RELSZ = 18,
584 DT_RELENT = 19,
585 DT_PLTREL = 20,
586 DT_DEBUG = 21,
587 DT_TEXTREL = 22,
588 DT_JMPREL = 23,
589 DT_BIND_NOW = 24,
590 DT_INIT_ARRAY = 25,
591 DT_FINI_ARRAY = 26,
592 DT_INIT_ARRAYSZ = 27,
593 DT_FINI_ARRAYSZ = 28,
594 DT_RUNPATH = 29,
595 DT_FLAGS = 30,
596 DT_ENCODING = 32,
597 DT_PREINIT_ARRAY = 33,
598 DT_PREINIT_ARRAYSZ = 33,
599 DT_LOOS = 0x6000000d,
600 DT_HIOS = 0x6ffff000,
601 DT_LOPROC = 0x70000000,
602 DT_HIPROC = 0x7fffffff,
604 // The remaining values are extensions used by GNU or Solaris.
605 DT_VALRNGLO = 0x6ffffd00,
606 DT_GNU_PRELINKED = 0x6ffffdf5,
607 DT_GNU_CONFLICTSZ = 0x6ffffdf6,
608 DT_GNU_LIBLISTSZ = 0x6ffffdf7,
609 DT_CHECKSUM = 0x6ffffdf8,
610 DT_PLTPADSZ = 0x6ffffdf9,
611 DT_MOVEENT = 0x6ffffdfa,
612 DT_MOVESZ = 0x6ffffdfb,
613 DT_FEATURE = 0x6ffffdfc,
614 DT_POSFLAG_1 = 0x6ffffdfd,
615 DT_SYMINSZ = 0x6ffffdfe,
616 DT_SYMINENT = 0x6ffffdff,
617 DT_VALRNGHI = 0x6ffffdff,
619 DT_ADDRRNGLO = 0x6ffffe00,
620 DT_GNU_HASH = 0x6ffffef5,
621 DT_TLSDESC_PLT = 0x6ffffef6,
622 DT_TLSDESC_GOT = 0x6ffffef7,
623 DT_GNU_CONFLICT = 0x6ffffef8,
624 DT_GNU_LIBLIST = 0x6ffffef9,
625 DT_CONFIG = 0x6ffffefa,
626 DT_DEPAUDIT = 0x6ffffefb,
627 DT_AUDIT = 0x6ffffefc,
628 DT_PLTPAD = 0x6ffffefd,
629 DT_MOVETAB = 0x6ffffefe,
630 DT_SYMINFO = 0x6ffffeff,
631 DT_ADDRRNGHI = 0x6ffffeff,
633 DT_RELACOUNT = 0x6ffffff9,
634 DT_RELCOUNT = 0x6ffffffa,
635 DT_FLAGS_1 = 0x6ffffffb,
636 DT_VERDEF = 0x6ffffffc,
637 DT_VERDEFNUM = 0x6ffffffd,
638 DT_VERNEED = 0x6ffffffe,
639 DT_VERNEEDNUM = 0x6fffffff,
641 DT_VERSYM = 0x6ffffff0,
643 DT_AUXILIARY = 0x7ffffffd,
644 DT_USED = 0x7ffffffe,
645 DT_FILTER = 0x7fffffff
648 // Flags found in the DT_FLAGS dynamic element.
650 enum DF
652 DF_ORIGIN = 0x1,
653 DF_SYMBOLIC = 0x2,
654 DF_TEXTREL = 0x4,
655 DF_BIND_NOW = 0x8,
656 DF_STATIC_TLS = 0x10
659 // Version numbers which appear in the vd_version field of a Verdef
660 // structure.
662 const int VER_DEF_NONE = 0;
663 const int VER_DEF_CURRENT = 1;
665 // Version numbers which appear in the vn_version field of a Verneed
666 // structure.
668 const int VER_NEED_NONE = 0;
669 const int VER_NEED_CURRENT = 1;
671 // Bit flags which appear in vd_flags of Verdef and vna_flags of
672 // Vernaux.
674 const int VER_FLG_BASE = 0x1;
675 const int VER_FLG_WEAK = 0x2;
677 // Special constants found in the SHT_GNU_versym entries.
679 const int VER_NDX_LOCAL = 0;
680 const int VER_NDX_GLOBAL = 1;
682 // A SHT_GNU_versym section holds 16-bit words. This bit is set if
683 // the symbol is hidden and can only be seen when referenced using an
684 // explicit version number. This is a GNU extension.
686 const int VERSYM_HIDDEN = 0x8000;
688 // This is the mask for the rest of the data in a word read from a
689 // SHT_GNU_versym section.
691 const int VERSYM_VERSION = 0x7fff;
693 } // End namespace elfcpp.
695 // Include internal details after defining the types.
696 #include "elfcpp_internal.h"
698 namespace elfcpp
701 // The offset of the ELF file header in the ELF file.
703 const int file_header_offset = 0;
705 // ELF structure sizes.
707 template<int size>
708 struct Elf_sizes
710 // Size of ELF file header.
711 static const int ehdr_size = sizeof(internal::Ehdr_data<size>);
712 // Size of ELF segment header.
713 static const int phdr_size = sizeof(internal::Phdr_data<size>);
714 // Size of ELF section header.
715 static const int shdr_size = sizeof(internal::Shdr_data<size>);
716 // Size of ELF symbol table entry.
717 static const int sym_size = sizeof(internal::Sym_data<size>);
718 // Sizes of ELF reloc entries.
719 static const int rel_size = sizeof(internal::Rel_data<size>);
720 static const int rela_size = sizeof(internal::Rela_data<size>);
721 // Size of ELF dynamic entry.
722 static const int dyn_size = sizeof(internal::Dyn_data<size>);
723 // Size of ELF version structures.
724 static const int verdef_size = sizeof(internal::Verdef_data);
725 static const int verdaux_size = sizeof(internal::Verdaux_data);
726 static const int verneed_size = sizeof(internal::Verneed_data);
727 static const int vernaux_size = sizeof(internal::Vernaux_data);
730 // Accessor class for the ELF file header.
732 template<int size, bool big_endian>
733 class Ehdr
735 public:
736 Ehdr(const unsigned char* p)
737 : p_(reinterpret_cast<const internal::Ehdr_data<size>*>(p))
740 template<typename File>
741 Ehdr(File* file, typename File::Location loc)
742 : p_(reinterpret_cast<const internal::Ehdr_data<size>*>(
743 file->view(loc.file_offset, loc.data_size).data()))
746 const unsigned char*
747 get_e_ident() const
748 { return this->p_->e_ident; }
750 Elf_Half
751 get_e_type() const
752 { return Convert<16, big_endian>::convert_host(this->p_->e_type); }
754 Elf_Half
755 get_e_machine() const
756 { return Convert<16, big_endian>::convert_host(this->p_->e_machine); }
758 Elf_Word
759 get_e_version() const
760 { return Convert<32, big_endian>::convert_host(this->p_->e_version); }
762 typename Elf_types<size>::Elf_Addr
763 get_e_entry() const
764 { return Convert<size, big_endian>::convert_host(this->p_->e_entry); }
766 typename Elf_types<size>::Elf_Off
767 get_e_phoff() const
768 { return Convert<size, big_endian>::convert_host(this->p_->e_phoff); }
770 typename Elf_types<size>::Elf_Off
771 get_e_shoff() const
772 { return Convert<size, big_endian>::convert_host(this->p_->e_shoff); }
774 Elf_Word
775 get_e_flags() const
776 { return Convert<32, big_endian>::convert_host(this->p_->e_flags); }
778 Elf_Half
779 get_e_ehsize() const
780 { return Convert<16, big_endian>::convert_host(this->p_->e_ehsize); }
782 Elf_Half
783 get_e_phentsize() const
784 { return Convert<16, big_endian>::convert_host(this->p_->e_phentsize); }
786 Elf_Half
787 get_e_phnum() const
788 { return Convert<16, big_endian>::convert_host(this->p_->e_phnum); }
790 Elf_Half
791 get_e_shentsize() const
792 { return Convert<16, big_endian>::convert_host(this->p_->e_shentsize); }
794 Elf_Half
795 get_e_shnum() const
796 { return Convert<16, big_endian>::convert_host(this->p_->e_shnum); }
798 Elf_Half
799 get_e_shstrndx() const
800 { return Convert<16, big_endian>::convert_host(this->p_->e_shstrndx); }
802 private:
803 const internal::Ehdr_data<size>* p_;
806 // Write class for the ELF file header.
808 template<int size, bool big_endian>
809 class Ehdr_write
811 public:
812 Ehdr_write(unsigned char* p)
813 : p_(reinterpret_cast<internal::Ehdr_data<size>*>(p))
816 void
817 put_e_ident(const unsigned char v[EI_NIDENT]) const
818 { memcpy(this->p_->e_ident, v, EI_NIDENT); }
820 void
821 put_e_type(Elf_Half v)
822 { this->p_->e_type = Convert<16, big_endian>::convert_host(v); }
824 void
825 put_e_machine(Elf_Half v)
826 { this->p_->e_machine = Convert<16, big_endian>::convert_host(v); }
828 void
829 put_e_version(Elf_Word v)
830 { this->p_->e_version = Convert<32, big_endian>::convert_host(v); }
832 void
833 put_e_entry(typename Elf_types<size>::Elf_Addr v)
834 { this->p_->e_entry = Convert<size, big_endian>::convert_host(v); }
836 void
837 put_e_phoff(typename Elf_types<size>::Elf_Off v)
838 { this->p_->e_phoff = Convert<size, big_endian>::convert_host(v); }
840 void
841 put_e_shoff(typename Elf_types<size>::Elf_Off v)
842 { this->p_->e_shoff = Convert<size, big_endian>::convert_host(v); }
844 void
845 put_e_flags(Elf_Word v)
846 { this->p_->e_flags = Convert<32, big_endian>::convert_host(v); }
848 void
849 put_e_ehsize(Elf_Half v)
850 { this->p_->e_ehsize = Convert<16, big_endian>::convert_host(v); }
852 void
853 put_e_phentsize(Elf_Half v)
854 { this->p_->e_phentsize = Convert<16, big_endian>::convert_host(v); }
856 void
857 put_e_phnum(Elf_Half v)
858 { this->p_->e_phnum = Convert<16, big_endian>::convert_host(v); }
860 void
861 put_e_shentsize(Elf_Half v)
862 { this->p_->e_shentsize = Convert<16, big_endian>::convert_host(v); }
864 void
865 put_e_shnum(Elf_Half v)
866 { this->p_->e_shnum = Convert<16, big_endian>::convert_host(v); }
868 void
869 put_e_shstrndx(Elf_Half v)
870 { this->p_->e_shstrndx = Convert<16, big_endian>::convert_host(v); }
872 private:
873 internal::Ehdr_data<size>* p_;
876 // Accessor class for an ELF section header.
878 template<int size, bool big_endian>
879 class Shdr
881 public:
882 Shdr(const unsigned char* p)
883 : p_(reinterpret_cast<const internal::Shdr_data<size>*>(p))
886 template<typename File>
887 Shdr(File* file, typename File::Location loc)
888 : p_(reinterpret_cast<const internal::Shdr_data<size>*>(
889 file->view(loc.file_offset, loc.data_size).data()))
892 Elf_Word
893 get_sh_name() const
894 { return Convert<32, big_endian>::convert_host(this->p_->sh_name); }
896 Elf_Word
897 get_sh_type() const
898 { return Convert<32, big_endian>::convert_host(this->p_->sh_type); }
900 typename Elf_types<size>::Elf_WXword
901 get_sh_flags() const
902 { return Convert<size, big_endian>::convert_host(this->p_->sh_flags); }
904 typename Elf_types<size>::Elf_Addr
905 get_sh_addr() const
906 { return Convert<size, big_endian>::convert_host(this->p_->sh_addr); }
908 typename Elf_types<size>::Elf_Off
909 get_sh_offset() const
910 { return Convert<size, big_endian>::convert_host(this->p_->sh_offset); }
912 typename Elf_types<size>::Elf_WXword
913 get_sh_size() const
914 { return Convert<size, big_endian>::convert_host(this->p_->sh_size); }
916 Elf_Word
917 get_sh_link() const
918 { return Convert<32, big_endian>::convert_host(this->p_->sh_link); }
920 Elf_Word
921 get_sh_info() const
922 { return Convert<32, big_endian>::convert_host(this->p_->sh_info); }
924 typename Elf_types<size>::Elf_WXword
925 get_sh_addralign() const
926 { return
927 Convert<size, big_endian>::convert_host(this->p_->sh_addralign); }
929 typename Elf_types<size>::Elf_WXword
930 get_sh_entsize() const
931 { return Convert<size, big_endian>::convert_host(this->p_->sh_entsize); }
933 private:
934 const internal::Shdr_data<size>* p_;
937 // Write class for an ELF section header.
939 template<int size, bool big_endian>
940 class Shdr_write
942 public:
943 Shdr_write(unsigned char* p)
944 : p_(reinterpret_cast<internal::Shdr_data<size>*>(p))
947 void
948 put_sh_name(Elf_Word v)
949 { this->p_->sh_name = Convert<32, big_endian>::convert_host(v); }
951 void
952 put_sh_type(Elf_Word v)
953 { this->p_->sh_type = Convert<32, big_endian>::convert_host(v); }
955 void
956 put_sh_flags(typename Elf_types<size>::Elf_WXword v)
957 { this->p_->sh_flags = Convert<size, big_endian>::convert_host(v); }
959 void
960 put_sh_addr(typename Elf_types<size>::Elf_Addr v)
961 { this->p_->sh_addr = Convert<size, big_endian>::convert_host(v); }
963 void
964 put_sh_offset(typename Elf_types<size>::Elf_Off v)
965 { this->p_->sh_offset = Convert<size, big_endian>::convert_host(v); }
967 void
968 put_sh_size(typename Elf_types<size>::Elf_WXword v)
969 { this->p_->sh_size = Convert<size, big_endian>::convert_host(v); }
971 void
972 put_sh_link(Elf_Word v)
973 { this->p_->sh_link = Convert<32, big_endian>::convert_host(v); }
975 void
976 put_sh_info(Elf_Word v)
977 { this->p_->sh_info = Convert<32, big_endian>::convert_host(v); }
979 void
980 put_sh_addralign(typename Elf_types<size>::Elf_WXword v)
981 { this->p_->sh_addralign = Convert<size, big_endian>::convert_host(v); }
983 void
984 put_sh_entsize(typename Elf_types<size>::Elf_WXword v)
985 { this->p_->sh_entsize = Convert<size, big_endian>::convert_host(v); }
987 private:
988 internal::Shdr_data<size>* p_;
991 // Accessor class for an ELF segment header.
993 template<int size, bool big_endian>
994 class Phdr
996 public:
997 Phdr(const unsigned char* p)
998 : p_(reinterpret_cast<const internal::Phdr_data<size>*>(p))
1001 template<typename File>
1002 Phdr(File* file, typename File::Location loc)
1003 : p_(reinterpret_cast<internal::Phdr_data<size>*>(
1004 file->view(loc.file_offset, loc.data_size).data()))
1007 Elf_Word
1008 get_p_type() const
1009 { return Convert<32, big_endian>::convert_host(this->p_->p_type); }
1011 typename Elf_types<size>::Elf_Off
1012 get_p_offset() const
1013 { return Convert<size, big_endian>::convert_host(this->p_->p_offset); }
1015 typename Elf_types<size>::Elf_Addr
1016 get_p_vaddr() const
1017 { return Convert<size, big_endian>::convert_host(this->p_->p_vaddr); }
1019 typename Elf_types<size>::Elf_Addr
1020 get_p_paddr() const
1021 { return Convert<size, big_endian>::convert_host(this->p_->p_paddr); }
1023 typename Elf_types<size>::Elf_WXword
1024 get_p_filesz() const
1025 { return Convert<size, big_endian>::convert_host(this->p_->p_filesz); }
1027 typename Elf_types<size>::Elf_WXword
1028 get_p_memsz() const
1029 { return Convert<size, big_endian>::convert_host(this->p_->p_memsz); }
1031 Elf_Word
1032 get_p_flags() const
1033 { return Convert<32, big_endian>::convert_host(this->p_->p_flags); }
1035 typename Elf_types<size>::Elf_WXword
1036 get_p_align() const
1037 { return Convert<size, big_endian>::convert_host(this->p_->p_align); }
1039 private:
1040 const internal::Phdr_data<size>* p_;
1043 // Write class for an ELF segment header.
1045 template<int size, bool big_endian>
1046 class Phdr_write
1048 public:
1049 Phdr_write(unsigned char* p)
1050 : p_(reinterpret_cast<internal::Phdr_data<size>*>(p))
1053 void
1054 put_p_type(Elf_Word v)
1055 { this->p_->p_type = Convert<32, big_endian>::convert_host(v); }
1057 void
1058 put_p_offset(typename Elf_types<size>::Elf_Off v)
1059 { this->p_->p_offset = Convert<size, big_endian>::convert_host(v); }
1061 void
1062 put_p_vaddr(typename Elf_types<size>::Elf_Addr v)
1063 { this->p_->p_vaddr = Convert<size, big_endian>::convert_host(v); }
1065 void
1066 put_p_paddr(typename Elf_types<size>::Elf_Addr v)
1067 { this->p_->p_paddr = Convert<size, big_endian>::convert_host(v); }
1069 void
1070 put_p_filesz(typename Elf_types<size>::Elf_WXword v)
1071 { this->p_->p_filesz = Convert<size, big_endian>::convert_host(v); }
1073 void
1074 put_p_memsz(typename Elf_types<size>::Elf_WXword v)
1075 { this->p_->p_memsz = Convert<size, big_endian>::convert_host(v); }
1077 void
1078 put_p_flags(Elf_Word v)
1079 { this->p_->p_flags = Convert<32, big_endian>::convert_host(v); }
1081 void
1082 put_p_align(typename Elf_types<size>::Elf_WXword v)
1083 { this->p_->p_align = Convert<size, big_endian>::convert_host(v); }
1085 private:
1086 internal::Phdr_data<size>* p_;
1089 // Accessor class for an ELF symbol table entry.
1091 template<int size, bool big_endian>
1092 class Sym
1094 public:
1095 Sym(const unsigned char* p)
1096 : p_(reinterpret_cast<const internal::Sym_data<size>*>(p))
1099 template<typename File>
1100 Sym(File* file, typename File::Location loc)
1101 : p_(reinterpret_cast<const internal::Sym_data<size>*>(
1102 file->view(loc.file_offset, loc.data_size).data()))
1105 Elf_Word
1106 get_st_name() const
1107 { return Convert<32, big_endian>::convert_host(this->p_->st_name); }
1109 typename Elf_types<size>::Elf_Addr
1110 get_st_value() const
1111 { return Convert<size, big_endian>::convert_host(this->p_->st_value); }
1113 typename Elf_types<size>::Elf_WXword
1114 get_st_size() const
1115 { return Convert<size, big_endian>::convert_host(this->p_->st_size); }
1117 unsigned char
1118 get_st_info() const
1119 { return this->p_->st_info; }
1122 get_st_bind() const
1123 { return elf_st_bind(this->get_st_info()); }
1126 get_st_type() const
1127 { return elf_st_type(this->get_st_info()); }
1129 unsigned char
1130 get_st_other() const
1131 { return this->p_->st_other; }
1134 get_st_visibility() const
1135 { return elf_st_visibility(this->get_st_other()); }
1137 unsigned char
1138 get_st_nonvis() const
1139 { return elf_st_nonvis(this->get_st_other()); }
1141 Elf_Half
1142 get_st_shndx() const
1143 { return Convert<16, big_endian>::convert_host(this->p_->st_shndx); }
1145 private:
1146 const internal::Sym_data<size>* p_;
1149 // Writer class for an ELF symbol table entry.
1151 template<int size, bool big_endian>
1152 class Sym_write
1154 public:
1155 Sym_write(unsigned char* p)
1156 : p_(reinterpret_cast<internal::Sym_data<size>*>(p))
1159 void
1160 put_st_name(Elf_Word v)
1161 { this->p_->st_name = Convert<32, big_endian>::convert_host(v); }
1163 void
1164 put_st_value(typename Elf_types<size>::Elf_Addr v)
1165 { this->p_->st_value = Convert<size, big_endian>::convert_host(v); }
1167 void
1168 put_st_size(typename Elf_types<size>::Elf_WXword v)
1169 { this->p_->st_size = Convert<size, big_endian>::convert_host(v); }
1171 void
1172 put_st_info(unsigned char v)
1173 { this->p_->st_info = v; }
1175 void
1176 put_st_info(STB bind, STT type)
1177 { this->p_->st_info = elf_st_info(bind, type); }
1179 void
1180 put_st_other(unsigned char v)
1181 { this->p_->st_other = v; }
1183 void
1184 put_st_other(STV vis, unsigned char nonvis)
1185 { this->p_->st_other = elf_st_other(vis, nonvis); }
1187 void
1188 put_st_shndx(Elf_Half v)
1189 { this->p_->st_shndx = Convert<16, big_endian>::convert_host(v); }
1191 Sym<size, big_endian>
1192 sym()
1193 { return Sym<size, big_endian>(reinterpret_cast<unsigned char*>(this->p_)); }
1195 private:
1196 internal::Sym_data<size>* p_;
1199 // Accessor classes for an ELF REL relocation entry.
1201 template<int size, bool big_endian>
1202 class Rel
1204 public:
1205 Rel(const unsigned char* p)
1206 : p_(reinterpret_cast<const internal::Rel_data<size>*>(p))
1209 template<typename File>
1210 Rel(File* file, typename File::Location loc)
1211 : p_(reinterpret_cast<const internal::Rel_data<size>*>(
1212 file->view(loc.file_offset, loc.data_size).data()))
1215 typename Elf_types<size>::Elf_Addr
1216 get_r_offset() const
1217 { return Convert<size, big_endian>::convert_host(this->p_->r_offset); }
1219 typename Elf_types<size>::Elf_WXword
1220 get_r_info() const
1221 { return Convert<size, big_endian>::convert_host(this->p_->r_info); }
1223 private:
1224 const internal::Rel_data<size>* p_;
1227 // Writer class for an ELF Rel relocation.
1229 template<int size, bool big_endian>
1230 class Rel_write
1232 public:
1233 Rel_write(unsigned char* p)
1234 : p_(reinterpret_cast<internal::Rel_data<size>*>(p))
1237 void
1238 put_r_offset(typename Elf_types<size>::Elf_Addr v)
1239 { this->p_->r_offset = Convert<size, big_endian>::convert_host(v); }
1241 void
1242 put_r_info(typename Elf_types<size>::Elf_WXword v)
1243 { this->p_->r_info = Convert<size, big_endian>::convert_host(v); }
1245 private:
1246 internal::Rel_data<size>* p_;
1249 // Accessor class for an ELF Rela relocation.
1251 template<int size, bool big_endian>
1252 class Rela
1254 public:
1255 Rela(const unsigned char* p)
1256 : p_(reinterpret_cast<const internal::Rela_data<size>*>(p))
1259 template<typename File>
1260 Rela(File* file, typename File::Location loc)
1261 : p_(reinterpret_cast<const internal::Rela_data<size>*>(
1262 file->view(loc.file_offset, loc.data_size).data()))
1265 typename Elf_types<size>::Elf_Addr
1266 get_r_offset() const
1267 { return Convert<size, big_endian>::convert_host(this->p_->r_offset); }
1269 typename Elf_types<size>::Elf_WXword
1270 get_r_info() const
1271 { return Convert<size, big_endian>::convert_host(this->p_->r_info); }
1273 typename Elf_types<size>::Elf_Swxword
1274 get_r_addend() const
1275 { return Convert<size, big_endian>::convert_host(this->p_->r_addend); }
1277 private:
1278 const internal::Rela_data<size>* p_;
1281 // Writer class for an ELF Rela relocation.
1283 template<int size, bool big_endian>
1284 class Rela_write
1286 public:
1287 Rela_write(unsigned char* p)
1288 : p_(reinterpret_cast<internal::Rela_data<size>*>(p))
1291 void
1292 put_r_offset(typename Elf_types<size>::Elf_Addr v)
1293 { this->p_->r_offset = Convert<size, big_endian>::convert_host(v); }
1295 void
1296 put_r_info(typename Elf_types<size>::Elf_WXword v)
1297 { this->p_->r_info = Convert<size, big_endian>::convert_host(v); }
1299 void
1300 put_r_addend(typename Elf_types<size>::Elf_Swxword v)
1301 { this->p_->r_addend = Convert<size, big_endian>::convert_host(v); }
1303 private:
1304 internal::Rela_data<size>* p_;
1307 // Accessor classes for entries in the ELF SHT_DYNAMIC section aka
1308 // PT_DYNAMIC segment.
1310 template<int size, bool big_endian>
1311 class Dyn
1313 public:
1314 Dyn(const unsigned char* p)
1315 : p_(reinterpret_cast<const internal::Dyn_data<size>*>(p))
1318 template<typename File>
1319 Dyn(File* file, typename File::Location loc)
1320 : p_(reinterpret_cast<const internal::Dyn_data<size>*>(
1321 file->view(loc.file_offset, loc.data_size).data()))
1324 typename Elf_types<size>::Elf_Swxword
1325 get_d_tag() const
1326 { return Convert<size, big_endian>::convert_host(this->p_->d_tag); }
1328 typename Elf_types<size>::Elf_WXword
1329 get_d_val() const
1330 { return Convert<size, big_endian>::convert_host(this->p_->d_val); }
1332 typename Elf_types<size>::Elf_Addr
1333 get_d_ptr() const
1334 { return Convert<size, big_endian>::convert_host(this->p_->d_val); }
1336 private:
1337 const internal::Dyn_data<size>* p_;
1340 // Write class for an entry in the SHT_DYNAMIC section.
1342 template<int size, bool big_endian>
1343 class Dyn_write
1345 public:
1346 Dyn_write(unsigned char* p)
1347 : p_(reinterpret_cast<internal::Dyn_data<size>*>(p))
1350 void
1351 put_d_tag(typename Elf_types<size>::Elf_Swxword v)
1352 { this->p_->d_tag = Convert<size, big_endian>::convert_host(v); }
1354 void
1355 put_d_val(typename Elf_types<size>::Elf_WXword v)
1356 { this->p_->d_val = Convert<size, big_endian>::convert_host(v); }
1358 void
1359 put_d_ptr(typename Elf_types<size>::Elf_Addr v)
1360 { this->p_->d_val = Convert<size, big_endian>::convert_host(v); }
1362 private:
1363 internal::Dyn_data<size>* p_;
1366 // Accessor classes for entries in the ELF SHT_GNU_verdef section.
1368 template<int size, bool big_endian>
1369 class Verdef
1371 public:
1372 Verdef(const unsigned char* p)
1373 : p_(reinterpret_cast<const internal::Verdef_data*>(p))
1376 template<typename File>
1377 Verdef(File* file, typename File::Location loc)
1378 : p_(reinterpret_cast<const internal::Verdef_data*>(
1379 file->view(loc.file_offset, loc.data_size).data()))
1382 Elf_Half
1383 get_vd_version() const
1384 { return Convert<16, big_endian>::convert_host(this->p_->vd_version); }
1386 Elf_Half
1387 get_vd_flags() const
1388 { return Convert<16, big_endian>::convert_host(this->p_->vd_flags); }
1390 Elf_Half
1391 get_vd_ndx() const
1392 { return Convert<16, big_endian>::convert_host(this->p_->vd_ndx); }
1394 Elf_Half
1395 get_vd_cnt() const
1396 { return Convert<16, big_endian>::convert_host(this->p_->vd_cnt); }
1398 Elf_Word
1399 get_vd_hash() const
1400 { return Convert<32, big_endian>::convert_host(this->p_->vd_hash); }
1402 Elf_Word
1403 get_vd_aux() const
1404 { return Convert<32, big_endian>::convert_host(this->p_->vd_aux); }
1406 Elf_Word
1407 get_vd_next() const
1408 { return Convert<32, big_endian>::convert_host(this->p_->vd_next); }
1410 private:
1411 const internal::Verdef_data* p_;
1414 template<int size, bool big_endian>
1415 class Verdef_write
1417 public:
1418 Verdef_write(unsigned char* p)
1419 : p_(reinterpret_cast<internal::Verdef_data*>(p))
1422 void
1423 set_vd_version(Elf_Half v)
1424 { this->p_->vd_version = Convert<16, big_endian>::convert_host(v); }
1426 void
1427 set_vd_flags(Elf_Half v)
1428 { this->p_->vd_flags = Convert<16, big_endian>::convert_host(v); }
1430 void
1431 set_vd_ndx(Elf_Half v)
1432 { this->p_->vd_ndx = Convert<16, big_endian>::convert_host(v); }
1434 void
1435 set_vd_cnt(Elf_Half v)
1436 { this->p_->vd_cnt = Convert<16, big_endian>::convert_host(v); }
1438 void
1439 set_vd_hash(Elf_Word v)
1440 { this->p_->vd_hash = Convert<32, big_endian>::convert_host(v); }
1442 void
1443 set_vd_aux(Elf_Word v)
1444 { this->p_->vd_aux = Convert<32, big_endian>::convert_host(v); }
1446 void
1447 set_vd_next(Elf_Word v)
1448 { this->p_->vd_next = Convert<32, big_endian>::convert_host(v); }
1450 private:
1451 internal::Verdef_data* p_;
1454 // Accessor classes for auxiliary entries in the ELF SHT_GNU_verdef
1455 // section.
1457 template<int size, bool big_endian>
1458 class Verdaux
1460 public:
1461 Verdaux(const unsigned char* p)
1462 : p_(reinterpret_cast<const internal::Verdaux_data*>(p))
1465 template<typename File>
1466 Verdaux(File* file, typename File::Location loc)
1467 : p_(reinterpret_cast<const internal::Verdaux_data*>(
1468 file->view(loc.file_offset, loc.data_size).data()))
1471 Elf_Word
1472 get_vda_name() const
1473 { return Convert<32, big_endian>::convert_host(this->p_->vda_name); }
1475 Elf_Word
1476 get_vda_next() const
1477 { return Convert<32, big_endian>::convert_host(this->p_->vda_next); }
1479 private:
1480 const internal::Verdaux_data* p_;
1483 template<int size, bool big_endian>
1484 class Verdaux_write
1486 public:
1487 Verdaux_write(unsigned char* p)
1488 : p_(reinterpret_cast<internal::Verdaux_data*>(p))
1491 void
1492 set_vda_name(Elf_Word v)
1493 { this->p_->vda_name = Convert<32, big_endian>::convert_host(v); }
1495 void
1496 set_vda_next(Elf_Word v)
1497 { this->p_->vda_next = Convert<32, big_endian>::convert_host(v); }
1499 private:
1500 internal::Verdaux_data* p_;
1503 // Accessor classes for entries in the ELF SHT_GNU_verneed section.
1505 template<int size, bool big_endian>
1506 class Verneed
1508 public:
1509 Verneed(const unsigned char* p)
1510 : p_(reinterpret_cast<const internal::Verneed_data*>(p))
1513 template<typename File>
1514 Verneed(File* file, typename File::Location loc)
1515 : p_(reinterpret_cast<const internal::Verneed_data*>(
1516 file->view(loc.file_offset, loc.data_size).data()))
1519 Elf_Half
1520 get_vn_version() const
1521 { return Convert<16, big_endian>::convert_host(this->p_->vn_version); }
1523 Elf_Half
1524 get_vn_cnt() const
1525 { return Convert<16, big_endian>::convert_host(this->p_->vn_cnt); }
1527 Elf_Word
1528 get_vn_file() const
1529 { return Convert<32, big_endian>::convert_host(this->p_->vn_file); }
1531 Elf_Word
1532 get_vn_aux() const
1533 { return Convert<32, big_endian>::convert_host(this->p_->vn_aux); }
1535 Elf_Word
1536 get_vn_next() const
1537 { return Convert<32, big_endian>::convert_host(this->p_->vn_next); }
1539 private:
1540 const internal::Verneed_data* p_;
1543 template<int size, bool big_endian>
1544 class Verneed_write
1546 public:
1547 Verneed_write(unsigned char* p)
1548 : p_(reinterpret_cast<internal::Verneed_data*>(p))
1551 void
1552 set_vn_version(Elf_Half v)
1553 { this->p_->vn_version = Convert<16, big_endian>::convert_host(v); }
1555 void
1556 set_vn_cnt(Elf_Half v)
1557 { this->p_->vn_cnt = Convert<16, big_endian>::convert_host(v); }
1559 void
1560 set_vn_file(Elf_Word v)
1561 { this->p_->vn_file = Convert<32, big_endian>::convert_host(v); }
1563 void
1564 set_vn_aux(Elf_Word v)
1565 { this->p_->vn_aux = Convert<32, big_endian>::convert_host(v); }
1567 void
1568 set_vn_next(Elf_Word v)
1569 { this->p_->vn_next = Convert<32, big_endian>::convert_host(v); }
1571 private:
1572 internal::Verneed_data* p_;
1575 // Accessor classes for auxiliary entries in the ELF SHT_GNU_verneed
1576 // section.
1578 template<int size, bool big_endian>
1579 class Vernaux
1581 public:
1582 Vernaux(const unsigned char* p)
1583 : p_(reinterpret_cast<const internal::Vernaux_data*>(p))
1586 template<typename File>
1587 Vernaux(File* file, typename File::Location loc)
1588 : p_(reinterpret_cast<const internal::Vernaux_data*>(
1589 file->view(loc.file_offset, loc.data_size).data()))
1592 Elf_Word
1593 get_vna_hash() const
1594 { return Convert<32, big_endian>::convert_host(this->p_->vna_hash); }
1596 Elf_Half
1597 get_vna_flags() const
1598 { return Convert<16, big_endian>::convert_host(this->p_->vna_flags); }
1600 Elf_Half
1601 get_vna_other() const
1602 { return Convert<16, big_endian>::convert_host(this->p_->vna_other); }
1604 Elf_Word
1605 get_vna_name() const
1606 { return Convert<32, big_endian>::convert_host(this->p_->vna_name); }
1608 Elf_Word
1609 get_vna_next() const
1610 { return Convert<32, big_endian>::convert_host(this->p_->vna_next); }
1612 private:
1613 const internal::Vernaux_data* p_;
1616 template<int size, bool big_endian>
1617 class Vernaux_write
1619 public:
1620 Vernaux_write(unsigned char* p)
1621 : p_(reinterpret_cast<internal::Vernaux_data*>(p))
1624 void
1625 set_vna_hash(Elf_Word v)
1626 { this->p_->vna_hash = Convert<32, big_endian>::convert_host(v); }
1628 void
1629 set_vna_flags(Elf_Half v)
1630 { this->p_->vna_flags = Convert<16, big_endian>::convert_host(v); }
1632 void
1633 set_vna_other(Elf_Half v)
1634 { this->p_->vna_other = Convert<16, big_endian>::convert_host(v); }
1636 void
1637 set_vna_name(Elf_Word v)
1638 { this->p_->vna_name = Convert<32, big_endian>::convert_host(v); }
1640 void
1641 set_vna_next(Elf_Word v)
1642 { this->p_->vna_next = Convert<32, big_endian>::convert_host(v); }
1644 private:
1645 internal::Vernaux_data* p_;
1648 } // End namespace elfcpp.
1650 #endif // !defined(ELFPCP_H)