[patch] Fix ELF stale reference
Jan Kratochvil
jan.kratochvil@redhat.com
Fri Nov 19 22:49:00 GMT 2010
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);
More information about the Gdb-patches
mailing list