Support 64-bit entry size in SHT_HASH (for s390).
authorMarcin Kościelnicki <koriakin@0x04.net>
Mon, 5 Oct 2015 14:57:11 +0000 (16:57 +0200)
committerCary Coutant <ccoutant@gmail.com>
Wed, 28 Oct 2015 23:45:37 +0000 (16:45 -0700)
gold/
* dynobj.cc (Dynobj::create_elf_hash_table): Create hash table with
target-specific entry size.
(Dynobj::sized_create_elf_hash_table): Add size template parameter.
* dynobj.h (Dynobj::sized_create_elf_hash_table): Likewise.
* layout.cc (Layout::create_dynamic_symtab): Set entsize to
hash_entry_size.
* target.h (Target::hash_entry_size): New method.
(Target::Target_info::hash_entry_size): New data member.

* aarch64.cc (Target_aarch64::aarch64_info): Add hash_entry_size.
* arm.cc (Target_arm::arm_info): Likewise.
(Target_arm_nacl::arm_nacl_info): Likewise.
* i386.cc (Target_i386::i386_info): Likewise.
(Target_i386_nacl::i386_nacl_info): Likewise.
(Target_iamcu::iamcu_info): Likewise.
* mips.cc (Target_mips::mips_info): Likewise.
(Target_mips_nacl::mips_nacl_info): Likewise.
* powerpc.cc (Target_powerpc::powerpc_info): Likewise.
* sparc.cc (Target_sparc::sparc_info): Likewise.
* tilegx.cc (Target_tilegx::tilegx_info): Likewise.
* x86_64.cc (Target_x86_64::x86_64_info): Likewise.
(Target_x86_64_nacl::x86_64_nacl_info): Likewise.
* testsuite/testfile.cc (Target_test::test_target_info): Likewise.

14 files changed:
gold/ChangeLog
gold/aarch64.cc
gold/arm.cc
gold/dynobj.cc
gold/dynobj.h
gold/i386.cc
gold/layout.cc
gold/mips.cc
gold/powerpc.cc
gold/sparc.cc
gold/target.h
gold/testsuite/testfile.cc
gold/tilegx.cc
gold/x86_64.cc

index c3cf6860f6cc2df4f79aa0fae69ae4be998bcbe8..e4558a8dcac294a76657fd313f0c3fcc4b9daea6 100644 (file)
@@ -1,3 +1,29 @@
+2015-10-28  Marcin Kościelnicki  <koriakin@0x04.net>
+
+       * dynobj.cc (Dynobj::create_elf_hash_table): Create hash table with
+       target-specific entry size.
+       (Dynobj::sized_create_elf_hash_table): Add size template parameter.
+       * dynobj.h (Dynobj::sized_create_elf_hash_table): Likewise.
+       * layout.cc (Layout::create_dynamic_symtab): Set entsize to
+       hash_entry_size.
+       * target.h (Target::hash_entry_size): New method.
+       (Target::Target_info::hash_entry_size): New data member.
+
+       * aarch64.cc (Target_aarch64::aarch64_info): Add hash_entry_size.
+       * arm.cc (Target_arm::arm_info): Likewise.
+       (Target_arm_nacl::arm_nacl_info): Likewise.
+       * i386.cc (Target_i386::i386_info): Likewise.
+       (Target_i386_nacl::i386_nacl_info): Likewise.
+       (Target_iamcu::iamcu_info): Likewise.
+       * mips.cc (Target_mips::mips_info): Likewise.
+       (Target_mips_nacl::mips_nacl_info): Likewise.
+       * powerpc.cc (Target_powerpc::powerpc_info): Likewise.
+       * sparc.cc (Target_sparc::sparc_info): Likewise.
+       * tilegx.cc (Target_tilegx::tilegx_info): Likewise.
+       * x86_64.cc (Target_x86_64::x86_64_info): Likewise.
+       (Target_x86_64_nacl::x86_64_nacl_info): Likewise.
+       * testsuite/testfile.cc (Target_test::test_target_info): Likewise.
+
 2015-10-28  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR gold/19177
index 275d94c308af51567f91e512d566b2347dee9a55..2dcd6204cdd7166f3468ec48326f259d2bde676e 100644 (file)
@@ -3434,7 +3434,8 @@ const Target::Target_info Target_aarch64<64, false>::aarch64_info =
   0,                   // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<>
