From: Kevin Buettner <kevinb@redhat.com>
To: Jim Blandy <jimb@redhat.com>, gdb-patches@sources.redhat.com
Subject: Re: [ppc64-linux]: correctly find a BFD's code entry point address
Date: Fri, 13 Jun 2003 05:45:00 -0000 [thread overview]
Message-ID: <1030613054523.ZM346@localhost.localdomain> (raw)
In-Reply-To: Jim Blandy <jimb@redhat.com> "[ppc64-linux]: correctly find a BFD's code entry point address" (Jun 12, 6:12pm)
On Jun 12, 6:12pm, Jim Blandy wrote:
> + /* Return the unrelocated code address at which execution begins for
> + ABFD, under the 64-bit PowerPC Linux ABI. On that system, the ELF
> + header e_entry field (which is what bfd_get_start_address gives
> + you) is the address of the function descriptor for the startup
> + function, not the address of the actual machine instruction you
> + jump to.
> +
> + This function doesn't just go and read the entry point from the
> + function descriptor. We need it to work when ABFD is the dynamic
> + linker, immediately after an exec. But ld.so is a dynamic
> + executable itself on PPC64 Linux, so it appears in memory whereever
> + the kernel drops it; this means that bfd_get_start_address's result
> + needs to be adjusted --- by some offset we don't know. So we can't
> + find the descriptor's address in memory to read the entry point
> + from it.
> +
> + Instead, we do it all based on ABFD's symbol table. We take the
> + address from bfd_get_start_address, find each symbol at that
> + address, stick a '.' on the front of its name to get the entry
> + point symbol name, try to look that up, and return the value of
> + what we find, if anything. We never touch memory, or talk with the
> + kernel about the inferior at all.
> +
> + Now, this address we return is straight from the symbol table, so
> + it hasn't been adjusted to take into account where ABFD was loaded.
> + But that's okay --- our job is just to return the unrelocated code
> + address. */
This approach strikes me as somewhat more complicated (and fragile)
than need be. I think it would be preferable to simply fetch the
necessary bytes from the address given by bfd_get_start_address in the
executable (or object) file.
Nice description though; I really appreciate comments like this.
Kevin
next prev parent reply other threads:[~2003-06-13 5:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-12 23:12 Jim Blandy
2003-06-13 5:45 ` Kevin Buettner [this message]
2003-06-14 0:03 ` Jim Blandy
2003-06-18 0:22 ` Kevin Buettner
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=1030613054523.ZM346@localhost.localdomain \
--to=kevinb@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=jimb@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