diff options
Diffstat (limited to 'bfd/linker.c')
-rw-r--r-- | bfd/linker.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/bfd/linker.c b/bfd/linker.c index 1afe4ed..483a0d4 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -482,11 +482,22 @@ _bfd_link_hash_table_init const char *), unsigned int entsize) { + bfd_boolean ret; + + BFD_ASSERT (!abfd->is_linker_output && !abfd->link.hash); table->undefs = NULL; table->undefs_tail = NULL; table->type = bfd_link_generic_hash_table; - return bfd_hash_table_init (&table->table, newfunc, entsize); + ret = bfd_hash_table_init (&table->table, newfunc, entsize); + if (ret) + { + /* Arrange for destruction of this hash table on closing ABFD. */ + table->hash_table_free = _bfd_generic_link_hash_table_free; + abfd->link.hash = table; + abfd->is_linker_output = TRUE; + } + return ret; } /* Look up a symbol in a link hash table. If follow is TRUE, we @@ -771,13 +782,16 @@ _bfd_generic_link_hash_table_create (bfd *abfd) } void -_bfd_generic_link_hash_table_free (struct bfd_link_hash_table *hash) +_bfd_generic_link_hash_table_free (bfd *obfd) { - struct generic_link_hash_table *ret - = (struct generic_link_hash_table *) hash; + struct generic_link_hash_table *ret; + BFD_ASSERT (obfd->is_linker_output && obfd->link.hash); + ret = (struct generic_link_hash_table *) obfd->link.hash; bfd_hash_table_free (&ret->root.table); free (ret); + obfd->link.hash = NULL; + obfd->is_linker_output = FALSE; } /* Grab the symbols for an object file when doing a generic link. We |