aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-06-13 19:11:29 +0930
committerAlan Modra <amodra@gmail.com>2014-06-13 19:11:29 +0930
commitcaa4096e844a000ff63c4fa9180d70ca2093fd2a (patch)
tree3857040b317d56523dc4bdf0a185fa7aa21494a8 /ld
parent68faa6378d757de1fdf29f7d27025c5eadd897ec (diff)
downloadgdb-caa4096e844a000ff63c4fa9180d70ca2093fd2a.zip
gdb-caa4096e844a000ff63c4fa9180d70ca2093fd2a.tar.gz
gdb-caa4096e844a000ff63c4fa9180d70ca2093fd2a.tar.bz2
Don't call bfd_link_hash_table_free
Freeing the linker hash table is a royal pain. It can't be freed before the _bfd_write_contents call in bfd_close, because some target bfd_write_contents functions access the hash table. It can't be freed after bfd_close either, since bfd_alloc memory holding side data structures disappears (PR17047). Clearly the only place it can be freed is actually in bfd_close. This patch doesn't do that, but kills off the existing means of freeing the hash table via a bfd target xvec call. bfd/ PR 17047 * targets.c (BFD_JUMP_TABLE): Delete NAME##_bfd_link_hash_table_free. (struct bfd_target <_bfd_link_hash_table_free>): Delete. * bfd.c (bfd_link_hash_table_free): Don't define. * aout-adobe.c, * aout-target.h, * aout-tic30.c, * binary.c, * bout.c, * coff64-rs6000.c, * coffcode.h, * elf-m10300.c, * elf32-arm.c, * elf32-avr.c, * elf32-hppa.c, * elf32-i386.c, * elf32-m68hc11.c, * elf32-m68hc12.c, * elf32-m68k.c, * elf32-metag.c, * elf32-nios2.c, * elf32-sparc.c, * elf32-xgate.c, * elf64-ia64-vms.c, * elf64-ppc.c, * elf64-sparc.c, * elf64-x86-64.c, * elfnn-aarch64.c, * elfnn-ia64.c, * elfxx-target.h, * i386msdos.c, * i386os9k.c, * ieee.c, * ihex.c, * libbfd-in.h, * libecoff.h, * mach-o-target.c, * mmo.c, * nlm-target.h, * oasys.c, * pef.c, * plugin.c, * ppcboot.c, * som.c, * srec.c, * tekhex.c, * verilog.c, * versados.c, * vms-alpha.c, * xsym.c: Don't define various link_hash_table_free defines, and remove from bfd_target vars. Temporarily reference some of the target link_hash_table_free functions to avoid warnings. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. ld/ PR 17047 * ldlang.c (output_bfd_hash_table_free_fn): Delete. (open_output): Don't set it.. * ldmain.c (ld_cleanup): ..or call it.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog7
-rw-r--r--ld/ldlang.c15
-rw-r--r--ld/ldmain.c4
3 files changed, 7 insertions, 19 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index e1abf43..783c4bd 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,12 @@
2014-06-13 Alan Modra <amodra@gmail.com>
+ PR 17047
+ * ldlang.c (output_bfd_hash_table_free_fn): Delete.
+ (open_output): Don't set it..
+ * ldmain.c (ld_cleanup): ..or call it.
+
+2014-06-13 Alan Modra <amodra@gmail.com>
+
* emultempl/cr16elf.em, * emultempl/elf32.em, * emultempl/genelf.em,
* emultempl/m68kcoff.em, * emultempl/m68kelf.em,
* emultempl/nds32elf.em, * emultempl/pe.em, * emultempl/pep.em,
diff --git a/ld/ldlang.c b/ld/ldlang.c
index add86da..e7c9669 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -3072,9 +3072,6 @@ lang_get_output_target (void)
return default_target;
}
-/* Stashed function to free link_info.hash; see open_output. */
-void (*output_bfd_hash_table_free_fn) (struct bfd_link_hash_table *);
-
/* Open the output file. */
static void
@@ -3154,18 +3151,6 @@ open_output (const char *name)
if (link_info.hash == NULL)
einfo (_("%P%F: can not create hash table: %E\n"));
- /* We want to please memory leak checkers by deleting link_info.hash.
- We can't do it in lang_finish, as a bfd target may hold references to
- symbols in this table and use them when their _bfd_write_contents
- function is invoked, as part of bfd_close on the output_bfd. But,
- output_bfd is deallocated at bfd_close, so we can't refer to
- output_bfd after that time, and dereferencing it is needed to call
- "bfd_link_hash_table_free". Smash this dependency deadlock and grab
- the function pointer; arrange to call it on link_info.hash in
- ld_cleanup. */
- output_bfd_hash_table_free_fn
- = link_info.output_bfd->xvec->_bfd_link_hash_table_free;
-
bfd_set_gp_size (link_info.output_bfd, g_switch_value);
}
diff --git a/ld/ldmain.c b/ld/ldmain.c
index d4be6f0..ea25afe 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -171,10 +171,6 @@ ld_cleanup (void)
#endif
if (output_filename && delete_output_file_on_failure)
unlink_if_ordinary (output_filename);
-
- /* See open_output in ldlang.c. */
- if (output_bfd_hash_table_free_fn != NULL)
- (*output_bfd_hash_table_free_fn) (link_info.hash);
}
/* If there's a BFD assertion, we'll notice and exit with an error