public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Sasha Da Rocha Pinheiro <darochapinhe@wisc.edu>,
	 "elfutils-devel@sourceware.org" <elfutils-devel@sourceware.org>
Subject: Re: location list
Date: Thu, 25 Jun 2020 16:13:36 +0200	[thread overview]
Message-ID: <c5efb168b3a9f5d13b16612201998a3a0f192eeb.camel@klomp.org> (raw)
In-Reply-To: <DM5PR06MB3115DC8E2F8EC8ACA2286162A6970@DM5PR06MB3115.namprd06.prod.outlook.com>

Hi Sasha,

On Tue, 2020-06-23 at 16:34 +0000, Sasha Da Rocha Pinheiro wrote:
> Since we are now using not only executables and .so, but ".o" files
> too, I'm trying to decide if I can use the same functions to all of
> them, like the code you pointed out to deal with ".o". Would that
> work for EXEC, SHARED, and RELOC?

Yes, it would work. The relocation resolving logic only triggers for .o
(ET_REL) files. But everything else works as expected also for ET_EXEC
and ET_DYN files.

> The idea is not to have two codes to parse modules and DIEs, two ways
> because as you pointed out ".o" files need some relocation to be
> performed, therefore using dwfl_*. Meanwhile for executables and .so
> we only use dwarf_* functions.
> In face of that, do you foresee bigger changes or things we should
> worry that we would have in case we use only dwfl_* to open all the
> ELF files with dwarf data, and drop the way we used to open them?
> Because our code base for a long time has only used the dwarf_*
> functions, this would be a big change.

The real "value" from the Dwfl interface comes from it trying to layout
objects as if dynamically loaded. So you can mimic a process even if it
isn't loaded (or a kernel plus modules). This is why some functions
return an "bias" indicating the difference between the Dwfl_Module
"assigned" addresses and any addresses you might read directly from the
Elf or Dwarf. But you can of course ignore that functionality and just
treat each object file independently.

Besides resolving those relocations for ET_REL files, Dwfl also
provides various (default/standard) callbacks to find/associate
separate debuginfo to an Elf file. See Dwfl_Callbacks and the "Standard
callbacks" in the libdwfl.h file. If you do use it, it might
override/change some search paths for where to get the Dwarf data/file
from. Again, you could not use this functionality if you don't like it.
(Dwfl also works when you provide it the Dwarf data files directly.)

Just look at what you need/want.

Cheers,

Mark

      reply	other threads:[~2020-06-25 14:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-02 14:18 Sasha Da Rocha Pinheiro
2020-06-02 17:19 ` Mark Wielaard
2020-06-02 18:12   ` Sasha Da Rocha Pinheiro
2020-06-06  0:30     ` Sasha Da Rocha Pinheiro
2020-06-06 14:05       ` Mark Wielaard
2020-06-09 16:38         ` Sasha Da Rocha Pinheiro
2020-06-10 11:33           ` Mark Wielaard
2020-06-23 16:34             ` Sasha Da Rocha Pinheiro
2020-06-25 14:13               ` Mark Wielaard [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=c5efb168b3a9f5d13b16612201998a3a0f192eeb.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=darochapinhe@wisc.edu \
    --cc=elfutils-devel@sourceware.org \
    /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).