public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Jeff Lin <jeffli@xilinx.com>
Cc: "elfutils-devel@sourceware.org" <elfutils-devel@sourceware.org>
Subject: Re: Using dwarf_getfuncs to get function from object stored in memory
Date: Mon, 23 Aug 2021 23:00:59 +0200	[thread overview]
Message-ID: <YSQMiwhvWuqW41eW@wildebeest.org> (raw)
In-Reply-To: <9584640F-85CC-4CEF-B059-0044C7FE2151@xilinx.com>

Hi Jeff,

On Tue, Aug 17, 2021 at 03:40:08AM +0000, Jeff Lin via Elfutils-devel wrote:
> I’ve written code to extract function from a shared object with
> dwarf_begin api that finds the dwarf objects with the file
> descriptor using dwarf_getfuncs.  However, when I tried to parse the
> same object that is loaded into memory first, dwarf_getfuncs is not
> able to get the function.  In the case of accessing the object that
> is in memory, I used the following line to get the dwarf object:
>
>   Elf *ehandle = elf_memory(const_cast<char *>(so_file), size);
>   Dwarf *dw = dwarf_begin_elf(ehandle, DWARF_C_READ, NULL);
> 
> I am able to get the offset and tag with dwarf_nextcu, but errors
> out with dwarf_getfuncs.  Does anyone know why dwarf_getfuncs does
> return properly when trying to process dwarf object that was store
> in memory?

If the ELF in memory is the same as the ELF on disk I don't know why
dwarf_getfuncs would work differently. Does the callback get called?
Does dwarf_getfuncs return -1? What does dwarf_errmsg say?

Cheers,

Mark


  reply	other threads:[~2021-08-23 21:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17  3:40 Jeff Lin
2021-08-23 21:00 ` Mark Wielaard [this message]
2021-08-24  6:48   ` Jeff Lin

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=YSQMiwhvWuqW41eW@wildebeest.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    --cc=jeffli@xilinx.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).