1 // elfcpp_internal.h -- internals for elfcpp -*- C++ -*-
3 // This is included by elfcpp.h, the external interface, but holds
4 // information which we want to keep private.
6 #include "elfcpp_config.h"
10 #ifndef ELFCPP_INTERNAL_H
11 #define ELFCPP_INTERNAL_H
19 #ifdef WORDS_BIGENDIAN
20 const bool host_big_endian
= true;
22 const bool host_big_endian
= false;
25 // Conversion routines between target and host.
29 template<bool same_endian
>
31 convert_half_host(Elf_Half v
);
35 convert_half_host
<true>(Elf_Half v
)
42 convert_half_host
<false>(Elf_Half v
)
47 template<bool big_endian
>
49 convert_half(Elf_Half v
)
51 return convert_half_host
<big_endian
== host_big_endian
>(v
);
56 template<bool same_endian
>
58 convert_word_host(Elf_Word v
);
62 convert_word_host
<true>(Elf_Word v
)
69 convert_word_host
<false>(Elf_Word v
)
74 template<bool big_endian
>
76 convert_word(Elf_Word v
)
78 return convert_word_host
<big_endian
== host_big_endian
>(v
);
83 template<bool same_endian
>
85 convert_xword_host(Elf_Xword v
);
89 convert_xword_host
<true>(Elf_Xword v
)
96 convert_xword_host
<false>(Elf_Xword v
)
101 template<bool big_endian
>
103 convert_xword(Elf_Xword v
)
105 return convert_xword_host
<big_endian
== host_big_endian
>(v
);
110 template<int size
, bool same_endian
>
111 typename Elf_types
<size
>::Elf_Addr
112 convert_addr_size(typename Elf_types
<size
>::Elf_Addr
);
115 inline Elf_types
<32>::Elf_Addr
116 convert_addr_size
<32, true>(Elf_types
<32>::Elf_Addr v
)
122 inline Elf_types
<64>::Elf_Addr
123 convert_addr_size
<64, true>(Elf_types
<64>::Elf_Addr v
)
129 inline Elf_types
<32>::Elf_Addr
130 convert_addr_size
<32, false>(Elf_types
<32>::Elf_Addr v
)
136 inline Elf_types
<64>::Elf_Addr
137 convert_addr_size
<64, false>(Elf_types
<64>::Elf_Addr v
)
142 template<int size
, bool big_endian
>
143 inline typename Elf_types
<size
>::Elf_Addr
144 convert_addr(typename Elf_types
<size
>::Elf_Addr v
)
146 return convert_addr_size
<size
, big_endian
== host_big_endian
>(v
);
151 template<int size
, bool big_endian
>
152 inline typename Elf_types
<size
>::Elf_Off
153 convert_off(typename Elf_types
<size
>::Elf_Off v
)
155 return convert_addr_size
<size
, big_endian
== host_big_endian
>(v
);
158 // Convert Elf_WXword.
160 template<int size
, bool big_endian
>
161 inline typename Elf_types
<size
>::Elf_WXword
162 convert_wxword(typename Elf_types
<size
>::Elf_WXword v
)
164 return convert_addr_size
<size
, big_endian
== host_big_endian
>(v
);
167 // Convert ELF_Swxword.
169 template<int size
, bool big_endian
>
170 inline typename Elf_types
<size
>::Elf_Swxword
171 convert_swxword(typename Elf_types
<size
>::Elf_Swxword v
)
173 return convert_addr_size
<size
, big_endian
== host_big_endian
>(v
);
176 // The ELF file header.
181 unsigned char e_ident
[EI_NIDENT
];
185 typename Elf_types
<size
>::Elf_Addr e_entry
;
186 typename Elf_types
<size
>::Elf_Off e_phoff
;
187 typename Elf_types
<size
>::Elf_Off e_shoff
;
190 Elf_Half e_phentsize
;
192 Elf_Half e_shentsize
;
197 // An Elf section header.
204 typename Elf_types
<size
>::Elf_WXword sh_flags
;
205 typename Elf_types
<size
>::Elf_Addr sh_addr
;
206 typename Elf_types
<size
>::Elf_Off sh_offset
;
207 typename Elf_types
<size
>::Elf_WXword sh_size
;
210 typename Elf_types
<size
>::Elf_WXword sh_addralign
;
211 typename Elf_types
<size
>::Elf_WXword sh_entsize
;
214 // An ELF segment header. We use template specialization for the
215 // 32-bit and 64-bit versions because the fields are in a different
225 Elf_types
<32>::Elf_Off p_offset
;
226 Elf_types
<32>::Elf_Addr p_vaddr
;
227 Elf_types
<32>::Elf_Addr p_paddr
;
239 Elf_types
<64>::Elf_Off p_offset
;
240 Elf_types
<64>::Elf_Addr p_vaddr
;
241 Elf_types
<64>::Elf_Addr p_paddr
;
247 // An ELF symbol table entry. We use template specialization for the
248 // 32-bit and 64-bit versions because the fields are in a different
258 Elf_types
<32>::Elf_Addr st_value
;
260 unsigned char st_info
;
261 unsigned char st_other
;
269 unsigned char st_info
;
270 unsigned char st_other
;
272 Elf_types
<64>::Elf_Addr st_value
;
276 // Elf relocation table entries.
281 typename Elf_types
<size
>::Elf_Addr r_offset
;
282 typename Elf_types
<size
>::Elf_WXword r_info
;
288 typename Elf_types
<size
>::Elf_Addr r_offset
;
289 typename Elf_types
<size
>::Elf_WXword r_info
;
290 typename Elf_types
<size
>::Elf_Swxword r_addend
;
293 } // End namespace internal.
295 } // End namespace elfcpp.
297 #endif // !defined(ELFCPP_INTERNAL_H)
This page took 0.036037 seconds and 5 git commands to generate.