public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/3] relocate the entry point addess when used
Date: Mon, 13 Jan 2014 20:46:00 -0000	[thread overview]
Message-ID: <8738kr1ug8.fsf@fleche.redhat.com> (raw)
In-Reply-To: <52CD5129.7090003@redhat.com> (Pedro Alves's message of "Wed, 08	Jan 2014 13:22:49 +0000")

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Tom> I think the existing code here is wrong.  It computes the entry point
Tom> address directly from the BFD, not applying any runtime offsets.
Tom> However, then objfile_relocate1 passes this address to find_pc_section
Tom> -- which does use the offsets .  So, it seems to me that the current
Tom> code can only find the correct address by luck.

Pedro> It's twisted, but I don't think it's luck.  You can convince yourself
Pedro> it works by debugging a PIE, and trying a backtrace past main
Pedro> ("set backtrace past-main" will then trigger the code to stop the
Pedro> backtrace at the entry point), or doing "info files" (shows the entry).

Well, what I don't understand is that most addresses in dwarf2read.c are
offset:

  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));

... however this is not done for the entry point, which comes directly
from the BFD:

      objfile->per_bfd->ei.entry_point = bfd_get_start_address (objfile->obfd);

I suppose there is some other invariant ensuring that the entry point is
only computed when all the objfile offsets are zero.  This part is not
obvious to me.

[...]
Pedro> This is assuming osect ends up NULL after iterating over all.
Pedro> It's violating the abstraction of the macro.  And, actually,
Pedro> it's wrong, showing exactly why such assumptions are a bad idea:

Sorry about that, I'll fix it up locally.

Tom

  reply	other threads:[~2014-01-13 20:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-06 20:30 [PATCH 0/3] move entry point info to the per-BFD object Tom Tromey
2014-01-06 20:30 ` [PATCH 1/3] change solib-frv to use entry_point_address_query Tom Tromey
2014-01-08 13:23   ` Pedro Alves
2014-01-06 20:30 ` [PATCH 2/3] relocate the entry point addess when used Tom Tromey
2014-01-08 13:22   ` Pedro Alves
2014-01-13 20:46     ` Tom Tromey [this message]
2014-01-15 11:42       ` Pedro Alves
2014-01-15 17:59         ` Tom Tromey
2014-01-15 18:02           ` Pedro Alves
2014-01-06 20:30 ` [PATCH 3/3] move the entry point info into the per-bfd object Tom Tromey
2014-01-08 13:30   ` Pedro Alves
2014-01-13 20:51     ` Tom Tromey
2014-01-15 18:01 ` [PATCH 0/3] move entry point info to the per-BFD object Tom Tromey

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=8738kr1ug8.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).