Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Jordan Rupprecht via gdb-patches" <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Cc: echristo@gmail.com, dblaikie@gmail.com, dje@google.com
Subject: Re: [PATCH] [dwarf2read] Fix crash when loading dwp files: calculate num_sections based on actual section indices, not just the number of sections.
Date: Mon, 25 Feb 2019 20:17:00 -0000	[thread overview]
Message-ID: <20190225201715.144927-1-rupprecht@google.com> (raw)
In-Reply-To: <439bf4f6859a539472a2e51a028b9503@polymtl.ca>

On Sat, Feb 23, 2019 at 8:01 PM Simon Marchi <simon.marchi@polymtl.ca> wrote:
>
> On 2019-02-22 19:53, Jordan Rupprecht via gdb-patches wrote:
> > When loading dwp files, we create an array of elf sections indexed by
> > the section index in the dwp file. The size of this array is
> > calculated by section_count + 1 (the +1 handling the null section).
> > However, when loading the bfd file, strtab/symtab sections are not
> > added to the list, nor do they increment section_count, so
> > section_count is actually smaller than the number of sections.
>
> Just wondering, is this the expected behavior of BFD, to not make the
> strtab section count as a section (as far as bfd_count_sections is
> concerned)?  If so, why?
I'm not very familiar with bfd, so I don't know if it's expected. It
seems that bfd->sections contains "interesting" sections (e.g.
progbits), and treats sections like strtab/symtab as a kind of
metadata section that get stored differently. The method I'm stepping
through is bfd_section_from_shdr here:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf.c;h=f16acaa08d8e24af9af069efcdcb244b2c19c734;hb=HEAD#l1994.
Running that method over a normal .dwp file, all the .debug_* methods
get added to sections, but .strtab/.symtab/.shstrtab don't.

So it *seems* like that's expected behavior, but I can't say for sure
that it is.

>
> Otherwise can we just elf_numsections instead of bfd_count_sections?
> Since we index the array by ELF section index, using the number of ELF
> sections seems appropriate, it should always match.  We wouldn't need
> the +1 then.

Don't know how I didn't see that. Now I don't need
get_largest_section_index() anymore. Thanks!
All your comments are basically not relevant any more :)



  reply	other threads:[~2019-02-25 20:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-23  0:54 Jordan Rupprecht via gdb-patches
2019-02-24  4:01 ` Simon Marchi
2019-02-25 20:17   ` Jordan Rupprecht via gdb-patches [this message]
2019-02-25 20:21     ` Simon Marchi
2019-02-25 20:21     ` Jordan Rupprecht via gdb-patches
2019-02-25 20:55       ` Simon Marchi
2019-02-25 21:22         ` Jordan Rupprecht via gdb-patches
2019-02-26 15:08         ` Tom Tromey
2019-02-26 16:24           ` Simon Marchi
2019-02-27  4:41             ` Simon Marchi
2019-02-27 17:22               ` Tom Tromey
2019-02-27 17:40                 ` Simon Marchi
2019-02-27 17:56                   ` Eric Christopher
2019-02-27 18:06                     ` Adrian Prantl
2019-02-27 18:13                       ` Simon Marchi
2019-02-27 19:33                       ` David Blaikie

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=20190225201715.144927-1-rupprecht@google.com \
    --to=gdb-patches@sourceware.org \
    --cc=dblaikie@gmail.com \
    --cc=dje@google.com \
    --cc=echristo@gmail.com \
    --cc=rupprecht@google.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