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: ld/3197: ld --hash-style=gnu crashes


The problem is that bucketcount isn't set when --hash-style=gnu is
used. There is no need to compute bucket when it isn't needed.


H.J.
-----
bfd/

2006-09-12  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/3197
	* elflink.c (elf_link_output_extsym): Compute bucket only if
	needed.

ld/testsuite/

2006-09-12  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/3197
	* ld-elf/hash.d: New test.

--- binutils/bfd/elflink.c.hash	2006-09-10 16:17:24.000000000 -0700
+++ binutils/bfd/elflink.c	2006-09-12 14:34:10.000000000 -0700
@@ -7061,8 +7061,6 @@ elf_link_output_extsym (struct elf_link_
   if (h->dynindx != -1
       && elf_hash_table (finfo->info)->dynamic_sections_created)
     {
-      size_t bucketcount;
-      size_t bucket;
       bfd_byte *esym;
 
       sym.st_name = h->dynstr_index;
@@ -7074,14 +7072,16 @@ elf_link_output_extsym (struct elf_link_
 	}
       bed->s->swap_symbol_out (finfo->output_bfd, &sym, esym, 0);
 
-      bucketcount = elf_hash_table (finfo->info)->bucketcount;
-      bucket = h->u.elf_hash_value % bucketcount;
-
       if (finfo->hash_sec != NULL)
 	{
 	  size_t hash_entry_size;
 	  bfd_byte *bucketpos;
 	  bfd_vma chain;
+	  size_t bucketcount;
+	  size_t bucket;
+
+	  bucketcount = elf_hash_table (finfo->info)->bucketcount;
+	  bucket = h->u.elf_hash_value % bucketcount;
 
 	  hash_entry_size
 	    = elf_section_data (finfo->hash_sec)->this_hdr.sh_entsize;
--- binutils/ld/testsuite/ld-elf/hash.d.hash	2006-09-12 14:25:23.000000000 -0700
+++ binutils/ld/testsuite/ld-elf/hash.d	2006-09-12 14:28:14.000000000 -0700
@@ -0,0 +1,8 @@
+#source: start.s
+#readelf: -d 
+#ld: -shared --hash-style=gnu
+#target: *-*-linux*
+
+#...
+[ 	]*0x[0-9a-z]+[ 	]+\(GNU_HASH\)[ 	]+0x[0-9a-z]+
+#...


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