aboutsummaryrefslogtreecommitdiff
path: root/gdb/bfd-target.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2009-07-28 15:05:01 +0000
committerPedro Alves <palves@redhat.com>2009-07-28 15:05:01 +0000
commite12af5a2d1eda2e448b279ac97eb635b4a29eef1 (patch)
tree1eee4c6ab788b44f1dd111cde965452fd3d295f3 /gdb/bfd-target.c
parent745a434e1500a955d8d5d4f0a7173b68d33a764e (diff)
downloadgdb-e12af5a2d1eda2e448b279ac97eb635b4a29eef1.zip
gdb-e12af5a2d1eda2e448b279ac97eb635b4a29eef1.tar.gz
gdb-e12af5a2d1eda2e448b279ac97eb635b4a29eef1.tar.bz2
* bfd-target.c (target_bfd_xclose): Only close the bfd if the
section tarble is not empty. (target_bfd_reopen): If the section table ends up empty, close the bfd here.
Diffstat (limited to 'gdb/bfd-target.c')
-rw-r--r--gdb/bfd-target.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c
index ffaa4ff..2b7894e 100644
--- a/gdb/bfd-target.c
+++ b/gdb/bfd-target.c
@@ -54,7 +54,10 @@ static void
target_bfd_xclose (struct target_ops *t, int quitting)
{
struct target_section_table *table = t->to_data;
- if (table->sections)
+
+ /* If the target sections table is empty, the bfd had already been
+ closed. */
+ if (table->sections != table->sections_end)
bfd_close (table->sections->bfd);
xfree (table->sections);
xfree (table);
@@ -70,6 +73,12 @@ target_bfd_reopen (struct bfd *bfd)
table = XZALLOC (struct target_section_table);
build_section_table (bfd, &table->sections, &table->sections_end);
+ /* No use keeping the bfd open if there are no target sections we
+ care about. This way, we avoid keeping the bfd pointer stored
+ somewhere so that target_bfd_xclose could use it. */
+ if (table->sections == table->sections_end)
+ bfd_close (bfd);
+
t = XZALLOC (struct target_ops);
t->to_shortname = "bfd";
t->to_longname = _("BFD backed target");