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_BIG_ENDIAN
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_Off
162 convert_wxword(typename Elf_types<size>::Elf_Off v)
164 return convert_addr_size<size, big_endian == host_big_endian>(v);
167 // The ELF file header.
172 unsigned char e_ident[EI_NIDENT];
176 typename Elf_types<size>::Elf_Addr e_entry;
177 typename Elf_types<size>::Elf_Off e_phoff;
178 typename Elf_types<size>::Elf_Off e_shoff;
181 Elf_Half e_phentsize;
183 Elf_Half e_shentsize;
188 // An Elf section header.
195 typename Elf_types<size>::Elf_WXword sh_flags;
196 typename Elf_types<size>::Elf_Addr sh_addr;
197 typename Elf_types<size>::Elf_Off sh_offset;
198 typename Elf_types<size>::Elf_WXword sh_size;
201 typename Elf_types<size>::Elf_WXword sh_addralign;
202 typename Elf_types<size>::Elf_WXword sh_entsize;
205 // An ELF symbol table entry. We use template specialization for the
206 // 32-bit and 64-bit versions because the fields are in a different
216 Elf_types<32>::Elf_Addr st_value;
218 unsigned char st_info;
219 unsigned char st_other;
227 unsigned char st_info;
228 unsigned char st_other;
230 Elf_types<64>::Elf_Addr st_value;
234 } // End namespace internal.
236 } // End namespace elfcpp.
238 #endif // !defined(ELFCPP_INTERNAL_H)