+ if (modname != NULL && mod->dwfl->executable_for_core != NULL
+ && (strcmp (modname, "[exe]") == 0 || strcmp (modname, "[pie]") == 0))
+ {
+ /* When dwfl_core_file_report was called with a non-NULL executable file
+ name this callback will replace the Dwfl_Module main.name with the
+ recorded executable file when the modname is [exe] or [pie] (which
+ then triggers opening and reporting of the executable). */
+ int fd = open64 (mod->dwfl->executable_for_core, O_RDONLY);
+ if (fd >= 0)
+ {
+ *file_name = strdup (mod->dwfl->executable_for_core);
+ if (*file_name != NULL)
+ return fd;
+ else
+ close (fd);
+ }
+ }
+ int fd = __libdwfl_open_mod_by_build_id (mod, false, file_name);