diff options
Diffstat (limited to 'gdb/elfread.c')
-rw-r--r-- | gdb/elfread.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gdb/elfread.c b/gdb/elfread.c index 65c63f05386..4a6576f8026 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1144,8 +1144,10 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, if (storage_needed > 0) { - symbol_table = (asymbol **) xmalloc (storage_needed); - make_cleanup (xfree, symbol_table); + /* Memory gets permanently referenced from ABFD after + bfd_canonicalize_symtab so it must not get freed before ABFD gets. */ + + symbol_table = bfd_alloc (abfd, storage_needed); symcount = bfd_canonicalize_symtab (objfile->obfd, symbol_table); if (symcount < 0) |