diff options
author | Ian Lance Taylor <iant@google.com> | 2006-11-06 22:45:08 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2006-11-06 22:45:08 +0000 |
commit | 8d9455b422d98d97f090923445aa2680e6882f20 (patch) | |
tree | 9b16d37baa6189eeb6e947bad643d27c1f717955 /elfcpp/elfcpp_internal.h | |
parent | 000ef4f0ec1b3d35dc93e6f0cd2ab830693394cb (diff) | |
download | gdb-8d9455b422d98d97f090923445aa2680e6882f20.zip gdb-8d9455b422d98d97f090923445aa2680e6882f20.tar.gz gdb-8d9455b422d98d97f090923445aa2680e6882f20.tar.bz2 |
Rework swapping code.
Diffstat (limited to 'elfcpp/elfcpp_internal.h')
-rw-r--r-- | elfcpp/elfcpp_internal.h | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/elfcpp/elfcpp_internal.h b/elfcpp/elfcpp_internal.h index e4c8636..c991535 100644 --- a/elfcpp/elfcpp_internal.h +++ b/elfcpp/elfcpp_internal.h @@ -5,8 +5,6 @@ #include "elfcpp_config.h" -#include <byteswap.h> - #ifndef ELFCPP_INTERNAL_H #define ELFCPP_INTERNAL_H @@ -16,163 +14,6 @@ namespace elfcpp namespace internal { -#ifdef WORDS_BIGENDIAN -const bool host_big_endian = true; -#else -const bool host_big_endian = false; -#endif - -// Conversion routines between target and host. - -// Convert Elf_Half. - -template<bool same_endian> -Elf_Half -convert_half_host(Elf_Half v); - -template<> -inline Elf_Half -convert_half_host<true>(Elf_Half v) -{ - return v; -} - -template<> -inline Elf_Half -convert_half_host<false>(Elf_Half v) -{ - return bswap_16(v); -} - -template<bool big_endian> -inline Elf_Half -convert_half(Elf_Half v) -{ - return convert_half_host<big_endian == host_big_endian>(v); -} - -// Convert Elf_Word. - -template<bool same_endian> -Elf_Word -convert_word_host(Elf_Word v); - -template<> -inline Elf_Word -convert_word_host<true>(Elf_Word v) -{ - return v; -} - -template<> -inline Elf_Word -convert_word_host<false>(Elf_Word v) -{ - return bswap_32(v); -} - -template<bool big_endian> -inline Elf_Word -convert_word(Elf_Word v) -{ - return convert_word_host<big_endian == host_big_endian>(v); -} - -// Convert Elf_Xword. - -template<bool same_endian> -Elf_Xword -convert_xword_host(Elf_Xword v); - -template<> -inline Elf_Xword -convert_xword_host<true>(Elf_Xword v) -{ - return v; -} - -template<> -inline Elf_Xword -convert_xword_host<false>(Elf_Xword v) -{ - return bswap_64(v); -} - -template<bool big_endian> -inline Elf_Xword -convert_xword(Elf_Xword v) -{ - return convert_xword_host<big_endian == host_big_endian>(v); -} - -// Convert Elf_addr. - -template<int size, bool same_endian> -typename Elf_types<size>::Elf_Addr -convert_addr_size(typename Elf_types<size>::Elf_Addr); - -template<> -inline Elf_types<32>::Elf_Addr -convert_addr_size<32, true>(Elf_types<32>::Elf_Addr v) -{ - return v; -} - -template<> -inline Elf_types<64>::Elf_Addr -convert_addr_size<64, true>(Elf_types<64>::Elf_Addr v) -{ - return v; -} - -template<> -inline Elf_types<32>::Elf_Addr -convert_addr_size<32, false>(Elf_types<32>::Elf_Addr v) -{ - return bswap_32(v); -} - -template<> -inline Elf_types<64>::Elf_Addr -convert_addr_size<64, false>(Elf_types<64>::Elf_Addr v) -{ - return bswap_64(v); -} - -template<int size, bool big_endian> -inline typename Elf_types<size>::Elf_Addr -convert_addr(typename Elf_types<size>::Elf_Addr v) -{ - return convert_addr_size<size, big_endian == host_big_endian>(v); -} - -// Convert Elf_Off. - -template<int size, bool big_endian> -inline typename Elf_types<size>::Elf_Off -convert_off(typename Elf_types<size>::Elf_Off v) -{ - return convert_addr_size<size, big_endian == host_big_endian>(v); -} - -// Convert Elf_WXword. - -template<int size, bool big_endian> -inline typename Elf_types<size>::Elf_WXword -convert_wxword(typename Elf_types<size>::Elf_WXword v) -{ - return convert_addr_size<size, big_endian == host_big_endian>(v); -} - -// Convert ELF_Swxword. - -template<int size, bool big_endian> -inline typename Elf_types<size>::Elf_Swxword -convert_swxword(typename Elf_types<size>::Elf_Swxword v) -{ - return convert_addr_size<size, big_endian == host_big_endian>(v); -} - // The ELF file header. template<int size> |