This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Prevent broken sysv-style hash table when --hash-style=both


The root cause seem the gold::Dynobj::create_gnu_hash_table will
change the dynsym_index,

so this patch just reorder the symbol table generate order to
guarantee the gold::Dynobj::create_elf_hash_table get correct
dynsym_index.

However it's will change the section order between .hash and
.gnu.hash, any suggestion ?

[1] http://sourceware.org/bugzilla/show_bug.cgi?id=13597

Index: gold/layout.cc
===================================================================
RCS file: /cvs/src/src/gold/layout.cc,v
retrieving revision 1.222
diff -r1.222 layout.cc
3835c3835
<   if (strcmp(parameters->options().hash_style(), "sysv") == 0
---
>   if (strcmp(parameters->options().hash_style(), "gnu") == 0
3840c3840
<       Dynobj::create_elf_hash_table(*pdynamic_symbols, local_symcount,
---
>       Dynobj::create_gnu_hash_table(*pdynamic_symbols, local_symcount,
3844c3844
< 	this->choose_output_section(NULL, ".hash", elfcpp::SHT_HASH,
---
> 	this->choose_output_section(NULL, ".gnu.hash", elfcpp::SHT_GNU_HASH,
3859,3860d3858
< 	  hashsec->set_entsize(4);
< 	}
3862,3863c3860,3868
<       if (odyn != NULL)
< 	odyn->add_section_address(elfcpp::DT_HASH, hashsec);
---
> 	  // For a 64-bit target, the entries in .gnu.hash do not have
> 	  // a uniform size, so we only set the entry size for a
> 	  // 32-bit target.
> 	  if (parameters->target().get_size() == 32)
> 	    hashsec->set_entsize(4);
>
> 	  if (odyn != NULL)
> 	    odyn->add_section_address(elfcpp::DT_GNU_HASH, hashsec);
> 	}
3866c3871
<   if (strcmp(parameters->options().hash_style(), "gnu") == 0
---
>   if (strcmp(parameters->options().hash_style(), "sysv") == 0
3871c3876
<       Dynobj::create_gnu_hash_table(*pdynamic_symbols, local_symcount,
---
>       Dynobj::create_elf_hash_table(*pdynamic_symbols, local_symcount,
3875c3880
< 	this->choose_output_section(NULL, ".gnu.hash", elfcpp::SHT_GNU_HASH,
---
> 	this->choose_output_section(NULL, ".hash", elfcpp::SHT_HASH,
3890,3898c3895
<
< 	  // For a 64-bit target, the entries in .gnu.hash do not have
< 	  // a uniform size, so we only set the entry size for a
< 	  // 32-bit target.
< 	  if (parameters->target().get_size() == 32)
< 	    hashsec->set_entsize(4);
<
< 	  if (odyn != NULL)
< 	    odyn->add_section_address(elfcpp::DT_GNU_HASH, hashsec);
---
> 	  hashsec->set_entsize(4);
3899a3897,3899
>
>       if (odyn != NULL)
> 	odyn->add_section_address(elfcpp::DT_HASH, hashsec);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]