From: Andreas Schwab Port to GNU Emacs 29.1: Werner Fink Index: src/emacs.c =================================================================== --- src/emacs.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) --- src/emacs.c +++ src/emacs.c 2023-08-07 07:30:34.317996305 +0000 @@ -867,12 +867,16 @@ load_pdump (int argc, char **argv) NULL #endif ; +#ifdef PDMP_BASE + const char *argv0_base = PDMP_BASE +#else const char *argv0_base = #ifdef NS_SELF_CONTAINED "Emacs" #else "emacs" #endif +#endif ; /* TODO: maybe more thoroughly scrub process environment in order to @@ -957,6 +961,29 @@ load_pdump (int argc, char **argv) path_exec = ns_relocate (path_exec); #endif +#ifdef PDMP_BASE + if (emacs_executable && *emacs_executable) + { + needed = (strlen (path_exec) + + 1 + + strlen (argv0_base) + + 1 + + strlen (suffix) + + 1); + if (bufsize < needed) + { + xfree (dump_file); + dump_file = xpalloc (NULL, &bufsize, needed - bufsize, -1, 1); + } + sprintf (dump_file, "%s%c%s%s", + path_exec, DIRECTORY_SEP, argv0_base, suffix); + result = pdumper_load (dump_file, emacs_executable); + + if (result == PDUMPER_LOAD_SUCCESS) + goto out; + } +#endif + /* Look for "emacs-FINGERPRINT.pdmp" in PATH_EXEC. We hardcode "emacs" in "emacs-FINGERPRINT.pdmp" so that the Emacs binary still works if the user copies and renames it. */