public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Prevent broken sysv-style hash table when --hash-style=both
@ 2012-01-17 20:35 Kito Cheng
  2012-01-17 20:56 ` Mike Frysinger
  0 siblings, 1 reply; 3+ messages in thread
From: Kito Cheng @ 2012-01-17 20:35 UTC (permalink / raw)
  To: binutils, Ian Lance Taylor; +Cc: Jim Huang

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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Prevent broken sysv-style hash table when --hash-style=both
  2012-01-17 20:35 [PATCH] Prevent broken sysv-style hash table when --hash-style=both Kito Cheng
@ 2012-01-17 20:56 ` Mike Frysinger
  2012-01-17 21:10   ` Kito Cheng
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Frysinger @ 2012-01-17 20:56 UTC (permalink / raw)
  To: binutils; +Cc: Kito Cheng, Ian Lance Taylor, Jim Huang

[-- Attachment #1: Type: Text/Plain, Size: 538 bytes --]

On Tuesday 17 January 2012 15:35:10 Kito Cheng wrote:
> 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

please submit patches in the unified diff format.  this is easy to do by default 
with cvs:
	$ echo 'diff -uNp' >> ~/.cvsrc
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Prevent broken sysv-style hash table when --hash-style=both
  2012-01-17 20:56 ` Mike Frysinger
@ 2012-01-17 21:10   ` Kito Cheng
  0 siblings, 0 replies; 3+ messages in thread
From: Kito Cheng @ 2012-01-17 21:10 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: binutils, Ian Lance Taylor

> please submit patches in the unified diff format.  this is easy to do by default

thanks, it's the unified diff format for this patch

Index: layout.cc
===================================================================
RCS file: /cvs/src/src/gold/layout.cc,v
retrieving revision 1.222
diff -u -p -r1.222 layout.cc
--- layout.cc	19 Oct 2011 15:05:58 -0000	1.222
+++ layout.cc	17 Jan 2012 21:08:27 -0000
@@ -3832,16 +3832,16 @@ Layout::create_dynamic_symtab(const Inpu

   // Create the hash tables.

-  if (strcmp(parameters->options().hash_style(), "sysv") == 0
+  if (strcmp(parameters->options().hash_style(), "gnu") == 0
       || strcmp(parameters->options().hash_style(), "both") == 0)
     {
       unsigned char* phash;
       unsigned int hashlen;
-      Dynobj::create_elf_hash_table(*pdynamic_symbols, local_symcount,
+      Dynobj::create_gnu_hash_table(*pdynamic_symbols, local_symcount,
 				    &phash, &hashlen);

       Output_section* hashsec =
-	this->choose_output_section(NULL, ".hash", elfcpp::SHT_HASH,
+	this->choose_output_section(NULL, ".gnu.hash", elfcpp::SHT_GNU_HASH,
 				    elfcpp::SHF_ALLOC, false,
 				    ORDER_DYNAMIC_LINKER, false);

@@ -3856,23 +3856,28 @@ Layout::create_dynamic_symtab(const Inpu
 	{
 	  if (dynsym != NULL)
 	    hashsec->set_link_section(dynsym);
-	  hashsec->set_entsize(4);
-	}

-      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);
+	}
     }

-  if (strcmp(parameters->options().hash_style(), "gnu") == 0
+  if (strcmp(parameters->options().hash_style(), "sysv") == 0
       || strcmp(parameters->options().hash_style(), "both") == 0)
     {
       unsigned char* phash;
       unsigned int hashlen;
-      Dynobj::create_gnu_hash_table(*pdynamic_symbols, local_symcount,
+      Dynobj::create_elf_hash_table(*pdynamic_symbols, local_symcount,
 				    &phash, &hashlen);

       Output_section* hashsec =
-	this->choose_output_section(NULL, ".gnu.hash", elfcpp::SHT_GNU_HASH,
+	this->choose_output_section(NULL, ".hash", elfcpp::SHT_HASH,
 				    elfcpp::SHF_ALLOC, false,
 				    ORDER_DYNAMIC_LINKER, false);

@@ -3887,16 +3892,11 @@ Layout::create_dynamic_symtab(const Inpu
 	{
 	  if (dynsym != NULL)
 	    hashsec->set_link_section(dynsym);
-
-	  // 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);
 	}
+
+      if (odyn != NULL)
+	odyn->add_section_address(elfcpp::DT_HASH, hashsec);
     }
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-01-17 21:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-17 20:35 [PATCH] Prevent broken sysv-style hash table when --hash-style=both Kito Cheng
2012-01-17 20:56 ` Mike Frysinger
2012-01-17 21:10   ` Kito Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).