From: Nurdin <npremji@redhat.com>
To: Roland McGrath <roland@redhat.com>
Cc: Frysk List <frysk@sourceware.org>
Subject: Re: getting vDSO image into libdwfl
Date: Fri, 25 May 2007 16:50:00 -0000 [thread overview]
Message-ID: <4655F80E.9010101@redhat.com> (raw)
In-Reply-To: <20070518071438.4FF511F804E@magilla.localdomain>
Roland McGrath wrote:
> The dwfl_linux_proc_find_elf callback does this as a skeletal example.
> It uses this function (see libdwfl/elf-from-memory.c):
>
> /* Reconstruct an ELF file by reading the segments out of remote memory
> based on the ELF file header at EHDR_VMA and the ELF program headers it
> points to. If not null, *LOADBASEP is filled in with the difference
> between the addresses from which the segments were read, and the
> addresses the file headers put them at.
>
> The function READ_MEMORY is called to copy at least MINREAD and at most
> MAXREAD bytes from the remote memory at target address ADDRESS into the
> local buffer at DATA; it should return -1 for errors (with code in
> `errno'), 0 if it failed to read at least MINREAD bytes due to EOF, or
> the number of bytes read if >= MINREAD. ARG is passed through. */
>
> Elf *
> elf_from_remote_memory (GElf_Addr ehdr_vma,
> GElf_Addr *loadbasep,
> ssize_t (*read_memory) (void *arg, void *data,
> GElf_Addr address,
> size_t minread,
> size_t maxread),
> void *arg)
>
> This is an internal function not exported in the DSO or declared anywhere.
> I wrote it as the necessary and separable component (and analogous to the
> BFD function bfd_elf_bfd_from_remote_memory I added for the gdb vDSO
> support). I tested it via dwfl_linux_proc_find_elf (-p option to
> eu-addr2line et al). (Back then, /proc/PID/mem had not been made so
> "secure", so it even worked in eu-foo without ptrace.) I figured the
> details of interface to that code and how it integrates with everything
> would be ironed out when a real user came along. Now here we are.
>
> The signature of the read_memory callback is arbitrary.
> It just seemed like the roughly appropriate general thing.
> It's easy to change.
>
> This function doesn't really fit with the libelf interfaces. It could be
> exposed by libdwfl in some fashion I suppose. I hadn't really figured out
> what seemed right, which is why it's as it is. I could just change its
> name and signature slightly, and export it from libdwfl.
I just exposed this method inside libdwfl.h and I haven't needed to
change the read_memory interface at all.
prev parent reply other threads:[~2007-05-24 20:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-17 18:04 Dwfl Callbacks, how would I pass a ByteBuffer to find_elf (possibly through user_data) Nurdin
2007-05-18 7:14 ` Dwfl Callbacks Roland McGrath
2007-05-18 16:53 ` getting vDSO image into libdwfl Roland McGrath
2007-05-25 16:50 ` Nurdin [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=4655F80E.9010101@redhat.com \
--to=npremji@redhat.com \
--cc=frysk@sourceware.org \
--cc=roland@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).