This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix ELF stale reference [Re: [patch] .gdb_index: Do not crash on NOBITS]


On Thu, Sep 9, 2010 at 2:05 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
>
> gdb/
> 2010-09-09 ?Jan Kratochvil ?<jan.kratochvil@redhat.com>
>
> ? ? ? ?Fix stale memory references.
> ? ? ? ?* elfread.c: Include libbfd.h.
> ? ? ? ?(elf_symfile_read): Replace xmalloc by bfd_alloc, drop xfree, new
> ? ? ? ?comment.
>
> --- a/gdb/elfread.c
> +++ b/gdb/elfread.c
> @@ -37,6 +37,7 @@
> ?#include "complaints.h"
> ?#include "demangle.h"
> ?#include "psympriv.h"
> +#include "libbfd.h"

Apologies for nitpicking but this raises an issue I'd like to understand better.
I thought libbfd.h was an internal bfd header.
[I know I've wanted to use it at least once and been told "No." :-)]

>
> ?extern void _initialize_elfread (void);
>
> @@ -792,8 +793,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);
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]