summaryrefslogtreecommitdiff
path: root/bfd/elf-strtab.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2013-02-18 10:40:18 +0000
committerAlan Modra <amodra@bigpond.net.au>2013-02-18 10:40:18 +0000
commit4d4c252e23651d964bb491e371708e14c4bf9b03 (patch)
treecd400f949d71561de280733ba9de7296933020f0 /bfd/elf-strtab.c
parent4811964691137717d061b5e3708ff1399bccaed5 (diff)
downloadbinutils-redhat-4d4c252e23651d964bb491e371708e14c4bf9b03.tar.gz
PR ld/12549
* elf-bfd.h (_bfd_elf_strtab_clear_refs): Delete. (_bfd_elf_strtab_clear_all_refs): Declare. (_bfd_elf_strtab_resize): Declare. * elf-strtab.c (_bfd_elf_strtab_clear_refs): Delete. (_bfd_elf_strtab_clear_all_refs): New function. (_bfd_elf_strtab_resize): Likewise. * elflink.c (elf_link_add_object_symbols): Use _bfd_elf_strtab_resize.
Diffstat (limited to 'bfd/elf-strtab.c')
-rw-r--r--bfd/elf-strtab.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/bfd/elf-strtab.c b/bfd/elf-strtab.c
index 45743f608a..61cedaedcc 100644
--- a/bfd/elf-strtab.c
+++ b/bfd/elf-strtab.c
@@ -208,10 +208,32 @@ _bfd_elf_strtab_refcount (struct elf_strtab_hash *tab, bfd_size_type idx)
}
void
-_bfd_elf_strtab_clear_refs (struct elf_strtab_hash *tab, bfd_size_type idx)
+_bfd_elf_strtab_clear_all_refs (struct elf_strtab_hash *tab)
{
- while (idx < tab->size)
- tab->array[idx++]->refcount = 0;
+ bfd_size_type idx;
+
+ for (idx = 1; idx < tab->size; idx++)
+ tab->array[idx]->refcount = 0;
+}
+
+/* Downsizes strtab. Entries from IDX up to the current size are
+ removed from the array. */
+void
+_bfd_elf_strtab_restore_size (struct elf_strtab_hash *tab, bfd_size_type idx)
+{
+ bfd_size_type curr_size = tab->size;
+
+ BFD_ASSERT (tab->sec_size == 0);
+ BFD_ASSERT (idx <= curr_size);
+ tab->size = idx;
+ for (; idx < curr_size; ++idx)
+ {
+ /* We don't remove entries from the hash table, just set their
+ REFCOUNT to zero. Setting LEN zero will result in the size
+ growing if the entry is added again. See _bfd_elf_strtab_add. */
+ tab->array[idx]->refcount = 0;
+ tab->array[idx]->len = 0;
+ }
}
bfd_size_type