aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2010-11-19 22:30:47 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2010-11-19 22:30:47 +0000
commit3f1eff0a2c7f0e7078f011f55b8e7f710aae0cc2 (patch)
tree71d6a15c23d685d9d022894ad5cd1c51c1261f42
parente552509bcb9d7f5aa2735fb0f8630a04649c55c0 (diff)
downloadgdb-3f1eff0a2c7f0e7078f011f55b8e7f710aae0cc2.zip
gdb-3f1eff0a2c7f0e7078f011f55b8e7f710aae0cc2.tar.gz
gdb-3f1eff0a2c7f0e7078f011f55b8e7f710aae0cc2.tar.bz2
gdb/
Fix stale memory references. * elfread.c (elf_symfile_read): Replace xmalloc by bfd_alloc, drop xfree, new comment.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/elfread.c10
2 files changed, 14 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 39d48ef..fcbd31d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 270f93f..d607b87 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -790,8 +790,14 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
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);