Rework swapping code.
[deliverable/binutils-gdb.git] / elfcpp / elfcpp_internal.h
1 // elfcpp_internal.h -- internals for elfcpp -*- C++ -*-
2
3 // This is included by elfcpp.h, the external interface, but holds
4 // information which we want to keep private.
5
6 #include "elfcpp_config.h"
7
8 #ifndef ELFCPP_INTERNAL_H
9 #define ELFCPP_INTERNAL_H
10
11 namespace elfcpp
12 {
13
14 namespace internal
15 {
16
17 // The ELF file header.
18
19 template<int size>
20 struct Ehdr_data
21 {
22 unsigned char e_ident[EI_NIDENT];
23 Elf_Half e_type;
24 Elf_Half e_machine;
25 Elf_Word e_version;
26 typename Elf_types<size>::Elf_Addr e_entry;
27 typename Elf_types<size>::Elf_Off e_phoff;
28 typename Elf_types<size>::Elf_Off e_shoff;
29 Elf_Word e_flags;
30 Elf_Half e_ehsize;
31 Elf_Half e_phentsize;
32 Elf_Half e_phnum;
33 Elf_Half e_shentsize;
34 Elf_Half e_shnum;
35 Elf_Half e_shstrndx;
36 };
37
38 // An Elf section header.
39
40 template<int size>
41 struct Shdr_data
42 {
43 Elf_Word sh_name;
44 Elf_Word sh_type;
45 typename Elf_types<size>::Elf_WXword sh_flags;
46 typename Elf_types<size>::Elf_Addr sh_addr;
47 typename Elf_types<size>::Elf_Off sh_offset;
48 typename Elf_types<size>::Elf_WXword sh_size;
49 Elf_Word sh_link;
50 Elf_Word sh_info;
51 typename Elf_types<size>::Elf_WXword sh_addralign;
52 typename Elf_types<size>::Elf_WXword sh_entsize;
53 };
54
55 // An ELF segment header. We use template specialization for the
56 // 32-bit and 64-bit versions because the fields are in a different
57 // order.
58
59 template<int size>
60 struct Phdr_data;
61
62 template<>
63 struct Phdr_data<32>
64 {
65 Elf_Word p_type;
66 Elf_types<32>::Elf_Off p_offset;
67 Elf_types<32>::Elf_Addr p_vaddr;
68 Elf_types<32>::Elf_Addr p_paddr;
69 Elf_Word p_filesz;
70 Elf_Word p_memsz;
71 Elf_Word p_flags;
72 Elf_Word p_align;
73 };
74
75 template<>
76 struct Phdr_data<64>
77 {
78 Elf_Word p_type;
79 Elf_Word p_flags;
80 Elf_types<64>::Elf_Off p_offset;
81 Elf_types<64>::Elf_Addr p_vaddr;
82 Elf_types<64>::Elf_Addr p_paddr;
83 Elf_Xword p_filesz;
84 Elf_Xword p_memsz;
85 Elf_Xword p_align;
86 };
87
88 // An ELF symbol table entry. We use template specialization for the
89 // 32-bit and 64-bit versions because the fields are in a different
90 // order.
91
92 template<int size>
93 struct Sym_data;
94
95 template<>
96 struct Sym_data<32>
97 {
98 Elf_Word st_name;
99 Elf_types<32>::Elf_Addr st_value;
100 Elf_Word st_size;
101 unsigned char st_info;
102 unsigned char st_other;
103 Elf_Half st_shndx;
104 };
105
106 template<>
107 struct Sym_data<64>
108 {
109 Elf_Word st_name;
110 unsigned char st_info;
111 unsigned char st_other;
112 Elf_Half st_shndx;
113 Elf_types<64>::Elf_Addr st_value;
114 Elf_Xword st_size;
115 };
116
117 // Elf relocation table entries.
118
119 template<int size>
120 struct Rel_data
121 {
122 typename Elf_types<size>::Elf_Addr r_offset;
123 typename Elf_types<size>::Elf_WXword r_info;
124 };
125
126 template<int size>
127 struct Rela_data
128 {
129 typename Elf_types<size>::Elf_Addr r_offset;
130 typename Elf_types<size>::Elf_WXword r_info;
131 typename Elf_types<size>::Elf_Swxword r_addend;
132 };
133
134 } // End namespace internal.
135
136 } // End namespace elfcpp.
137
138 #endif // !defined(ELFCPP_INTERNAL_H)
This page took 0.040012 seconds and 5 git commands to generate.