Mention PR ld/4701.
[deliverable/binutils-gdb.git] / elfcpp / elfcpp_internal.h
index f4dd8bd519542addb999ebe9975fa9a51de8a07e..7a2b5d4836bd8420fa83e21cd82b6d75a12058ee 100644 (file)
@@ -5,8 +5,6 @@
 
 #include "elfcpp_config.h"
 
-#include <byteswap.h>
-
 #ifndef ELFCPP_INTERNAL_H
 #define ELFCPP_INTERNAL_H
 
@@ -16,154 +14,6 @@ namespace elfcpp
 namespace internal
 {
 
-#ifdef WORDS_BIG_ENDIAN
-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_Off
-convert_wxword(typename Elf_types<size>::Elf_Off v)
-{
-  return convert_addr_size<size, big_endian == host_big_endian>(v);
-}
-
 // The ELF file header.
 
 template<int size>
@@ -185,7 +35,7 @@ struct Ehdr_data
   Elf_Half e_shstrndx;
 };
 
-// An Elf section header.
+// An ELF section header.
 
 template<int size>
 struct Shdr_data
@@ -202,6 +52,39 @@ struct Shdr_data
   typename Elf_types<size>::Elf_WXword sh_entsize;
 };
 
+// An ELF segment header.  We use template specialization for the
+// 32-bit and 64-bit versions because the fields are in a different
+// order.
+
+template<int size>
+struct Phdr_data;
+
+template<>
+struct Phdr_data<32>
+{
+  Elf_Word p_type;
+  Elf_types<32>::Elf_Off p_offset;
+  Elf_types<32>::Elf_Addr p_vaddr;
+  Elf_types<32>::Elf_Addr p_paddr;
+  Elf_Word p_filesz;
+  Elf_Word p_memsz;
+  Elf_Word p_flags;
+  Elf_Word p_align;
+};
+
+template<>
+struct Phdr_data<64>
+{
+  Elf_Word p_type;
+  Elf_Word p_flags;
+  Elf_types<64>::Elf_Off p_offset;
+  Elf_types<64>::Elf_Addr p_vaddr;
+  Elf_types<64>::Elf_Addr p_paddr;
+  Elf_Xword p_filesz;
+  Elf_Xword p_memsz;
+  Elf_Xword p_align;
+};
+
 // An ELF symbol table entry.  We use template specialization for the
 // 32-bit and 64-bit versions because the fields are in a different
 // order.
@@ -231,6 +114,98 @@ struct Sym_data<64>
   Elf_Xword st_size;
 };
 
+// ELF relocation table entries.
+
+template<int size>
+struct Rel_data
+{
+  typename Elf_types<size>::Elf_Addr r_offset;
+  typename Elf_types<size>::Elf_WXword r_info;
+};
+
+template<int size>
+struct Rela_data
+{
+  typename Elf_types<size>::Elf_Addr r_offset;
+  typename Elf_types<size>::Elf_WXword r_info;
+  typename Elf_types<size>::Elf_Swxword r_addend;
+};
+
+// An entry in the ELF SHT_DYNAMIC section aka PT_DYNAMIC segment.
+
+template<int size>
+struct Dyn_data
+{
+  typename Elf_types<size>::Elf_Swxword d_tag;
+  typename Elf_types<size>::Elf_WXword d_val;
+};
+
+// An entry in a SHT_GNU_verdef section.  This structure is the same
+// in 32-bit and 64-bit ELF files.
+
+struct Verdef_data
+{
+  // Version number of structure (VER_DEF_*).
+  Elf_Half vd_version;
+  // Bit flags (VER_FLG_*).
+  Elf_Half vd_flags;
+  // Version index.
+  Elf_Half vd_ndx;
+  // Number of auxiliary Verdaux entries.
+  Elf_Half vd_cnt;
+  // Hash of name.
+  Elf_Word vd_hash;
+  // Byte offset to first Verdaux entry.
+  Elf_Word vd_aux;
+  // Byte offset to next Verdef entry.
+  Elf_Word vd_next;
+};
+
+// An auxiliary entry in a SHT_GNU_verdef section.  This structure is
+// the same in 32-bit and 64-bit ELF files.
+
+struct Verdaux_data
+{
+  // Offset in string table of version name.
+  Elf_Word vda_name;
+  // Byte offset to next Verdaux entry.
+  Elf_Word vda_next;
+};
+
+// An entry in a SHT_GNU_verneed section.  This structure is the same
+// in 32-bit and 64-bit ELF files.
+
+struct Verneed_data
+{
+  // Version number of structure (VER_NEED_*).
+  Elf_Half vn_version;
+  // Number of auxiliary Vernaux entries.
+  Elf_Half vn_cnt;
+  // Offset in string table of library name.
+  Elf_Word vn_file;
+  // Byte offset to first Vernaux entry.
+  Elf_Word vn_aux;
+  // Byt eoffset to next Verneed entry.
+  Elf_Word vn_next;
+};
+
+// An auxiliary entry in a SHT_GNU_verneed section.  This structure is
+// the same in 32-bit and 64-bit ELF files.
+
+struct Vernaux_data
+{
+  // Hash of dependency name.
+  Elf_Word vna_hash;
+  // Bit flags (VER_FLG_*).
+  Elf_Half vna_flags;
+  // Version index used in SHT_GNU_versym entries.
+  Elf_Half vna_other;
+  // Offset in string table of version name.
+  Elf_Word vna_name;
+  // Byte offset to next Vernaux entry.
+  Elf_Word vna_next;
+};
+
 } // End namespace internal.
 
 } // End namespace elfcpp.
This page took 0.026012 seconds and 4 git commands to generate.