@@ -3461,7 +3462,8 @@ const Target::Target_info Target_aarch64<32, false>::aarch64_info =
   0,                   // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<>
@@ -3488,7 +3490,8 @@ const Target::Target_info Target_aarch64<64, true>::aarch64_info =
   0,                   // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<>
@@ -3515,7 +3518,8 @@ const Target::Target_info Target_aarch64<32, true>::aarch64_info =
   0,                   // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 // Get the GOT section, creating it if necessary.
index fa9fdb240c4032ef374a1cdf8cd73169355e7716..2795c943c644ae4cf06ed2ed05ffd224215a6da4 100644 (file)
@@ -2997,7 +2997,8 @@ const Target::Target_info Target_arm<big_endian>::arm_info =
   0,                   // large_common_section_flags
   ".ARM.attributes",   // attributes_section
   "aeabi",             // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 // Arm relocate functions class
@@ -12744,7 +12745,8 @@ const Target::Target_info Target_arm_nacl<big_endian>::arm_nacl_info =
   0,                   // large_common_section_flags
   ".ARM.attributes",   // attributes_section
   "aeabi",             // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<bool big_endian>
index 9ab6bf885919a846b077395443c42dd17ffa8202..c4852a9f0b9de498c113889057b06157dd4bda81 100644 (file)
@@ -946,31 +946,59 @@ Dynobj::create_elf_hash_table(const std::vector<Symbol*>& dynsyms,
       bucket[bucketpos] = dynsym_index;
     }
 
+  int size = parameters->target().hash_entry_size();
   unsigned int hashlen = ((2
                           + bucketcount
                           + local_dynsym_count
                           + dynsym_count)
-                         * 4);
+                         * size / 8);
   unsigned char* phash = new unsigned char[hashlen];
 
-  if (parameters->target().is_big_endian())
+  bool big_endian = parameters->target().is_big_endian();
+  if (size == 32)
     {
+      if (big_endian)
+       {
 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
-      Dynobj::sized_create_elf_hash_table<true>(bucket, chain, phash,
-                                               hashlen);
+         Dynobj::sized_create_elf_hash_table<32, true>(bucket, chain, phash,
+                                                       hashlen);
 #else
-      gold_unreachable();
+         gold_unreachable();
 #endif
+       }
+      else
+       {
+#if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
+         Dynobj::sized_create_elf_hash_table<32, false>(bucket, chain, phash,
+                                                        hashlen);
+#else
+         gold_unreachable();
+#endif
+       }
     }
-  else
+  else if (size == 64)
     {
+      if (big_endian)
+       {
+#if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
+         Dynobj::sized_create_elf_hash_table<64, true>(bucket, chain, phash,
+                                                       hashlen);
+#else
+         gold_unreachable();
+#endif
+       }
+      else
+       {
 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
-      Dynobj::sized_create_elf_hash_table<false>(bucket, chain, phash,
-                                                hashlen);
+         Dynobj::sized_create_elf_hash_table<64, false>(bucket, chain, phash,
+                                                        hashlen);
 #else
-      gold_unreachable();
+         gold_unreachable();
 #endif
+       }
     }
+  else
+    gold_unreachable();
 
   *pphash = phash;
   *phashlen = hashlen;
