From 844f1b84ccc4c6967c95165e9c62d9a6c94d791d Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Tue, 17 Dec 2013 15:00:13 +0100 Subject: [PATCH] Pass relocated address to tdep_get_func_addr The ppc64 implementation of tdep_get_func_addr would crash when attempting to retrieve the address of a function in a shared library. The problem was that it needs to dereference the function descriptor, but common code was passing the *unrelocated* adddress of the descriptor to the tdep_get_func_addr routine. Instead, common code would attempt to relocate the *result* of tdep_get_func_addr, which is also wrong: the ppc64 implementation reads the function address from the in-memory copy of the descriptor, which is already relocation and contains the final address. This patch fixes the problem by relocating the descriptor address before passing it to tdep_get_func_addr, instead of relocating the result of tdep_get_func_addr. Since ppc64 is the only non-trivial implementation of tdep_get_func_addr, this cannot affect any other platform. Signed-off-by: Ulrich Weigand --- src/elfxx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/elfxx.c b/src/elfxx.c index 3d873317..b1afce20 100644 --- a/src/elfxx.c +++ b/src/elfxx.c @@ -128,10 +128,11 @@ elf_w (lookup_symbol) (unw_addr_space_t as, if (ELF_W (ST_TYPE) (sym->st_info) == STT_FUNC && sym->st_shndx != SHN_UNDEF) { - if (tdep_get_func_addr (as, sym->st_value, &val) < 0) - continue; + val = sym->st_value; if (sym->st_shndx != SHN_ABS) val += load_offset; + if (tdep_get_func_addr (as, val, &val) < 0) + continue; Debug (16, "0x%016lx info=0x%02x %s\n", (long) val, sym->st_info, strtab + sym->st_name);