2007-06-29 H.J. Lu <hongjiu.lu@intel.com>
[deliverable/binutils-gdb.git] / elfcpp / elfcpp_internal.h
CommitLineData
bae7f79e
ILT
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
bae7f79e
ILT
8#ifndef ELFCPP_INTERNAL_H
9#define ELFCPP_INTERNAL_H
10
11namespace elfcpp
12{
13
14namespace internal
15{
16
bae7f79e
ILT
17// The ELF file header.
18
19template<int size>
20struct 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
dbe717ef 38// An ELF section header.
bae7f79e
ILT
39
40template<int size>
41struct 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
39081c14
ILT
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
59template<int size>
60struct Phdr_data;
61
62template<>
63struct 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
75template<>
76struct 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
bae7f79e
ILT
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
92template<int size>
93struct Sym_data;
94
95template<>
96struct 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
106template<>
107struct 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
dbe717ef 117// ELF relocation table entries.
61ba1cf9
ILT
118
119template<int size>
120struct Rel_data
121{
122 typename Elf_types<size>::Elf_Addr r_offset;
123 typename Elf_types<size>::Elf_WXword r_info;
124};
125
126template<int size>
127struct 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
dbe717ef
ILT
134// An entry in the ELF SHT_DYNAMIC section aka PT_DYNAMIC segment.
135
136template<int size>
137struct Dyn_data
138{
139 typename Elf_types<size>::Elf_Swxword d_tag;
140 typename Elf_types<size>::Elf_WXword d_val;
141};
142
143// An entry in a SHT_GNU_verdef section. This structure is the same
144// in 32-bit and 64-bit ELF files.
145
146struct Verdef_data
147{
148 // Version number of structure (VER_DEF_*).
149 Elf_Half vd_version;
150 // Bit flags (VER_FLG_*).
151 Elf_Half vd_flags;
152 // Version index.
153 Elf_Half vd_ndx;
154 // Number of auxiliary Verdaux entries.
155 Elf_Half vd_cnt;
156 // Hash of name.
157 Elf_Word vd_hash;
158 // Byte offset to first Verdaux entry.
159 Elf_Word vd_aux;
160 // Byte offset to next Verdef entry.
161 Elf_Word vd_next;
162};
163
164// An auxiliary entry in a SHT_GNU_verdef section. This structure is
165// the same in 32-bit and 64-bit ELF files.
166
167struct Verdaux_data
168{
169 // Offset in string table of version name.
170 Elf_Word vda_name;
171 // Byte offset to next Verdaux entry.
172 Elf_Word vda_next;
173};
174
175// An entry in a SHT_GNU_verneed section. This structure is the same
176// in 32-bit and 64-bit ELF files.
177
178struct Verneed_data
179{
180 // Version number of structure (VER_NEED_*).
181 Elf_Half vn_version;
182 // Number of auxiliary Vernaux entries.
183 Elf_Half vn_cnt;
184 // Offset in string table of library name.
185 Elf_Word vn_file;
186 // Byte offset to first Vernaux entry.
187 Elf_Word vn_aux;
188 // Byt eoffset to next Verneed entry.
189 Elf_Word vn_next;
190};
191
192// An auxiliary entry in a SHT_GNU_verneed section. This structure is
193// the same in 32-bit and 64-bit ELF files.
194
195struct Vernaux_data
196{
197 // Hash of dependency name.
198 Elf_Word vna_hash;
199 // Bit flags (VER_FLG_*).
200 Elf_Half vna_flags;
201 // Version index used in SHT_GNU_versym entries.
202 Elf_Half vna_other;
203 // Offset in string table of version name.
204 Elf_Word vna_name;
205 // Byte offset to next Vernaux entry.
206 Elf_Word vna_next;
207};
208
bae7f79e
ILT
209} // End namespace internal.
210
211} // End namespace elfcpp.
212
213#endif // !defined(ELFCPP_INTERNAL_H)
This page took 0.05378 seconds and 4 git commands to generate.