[PATCH 1/6] gold: Support 64-bit entry size in SHT_HASH.

Marcin Kościelnicki koriakin@0x04.net
Thu Oct 29 00:57:00 GMT 2015


On 28/10/15 23:42, Cary Coutant wrote:
>> -  if (parameters->target().is_big_endian())
>> +  bool big_endian = parameters->target().is_big_endian();
>> +  if (size == 32)
>>       {
>> -#if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
>> -      Dynobj::sized_create_elf_hash_table<true>(bucket, chain, phash,
>> -                                               hashlen);
>> +      if (big_endian)
>> +       {
>> +#ifdef HAVE_TARGET_32_BIG
>> +         Dynobj::sized_create_elf_hash_table<32, true>(bucket, chain, phash,
>> +                                                       hashlen);
>> +#else
>> +         gold_unreachable();
>> +#endif
>> +       }
>> +      else
>> +       {
>> +#ifdef HAVE_TARGET_32_LITTLE
>> +         Dynobj::sized_create_elf_hash_table<32, false>(bucket, chain, phash,
>> +                                                        hashlen);
>>   #else
>> -      gold_unreachable();
>> +         gold_unreachable();
>>   #endif
>> +       }
>
> This part won't work for 64-bit targets with 32-bit hash table
> entries: since the size of the target and the size of the hash entry
> are now independent, we can't assume that we don't need a 32-bit hash
> entry if we haven't instantiated a 32-bit target.

Oops, sorry for that!
>
>>       }
>> -  else
>> +  else if (size == 64)
>>       {
>> -#if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
>> -      Dynobj::sized_create_elf_hash_table<false>(bucket, chain, phash,
>> -                                                hashlen);
>> +      if (big_endian)
>> +       {
>> +#ifdef HAVE_TARGET_64_BIG
>> +         Dynobj::sized_create_elf_hash_table<64, true>(bucket, chain, phash,
>> +                                                       hashlen);
>>   #else
>> -      gold_unreachable();
>> +         gold_unreachable();
>> +#endif
>> +       }
>> +      else
>> +       {
>> +#ifdef HAVE_TARGET_64_LITTLE
>> +         Dynobj::sized_create_elf_hash_table<64, false>(bucket, chain, phash,
>> +                                                        hashlen);
>> +#else
>> +         gold_unreachable();
>>   #endif
>> +       }
>
> Likewise for a hypothetical 32-bit target with 64-bit hash table entries.
>
> I will commit the attached patch on your behalf, along with this
> ChangeLog entry:
>
> 2015-10-28  Marcin Kościelnicki  <koriakin@0x04.net>
>
> 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.
>
> (Normally, I'd have asked you to write the ChangeLog entry, but since
> I took so long to review this patch set, I wrote it for you.)

Ack, thanks for the review!

> -cary
>



More information about the Binutils mailing list