1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-05-10 00:25:18 +02:00

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 <uweigand@de.ibm.com>
This commit is contained in:
Ulrich Weigand 2013-12-17 15:00:13 +01:00 committed by Arun Sharma
parent 5710c98fbf
commit 844f1b84cc

View file

@ -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);