|
| 1 | +diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c |
| 2 | +index 3ef62a7d..09ee37b3 100644 |
| 3 | +--- a/libdwfl/dwfl_segment_report_module.c |
| 4 | ++++ b/libdwfl/dwfl_segment_report_module.c |
| 5 | +@@ -737,17 +737,34 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, |
| 6 | + && invalid_elf (module->elf, module->disk_file_has_build_id, |
| 7 | + &build_id)) |
| 8 | + { |
| 9 | +- elf_end (module->elf); |
| 10 | +- close (module->fd); |
| 11 | +- module->elf = NULL; |
| 12 | +- module->fd = -1; |
| 13 | ++ /* If MODULE's build-id doesn't match the disk file's |
| 14 | ++ build-id, close ELF only if MODULE and ELF refer to |
| 15 | ++ different builds of files with the same name. This |
| 16 | ++ prevents premature closure of the correct ELF in cases |
| 17 | ++ where segments of a module are non-contiguous in memory. */ |
| 18 | ++ if (name != NULL && module->name[0] != '\0' |
| 19 | ++ && strcmp (basename (module->name), basename (name)) == 0) |
| 20 | ++ { |
| 21 | ++ elf_end (module->elf); |
| 22 | ++ close (module->fd); |
| 23 | ++ module->elf = NULL; |
| 24 | ++ module->fd = -1; |
| 25 | ++ } |
| 26 | + } |
| 27 | +- if (module->elf != NULL) |
| 28 | ++ else if (module->elf != NULL) |
| 29 | + { |
| 30 | +- /* Ignore this found module if it would conflict in address |
| 31 | +- space with any already existing module of DWFL. */ |
| 32 | ++ /* This module has already been reported. */ |
| 33 | + skip_this_module = true; |
| 34 | + } |
| 35 | ++ else |
| 36 | ++ { |
| 37 | ++ /* Only report this module if we haven't already done so. */ |
| 38 | ++ for (Dwfl_Module *mod = dwfl->modulelist; mod != NULL; |
| 39 | ++ mod = mod->next) |
| 40 | ++ if (mod->low_addr == module_start |
| 41 | ++ && mod->high_addr == module_end) |
| 42 | ++ skip_this_module = true; |
| 43 | ++ } |
| 44 | + } |
| 45 | + if (skip_this_module) |
| 46 | + goto out; |
| 47 | +@@ -781,10 +798,6 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | +- /* Our return value now says to skip the segments contained |
| 52 | +- within the module. */ |
| 53 | +- ndx = addr_segndx (dwfl, segment, module_end, true); |
| 54 | +- |
| 55 | + /* Examine its .dynamic section to get more interesting details. |
| 56 | + If it has DT_SONAME, we'll use that as the module name. |
| 57 | + If it has a DT_DEBUG, then it's actually a PIE rather than a DSO. |
| 58 | +@@ -929,6 +942,8 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, |
| 59 | + ndx = -1; |
| 60 | + goto out; |
| 61 | + } |
| 62 | ++ else |
| 63 | ++ ndx++; |
| 64 | + |
| 65 | + /* We have reported the module. Now let the caller decide whether we |
| 66 | + should read the whole thing in right now. */ |
0 commit comments