This is the mail archive of the
mailing list for the elfutils project.
Re: dwfl_module_addrinfo and @plt entries
- From: Mark Wielaard <mark at klomp dot org>
- To: Milian Wolff <mail at milianw dot de>
- Cc: elfutils-devel at sourceware dot org
- Date: Fri, 07 Jul 2017 13:03:32 +0200
- Subject: Re: dwfl_module_addrinfo and @plt entries
- Authentication-results: sourceware.org; auth=none
- References: <4389913.7LHyNoxDn3@agathebauer> <4367790.cbajsgPFcv@milian-kdab2> <20170106191753.GB8669@stream> <3866408.Fn4hcxxxTc@milian-kdab2>
First congrats on https://www.kdab.com/hotspot-gui-linux-perf-profiler/
On Wed, 2017-07-05 at 15:34 +0200, Milian Wolff wrote:
> On Friday, January 6, 2017 8:17:53 PM CEST Mark Wielaard wrote:
> I have now looked into this issue again and have found a way to workaround
> this limitation outside of elfutils, by manually resolving the address in a
> .plt section to a symbol. See:
> This seems to work in my limited tests (only on X86_64). Beside the 32bit/
> 64bit difference, it isn't really platform dependent, is it? Or was this what
> you had in mind when you said the elfutils code would be "architecture
> specific [and] we would need a backend function that translates an address
> pointing into the PLT into an actual function address"?
> If my code is roughly OK, then I'll try to put it into a patch for elfutils
> and submit it there. If it's fundamentally broken, please tell me. I still
> plan to get this functionality upstream into elfutils.
Thanks for the research. I don't know if the PLT/GOT resolving works
identical for all architectures. But yes, it does look like what you
came up with is in general architecture independent.
In general it would be nice if we could avoid any name based section
lookups (or only do them as fallbacks) since we might not have section
headers (for example if you got the ELF image from memory).
I wonder if we can get all the information needed from the dynamic
segment. For example it seems we have a DT_JMPREL that points directly
at the .plt table, DT_PLTREL gives you what kind of relocation entries
REL or RELA it contains and DT_PLTRELSZ gives the size of the plt
In your code you get the GOT address through DT_PLTGOT, but then use
that address to lookup the .got.plt section and use its sh_addr to index
into the table. Why is that? Isn't that address equal to what you
already got through DT_PLTGOT?