public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Tom Tromey <tom@tromey.com>
Cc: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb/symtab] Fix out-of-bounds in objfile::section_offset
Date: Mon, 18 Jul 2022 15:34:47 +0100	[thread overview]
Message-ID: <a096a994-f6d0-432b-e6af-f27eda6528e3@palves.net> (raw)
In-Reply-To: <87bktqnr3c.fsf@tromey.com>

On 2022-07-15 7:55 p.m., Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:
> 
> Pedro> Another question is, why do the bfd sections grow in the first
> Pedro> place?
> 
> It does seem bad if this can happen randomly.  If it can be done
> intentionally though we could have gdb take whatever action is needed
> when first reading the BFD to get the full section count.

See Alan's reply here:

 https://lists.gnu.org/archive/html/bug-binutils/2022-07/msg00128.html

His last sentence:

 "Hmm, I suppose you could argue that since this is done for the linker, there is no
 need to do so for simple_get_relocated_section_contents."

... suggests this could be fixed in bfd.  I have no idea what that entails, but if it's
just not doing something, then maybe it's simple enough?

> 
> All this stuff with section indices only exists for the case where an
> objfile is loaded using different offsets for different sections.  Can
> this really happen (aside from absolute sections)?  If not maybe we
> could just get rid of all of it.

Given:

  add-symbol-file FILE [-s SECT-NAME SECT-ADDR]...

... I think that yes, it happens.

Also, there are targets where shared libraries aren't really fully
linked libraries, but instead relocatable objects (https://sourceware.org/gdb/current/onlinedocs/gdb/Library-List-Format.html),
and for those, I don't think we can assume a single offset works for all sections.

Even if we have fully linked binaries and segments, then it can be that different
segments are loaded independently, with different bias offsets?  That would mean different
offsets for different sections too.

      reply	other threads:[~2022-07-18 14:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-12  8:00 Tom de Vries
2022-07-12  9:30 ` Pedro Alves
2022-07-12 10:16   ` Tom de Vries
2022-07-12 10:25     ` Pedro Alves
2022-07-12 12:09       ` Tom de Vries
2022-07-15 18:55       ` Tom Tromey
2022-07-18 14:34         ` Pedro Alves [this message]

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=a096a994-f6d0-432b-e6af-f27eda6528e3@palves.net \
    --to=pedro@palves.net \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    --cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).