[PATCH] Getter and setter for Dwfl's offline_next_address

Mark Wielaard mark@klomp.org
Sun Mar 24 17:08:55 GMT 2024


Hi Martin,

On Sun, Mar 24, 2024 at 11:11:21AM -0300, Martin Rodriguez Reboredo wrote:
> On 3/20/24 19:52, Mark Wielaard wrote:
> >Could you show an example of when/where you need it and what address
> >you set it to?
> 
> For example, this test program reports the name and location pointed by
> the passed address.
> 
> $ ./report /home/yakoyoku/.debug/.build-id/.../elf 0x0003281f
> 0x000000000003281f
> ??
> ??:0
> 
> But due to the mentioned bias both of them are unknown or out of range.
> 
> >The offline_next_address is only relevant for ET_REL files (like
> >object files or kernel modules). In general you will need to check the
> >bias, which various dwfl functions return to know the difference
> >between the addresses in the ELF, Dwarf or the module load address.
> >
> >That said, readelf, nm and dwfl_argp do "cheat" by setting the
> >offline_next_address to zero if they know they are just inspecting a
> >single object file. So maybe this is a functionality we need to
> >expose. But I don't fully understand why you need both a getter and a
> >setter for any arbitrary address.
> 
> I've erroneously thought that setting `offline_next_address` was a
> requirement to obtain what I've needed. But if I use
> `dwfl_module_getelf` or `dwfl_module_getdwarf` I can get the correct
> name and location.
> 
> 0x000000000003281f
> _ZNSt11__copy_moveILb0ELb0ESt26random_access_iterator_tagE8__copy_mIPcPhEET0_T_S6_S5_
> /usr/include/c++/13.2.1/bits/stl_algobase.h:388,18
> 
> So this patch is kinda pointless, but at least I've managed to learn
> what I was missing. Anyways, thanks for the heads-up. :)

I don't think it was pointless. Clearly our documentation is not very
good (and given eu-readelf and eu-nm do cheat, maybe our interface/api
isn't really good either).

Maybe you could post your code for that ./report program and what you
had to do to get it to print the correct address/symbols. Then we at
least have some documentation for others which hit the same issue.

Thanks,

Mark


More information about the Elfutils-devel mailing list