forked from Imagelibrary/binutils-gdb
* elfcode.h (elf_checksum_contents): Free contents.
* elf-bfd.h (_bfd_elf_link_hash_table_free): Declare. * elflink.c (_bfd_elf_link_hash_table_free): New function. (elf_final_link_free): New function, extracted from.. (bfd_elf_final_link): ..here. Always call _bfd_elf_write_section_eh_frame_hdr. * elfxx-target.h (bfd_elfNN_bfd_link_hash_table_free): Default to _bfd_elf_link_hash_table_free. * libbfd-in.h (_bfd_merge_sections_free): Declare. * libbfd.h: Regenerate. * merge.c (_bfd_merge_sections_free): New function. * elf-eh-frame.c (_bfd_elf_write_section_eh_frame_hdr): Free hdr_info->array. * elf-m10300.c (elf32_mn10300_link_hash_table_free): Call _bfd_elf_link_hash_table_free. * elf32-arm.c (elf32_arm_link_hash_table_free): Likewise. * elf32-avr.c (elf32_avr_link_hash_table_free): Likewise. * elf32-hppa.c (elf32_hppa_link_hash_table_free): Likewise. * elf32-i386.c (elf_i386_link_hash_table_free): Likewise. * elf32-m68hc1x.c (m68hc11_elf_hash_table_free): Likewise. * elf32-m68k.c (elf_m68k_link_hash_table_free): Likewise. * elf32-metag.c (elf_metag_link_hash_table_free): Likewise. * elf32-xgate.c (xgate_elf_bfd_link_hash_table_free): Likewise. * elf64-aarch64.c (elf64_aarch64_link_hash_table_free): Likewise. * elf64-ia64-vms.c (elf64_ia64_hash_table_free): Likewise. * elf64-ppc.c (ppc64_elf_link_hash_table_free): Likewise. * elf64-x86-64.c (elf_x86_64_link_hash_table_free): Likewise. * elfnn-ia64.c (elfNN_ia64_hash_table_free): Likewise. * elf32-cr16.c (elf32_cr16_link_hash_table_free): Delete. (bfd_elf32_bfd_link_hash_table_free): Don't define. * elf32-tic6x.c (elf32_tic6x_link_hash_table_free): Delete. (bfd_elf32_bfd_link_hash_table_free): Dont' define.
This commit is contained in:
118
bfd/elflink.c
118
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user