From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org, Doug Evans <dje@google.com>
Subject: Re: [patch] Fix ELF stale reference
Date: Fri, 19 Nov 2010 22:49:00 -0000 [thread overview]
Message-ID: <20101119224854.GA4675@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <m3hbgo8y6y.fsf@fleche.redhat.com>
On Thu, 14 Oct 2010 19:46:13 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>
> Jan> OK to check-in? Or some bfd/ API improvement should be made?
>
> I think this is probably the cleanest fix.
Checked in.
> However, libbfd.h does say right at the top that it shouldn't be used.
>
> I guess we could ask for advice on the binutils list.
This part has been fixed recently in binutils (as you forwarded me):
http://sourceware.org/ml/binutils/2010-10/msg00413.html
So no new libbfd.h include is now needed in GDB.
Regarding the introduced memory leak it seems to be fixable but I have only
filed GDB PR for it now:
http://sourceware.org/bugzilla/show_bug.cgi?id=12243
Thanks,
Jan
http://sourceware.org/ml/gdb-cvs/2010-11/msg00094.html
--- src/gdb/ChangeLog 2010/11/19 18:10:43 1.12319
+++ src/gdb/ChangeLog 2010/11/19 22:30:44 1.12320
@@ -1,4 +1,10 @@
2010-11-19 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix stale memory references.
+ * elfread.c (elf_symfile_read): Replace xmalloc by bfd_alloc, drop
+ xfree, new comment.
+
+2010-11-19 Jan Kratochvil <jan.kratochvil@redhat.com>
Tom Tromey <tromey@redhat.com>
* Makefile.in (.y.c): Directly create $@ from YLWRAP.
--- src/gdb/elfread.c 2010/10/01 20:26:11 1.99
+++ src/gdb/elfread.c 2010/11/19 22:30:47 1.100
@@ -790,8 +790,14 @@
if (storage_needed > 0)
{
- dyn_symbol_table = (asymbol **) xmalloc (storage_needed);
- make_cleanup (xfree, dyn_symbol_table);
+ /* Memory gets permanently referenced from ABFD after
+ bfd_get_synthetic_symtab so it must not get freed before ABFD gets.
+ It happens only in the case when elf_slurp_reloc_table sees
+ asection->relocation NULL. Determining which section is asection is
+ done by _bfd_elf_get_synthetic_symtab which is all a bfd
+ implementation detail, though. */
+
+ dyn_symbol_table = bfd_alloc (abfd, storage_needed);
dynsymcount = bfd_canonicalize_dynamic_symtab (objfile->obfd,
dyn_symbol_table);
prev parent reply other threads:[~2010-11-19 22:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-08 19:40 [patch] .gdb_index: Do not crash on NOBITS Jan Kratochvil
2010-09-08 23:19 ` Tom Tromey
2010-09-08 23:36 ` Jan Kratochvil
2010-09-09 14:05 ` [patch] Fix ELF stale reference [Re: [patch] .gdb_index: Do not crash on NOBITS] Jan Kratochvil
2010-09-09 16:01 ` Doug Evans
2010-09-09 16:11 ` Jan Kratochvil
2010-10-14 16:07 ` [patch] Fix ELF stale reference Jan Kratochvil
2010-10-14 17:46 ` Tom Tromey
2010-11-19 22:49 ` Jan Kratochvil [this message]
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=20101119224854.GA4675@host0.dyn.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@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).