X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;ds=sidebyside;f=bfd%2Felf-strtab.c;h=61cedaedcc34d3a5c7c7639545a388ede9068de0;hb=6dd38d7935978de2a692f3042333a879eef18374;hp=1526755ab7da5b24c87bd67905a48c4bb5de0493;hpb=a4542f1b2305d1ebb7f9f5e9c88e6af826923452;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf-strtab.c b/bfd/elf-strtab.c index 1526755ab7..61cedaedcc 100644 --- a/bfd/elf-strtab.c +++ b/bfd/elf-strtab.c @@ -201,11 +201,39 @@ _bfd_elf_strtab_delref (struct elf_strtab_hash *tab, bfd_size_type idx) --tab->array[idx]->refcount; } +unsigned int +_bfd_elf_strtab_refcount (struct elf_strtab_hash *tab, bfd_size_type idx) +{ + return tab->array[idx]->refcount; +} + +void +_bfd_elf_strtab_clear_all_refs (struct elf_strtab_hash *tab) +{ + 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_clear_refs (struct elf_strtab_hash *tab, bfd_size_type idx) +_bfd_elf_strtab_restore_size (struct elf_strtab_hash *tab, bfd_size_type idx) { - while (idx < tab->size) - tab->array[idx++]->refcount = 0; + 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