From: Jan Kratochvil Date: Thu, 21 Nov 2013 14:31:04 +0000 (+0100) Subject: Verify file vs. core build-id, when both available X-Git-Tag: elfutils-0.158~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b301c2efeab0a712570bfd72ae5e07a63f1ba784;p=thirdparty%2Felfutils.git Verify file vs. core build-id, when both available Signed-off-by: Jan Kratochvil --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index c0fbc831d..3c2ffc814 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2013-11-21 Jan Kratochvil + + * 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 link_map: Use proper bias, not l_addr. diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 97f4a1afc..55f6d3883 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. */