From: Markus Metzger <markus.t.metzger@intel.com>
To: palves@redhat.com
Cc: gdb-patches@sourceware.org
Subject: [PATCH] symfile, vdso: remove target sections
Date: Wed, 04 Jun 2014 12:31:00 -0000 [thread overview]
Message-ID: <1401885066-10620-1-git-send-email-markus.t.metzger@intel.com> (raw)
Target sections added by the add-symbol-file-from-memory command are not
removed when the process exits. In fact, they are not removed, at all.
This causes GDB to crash in gdb.base/break-interp.exp.
Change the owner of those target sections to the object file generated in
symbol_file_add_from_memory and generalize the free_objfile observer in
symfile.c to remove target sections of any freed object file.
2014-06-04 Markus Metzger <markus.t.metzger@intel.com>
* symfile.c (symfile_free_objfile): Remove restriction to
OBJF_USERLOADED.
* symfile-mem.c (symbol_file_add_from_memory): Call
add_target_sections_of_objfile.
---
gdb/symfile-mem.c | 18 +-----------------
gdb/symfile.c | 2 +-
2 files changed, 2 insertions(+), 18 deletions(-)
diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c
index b29421e..ef48f7d 100644
--- a/gdb/symfile-mem.c
+++ b/gdb/symfile-mem.c
@@ -92,7 +92,6 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr,
struct section_addr_info *sai;
unsigned int i;
struct cleanup *cleanup;
- struct target_section *sections, *sections_end, *tsec;
if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
error (_("add-symbol-file-from-memory not supported for this target"));
@@ -132,22 +131,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr,
from_tty ? SYMFILE_VERBOSE : 0,
sai, OBJF_SHARED, NULL);
- sections = NULL;
- sections_end = NULL;
-
- if (build_section_table (nbfd, §ions, §ions_end) == 0)
- {
- make_cleanup (xfree, sections);
-
- /* Adjust the target section addresses by the load address. */
- for (tsec = sections; tsec != sections_end; ++tsec)
- {
- tsec->addr += loadbase;
- tsec->endaddr += loadbase;
- }
-
- add_target_sections (&nbfd, sections, sections_end);
- }
+ add_target_sections_of_objfile (objf);
/* This might change our ideas about frames already looked at. */
reinit_frame_cache ();
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 64a83c6..caa0722 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3893,7 +3893,7 @@ static void
symfile_free_objfile (struct objfile *objfile)
{
/* Remove the target sections of user-added objfiles. */
- if (objfile != 0 && objfile->flags & OBJF_USERLOADED)
+ if (objfile != NULL)
remove_target_sections ((void *) objfile);
}
--
1.8.3.1
next reply other threads:[~2014-06-04 12:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-04 12:31 Markus Metzger [this message]
2014-06-04 16:05 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1401885066-10620-1-git-send-email-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).