diff options
| author | Mark Wielaard <[email protected]> | 2013-12-18 11:05:54 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2013-12-20 10:09:49 +0100 |
| commit | 159ac52b061c60947a943c102298cd692223274f (patch) | |
| tree | d3d3a07d249704f95424072064e160df4ae4c156 /src/readelf.c | |
| parent | 565149d564cfe9da3b5cd94c9387ee0473d0704a (diff) | |
libdwfl: Introduce dwfl_module_getsym_info and dwfl_module_addrinfo.
Some arches like ppc64 use function descriptor values instead of function
addresses causing matching of names and addresses to fail when using
dwfl_module_getsym or dwfl_module_addrsym.
Add ebl hook to resolve any function descriptor values found in non-ET_REL
modules.
The new function dwfl_module_getsym_info doesn't adjust the symbol value
in any way, but returns the adjusted and/or resolved address associated
with the symbol separately. The new function dwfl_module_addrinfo resolves
against both the address associated with the symbol (which could be the
function entry address) value and the adjusted st_value. So that it is
easy to resolve and match either function descriptors and/or function
entry addresses.
Since these new functions also return more information they replace the
dwfl_module_getsym_elf and dwfl_module_addrsym_elf functions that never
made it into a released elfutils version.
addr2line and readelf now use the new functions when looking up functions
names. addr2line will now also display the section the address was found
in when given -x.
Extra testcases were added for both addr2line and the dwflsyms testscase.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'src/readelf.c')
| -rw-r--r-- | src/readelf.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/readelf.c b/src/readelf.c index 7ed9f4a5..739156cf 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -3290,10 +3290,10 @@ format_dwarf_addr (Dwfl_Module *dwflmod, { /* See if there is a name we can give for this address. */ GElf_Sym sym; + GElf_Off off = 0; const char *name = (print_address_names && ! print_unresolved_addresses) - ? dwfl_module_addrsym (dwflmod, address, &sym, NULL) : NULL; - if (name != NULL) - sym.st_value = address - sym.st_value; + ? dwfl_module_addrinfo (dwflmod, address, &off, &sym, NULL, NULL, NULL) + : NULL; const char *scn; if (print_unresolved_addresses) @@ -3314,24 +3314,24 @@ format_dwarf_addr (Dwfl_Module *dwflmod, char *result; if ((name != NULL - ? (sym.st_value != 0 + ? (off != 0 ? (scn != NULL ? (address_size == 0 ? asprintf (&result, gettext ("%s+%#" PRIx64 " <%s+%#" PRIx64 ">"), - scn, address, name, sym.st_value) + scn, address, name, off) : asprintf (&result, gettext ("%s+%#0*" PRIx64 " <%s+%#" PRIx64 ">"), scn, 2 + address_size * 2, address, - name, sym.st_value)) + name, off)) : (address_size == 0 ? asprintf (&result, gettext ("%#" PRIx64 " <%s+%#" PRIx64 ">"), - address, name, sym.st_value) + address, name, off) : asprintf (&result, gettext ("%#0*" PRIx64 " <%s+%#" PRIx64 ">"), 2 + address_size * 2, address, - name, sym.st_value))) + name, off))) : (scn != NULL ? (address_size == 0 ? asprintf (&result, |
