diff options
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 118 |
1 files changed, 52 insertions, 66 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index 1bae437..d423ca4 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -6962,6 +6962,18 @@ _bfd_elf_link_hash_table_create (bfd *abfd) return &ret->root; } +/* Destroy an ELF linker hash table. */ + +void +_bfd_elf_link_hash_table_free (struct bfd_link_hash_table *hash) +{ + struct elf_link_hash_table *htab = (struct elf_link_hash_table *) hash; + if (htab->dynstr != NULL) + _bfd_elf_strtab_free (htab->dynstr); + _bfd_merge_sections_free (htab->merge_info); + _bfd_generic_link_hash_table_free (hash); +} + /* This is a hook for the ELF emulation code in the generic linker to tell the backend linker what file name to use for the DT_NEEDED entry for a dynamic object. */ @@ -10432,6 +10444,42 @@ elf_fixup_link_order (bfd *abfd, asection *o) return TRUE; } +static void +elf_final_link_free (bfd *obfd, struct elf_final_link_info *flinfo) +{ + asection *o; + + if (flinfo->symstrtab != NULL) + _bfd_stringtab_free (flinfo->symstrtab); + if (flinfo->contents != NULL) + free (flinfo->contents); + if (flinfo->external_relocs != NULL) + free (flinfo->external_relocs); + if (flinfo->internal_relocs != NULL) + free (flinfo->internal_relocs); + if (flinfo->external_syms != NULL) + free (flinfo->external_syms); + if (flinfo->locsym_shndx != NULL) + free (flinfo->locsym_shndx); + if (flinfo->internal_syms != NULL) + free (flinfo->internal_syms); + if (flinfo->indices != NULL) + free (flinfo->indices); + if (flinfo->sections != NULL) + free (flinfo->sections); + if (flinfo->symbuf != NULL) + free (flinfo->symbuf); + if (flinfo->symshndxbuf != NULL) + free (flinfo->symshndxbuf); + for (o = obfd->sections; o != NULL; o = o->next) + { + struct bfd_elf_section_data *esdo = elf_section_data (o); + if ((o->flags & SEC_RELOC) != 0 && esdo->rel.hashes != NULL) + free (esdo->rel.hashes); + if ((o->flags & SEC_RELOC) != 0 && esdo->rela.hashes != NULL) + free (esdo->rela.hashes); + } +} /* Do the final step of an ELF link. */ @@ -11479,42 +11527,10 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) goto error_return; } - if (info->eh_frame_hdr) - { - if (! _bfd_elf_write_section_eh_frame_hdr (abfd, info)) - goto error_return; - } + if (! _bfd_elf_write_section_eh_frame_hdr (abfd, info)) + goto error_return; - if (flinfo.symstrtab != NULL) - _bfd_stringtab_free (flinfo.symstrtab); - if (flinfo.contents != NULL) - free (flinfo.contents); - if (flinfo.external_relocs != NULL) - free (flinfo.external_relocs); - if (flinfo.internal_relocs != NULL) - free (flinfo.internal_relocs); - if (flinfo.external_syms != NULL) - free (flinfo.external_syms); - if (flinfo.locsym_shndx != NULL) - free (flinfo.locsym_shndx); - if (flinfo.internal_syms != NULL) - free (flinfo.internal_syms); - if (flinfo.indices != NULL) - free (flinfo.indices); - if (flinfo.sections != NULL) - free (flinfo.sections); - if (flinfo.symbuf != NULL) - free (flinfo.symbuf); - if (flinfo.symshndxbuf != NULL) - free (flinfo.symshndxbuf); - for (o = abfd->sections; o != NULL; o = o->next) - { - struct bfd_elf_section_data *esdo = elf_section_data (o); - if ((o->flags & SEC_RELOC) != 0 && esdo->rel.hashes != NULL) - free (esdo->rel.hashes); - if ((o->flags & SEC_RELOC) != 0 && esdo->rela.hashes != NULL) - free (esdo->rela.hashes); - } + elf_final_link_free (abfd, &flinfo); elf_tdata (abfd)->linker = TRUE; @@ -11531,37 +11547,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) return TRUE; error_return: - if (flinfo.symstrtab != NULL) - _bfd_stringtab_free (flinfo.symstrtab); - if (flinfo.contents != NULL) - free (flinfo.contents); - if (flinfo.external_relocs != NULL) - free (flinfo.external_relocs); - if (flinfo.internal_relocs != NULL) - free (flinfo.internal_relocs); - if (flinfo.external_syms != NULL) - free (flinfo.external_syms); - if (flinfo.locsym_shndx != NULL) - free (flinfo.locsym_shndx); - if (flinfo.internal_syms != NULL) - free (flinfo.internal_syms); - if (flinfo.indices != NULL) - free (flinfo.indices); - if (flinfo.sections != NULL) - free (flinfo.sections); - if (flinfo.symbuf != NULL) - free (flinfo.symbuf); - if (flinfo.symshndxbuf != NULL) - free (flinfo.symshndxbuf); - for (o = abfd->sections; o != NULL; o = o->next) - { - struct bfd_elf_section_data *esdo = elf_section_data (o); - if ((o->flags & SEC_RELOC) != 0 && esdo->rel.hashes != NULL) - free (esdo->rel.hashes); - if ((o->flags & SEC_RELOC) != 0 && esdo->rela.hashes != NULL) - free (esdo->rela.hashes); - } - + elf_final_link_free (abfd, &flinfo); return FALSE; } |