@@ -978,7 +1006,7 @@ Dynobj::create_elf_hash_table(const std::vector<Symbol*>& dynsyms,
 
 // Fill in an ELF hash table.
 
-template<bool big_endian>
+template<int size, bool big_endian>
 void
 Dynobj::sized_create_elf_hash_table(const std::vector<uint32_t>& bucket,
                                    const std::vector<uint32_t>& chain,
@@ -990,21 +1018,21 @@ Dynobj::sized_create_elf_hash_table(const std::vector<uint32_t>& bucket,
   const unsigned int bucketcount = bucket.size();
   const unsigned int chaincount = chain.size();
 
-  elfcpp::Swap<32, big_endian>::writeval(p, bucketcount);
-  p += 4;
-  elfcpp::Swap<32, big_endian>::writeval(p, chaincount);
-  p += 4;
+  elfcpp::Swap<size, big_endian>::writeval(p, bucketcount);
+  p += size / 8;
+  elfcpp::Swap<size, big_endian>::writeval(p, chaincount);
+  p += size / 8;
 
   for (unsigned int i = 0; i < bucketcount; ++i)
     {
-      elfcpp::Swap<32, big_endian>::writeval(p, bucket[i]);
-      p += 4;
+      elfcpp::Swap<size, big_endian>::writeval(p, bucket[i]);
+      p += size / 8;
     }
 
   for (unsigned int i = 0; i < chaincount; ++i)
     {
-      elfcpp::Swap<32, big_endian>::writeval(p, chain[i]);
-      p += 4;
+      elfcpp::Swap<size, big_endian>::writeval(p, chain[i]);
+      p += size / 8;
     }
 
   gold_assert(static_cast<unsigned int>(p - phash) == hashlen);
index c08c1dedcdce90b2129de3204ec9e483cc9babdb..9214266249759039ad91b9e00faa4336cb825d34 100644 (file)
@@ -132,7 +132,7 @@ class Dynobj : public Object
                       bool for_gnu_hash_table);
 
   // Sized version of create_elf_hash_table.
-  template<bool big_endian>
+  template<int size, bool big_endian>
   static void
   sized_create_elf_hash_table(const std::vector<uint32_t>& bucket,
                              const std::vector<uint32_t>& chain,
index 4c18de077a5abc1310dbb3ee6c7bc73cabd4acc1..386de03cfe11cee9130ee91ab0be6fc5f7c27f4b 100644 (file)
@@ -898,7 +898,8 @@ const Target::Target_info Target_i386::i386_info =
   0,                   // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 // Get the GOT section, creating it if necessary.
@@ -4084,7 +4085,8 @@ const Target::Target_info Target_i386_nacl::i386_nacl_info =
   0,                   // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 #define        NACLMASK        0xe0            // 32-byte alignment mask
@@ -4320,7 +4322,8 @@ const Target::Target_info Target_iamcu::iamcu_info =
   0,                   // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 class Target_selector_iamcu : public Target_selector
index b454c101b71ddf1cabc965719c6174374e4e3fa8..ad92fccca42eb1db809a221c030dbd90f8d8c20b 100644 (file)
@@ -4409,7 +4409,7 @@ Layout::create_dynamic_symtab(const Input_objects* input_objects,
        {
          if (dynsym != NULL)
            hashsec->set_link_section(dynsym);
-         hashsec->set_entsize(4);
+         hashsec->set_entsize(parameters->target().hash_entry_size() / 8);
        }
 
       if (odyn != NULL)
index 01cf33fe38a8d1c580afc410c200ddd446e71a4a..6cfe924ecd58ca15046761aea2dad26d199292f3 100644 (file)
@@ -10490,7 +10490,8 @@ const Target::Target_info Target_mips<size, big_endian>::mips_info =
   0,                    // large_common_section_flags
   NULL,                 // attributes_section
   NULL,                 // attributes_vendor
-  "__start"            // entry_symbol_name
+  "__start",           // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<int size, bool big_endian>
@@ -10529,7 +10530,8 @@ const Target::Target_info Target_mips_nacl<size, big_endian>::mips_nacl_info =
   0,                    // large_common_section_flags
   NULL,                 // attributes_section
   NULL,                 // attributes_vendor
-  "_start"              // entry_symbol_name
+  "_start",             // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 // Target selector for Mips.  Note this is never instantiated directly.
index 80f9e336c16987c025a52dc508e69d4ce3bac726..28bcd56ad55c9dae95d8df62b443ab4ef6e2236f 100644 (file)
@@ -1352,7 +1352,8 @@ Target::Target_info Target_powerpc<32, true>::powerpc_info =
   0,                   // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<>
@@ -1379,7 +1380,8 @@ Target::Target_info Target_powerpc<32, false>::powerpc_info =
   0,                   // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<>
@@ -1406,7 +1408,8 @@ Target::Target_info Target_powerpc<64, true>::powerpc_info =
   0,                   // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<>
@@ -1433,7 +1436,8 @@ Target::Target_info Target_powerpc<64, false>::powerpc_info =
   0,                   // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 inline bool
index db845b78fb9176ceed0daa6d045a0e8b83137dea..fc0dc81180811abe65e3cc69ae7dc8b047576718 100644 (file)
@@ -482,7 +482,8 @@ Target::Target_info Target_sparc<32, true>::sparc_info =
   0,                   // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<>
@@ -509,7 +510,8 @@ Target::Target_info Target_sparc<64, true>::sparc_info =
   0,                   // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 // We have to take care here, even when operating in little-endian
index dfbc5eee6a710cb4e05afe5f3bad17d4f8d9d0d3..db093b7fe0011d717ad8200cf438bde8a2a13662 100644 (file)
@@ -455,6 +455,11 @@ class Target
   entry_symbol_name() const
   { return this->pti_->entry_symbol_name; }
 
+  // Return the size in bits of SHT_HASH entry.
+  int
+  hash_entry_size() const
+  { return this->pti_->hash_entry_size; }
+
   // Whether the target has a custom set_dynsym_indexes method.
   bool
   has_custom_set_dynsym_indexes() const
@@ -540,6 +545,9 @@ class Target
     const char* attributes_vendor;
     // Name of the main entry point to the program.
     const char* entry_symbol_name;
+    // Size (in bits) of SHT_HASH entry. Always equal to 32, except for
+    // 64-bit S/390.
+    const int hash_entry_size;
   };
 
   Target(const Target_info* pti)
index c67caff4c688bf5cad8216728f075e7bec76848b..2e7f40c57b9b57af848bee584c053327fae6c160 100644 (file)
@@ -108,7 +108,8 @@ const Target::Target_info Target_test<size, big_endian>::test_target_info =
   0,                                   // large_common_section_flags
   NULL,                                        // attributes_section
   NULL,                                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",                            // entry_symbol_name
+  32,                                  // hash_entry_size
 };
 
 // The test targets.
index 5d972715477aee0cada2eb6c200802680e95139d..ce449a425b56096d65ee732e70f5792e0623074a 100644 (file)
@@ -680,7 +680,8 @@ const Target::Target_info Target_tilegx<64, false>::tilegx_info =
   0,                    // large_common_section_flags
   NULL,                 // attributes_section
   NULL,                 // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<>
@@ -707,7 +708,8 @@ const Target::Target_info Target_tilegx<32, false>::tilegx_info =
   0,                    // large_common_section_flags
   NULL,                 // attributes_section
   NULL,                 // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<>
@@ -734,7 +736,8 @@ const Target::Target_info Target_tilegx<64, true>::tilegx_info =
   0,                    // large_common_section_flags
   NULL,                 // attributes_section
   NULL,                 // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<>
@@ -761,7 +764,8 @@ const Target::Target_info Target_tilegx<32, true>::tilegx_info =
   0,                    // large_common_section_flags
   NULL,                 // attributes_section
   NULL,                  // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 // tilegx relocation handlers
index c728a0061877cb7918c9895d0335c582d60dd30a..d637b5ef7fea70cb97f82d7e8db8ee03e1f32e06 100644 (file)
@@ -1052,7 +1052,8 @@ const Target::Target_info Target_x86_64<64>::x86_64_info =
   elfcpp::SHF_X86_64_LARGE,    // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<>
@@ -1079,7 +1080,8 @@ const Target::Target_info Target_x86_64<32>::x86_64_info =
   elfcpp::SHF_X86_64_LARGE,    // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 // This is called when a new output section is created.  This is where
@@ -4818,7 +4820,8 @@ const Target::Target_info Target_x86_64_nacl<64>::x86_64_nacl_info =
   elfcpp::SHF_X86_64_LARGE,    // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 template<>
@@ -4845,7 +4848,8 @@ const Target::Target_info Target_x86_64_nacl<32>::x86_64_nacl_info =
   elfcpp::SHF_X86_64_LARGE,    // large_common_section_flags
   NULL,                        // attributes_section
   NULL,                        // attributes_vendor
-  "_start"             // entry_symbol_name
+  "_start",            // entry_symbol_name
+  32,                  // hash_entry_size
 };
 
 #define        NACLMASK        0xe0            // 32-byte alignment mask.
This page took 0.056498 seconds and 4 git commands to generate.