From: Jan Kratochvil Date: Thu, 24 Jul 2014 18:47:17 +0000 (+0200) Subject: Fix report_r_debug for prelinked libraries X-Git-Tag: elfutils-0.160~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=475849fdb25265706772905b856cd7028c566a71;p=thirdparty%2Felfutils.git Fix report_r_debug for prelinked libraries Signed-off-by: Jan Kratochvil --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 4a1b9d5c4..ab47c4040 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2014-07-24 Jan Kratochvil + + Fix report_r_debug for prelinked libraries. + * link_map.c (report_r_debug): Comment out variable l_addr. + Use instead new variable base recalculated from l_ld. + 2014-06-24 Kurt Roeckx * linux-pid-attach.c: Make it build on non linux hosts. diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c index 2913d9f73..272f89ba7 100644 --- a/libdwfl/link_map.c +++ b/libdwfl/link_map.c @@ -321,7 +321,11 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata, if (read_addrs (next, 4)) return release_buffer (-1); - GElf_Addr l_addr = addrs[0]; + /* Unused: l_addr is the difference between the address in memory + and the ELF file when the core was created. We need to + recalculate the difference below because the ELF file we use + might be differently pre-linked. */ + // GElf_Addr l_addr = addrs[0]; GElf_Addr l_name = addrs[1]; GElf_Addr l_ld = addrs[2]; next = addrs[3]; @@ -432,11 +436,14 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata, if (valid) { + // It is like l_addr but it handles differently prelinked + // files at core dumping vs. core loading time. + GElf_Addr base = l_ld - elf_dynamic_vaddr; if (r_debug_info_module == NULL) { // XXX hook for sysroot mod = __libdwfl_report_elf (dwfl, basename (name), - name, fd, elf, l_addr, + name, fd, elf, base, true, true); if (mod != NULL) { @@ -444,7 +451,7 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata, fd = -1; } } - else if (__libdwfl_elf_address_range (elf, l_addr, true, + else if (__libdwfl_elf_address_range (elf, base, true, true, NULL, NULL, &r_debug_info_module->start, &r_debug_info_module->end,