On 3/20/24 19:52, Mark Wielaard wrote:
Hi Martin,
On Wed, Mar 06, 2024 at 04:22:49PM -0300, Martin Rodriguez Reboredo wrote:
Added new functions dwfl_get_offline_next_address and
dwfl_set_offline_next_address which will get plus set said field from
the Dwfl struct. This is a requirement for listing functions from their
addresses when using libdwfl offline, otherwise wrong symbols are going
to be returned.
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. :)