[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libunwind-devel] [PATCH] Pass relocated address to tdep_get_func_addr
From: |
Ulrich Weigand |
Subject: |
[Libunwind-devel] [PATCH] Pass relocated address to tdep_get_func_addr |
Date: |
Tue, 17 Dec 2013 15:00:13 +0100 (CET) |
[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 <address@hidden>
---
src/elfxx.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/elfxx.c b/src/elfxx.c
index 3d87331..b1afce2 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);
--
1.8.5
--
Dr. Ulrich Weigand
GNU/Linux compilers and toolchain
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Libunwind-devel] [PATCH] Pass relocated address to tdep_get_func_addr,
Ulrich Weigand <=