aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2013-01-11 13:55:02 +0000
committerAlan Modra <amodra@gmail.com>2013-01-11 13:55:02 +0000
commita4542f1b2305d1ebb7f9f5e9c88e6af826923452 (patch)
treef729d224c08b43f400e7f6e5ac254c3d0234c385 /bfd/elflink.c
parentc2e5e6d74e831490fb9afac70a31c79d38a1f812 (diff)
downloadgdb-a4542f1b2305d1ebb7f9f5e9c88e6af826923452.zip
gdb-a4542f1b2305d1ebb7f9f5e9c88e6af826923452.tar.gz
gdb-a4542f1b2305d1ebb7f9f5e9c88e6af826923452.tar.bz2
PR ld/12549
* elf-bfd.h (_bfd_elf_strtab_clear_refs): Declare. (_bfd_elf_strtab_clear_all_refs): Define. * elf-strtab.c (_bfd_elf_strtab_clear_refs): New function. (_bfd_elf_strtab_clear_all_refs): Delete. * elflink.c (elf_link_add_object_symbols): Clear out added strtab refs. Correct handling of warning common symbols.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 7df2775..ee6288a 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -3385,6 +3385,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
struct bfd_link_hash_entry *old_undefs = NULL;
struct bfd_link_hash_entry *old_undefs_tail = NULL;
long old_dynsymcount = 0;
+ bfd_size_type old_dynstr_size = 0;
size_t tabsize = 0;
size_t hashsize = 0;
@@ -3834,6 +3835,7 @@ error_free_dyn:
old_size = htab->root.table.size;
old_count = htab->root.table.count;
old_dynsymcount = htab->dynsymcount;
+ old_dynstr_size = _bfd_elf_strtab_size (htab->dynstr);
for (i = 0; i < htab->root.table.size; i++)
{
@@ -4566,6 +4568,7 @@ error_free_dyn:
memcpy (sym_hash, old_hash, hashsize);
htab->root.undefs = old_undefs;
htab->root.undefs_tail = old_undefs_tail;
+ _bfd_elf_strtab_clear_refs (htab->dynstr, old_dynstr_size);
for (i = 0; i < htab->root.table.size; i++)
{
struct bfd_hash_entry *p;
@@ -4578,12 +4581,13 @@ error_free_dyn:
h = (struct elf_link_hash_entry *) p;
if (h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
- if (h->dynindx >= old_dynsymcount)
+ if (h->dynindx >= old_dynsymcount
+ && h->dynstr_index < old_dynstr_size)
_bfd_elf_strtab_delref (htab->dynstr, h->dynstr_index);
/* Preserve the maximum alignment and size for common
symbols even if this dynamic lib isn't on DT_NEEDED
- since it can still be loaded at the run-time by another
+ since it can still be loaded at run time by another
dynamic lib. */
if (h->root.type == bfd_link_hash_common)
{
@@ -4602,8 +4606,9 @@ error_free_dyn:
{
memcpy (h->root.u.i.link, old_ent, htab->root.table.entsize);
old_ent = (char *) old_ent + htab->root.table.entsize;
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
}
- else if (h->root.type == bfd_link_hash_common)
+ if (h->root.type == bfd_link_hash_common)
{
if (size > h->root.u.c.size)
h->root.u.c.size = size;