This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: ld/3197: ld --hash-style=gnu crashes
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Cc: jakub at redhat dot com
- Date: Tue, 12 Sep 2006 14:40:44 -0700
- Subject: 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]+
+#...