]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Fix report_r_debug for prelinked libraries
authorJan Kratochvil <jan.kratochvil@redhat.com>
Thu, 24 Jul 2014 18:47:17 +0000 (20:47 +0200)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 28 Jul 2014 19:00:13 +0000 (21:00 +0200)
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
libdwfl/ChangeLog
libdwfl/link_map.c

index 4a1b9d5c4591ea04c7eb78dbdc50f4dd38dbd918..ab47c4040411dbf2d5da375342c9e577ce03eb7e 100644 (file)
@@ -1,3 +1,9 @@
+2014-07-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       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  <kurt@roeckx.be>
 
        * linux-pid-attach.c: Make it build on non linux hosts.
index 2913d9f73a0ac70aa1676d20bc096e1de4643f76..272f89ba7f17285b6a0e5a8f9b081d2843f98142 100644 (file)
@@ -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,