Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [patch] Fix ELF stale reference [Re: [patch] .gdb_index: Do not crash on NOBITS]
Date: Thu, 09 Sep 2010 16:01:00 -0000	[thread overview]
Message-ID: <AANLkTikm4c_dPTiqA8hsw8AkNbpKbyQNxC3qgRJi98Au@mail.gmail.com> (raw)
In-Reply-To: <20100909090511.GA937@host1.dyn.jankratochvil.net>

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);
>


  reply	other threads:[~2010-09-09 14:52 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 [this message]
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

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=AANLkTikm4c_dPTiqA8hsw8AkNbpKbyQNxC3qgRJi98Au@mail.gmail.com \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --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