add this momentarily, will move them to the attic soon
[binutils.git] / elfcpp / elfcpp.h
blob305487f8bf03fb69b6bd8c03dc385cf25620fd8e
1 // elfcpp.h -- main header file for elfcpp -*- C++ -*-
3 // This is the external interface for elfcpp.
5 #ifndef ELFCPP_H
6 #define ELFCPP_H
8 #include "elfcpp_config.h"
9 #include "elfcpp_swap.h"
11 #include <stdint.h>
13 namespace elfcpp
16 // Basic ELF types.
18 // These types are always the same size.
20 typedef uint16_t Elf_Half;
21 typedef uint32_t Elf_Word;
22 typedef int32_t Elf_Sword;
23 typedef uint64_t Elf_Xword;
24 typedef int64_t Elf_Sxword;
26 // These types vary in size depending on the ELF file class. The
27 // template parameter should be 32 or 64.
29 template<int size>
30 struct Elf_types;
32 template<>
33 struct Elf_types<32>
35 typedef uint32_t Elf_Addr;
36 typedef uint32_t Elf_Off;
37 typedef uint32_t Elf_WXword;
38 typedef int32_t Elf_Swxword;
41 template<>
42 struct Elf_types<64>
44 typedef uint64_t Elf_Addr;
45 typedef uint64_t Elf_Off;
46 typedef uint64_t Elf_WXword;
47 typedef int64_t Elf_Swxword;
50 // Offsets within the Ehdr e_ident field.
52 const int EI_MAG0 = 0;
53 const int EI_MAG1 = 1;
54 const int EI_MAG2 = 2;
55 const int EI_MAG3 = 3;
56 const int EI_CLASS = 4;
57 const int EI_DATA = 5;
58 const int EI_VERSION = 6;
59 const int EI_OSABI = 7;
60 const int EI_ABIVERSION = 8;
61 const int EI_PAD = 9;
62 const int EI_NIDENT = 16;
64 // The valid values found in Ehdr e_ident[EI_MAG0 through EI_MAG3].
66 const int ELFMAG0 = 0x7f;
67 const int ELFMAG1 = 'E';
68 const int ELFMAG2 = 'L';
69 const int ELFMAG3 = 'F';
71 // The valid values found in Ehdr e_ident[EI_CLASS].
73 enum
75 ELFCLASSNONE = 0,
76 ELFCLASS32 = 1,
77 ELFCLASS64 = 2
80 // The valid values found in Ehdr e_ident[EI_DATA].
82 enum
84 ELFDATANONE = 0,
85 ELFDATA2LSB = 1,
86 ELFDATA2MSB = 2
89 // The valid values found in Ehdr e_ident[EI_VERSION] and e_version.
91 enum
93 EV_NONE = 0,
94 EV_CURRENT = 1
97 // The valid values found in Ehdr e_ident[EI_OSABI].
99 enum ELFOSABI
101 ELFOSABI_NONE = 0,
102 ELFOSABI_HPUX = 1,
103 ELFOSABI_NETBSD = 2,
104 // ELFOSABI_LINUX is not listed in the ELF standard.
105 ELFOSABI_LINUX = 3,
106 // ELFOSABI_HURD is not listed in the ELF standard.
107 ELFOSABI_HURD = 4,
108 ELFOSABI_SOLARIS = 6,
109 ELFOSABI_AIX = 7,
110 ELFOSABI_IRIX = 8,
111 ELFOSABI_FREEBSD = 9,
112 ELFOSABI_TRU64 = 10,
113 ELFOSABI_MODESTO = 11,
114 ELFOSABI_OPENBSD = 12,
115 ELFOSABI_OPENVMS = 13,
116 ELFOSABI_NSK = 14,
117 ELFOSABI_AROS = 15,
118 // A GNU extension for the ARM.
119 ELFOSABI_ARM = 97,
120 // A GNU extension for the MSP.
121 ELFOSABI_STANDALONE = 255
124 // The valid values found in the Ehdr e_type field.
126 enum ET
128 ET_NONE = 0,
129 ET_REL = 1,
130 ET_EXEC = 2,
131 ET_DYN = 3,
132 ET_CORE = 4,
133 ET_LOOS = 0xfe00,
134 ET_HIOS = 0xfeff,
135 ET_LOPROC = 0xff00,
136 ET_HIPROC = 0xffff
139 // The valid values found in the Ehdr e_machine field.
141 enum EM
143 EM_NONE = 0,
144 EM_M32 = 1,
145 EM_SPARC = 2,
146 EM_386 = 3,
147 EM_68K = 4,
148 EM_88K = 5,
149 // 6 used to be EM_486
150 EM_860 = 7,
151 EM_MIPS = 8,
152 EM_S370 = 9,
153 EM_MIPS_RS3_LE = 10,
154 // 11 was the old Sparc V9 ABI.
155 // 12 through 14 are reserved.
156 EM_PARISC = 15,
157 // 16 is reserved.
158 // Some old PowerPC object files use 17.
159 EM_VPP500 = 17,
160 EM_SPARC32PLUS = 18,
161 EM_960 = 19,
162 EM_PPC = 20,
163 EM_PPC64 = 21,
164 EM_S390 = 22,
165 // 23 through 35 are served.
166 EM_V800 = 36,
167 EM_FR20 = 37,
168 EM_RH32 = 38,
169 EM_RCE = 39,
170 EM_ARM = 40,
171 EM_ALPHA = 41,
172 EM_SH = 42,
173 EM_SPARCV9 = 43,
174 EM_TRICORE = 44,
175 EM_ARC = 45,
176 EM_H8_300 = 46,
177 EM_H8_300H = 47,
178 EM_H8S = 48,
179 EM_H8_500 = 49,
180 EM_IA_64 = 50,
181 EM_MIPS_X = 51,
182 EM_COLDFIRE = 52,
183 EM_68HC12 = 53,
184 EM_MMA = 54,
185 EM_PCP = 55,
186 EM_NCPU = 56,
187 EM_NDR1 = 57,
188 EM_STARCORE = 58,
189 EM_ME16 = 59,
190 EM_ST100 = 60,
191 EM_TINYJ = 61,
192 EM_X86_64 = 62,
193 EM_PDSP = 63,
194 EM_PDP10 = 64,
195 EM_PDP11 = 65,
196 EM_FX66 = 66,
197 EM_ST9PLUS = 67,
198 EM_ST7 = 68,
199 EM_68HC16 = 69,
200 EM_68HC11 = 70,
201 EM_68HC08 = 71,
202 EM_68HC05 = 72,
203 EM_SVX = 73,
204 EM_ST19 = 74,
205 EM_VAX = 75,
206 EM_CRIS = 76,
207 EM_JAVELIN = 77,
208 EM_FIREPATH = 78,
209 EM_ZSP = 79,
210 EM_MMIX = 80,
211 EM_HUANY = 81,
212 EM_PRISM = 82,
213 EM_AVR = 83,
214 EM_FR30 = 84,
215 EM_D10V = 85,
216 EM_D30V = 86,
217 EM_V850 = 87,
218 EM_M32R = 88,
219 EM_MN10300 = 89,
220 EM_MN10200 = 90,
221 EM_PJ = 91,
222 EM_OPENRISC = 92,
223 EM_ARC_A5 = 93,
224 EM_XTENSA = 94,
225 EM_VIDEOCORE = 95,
226 EM_TMM_GPP = 96,
227 EM_NS32K = 97,
228 EM_TPC = 98,
229 // Some old picoJava object files use 99 (EM_PJ is correct).
230 EM_SNP1K = 99,
231 EM_ST200 = 100,
232 EM_IP2K = 101,
233 EM_MAX = 102,
234 EM_CR = 103,
235 EM_F2MC16 = 104,
236 EM_MSP430 = 105,
237 EM_BLACKFIN = 106,
238 EM_SE_C33 = 107,
239 EM_SEP = 108,
240 EM_ARCA = 109,
241 EM_UNICORE = 110,
242 EM_ALTERA_NIOS2 = 113,
243 EM_CRX = 114,
244 // The Morph MT.
245 EM_MT = 0x2530,
246 // DLX.
247 EM_DLX = 0x5aa5,
248 // FRV.
249 EM_FRV = 0x5441,
250 // Infineon Technologies 16-bit microcontroller with C166-V2 core.
251 EM_X16X = 0x4688,
252 // Xstorym16
253 EM_XSTORMY16 = 0xad45,
254 // Renesas M32C
255 EM_M32C = 0xfeb0,
256 // Vitesse IQ2000
257 EM_IQ2000 = 0xfeba,
258 // NIOS
259 EM_NIOS32 = 0xfebb
260 // Old AVR objects used 0x1057 (EM_AVR is correct).
261 // Old MSP430 objects used 0x1059 (EM_MSP430 is correct).
262 // Old FR30 objects used 0x3330 (EM_FR30 is correct).
263 // Old OpenRISC objects used 0x3426 and 0x8472 (EM_OPENRISC is correct).
264 // Old D10V objects used 0x7650 (EM_D10V is correct).
265 // Old D30V objects used 0x7676 (EM_D30V is correct).
266 // Old IP2X objects used 0x8217 (EM_IP2K is correct).
267 // Old PowerPC objects used 0x9025 (EM_PPC is correct).
268 // Old Alpha objects used 0x9026 (EM_ALPHA is correct).
269 // Old M32R objects used 0x9041 (EM_M32R is correct).
270 // Old V850 objects used 0x9080 (EM_V850 is correct).
271 // Old S/390 objects used 0xa390 (EM_S390 is correct).
272 // Old Xtensa objects used 0xabc7 (EM_XTENSA is correct).
273 // Old MN10300 objects used 0xbeef (EM_MN10300 is correct).
274 // Old MN10200 objects used 0xdead (EM_MN10200 is correct).
277 // Special section indices.
279 enum
281 SHN_UNDEF = 0,
282 SHN_LORESERVE = 0xff00,
283 SHN_LOPROC = 0xff00,
284 SHN_HIPROC = 0xff1f,
285 SHN_LOOS = 0xff20,
286 SHN_HIOS = 0xff3f,
287 SHN_ABS = 0xfff1,
288 SHN_COMMON = 0xfff2,
289 SHN_XINDEX = 0xffff,
290 SHN_HIRESERVE = 0xffff
293 // The valid values found in the Shdr sh_type field.
295 enum SHT
297 SHT_NULL = 0,
298 SHT_PROGBITS = 1,
299 SHT_SYMTAB = 2,
300 SHT_STRTAB = 3,
301 SHT_RELA = 4,
302 SHT_HASH = 5,
303 SHT_DYNAMIC = 6,
304 SHT_NOTE = 7,
305 SHT_NOBITS = 8,
306 SHT_REL = 9,
307 SHT_SHLIB = 10,
308 SHT_DYNSYM = 11,
309 SHT_INIT_ARRAY = 14,
310 SHT_FINI_ARRAY = 15,
311 SHT_PREINIT_ARRAY = 16,
312 SHT_GROUP = 17,
313 SHT_SYMTAB_SHNDX = 18,
314 SHT_LOOS = 0x60000000,
315 SHT_HIOS = 0x6fffffff,
316 SHT_LOPROC = 0x70000000,
317 SHT_HIPROC = 0x7fffffff,
318 SHT_LOUSER = 0x80000000,
319 SHT_HIUSER = 0xffffffff,
320 // The remaining values are not in the standard.
321 // List of prelink dependencies.
322 SHT_GNU_LIBLIST = 0x6ffffff7,
323 // Versions defined by file.
324 SHT_SUNW_verdef = 0x6ffffffd,
325 SHT_GNU_verdef = 0x6ffffffd,
326 // Versions needed by file.
327 SHT_SUNW_verneed = 0x6ffffffe,
328 SHT_GNU_verneed = 0x6ffffffe,
329 // Symbol versions,
330 SHT_SUNW_versym = 0x6fffffff,
331 SHT_GNU_versym = 0x6fffffff,
334 // The valid bit flags found in the Shdr sh_flags field.
336 enum SHF
338 SHF_WRITE = 0x1,
339 SHF_ALLOC = 0x2,
340 SHF_EXECINSTR = 0x4,
341 SHF_MERGE = 0x10,
342 SHF_STRINGS = 0x20,
343 SHF_INFO_LINK = 0x40,
344 SHF_LINK_ORDER = 0x80,
345 SHF_OS_NONCONFORMING = 0x100,
346 SHF_GROUP = 0x200,
347 SHF_TLS = 0x400,
348 SHF_MASKOS = 0x0ff00000,
349 SHF_MASKPROC = 0xf0000000
352 // Bit flags which appear in the first 32-bit word of the section data
353 // of a SHT_GROUP section.
355 enum
357 GRP_COMDAT = 0x1,
358 GRP_MASKOS = 0x0ff00000,
359 GRP_MASKPROC = 0xf0000000
362 // The valid values found in the Phdr p_type field.
364 enum PT
366 PT_NULL = 0,
367 PT_LOAD = 1,
368 PT_DYNAMIC = 2,
369 PT_INTERP = 3,
370 PT_NOTE = 4,
371 PT_SHLIB = 5,
372 PT_PHDR = 6,
373 PT_TLS = 7,
374 PT_LOOS = 0x60000000,
375 PT_HIOS = 0x6fffffff,
376 PT_LOPROC = 0x70000000,
377 PT_HIPROC = 0x7fffffff,
378 // The remaining values are not in the standard.
379 // Frame unwind information.
380 PT_GNU_EH_FRAME = 0x6474e550,
381 PT_SUNW_EH_FRAME = 0x6474e550,
382 // Stack flags.
383 PT_GNU_STACK = 0x6474e551,
384 // Read only after relocation.
385 PT_GNU_RELRO = 0x6474e552
388 // The valid bit flags found in the Phdr p_flags field.
390 enum PF
392 PF_X = 0x1,
393 PF_W = 0x2,
394 PF_R = 0x4,
395 PF_MASKOS = 0x0ff00000,
396 PF_MASKPROC = 0xf0000000
399 // Symbol binding from Sym st_info field.
401 enum STB
403 STB_LOCAL = 0,
404 STB_GLOBAL = 1,
405 STB_WEAK = 2,
406 STB_LOOS = 10,
407 STB_HIOS = 12,
408 STB_LOPROC = 13,
409 STB_HIPROC = 15
412 // Symbol types from Sym st_info field.
414 enum STT
416 STT_NOTYPE = 0,
417 STT_OBJECT = 1,
418 STT_FUNC = 2,
419 STT_SECTION = 3,
420 STT_FILE = 4,
421 STT_COMMON = 5,
422 STT_TLS = 6,
423 STT_LOOS = 10,
424 STT_HIOS = 12,
425 STT_LOPROC = 13,
426 STT_HIPROC = 15
429 inline STB
430 elf_st_bind(unsigned char info)
432 return static_cast<STB>(info >> 4);
435 inline STT
436 elf_st_type(unsigned char info)
438 return static_cast<STT>(info & 0xf);
441 inline unsigned char
442 elf_st_info(STB bind, STT type)
444 return ((static_cast<unsigned char>(bind) << 4)
445 + (static_cast<unsigned char>(type) & 0xf));
448 // Symbol visibility from Sym st_other field.
450 enum STV
452 STV_DEFAULT = 0,
453 STV_INTERNAL = 1,
454 STV_HIDDEN = 2,
455 STV_PROTECTED = 3
458 inline STV
459 elf_st_visibility(unsigned char other)
461 return static_cast<STV>(other & 0x3);
464 inline unsigned char
465 elf_st_nonvis(unsigned char other)
467 return static_cast<STV>(other >> 2);
470 inline unsigned char
471 elf_st_other(STV vis, unsigned char nonvis)
473 return ((nonvis << 2)
474 + (static_cast<unsigned char>(vis) & 3));
477 // Reloc information from Rel/Rela r_info field.
479 template<int size>
480 unsigned int
481 elf_r_sym(typename Elf_types<size>::Elf_WXword);
483 template<>
484 inline unsigned int
485 elf_r_sym<32>(Elf_Word v)
487 return v >> 8;
490 template<>
491 inline unsigned int
492 elf_r_sym<64>(Elf_Xword v)
494 return v >> 32;
497 template<int size>
498 unsigned int
499 elf_r_type(typename Elf_types<size>::Elf_WXword);
501 template<>
502 inline unsigned int
503 elf_r_type<32>(Elf_Word v)
505 return v & 0xff;
508 template<>
509 inline unsigned int
510 elf_r_type<64>(Elf_Xword v)
512 return v & 0xffffffff;
515 template<int size>
516 typename Elf_types<size>::Elf_WXword
517 elf_r_info(unsigned int s, unsigned int t);
519 template<>
520 inline Elf_Word
521 elf_r_info<32>(unsigned int s, unsigned int t)
523 return (s << 8) + (t & 0xff);
526 template<>
527 inline Elf_Xword
528 elf_r_info<64>(unsigned int s, unsigned int t)
530 return (static_cast<Elf_Xword>(s) << 32) + (t & 0xffffffff);
533 // Dynamic tags found in the PT_DYNAMIC segment.
535 enum DT
537 DT_NULL = 0,
538 DT_NEEDED = 1,
539 DT_PLTRELSZ = 2,
540 DT_PLTGOT = 3,
541 DT_HASH = 4,
542 DT_STRTAB = 5,
543 DT_SYMTAB = 6,
544 DT_RELA = 7,
545 DT_RELASZ = 8,
546 DT_RELAENT = 9,
547 DT_STRSZ = 10,
548 DT_SYMENT = 11,
549 DT_INIT = 12,
550 DT_FINI = 13,
551 DT_SONAME = 14,
552 DT_RPATH = 15,
553 DT_SYMBOLIC = 16,
554 DT_REL = 17,
555 DT_RELSZ = 18,
556 DT_RELENT = 19,
557 DT_PLTREL = 20,
558 DT_DEBUG = 21,
559 DT_TEXTREL = 22,
560 DT_JMPREL = 23,
561 DT_BIND_NOW = 24,
562 DT_INIT_ARRAY = 25,
563 DT_FINI_ARRAY = 26,
564 DT_INIT_ARRAYSZ = 27,
565 DT_FINI_ARRAYSZ = 28,
566 DT_RUNPATH = 29,
567 DT_FLAGS = 30,
568 DT_ENCODING = 32,
569 DT_PREINIT_ARRAY = 33,
570 DT_PREINIT_ARRAYSZ = 33,
571 DT_LOOS = 0x6000000d,
572 DT_HIOS = 0x6ffff000,
573 DT_LOPROC = 0x70000000,
574 DT_HIPROC = 0x7fffffff,
576 // The remaining values are extensions used by GNU or Solaris.
577 DT_VALRNGLO = 0x6ffffd00,
578 DT_GNU_PRELINKED = 0x6ffffdf5,
579 DT_GNU_CONFLICTSZ = 0x6ffffdf6,
580 DT_GNU_LIBLISTSZ = 0x6ffffdf7,
581 DT_CHECKSUM = 0x6ffffdf8,
582 DT_PLTPADSZ = 0x6ffffdf9,
583 DT_MOVEENT = 0x6ffffdfa,
584 DT_MOVESZ = 0x6ffffdfb,
585 DT_FEATURE = 0x6ffffdfc,
586 DT_POSFLAG_1 = 0x6ffffdfd,
587 DT_SYMINSZ = 0x6ffffdfe,
588 DT_SYMINENT = 0x6ffffdff,
589 DT_VALRNGHI = 0x6ffffdff,
591 DT_ADDRRNGLO = 0x6ffffe00,
592 DT_GNU_HASH = 0x6ffffef5,
593 DT_TLSDESC_PLT = 0x6ffffef6,
594 DT_TLSDESC_GOT = 0x6ffffef7,
595 DT_GNU_CONFLICT = 0x6ffffef8,
596 DT_GNU_LIBLIST = 0x6ffffef9,
597 DT_CONFIG = 0x6ffffefa,
598 DT_DEPAUDIT = 0x6ffffefb,
599 DT_AUDIT = 0x6ffffefc,
600 DT_PLTPAD = 0x6ffffefd,
601 DT_MOVETAB = 0x6ffffefe,
602 DT_SYMINFO = 0x6ffffeff,
603 DT_ADDRRNGHI = 0x6ffffeff,
605 DT_RELACOUNT = 0x6ffffff9,
606 DT_RELCOUNT = 0x6ffffffa,
607 DT_FLAGS_1 = 0x6ffffffb,
608 DT_VERDEF = 0x6ffffffc,
609 DT_VERDEFNUM = 0x6ffffffd,
610 DT_VERNEED = 0x6ffffffe,
611 DT_VERNEEDNUM = 0x6fffffff,
613 DT_VERSYM = 0x6ffffff0,
615 DT_AUXILIARY = 0x7ffffffd,
616 DT_USED = 0x7ffffffe,
617 DT_FILTER = 0x7fffffff
620 // Flags found in the DT_FLAGS dynamic element.
622 enum DF
624 DF_ORIGIN = 0x1,
625 DF_SYMBOLIC = 0x2,
626 DF_TEXTREL = 0x4,
627 DF_BIND_NOW = 0x8,
628 DF_STATIC_TLS = 0x10
631 // Version numbers which appear in the vd_version field of a Verdef
632 // structure.
634 const int VER_DEF_NONE = 0;
635 const int VER_DEF_CURRENT = 1;
637 // Version numbers which appear in the vn_version field of a Verneed
638 // structure.
640 const int VER_NEED_NONE = 0;
641 const int VER_NEED_CURRENT = 1;
643 // Bit flags which appear in vd_flags of Verdef and vna_flags of
644 // Vernaux.
646 const int VER_FLG_BASE = 0x1;
647 const int VER_FLG_WEAK = 0x2;
649 // Special constants found in the SHT_GNU_versym entries.
651 const int VER_NDX_LOCAL = 0;
652 const int VER_NDX_GLOBAL = 1;
654 // A SHT_GNU_versym section holds 16-bit words. This bit is set if
655 // the symbol is hidden and can only be seen when referenced using an
656 // explicit version number. This is a GNU extension.
658 const int VERSYM_HIDDEN = 0x8000;
660 // This is the mask for the rest of the data in a word read from a
661 // SHT_GNU_versym section.
663 const int VERSYM_VERSION = 0x7fff;
665 } // End namespace elfcpp.
667 // Include internal details after defining the types.
668 #include "elfcpp_internal.h"
670 namespace elfcpp
673 // The offset of the ELF file header in the ELF file.
675 const int file_header_offset = 0;
677 // ELF structure sizes.
679 template<int size>
680 struct Elf_sizes
682 // Size of ELF file header.
683 static const int ehdr_size = sizeof(internal::Ehdr_data<size>);
684 // Size of ELF segment header.
685 static const int phdr_size = sizeof(internal::Phdr_data<size>);
686 // Size of ELF section header.
687 static const int shdr_size = sizeof(internal::Shdr_data<size>);
688 // Size of ELF symbol table entry.
689 static const int sym_size = sizeof(internal::Sym_data<size>);
690 // Sizes of ELF reloc entries.
691 static const int rel_size = sizeof(internal::Rel_data<size>);
692 static const int rela_size = sizeof(internal::Rela_data<size>);
693 // Size of ELF dynamic entry.
694 static const int dyn_size = sizeof(internal::Dyn_data<size>);
695 // Size of ELF version structures.
696 static const int verdef_size = sizeof(internal::Verdef_data);
697 static const int verdaux_size = sizeof(internal::Verdaux_data);
698 static const int verneed_size = sizeof(internal::Verneed_data);
699 static const int vernaux_size = sizeof(internal::Vernaux_data);
702 // Accessor class for the ELF file header.
704 template<int size, bool big_endian>
705 class Ehdr
707 public:
708 Ehdr(const unsigned char* p)
709 : p_(reinterpret_cast<const internal::Ehdr_data<size>*>(p))
712 template<typename File>
713 Ehdr(File* file, typename File::Location loc)
714 : p_(reinterpret_cast<const internal::Ehdr_data<size>*>(
715 file->view(loc.file_offset, loc.data_size).data()))
718 const unsigned char*
719 get_e_ident() const
720 { return this->p_->e_ident; }
722 Elf_Half
723 get_e_type() const
724 { return Convert<16, big_endian>::convert_host(this->p_->e_type); }
726 Elf_Half
727 get_e_machine() const
728 { return Convert<16, big_endian>::convert_host(this->p_->e_machine); }
730 Elf_Word
731 get_e_version() const
732 { return Convert<32, big_endian>::convert_host(this->p_->e_version); }
734 typename Elf_types<size>::Elf_Addr
735 get_e_entry() const
736 { return Convert<size, big_endian>::convert_host(this->p_->e_entry); }
738 typename Elf_types<size>::Elf_Off
739 get_e_phoff() const
740 { return Convert<size, big_endian>::convert_host(this->p_->e_phoff); }
742 typename Elf_types<size>::Elf_Off
743 get_e_shoff() const
744 { return Convert<size, big_endian>::convert_host(this->p_->e_shoff); }
746 Elf_Word
747 get_e_flags() const
748 { return Convert<32, big_endian>::convert_host(this->p_->e_flags); }
750 Elf_Half
751 get_e_ehsize() const
752 { return Convert<16, big_endian>::convert_host(this->p_->e_ehsize); }
754 Elf_Half
755 get_e_phentsize() const
756 { return Convert<16, big_endian>::convert_host(this->p_->e_phentsize); }
758 Elf_Half
759 get_e_phnum() const
760 { return Convert<16, big_endian>::convert_host(this->p_->e_phnum); }
762 Elf_Half
763 get_e_shentsize() const
764 { return Convert<16, big_endian>::convert_host(this->p_->e_shentsize); }
766 Elf_Half
767 get_e_shnum() const
768 { return Convert<16, big_endian>::convert_host(this->p_->e_shnum); }
770 Elf_Half
771 get_e_shstrndx() const
772 { return Convert<16, big_endian>::convert_host(this->p_->e_shstrndx); }
774 private:
775 const internal::Ehdr_data<size>* p_;
778 // Write class for the ELF file header.
780 template<int size, bool big_endian>
781 class Ehdr_write
783 public:
784 Ehdr_write(unsigned char* p)
785 : p_(reinterpret_cast<internal::Ehdr_data<size>*>(p))
788 void
789 put_e_ident(const unsigned char v[EI_NIDENT]) const
790 { memcpy(this->p_->e_ident, v, EI_NIDENT); }
792 void
793 put_e_type(Elf_Half v)
794 { this->p_->e_type = Convert<16, big_endian>::convert_host(v); }
796 void
797 put_e_machine(Elf_Half v)
798 { this->p_->e_machine = Convert<16, big_endian>::convert_host(v); }
800 void
801 put_e_version(Elf_Word v)
802 { this->p_->e_version = Convert<32, big_endian>::convert_host(v); }
804 void
805 put_e_entry(typename Elf_types<size>::Elf_Addr v)
806 { this->p_->e_entry = Convert<size, big_endian>::convert_host(v); }
808 void
809 put_e_phoff(typename Elf_types<size>::Elf_Off v)
810 { this->p_->e_phoff = Convert<size, big_endian>::convert_host(v); }
812 void
813 put_e_shoff(typename Elf_types<size>::Elf_Off v)
814 { this->p_->e_shoff = Convert<size, big_endian>::convert_host(v); }
816 void
817 put_e_flags(Elf_Word v)
818 { this->p_->e_flags = Convert<32, big_endian>::convert_host(v); }
820 void
821 put_e_ehsize(Elf_Half v)
822 { this->p_->e_ehsize = Convert<16, big_endian>::convert_host(v); }
824 void
825 put_e_phentsize(Elf_Half v)
826 { this->p_->e_phentsize = Convert<16, big_endian>::convert_host(v); }
828 void
829 put_e_phnum(Elf_Half v)
830 { this->p_->e_phnum = Convert<16, big_endian>::convert_host(v); }
832 void
833 put_e_shentsize(Elf_Half v)
834 { this->p_->e_shentsize = Convert<16, big_endian>::convert_host(v); }
836 void
837 put_e_shnum(Elf_Half v)
838 { this->p_->e_shnum = Convert<16, big_endian>::convert_host(v); }
840 void
841 put_e_shstrndx(Elf_Half v)
842 { this->p_->e_shstrndx = Convert<16, big_endian>::convert_host(v); }
844 private:
845 internal::Ehdr_data<size>* p_;
848 // Accessor class for an ELF section header.
850 template<int size, bool big_endian>
851 class Shdr
853 public:
854 Shdr(const unsigned char* p)
855 : p_(reinterpret_cast<const internal::Shdr_data<size>*>(p))
858 template<typename File>
859 Shdr(File* file, typename File::Location loc)
860 : p_(reinterpret_cast<const internal::Shdr_data<size>*>(
861 file->view(loc.file_offset, loc.data_size).data()))
864 Elf_Word
865 get_sh_name() const
866 { return Convert<32, big_endian>::convert_host(this->p_->sh_name); }
868 Elf_Word
869 get_sh_type() const
870 { return Convert<32, big_endian>::convert_host(this->p_->sh_type); }
872 typename Elf_types<size>::Elf_WXword
873 get_sh_flags() const
874 { return Convert<size, big_endian>::convert_host(this->p_->sh_flags); }
876 typename Elf_types<size>::Elf_Addr
877 get_sh_addr() const
878 { return Convert<size, big_endian>::convert_host(this->p_->sh_addr); }
880 typename Elf_types<size>::Elf_Off
881 get_sh_offset() const
882 { return Convert<size, big_endian>::convert_host(this->p_->sh_offset); }
884 typename Elf_types<size>::Elf_WXword
885 get_sh_size() const
886 { return Convert<size, big_endian>::convert_host(this->p_->sh_size); }
888 Elf_Word
889 get_sh_link() const
890 { return Convert<32, big_endian>::convert_host(this->p_->sh_link); }
892 Elf_Word
893 get_sh_info() const
894 { return Convert<32, big_endian>::convert_host(this->p_->sh_info); }
896 typename Elf_types<size>::Elf_WXword
897 get_sh_addralign() const
898 { return
899 Convert<size, big_endian>::convert_host(this->p_->sh_addralign); }
901 typename Elf_types<size>::Elf_WXword
902 get_sh_entsize() const
903 { return Convert<size, big_endian>::convert_host(this->p_->sh_entsize); }
905 private:
906 const internal::Shdr_data<size>* p_;
909 // Write class for an ELF section header.
911 template<int size, bool big_endian>
912 class Shdr_write
914 public:
915 Shdr_write(unsigned char* p)
916 : p_(reinterpret_cast<internal::Shdr_data<size>*>(p))
919 void
920 put_sh_name(Elf_Word v)
921 { this->p_->sh_name = Convert<32, big_endian>::convert_host(v); }
923 void
924 put_sh_type(Elf_Word v)
925 { this->p_->sh_type = Convert<32, big_endian>::convert_host(v); }
927 void
928 put_sh_flags(typename Elf_types<size>::Elf_WXword v)
929 { this->p_->sh_flags = Convert<size, big_endian>::convert_host(v); }
931 void
932 put_sh_addr(typename Elf_types<size>::Elf_Addr v)
933 { this->p_->sh_addr = Convert<size, big_endian>::convert_host(v); }
935 void
936 put_sh_offset(typename Elf_types<size>::Elf_Off v)
937 { this->p_->sh_offset = Convert<size, big_endian>::convert_host(v); }
939 void
940 put_sh_size(typename Elf_types<size>::Elf_WXword v)
941 { this->p_->sh_size = Convert<size, big_endian>::convert_host(v); }
943 void
944 put_sh_link(Elf_Word v)
945 { this->p_->sh_link = Convert<32, big_endian>::convert_host(v); }
947 void
948 put_sh_info(Elf_Word v)
949 { this->p_->sh_info = Convert<32, big_endian>::convert_host(v); }
951 void
952 put_sh_addralign(typename Elf_types<size>::Elf_WXword v)
953 { this->p_->sh_addralign = Convert<size, big_endian>::convert_host(v); }
955 void
956 put_sh_entsize(typename Elf_types<size>::Elf_WXword v)
957 { this->p_->sh_entsize = Convert<size, big_endian>::convert_host(v); }
959 private:
960 internal::Shdr_data<size>* p_;
963 // Accessor class for an ELF segment header.
965 template<int size, bool big_endian>
966 class Phdr
968 public:
969 Phdr(const unsigned char* p)
970 : p_(reinterpret_cast<const internal::Phdr_data<size>*>(p))
973 template<typename File>
974 Phdr(File* file, typename File::Location loc)
975 : p_(reinterpret_cast<internal::Phdr_data<size>*>(
976 file->view(loc.file_offset, loc.data_size).data()))
979 Elf_Word
980 get_p_type() const
981 { return Convert<32, big_endian>::convert_host(this->p_->p_type); }
983 typename Elf_types<size>::Elf_Off
984 get_p_offset() const
985 { return Convert<size, big_endian>::convert_host(this->p_->p_offset); }
987 typename Elf_types<size>::Elf_Addr
988 get_p_vaddr() const
989 { return Convert<size, big_endian>::convert_host(this->p_->p_vaddr); }
991 typename Elf_types<size>::Elf_Addr
992 get_p_paddr() const
993 { return Convert<size, big_endian>::convert_host(this->p_->p_paddr); }
995 typename Elf_types<size>::Elf_WXword
996 get_p_filesz() const
997 { return Convert<size, big_endian>::convert_host(this->p_->p_filesz); }
999 typename Elf_types<size>::Elf_WXword
1000 get_p_memsz() const
1001 { return Convert<size, big_endian>::convert_host(this->p_->p_memsz); }
1003 Elf_Word
1004 get_p_flags() const
1005 { return Convert<32, big_endian>::convert_host(this->p_->p_flags); }
1007 typename Elf_types<size>::Elf_WXword
1008 get_p_align() const
1009 { return Convert<size, big_endian>::convert_host(this->p_->p_align); }
1011 private:
1012 const internal::Phdr_data<size>* p_;
1015 // Write class for an ELF segment header.
1017 template<int size, bool big_endian>
1018 class Phdr_write
1020 public:
1021 Phdr_write(unsigned char* p)
1022 : p_(reinterpret_cast<internal::Phdr_data<size>*>(p))
1025 void
1026 put_p_type(Elf_Word v)
1027 { this->p_->p_type = Convert<32, big_endian>::convert_host(v); }
1029 void
1030 put_p_offset(typename Elf_types<size>::Elf_Off v)
1031 { this->p_->p_offset = Convert<size, big_endian>::convert_host(v); }
1033 void
1034 put_p_vaddr(typename Elf_types<size>::Elf_Addr v)
1035 { this->p_->p_vaddr = Convert<size, big_endian>::convert_host(v); }
1037 void
1038 put_p_paddr(typename Elf_types<size>::Elf_Addr v)
1039 { this->p_->p_paddr = Convert<size, big_endian>::convert_host(v); }
1041 void
1042 put_p_filesz(typename Elf_types<size>::Elf_WXword v)
1043 { this->p_->p_filesz = Convert<size, big_endian>::convert_host(v); }
1045 void
1046 put_p_memsz(typename Elf_types<size>::Elf_WXword v)
1047 { this->p_->p_memsz = Convert<size, big_endian>::convert_host(v); }
1049 void
1050 put_p_flags(Elf_Word v)
1051 { this->p_->p_flags = Convert<32, big_endian>::convert_host(v); }
1053 void
1054 put_p_align(typename Elf_types<size>::Elf_WXword v)
1055 { this->p_->p_align = Convert<size, big_endian>::convert_host(v); }
1057 private:
1058 internal::Phdr_data<size>* p_;
1061 // Accessor class for an ELF symbol table entry.
1063 template<int size, bool big_endian>
1064 class Sym
1066 public:
1067 Sym(const unsigned char* p)
1068 : p_(reinterpret_cast<const internal::Sym_data<size>*>(p))
1071 template<typename File>
1072 Sym(File* file, typename File::Location loc)
1073 : p_(reinterpret_cast<const internal::Sym_data<size>*>(
1074 file->view(loc.file_offset, loc.data_size).data()))
1077 Elf_Word
1078 get_st_name() const
1079 { return Convert<32, big_endian>::convert_host(this->p_->st_name); }
1081 typename Elf_types<size>::Elf_Addr
1082 get_st_value() const
1083 { return Convert<size, big_endian>::convert_host(this->p_->st_value); }
1085 typename Elf_types<size>::Elf_WXword
1086 get_st_size() const
1087 { return Convert<size, big_endian>::convert_host(this->p_->st_size); }
1089 unsigned char
1090 get_st_info() const
1091 { return this->p_->st_info; }
1094 get_st_bind() const
1095 { return elf_st_bind(this->get_st_info()); }
1098 get_st_type() const
1099 { return elf_st_type(this->get_st_info()); }
1101 unsigned char
1102 get_st_other() const
1103 { return this->p_->st_other; }
1106 get_st_visibility() const
1107 { return elf_st_visibility(this->get_st_other()); }
1109 unsigned char
1110 get_st_nonvis() const
1111 { return elf_st_nonvis(this->get_st_other()); }
1113 Elf_Half
1114 get_st_shndx() const
1115 { return Convert<16, big_endian>::convert_host(this->p_->st_shndx); }
1117 private:
1118 const internal::Sym_data<size>* p_;
1121 // Writer class for an ELF symbol table entry.
1123 template<int size, bool big_endian>
1124 class Sym_write
1126 public:
1127 Sym_write(unsigned char* p)
1128 : p_(reinterpret_cast<internal::Sym_data<size>*>(p))
1131 void
1132 put_st_name(Elf_Word v)
1133 { this->p_->st_name = Convert<32, big_endian>::convert_host(v); }
1135 void
1136 put_st_value(typename Elf_types<size>::Elf_Addr v)
1137 { this->p_->st_value = Convert<size, big_endian>::convert_host(v); }
1139 void
1140 put_st_size(typename Elf_types<size>::Elf_WXword v)
1141 { this->p_->st_size = Convert<size, big_endian>::convert_host(v); }
1143 void
1144 put_st_info(unsigned char v)
1145 { this->p_->st_info = v; }
1147 void
1148 put_st_info(STB bind, STT type)
1149 { this->p_->st_info = elf_st_info(bind, type); }
1151 void
1152 put_st_other(unsigned char v)
1153 { this->p_->st_other = v; }
1155 void
1156 put_st_other(STV vis, unsigned char nonvis)
1157 { this->p_->st_other = elf_st_other(vis, nonvis); }
1159 void
1160 put_st_shndx(Elf_Half v)
1161 { this->p_->st_shndx = Convert<16, big_endian>::convert_host(v); }
1163 Sym<size, big_endian>
1164 sym()
1165 { return Sym<size, big_endian>(reinterpret_cast<unsigned char*>(this->p_)); }
1167 private:
1168 internal::Sym_data<size>* p_;
1171 // Accessor classes for an ELF REL relocation entry.
1173 template<int size, bool big_endian>
1174 class Rel
1176 public:
1177 Rel(const unsigned char* p)
1178 : p_(reinterpret_cast<const internal::Rel_data<size>*>(p))
1181 template<typename File>
1182 Rel(File* file, typename File::Location loc)
1183 : p_(reinterpret_cast<const internal::Rel_data<size>*>(
1184 file->view(loc.file_offset, loc.data_size).data()))
1187 typename Elf_types<size>::Elf_Addr
1188 get_r_offset() const
1189 { return Convert<size, big_endian>::convert_host(this->p_->r_offset); }
1191 typename Elf_types<size>::Elf_WXword
1192 get_r_info() const
1193 { return Convert<size, big_endian>::convert_host(this->p_->r_info); }
1195 private:
1196 const internal::Rel_data<size>* p_;
1199 // Writer class for an ELF Rel relocation.
1201 template<int size, bool big_endian>
1202 class Rel_write
1204 public:
1205 Rel_write(unsigned char* p)
1206 : p_(reinterpret_cast<internal::Rel_data<size>*>(p))
1209 void
1210 put_r_offset(typename Elf_types<size>::Elf_Addr v)
1211 { this->p_->r_offset = Convert<size, big_endian>::convert_host(v); }
1213 void
1214 put_r_info(typename Elf_types<size>::Elf_WXword v)
1215 { this->p_->r_info = Convert<size, big_endian>::convert_host(v); }
1217 private:
1218 internal::Rel_data<size>* p_;
1221 // Accessor class for an ELF Rela relocation.
1223 template<int size, bool big_endian>
1224 class Rela
1226 public:
1227 Rela(const unsigned char* p)
1228 : p_(reinterpret_cast<const internal::Rela_data<size>*>(p))
1231 template<typename File>
1232 Rela(File* file, typename File::Location loc)
1233 : p_(reinterpret_cast<const internal::Rela_data<size>*>(
1234 file->view(loc.file_offset, loc.data_size).data()))
1237 typename Elf_types<size>::Elf_Addr
1238 get_r_offset() const
1239 { return Convert<size, big_endian>::convert_host(this->p_->r_offset); }
1241 typename Elf_types<size>::Elf_WXword
1242 get_r_info() const
1243 { return Convert<size, big_endian>::convert_host(this->p_->r_info); }
1245 typename Elf_types<size>::Elf_Swxword
1246 get_r_addend() const
1247 { return Convert<size, big_endian>::convert_host(this->p_->r_addend); }
1249 private:
1250 const internal::Rela_data<size>* p_;
1253 // Writer class for an ELF Rela relocation.
1255 template<int size, bool big_endian>
1256 class Rela_write
1258 public:
1259 Rela_write(unsigned char* p)
1260 : p_(reinterpret_cast<internal::Rela_data<size>*>(p))
1263 void
1264 put_r_offset(typename Elf_types<size>::Elf_Addr v)
1265 { this->p_->r_offset = Convert<size, big_endian>::convert_host(v); }
1267 void
1268 put_r_info(typename Elf_types<size>::Elf_WXword v)
1269 { this->p_->r_info = Convert<size, big_endian>::convert_host(v); }
1271 void
1272 put_r_addend(typename Elf_types<size>::Elf_Swxword v)
1273 { this->p_->r_addend = Convert<size, big_endian>::convert_host(v); }
1275 private:
1276 internal::Rela_data<size>* p_;
1279 // Accessor classes for entries in the ELF SHT_DYNAMIC section aka
1280 // PT_DYNAMIC segment.
1282 template<int size, bool big_endian>
1283 class Dyn
1285 public:
1286 Dyn(const unsigned char* p)
1287 : p_(reinterpret_cast<const internal::Dyn_data<size>*>(p))
1290 template<typename File>
1291 Dyn(File* file, typename File::Location loc)
1292 : p_(reinterpret_cast<const internal::Dyn_data<size>*>(
1293 file->view(loc.file_offset, loc.data_size).data()))
1296 typename Elf_types<size>::Elf_Swxword
1297 get_d_tag() const
1298 { return Convert<size, big_endian>::convert_host(this->p_->d_tag); }
1300 typename Elf_types<size>::Elf_WXword
1301 get_d_val() const
1302 { return Convert<size, big_endian>::convert_host(this->p_->d_val); }
1304 typename Elf_types<size>::Elf_Addr
1305 get_d_ptr() const
1306 { return Convert<size, big_endian>::convert_host(this->p_->d_val); }
1308 private:
1309 const internal::Dyn_data<size>* p_;
1312 // Write class for an entry in the SHT_DYNAMIC section.
1314 template<int size, bool big_endian>
1315 class Dyn_write
1317 public:
1318 Dyn_write(unsigned char* p)
1319 : p_(reinterpret_cast<internal::Dyn_data<size>*>(p))
1322 void
1323 put_d_tag(typename Elf_types<size>::Elf_Swxword v)
1324 { this->p_->d_tag = Convert<size, big_endian>::convert_host(v); }
1326 void
1327 put_d_val(typename Elf_types<size>::Elf_WXword v)
1328 { this->p_->d_val = Convert<size, big_endian>::convert_host(v); }
1330 void
1331 put_d_ptr(typename Elf_types<size>::Elf_Addr v)
1332 { this->p_->d_val = Convert<size, big_endian>::convert_host(v); }
1334 private:
1335 internal::Dyn_data<size>* p_;
1338 // Accessor classes for entries in the ELF SHT_GNU_verdef section.
1340 template<int size, bool big_endian>
1341 class Verdef
1343 public:
1344 Verdef(const unsigned char* p)
1345 : p_(reinterpret_cast<const internal::Verdef_data*>(p))
1348 template<typename File>
1349 Verdef(File* file, typename File::Location loc)
1350 : p_(reinterpret_cast<const internal::Verdef_data*>(
1351 file->view(loc.file_offset, loc.data_size).data()))
1354 Elf_Half
1355 get_vd_version() const
1356 { return Convert<16, big_endian>::convert_host(this->p_->vd_version); }
1358 Elf_Half
1359 get_vd_flags() const
1360 { return Convert<16, big_endian>::convert_host(this->p_->vd_flags); }
1362 Elf_Half
1363 get_vd_ndx() const
1364 { return Convert<16, big_endian>::convert_host(this->p_->vd_ndx); }
1366 Elf_Half
1367 get_vd_cnt() const
1368 { return Convert<16, big_endian>::convert_host(this->p_->vd_cnt); }
1370 Elf_Word
1371 get_vd_hash() const
1372 { return Convert<32, big_endian>::convert_host(this->p_->vd_hash); }
1374 Elf_Word
1375 get_vd_aux() const
1376 { return Convert<32, big_endian>::convert_host(this->p_->vd_aux); }
1378 Elf_Word
1379 get_vd_next() const
1380 { return Convert<32, big_endian>::convert_host(this->p_->vd_next); }
1382 private:
1383 const internal::Verdef_data* p_;
1386 template<int size, bool big_endian>
1387 class Verdef_write
1389 public:
1390 Verdef_write(unsigned char* p)
1391 : p_(reinterpret_cast<internal::Verdef_data*>(p))
1394 void
1395 set_vd_version(Elf_Half v)
1396 { this->p_->vd_version = Convert<16, big_endian>::convert_host(v); }
1398 void
1399 set_vd_flags(Elf_Half v)
1400 { this->p_->vd_flags = Convert<16, big_endian>::convert_host(v); }
1402 void
1403 set_vd_ndx(Elf_Half v)
1404 { this->p_->vd_ndx = Convert<16, big_endian>::convert_host(v); }
1406 void
1407 set_vd_cnt(Elf_Half v)
1408 { this->p_->vd_cnt = Convert<16, big_endian>::convert_host(v); }
1410 void
1411 set_vd_hash(Elf_Word v)
1412 { this->p_->vd_hash = Convert<32, big_endian>::convert_host(v); }
1414 void
1415 set_vd_aux(Elf_Word v)
1416 { this->p_->vd_aux = Convert<32, big_endian>::convert_host(v); }
1418 void
1419 set_vd_next(Elf_Word v)
1420 { this->p_->vd_next = Convert<32, big_endian>::convert_host(v); }
1422 private:
1423 internal::Verdef_data* p_;
1426 // Accessor classes for auxiliary entries in the ELF SHT_GNU_verdef
1427 // section.
1429 template<int size, bool big_endian>
1430 class Verdaux
1432 public:
1433 Verdaux(const unsigned char* p)
1434 : p_(reinterpret_cast<const internal::Verdaux_data*>(p))
1437 template<typename File>
1438 Verdaux(File* file, typename File::Location loc)
1439 : p_(reinterpret_cast<const internal::Verdaux_data*>(
1440 file->view(loc.file_offset, loc.data_size).data()))
1443 Elf_Word
1444 get_vda_name() const
1445 { return Convert<32, big_endian>::convert_host(this->p_->vda_name); }
1447 Elf_Word
1448 get_vda_next() const
1449 { return Convert<32, big_endian>::convert_host(this->p_->vda_next); }
1451 private:
1452 const internal::Verdaux_data* p_;
1455 template<int size, bool big_endian>
1456 class Verdaux_write
1458 public:
1459 Verdaux_write(unsigned char* p)
1460 : p_(reinterpret_cast<internal::Verdaux_data*>(p))
1463 void
1464 set_vda_name(Elf_Word v)
1465 { this->p_->vda_name = Convert<32, big_endian>::convert_host(v); }
1467 void
1468 set_vda_next(Elf_Word v)
1469 { this->p_->vda_next = Convert<32, big_endian>::convert_host(v); }
1471 private:
1472 internal::Verdaux_data* p_;
1475 // Accessor classes for entries in the ELF SHT_GNU_verneed section.
1477 template<int size, bool big_endian>
1478 class Verneed
1480 public:
1481 Verneed(const unsigned char* p)
1482 : p_(reinterpret_cast<const internal::Verneed_data*>(p))
1485 template<typename File>
1486 Verneed(File* file, typename File::Location loc)
1487 : p_(reinterpret_cast<const internal::Verneed_data*>(
1488 file->view(loc.file_offset, loc.data_size).data()))
1491 Elf_Half
1492 get_vn_version() const
1493 { return Convert<16, big_endian>::convert_host(this->p_->vn_version); }
1495 Elf_Half
1496 get_vn_cnt() const
1497 { return Convert<16, big_endian>::convert_host(this->p_->vn_cnt); }
1499 Elf_Word
1500 get_vn_file() const
1501 { return Convert<32, big_endian>::convert_host(this->p_->vn_file); }
1503 Elf_Word
1504 get_vn_aux() const
1505 { return Convert<32, big_endian>::convert_host(this->p_->vn_aux); }
1507 Elf_Word
1508 get_vn_next() const
1509 { return Convert<32, big_endian>::convert_host(this->p_->vn_next); }
1511 private:
1512 const internal::Verneed_data* p_;
1515 template<int size, bool big_endian>
1516 class Verneed_write
1518 public:
1519 Verneed_write(unsigned char* p)
1520 : p_(reinterpret_cast<internal::Verneed_data*>(p))
1523 void
1524 set_vn_version(Elf_Half v)
1525 { this->p_->vn_version = Convert<16, big_endian>::convert_host(v); }
1527 void
1528 set_vn_cnt(Elf_Half v)
1529 { this->p_->vn_cnt = Convert<16, big_endian>::convert_host(v); }
1531 void
1532 set_vn_file(Elf_Word v)
1533 { this->p_->vn_file = Convert<32, big_endian>::convert_host(v); }
1535 void
1536 set_vn_aux(Elf_Word v)
1537 { this->p_->vn_aux = Convert<32, big_endian>::convert_host(v); }
1539 void
1540 set_vn_next(Elf_Word v)
1541 { this->p_->vn_next = Convert<32, big_endian>::convert_host(v); }
1543 private:
1544 internal::Verneed_data* p_;
1547 // Accessor classes for auxiliary entries in the ELF SHT_GNU_verneed
1548 // section.
1550 template<int size, bool big_endian>
1551 class Vernaux
1553 public:
1554 Vernaux(const unsigned char* p)
1555 : p_(reinterpret_cast<const internal::Vernaux_data*>(p))
1558 template<typename File>
1559 Vernaux(File* file, typename File::Location loc)
1560 : p_(reinterpret_cast<const internal::Vernaux_data*>(
1561 file->view(loc.file_offset, loc.data_size).data()))
1564 Elf_Word
1565 get_vna_hash() const
1566 { return Convert<32, big_endian>::convert_host(this->p_->vna_hash); }
1568 Elf_Half
1569 get_vna_flags() const
1570 { return Convert<16, big_endian>::convert_host(this->p_->vna_flags); }
1572 Elf_Half
1573 get_vna_other() const
1574 { return Convert<16, big_endian>::convert_host(this->p_->vna_other); }
1576 Elf_Word
1577 get_vna_name() const
1578 { return Convert<32, big_endian>::convert_host(this->p_->vna_name); }
1580 Elf_Word
1581 get_vna_next() const
1582 { return Convert<32, big_endian>::convert_host(this->p_->vna_next); }
1584 private:
1585 const internal::Vernaux_data* p_;
1588 template<int size, bool big_endian>
1589 class Vernaux_write
1591 public:
1592 Vernaux_write(unsigned char* p)
1593 : p_(reinterpret_cast<internal::Vernaux_data*>(p))
1596 void
1597 set_vna_hash(Elf_Word v)
1598 { this->p_->vna_hash = Convert<32, big_endian>::convert_host(v); }
1600 void
1601 set_vna_flags(Elf_Half v)
1602 { this->p_->vna_flags = Convert<16, big_endian>::convert_host(v); }
1604 void
1605 set_vna_other(Elf_Half v)
1606 { this->p_->vna_other = Convert<16, big_endian>::convert_host(v); }
1608 void
1609 set_vna_name(Elf_Word v)
1610 { this->p_->vna_name = Convert<32, big_endian>::convert_host(v); }
1612 void
1613 set_vna_next(Elf_Word v)
1614 { this->p_->vna_next = Convert<32, big_endian>::convert_host(v); }
1616 private:
1617 internal::Vernaux_data* p_;
1620 } // End namespace elfcpp.
1622 #endif // !defined(ELFPCP_H)