summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2013-11-21 15:31:04 +0100
committerJan Kratochvil <jan.kratochvil@redhat.com>2013-11-21 15:31:04 +0100
commitb301c2efeab0a712570bfd72ae5e07a63f1ba784 (patch)
tree5a602b4cb56bd947bbb11c6694c266b38de04bc8
parent463e983e20fdb945b11bb175ca71e23b31146d8e (diff)
downloadelfutils-b301c2efeab0a712570bfd72ae5e07a63f1ba784.tar.gz
Verify file vs. core build-id, when both available
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
-rw-r--r--libdwfl/ChangeLog6
-rw-r--r--libdwfl/dwfl_segment_report_module.c30
2 files changed, 31 insertions, 5 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index c0fbc831..3c2ffc81 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,11 @@
2013-11-21 Jan Kratochvil <jan.kratochvil@redhat.com>
+ * dwfl_segment_report_module.c (dwfl_segment_report_module): New
+ variable close_elf. Call __libdwfl_find_elf_build_id and compare the
+ content, if possible.
+
+2013-11-21 Jan Kratochvil <jan.kratochvil@redhat.com>
+
link_map: Use proper bias, not l_addr.
* core-file.c (dynamic_vaddr_get): Rename to ...
(__libdwfl_dynamic_vaddr_get): ... here, make it global,
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index 97f4a1af..55f6d388 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -478,20 +478,40 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
if ((module_end > module->start && module_start < module->end)
|| dyn_vaddr == module->l_ld)
{
+ bool close_elf = false;
if (! module->disk_file_has_build_id && build_id_len > 0)
{
/* Module found in segments with build-id is more reliable
than a module found via DT_DEBUG on disk without any
build-id. */
if (module->elf != NULL)
+ close_elf = true;
+ }
+ if (module->elf != NULL
+ && module->disk_file_has_build_id && build_id_len > 0)
+ {
+ const void *elf_build_id;
+ GElf_Addr elf_build_id_elfaddr;
+ int elf_build_id_len;
+
+ if (__libdwfl_find_elf_build_id (NULL, module->elf,
+ &elf_build_id,
+ &elf_build_id_elfaddr,
+ &elf_build_id_len) > 0)
{
- elf_end (module->elf);
- close (module->fd);
- module->elf = NULL;
- module->fd = -1;
+ if (build_id_len != (size_t) elf_build_id_len
+ || memcmp (build_id, elf_build_id, build_id_len) != 0)
+ close_elf = true;
}
}
- else if (module->elf != NULL)
+ if (close_elf)
+ {
+ elf_end (module->elf);
+ close (module->fd);
+ module->elf = NULL;
+ module->fd = -1;
+ }
+ if (module->elf != NULL)
{
/* Ignore this found module if it would conflict in address
space with any already existing module of DWFL. */