This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Fix --gc-sections for MIPS.
- From: David Daney <ddaney at avtrex dot com>
- To: binutils at sources dot redhat dot com
- Date: Sat, 30 Jul 2005 22:43:48 -0700
- Subject: [PATCH] Fix --gc-sections for MIPS.
ld --gc-sections was causing an assertion failure in elfxx-mips.c:
mips_elf_sort_hash_table().
The problem was that elf_gc_sweep() was setting dynsymcount incorrectly.
It was not accounting for the unused NULL entry as is done in
_bfd_elf_link_renumber_dynsyms().
The attached patch adds the missing logic to elf_gc_sweep().
The problem was not fatal in all architectures as
_bfd_elf_link_renumber_dynsyms() is being called after elf_gc_sweep()
and cleaned up the mess.
On MIPS mips_elf_sort_hash_table() is called while dynsymcount had the
incorrect value causing the assertion failure.
Tested on i686-pc-linux-gnu configured as --target=mipsel-linux: make
-k check no new failures.
2005-07-30 David Daney <ddaney@avtrex.com>
* elflink.c (elf_gc_sweep): Set dynsymcount to correct value.
OK to commit?
David Daney
Index: elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.184
diff -c -p -r1.184 elflink.c
*** elflink.c 29 Jul 2005 02:46:03 -0000 1.184
--- elflink.c 31 Jul 2005 05:26:53 -0000
*************** elf_gc_sweep (struct bfd_link_info *info
*** 8943,8948 ****
--- 8943,8954 ----
elf_link_hash_traverse (elf_hash_table (info), elf_gc_sweep_symbol, &i);
+ /* There is an unused NULL entry at the head of the table which
+ we must account for in our count. Unless there weren't any
+ symbols, which means we'll have no table at all. */
+ if (i != 0)
+ ++i;
+
elf_hash_table (info)->dynsymcount = i;
}