summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2009-02-21 00:28:18 +0100
committerMark Wielaard <mjw@redhat.com>2009-02-21 00:28:18 +0100
commit524c6f82b0a3c010d0fd6a67b1afcfbf55b789a6 (patch)
tree712f7712e32fdb66dc2109e63248677dfaf31d76
parent02615365a92ca2570c1f96abc8a97674aa2ccae1 (diff)
downloadsystemtap-steved-524c6f82b0a3c010d0fd6a67b1afcfbf55b789a6.tar.gz
systemtap-steved-524c6f82b0a3c010d0fd6a67b1afcfbf55b789a6.tar.xz
systemtap-steved-524c6f82b0a3c010d0fd6a67b1afcfbf55b789a6.zip
Adjust ET_DYN symbol addresses against module base.
* translate.cxx (dump_unwindsyms): Adjust sym_addr for ET_DYN always against module base as workaround for buggy elfutils < 0.138.
-rw-r--r--translate.cxx44
1 files changed, 13 insertions, 31 deletions
diff --git a/translate.cxx b/translate.cxx
index f2ebf762..530b077d 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -4551,37 +4551,19 @@ dump_unwindsyms (Dwfl_Module *m,
if (n > 0) // only try to relocate if there exist relocation bases
{
- Dwarf_Addr bias, save_addr = sym_addr;
- GElf_Ehdr *ehdr, ehdr_mem;
- GElf_Phdr *phdr = NULL, phdr_mem;
- Elf *elf = dwfl_module_getelf (m, &bias);
- int idx;
- int ki = dwfl_module_relocate_address (m, &sym_addr);
- dwfl_assert ("dwfl_module_relocate_address", ki >= 0);
- secname = dwfl_module_relocation_info (m, ki, NULL);
-
- // For ET_DYN files (secname == "") we do ignore the
- // dwfl_module_relocate_address adjustment. libdwfl
- // up to 0.137 would substract the wrong bias.
- if (ki == 0 && secname != NULL && secname[0] == '\0')
- sym_addr = save_addr - bias;
-
- // We just want the address relative to the start of the
- // segment as loaded into memory.
- ehdr = gelf_getehdr(elf, &ehdr_mem);
- for (idx = 0; idx < ehdr->e_phnum; idx++)
- {
- phdr = gelf_getphdr (elf, idx, &phdr_mem);
- if (phdr != NULL
- && phdr->p_type == PT_LOAD
- && phdr->p_flags & PF_X
- && sym_addr >= phdr->p_vaddr
- && sym_addr < phdr->p_vaddr + phdr->p_memsz)
- break;
- }
- if (phdr != NULL && idx < ehdr->e_phnum)
- sym_addr -= phdr->p_vaddr;
- }
+ Dwarf_Addr save_addr = sym_addr;
+ int ki = dwfl_module_relocate_address (m, &sym_addr);
+ dwfl_assert ("dwfl_module_relocate_address", ki >= 0);
+ secname = dwfl_module_relocation_info (m, ki, NULL);
+
+ // For ET_DYN files (secname == "") we do ignore the
+ // dwfl_module_relocate_address adjustment. libdwfl
+ // up to 0.137 would substract the wrong bias. So we do
+ // it ourself, it is always just the module base address
+ // in this case.
+ if (ki == 0 && secname != NULL && secname[0] == '\0')
+ sym_addr = save_addr - base;
+ }
if (n == 1 && modname == "kernel")
{