diff options
-rw-r--r-- | libdwfl/dwfl_module_getdwarf.c | 12 | ||||
-rw-r--r-- | libdwfl/dwfl_process_tracker_find_elf.c | 1 |
2 files changed, 12 insertions, 1 deletions
diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c index 6f98c02b..6aa87fdf 100644 --- a/libdwfl/dwfl_module_getdwarf.c +++ b/libdwfl/dwfl_module_getdwarf.c @@ -79,6 +79,18 @@ open_elf (Dwfl_Module *mod, struct dwfl_file *file) if (error != DWFL_E_NOERROR) return error; + /* Cache file->elf in Dwfl_Process_Tracker if available: */ + if (mod->dwfl->tracker != NULL && file->name != NULL) + { + dwfltracker_elftab_ent *ent = __libdwfl_process_tracker_elftab_find (mod->dwfl->tracker, file->name, false/* should_resize */); + if (ent != NULL) + { + /* assert(ent->elf == NULL || ent->elf == file->elf); */ /* TODO(PRERELEASE): Guard against redundant/leaked Elf *. */ + assert(ent->fd == file->fd); /* TODO(PRERELEASE): Guard against redundant open. */ + ent->elf = file->elf; + } + } + GElf_Ehdr ehdr_mem, *ehdr = gelf_getehdr (file->elf, &ehdr_mem); if (ehdr == NULL) { diff --git a/libdwfl/dwfl_process_tracker_find_elf.c b/libdwfl/dwfl_process_tracker_find_elf.c index d1871071..20c48bea 100644 --- a/libdwfl/dwfl_process_tracker_find_elf.c +++ b/libdwfl/dwfl_process_tracker_find_elf.c @@ -82,7 +82,6 @@ dwfl_process_tracker_find_elf (Dwfl_Module *mod, /* XXX fd < 0 implies elf_from_remote_memory, uses base, not cacheable */ if (tracker != NULL && ent != NULL && fd >= 0 && *file_name != NULL) { - /* TODO(WIP): *elfp may be NULL here, need to be populated later. */ ent->elf = *elfp; ent->fd = fd; rc = fstat(fd, &sb); |