aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGlenn Morris2021-10-11 14:03:26 +0200
committerLars Ingebrigtsen2021-10-11 14:03:26 +0200
commite81f1faca4382ed5c8f15fec84fb7c900a5468f9 (patch)
tree4e0166ef21252688f5af41814dfa2c577e23de0f /src
parent932c23f7978cf5e94ed9b6df4969b393f7551716 (diff)
downloademacs-e81f1faca4382ed5c8f15fec84fb7c900a5468f9.tar.gz
emacs-e81f1faca4382ed5c8f15fec84fb7c900a5468f9.zip
Make the installed pmdp file use a fingerprint
* Makefile.in (EMACS_PDMP): Use --fingerprint. * doc/emacs/cmdargs.texi (Action Arguments): Document --fingerprint. * src/emacs.c (load_pdump): Load the fingerprinted version of the pdmp file (bug#42790). (main): Support --fingerprint. * src/pdumper.c (dump_fingerprint): Make non-static. * src/pdumper.h: Declare dump_fingerprint.
Diffstat (limited to 'src')
-rw-r--r--src/emacs.c31
-rw-r--r--src/pdumper.c2
-rw-r--r--src/pdumper.h3
3 files changed, 33 insertions, 3 deletions
diff --git a/src/emacs.c b/src/emacs.c
index 866e43fda94..cda7a9bf77f 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -133,6 +133,7 @@ extern char etext;
133#endif 133#endif
134 134
135#include "pdumper.h" 135#include "pdumper.h"
136#include "fingerprint.h"
136#include "epaths.h" 137#include "epaths.h"
137 138
138static const char emacs_version[] = PACKAGE_VERSION; 139static const char emacs_version[] = PACKAGE_VERSION;
@@ -255,6 +256,7 @@ Initialization options:\n\
255#ifdef HAVE_PDUMPER 256#ifdef HAVE_PDUMPER
256 "\ 257 "\
257--dump-file FILE read dumped state from FILE\n\ 258--dump-file FILE read dumped state from FILE\n\
259--fingerprint output fingerprint and exit\n\
258", 260",
259#endif 261#endif
260#if SECCOMP_USABLE 262#if SECCOMP_USABLE
@@ -830,6 +832,8 @@ load_pdump (int argc, char **argv)
830 const char *const suffix = ".pdmp"; 832 const char *const suffix = ".pdmp";
831 int result; 833 int result;
832 char *emacs_executable = argv[0]; 834 char *emacs_executable = argv[0];
835 ptrdiff_t hexbuf_size;
836 char *hexbuf;
833 const char *strip_suffix = 837 const char *strip_suffix =
834#if defined DOS_NT || defined CYGWIN 838#if defined DOS_NT || defined CYGWIN
835 ".exe" 839 ".exe"
@@ -927,9 +931,15 @@ load_pdump (int argc, char **argv)
927 /* Look for "emacs.pdmp" in PATH_EXEC. We hardcode "emacs" in 931 /* Look for "emacs.pdmp" in PATH_EXEC. We hardcode "emacs" in
928 "emacs.pdmp" so that the Emacs binary still works if the user 932 "emacs.pdmp" so that the Emacs binary still works if the user
929 copies and renames it. */ 933 copies and renames it. */
934 hexbuf_size = 2 * sizeof fingerprint;
935 hexbuf = xmalloc (hexbuf_size + 1);
936 hexbuf_digest (hexbuf, (char *)fingerprint, sizeof fingerprint);
937 hexbuf[hexbuf_size] = '\0';
930 needed = (strlen (path_exec) 938 needed = (strlen (path_exec)
931 + 1 939 + 1
932 + strlen (argv0_base) 940 + strlen (argv0_base)
941 + 1
942 + strlen (hexbuf)
933 + strlen (suffix) 943 + strlen (suffix)
934 + 1); 944 + 1);
935 if (bufsize < needed) 945 if (bufsize < needed)
@@ -937,8 +947,8 @@ load_pdump (int argc, char **argv)
937 xfree (dump_file); 947 xfree (dump_file);
938 dump_file = xpalloc (NULL, &bufsize, needed - bufsize, -1, 1); 948 dump_file = xpalloc (NULL, &bufsize, needed - bufsize, -1, 1);
939 } 949 }
940 sprintf (dump_file, "%s%c%s%s", 950 sprintf (dump_file, "%s%c%s-%s%s",
941 path_exec, DIRECTORY_SEP, argv0_base, suffix); 951 path_exec, DIRECTORY_SEP, argv0_base, hexbuf, suffix);
942#if !defined (NS_SELF_CONTAINED) 952#if !defined (NS_SELF_CONTAINED)
943 /* Assume the Emacs binary lives in a sibling directory as set up by 953 /* Assume the Emacs binary lives in a sibling directory as set up by
944 the default installation configuration. */ 954 the default installation configuration. */
@@ -1387,6 +1397,23 @@ main (int argc, char **argv)
1387 exit (0); 1397 exit (0);
1388 } 1398 }
1389 1399
1400#ifdef HAVE_PDUMPER
1401 if (argmatch (argv, argc, "-fingerprint", "--fingerprint", 4,
1402 NULL, &skip_args))
1403 {
1404 if (initialized)
1405 {
1406 dump_fingerprint ("fingerprint", (unsigned char *)fingerprint);
1407 exit (0);
1408 }
1409 else
1410 {
1411 fputs ("Not initialized\n", stderr);
1412 exit (1);
1413 }
1414 }
1415#endif
1416
1390 emacs_wd = emacs_get_current_dir_name (); 1417 emacs_wd = emacs_get_current_dir_name ();
1391#ifdef HAVE_PDUMPER 1418#ifdef HAVE_PDUMPER
1392 if (dumped_with_pdumper_p ()) 1419 if (dumped_with_pdumper_p ())
diff --git a/src/pdumper.c b/src/pdumper.c
index 11c680d77b7..977f4fb2a85 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -312,7 +312,7 @@ dump_reloc_set_offset (struct dump_reloc *reloc, dump_off offset)
312 error ("dump relocation out of range"); 312 error ("dump relocation out of range");
313} 313}
314 314
315static void 315void
316dump_fingerprint (char const *label, 316dump_fingerprint (char const *label,
317 unsigned char const xfingerprint[sizeof fingerprint]) 317 unsigned char const xfingerprint[sizeof fingerprint])
318{ 318{
diff --git a/src/pdumper.h b/src/pdumper.h
index deec9af046d..bc339c42da5 100644
--- a/src/pdumper.h
+++ b/src/pdumper.h
@@ -50,6 +50,9 @@ enum { PDUMPER_NO_OBJECT = -1 };
50#define PDUMPER_REMEMBER_SCALAR(thing) \ 50#define PDUMPER_REMEMBER_SCALAR(thing) \
51 pdumper_remember_scalar (&(thing), sizeof (thing)) 51 pdumper_remember_scalar (&(thing), sizeof (thing))
52 52
53extern void dump_fingerprint (const char *label,
54 const unsigned char *xfingerprint);
55
53extern void pdumper_remember_scalar_impl (void *data, ptrdiff_t nbytes); 56extern void pdumper_remember_scalar_impl (void *data, ptrdiff_t nbytes);
54 57
55INLINE void 58INLINE void