From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#42790: [PATH] 27.1; Add version info into file name "emacs.pdmp" to avoid mismatch pdmp file Date: Wed, 21 Jul 2021 15:51:18 +0200 Message-ID: <87k0ljixm1.fsf@gnus.org> References: <87ft8unbwe.fsf@igel.home> <83o8jsysm8.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3578"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Glenn Morris , schwab@linux-m68k.org, 42790@debbugs.gnu.org, lin.sun@zoom.us To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 21 15:52:12 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m6Cdw-0000fM-5e for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 21 Jul 2021 15:52:12 +0200 Original-Received: from localhost ([::1]:39184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m6Cdv-0006Xr-7M for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 21 Jul 2021 09:52:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6Cdm-0006Sp-GD for bug-gnu-emacs@gnu.org; Wed, 21 Jul 2021 09:52:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m6Cdm-0006td-8x for bug-gnu-emacs@gnu.org; Wed, 21 Jul 2021 09:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m6Cdm-00019l-8L for bug-gnu-emacs@gnu.org; Wed, 21 Jul 2021 09:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Jul 2021 13:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42790 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch help confirmed Original-Received: via spool by 42790-submit@debbugs.gnu.org id=B42790.16268754934404 (code B ref 42790); Wed, 21 Jul 2021 13:52:02 +0000 Original-Received: (at 42790) by debbugs.gnu.org; 21 Jul 2021 13:51:33 +0000 Original-Received: from localhost ([127.0.0.1]:36600 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m6CdJ-00018y-4x for submit@debbugs.gnu.org; Wed, 21 Jul 2021 09:51:33 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:42914) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m6CdH-00018k-3X for 42790@debbugs.gnu.org; Wed, 21 Jul 2021 09:51:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=/0CbiM9sRCULJ2D7YyJhl+8xSOrDNJAvntxDI0hjIIY=; b=IKRBBO5vmJ5/VvK20NJTaPgcMR R8wrVRd2hrRhubl3J9X9DSzHhx9iKAe0R5/N+rRoZMJvQpCyrnX0j/pGTNy7BxEGCxcUToNyv2aCy O/EA0+eaVPKxsxDfRwqQqQeqAOIMWyeW0tka9PKK5LhpE7qrRpycDYZoKyq1kyaNnSOI=; Original-Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m6Cd4-00078d-Q2; Wed, 21 Jul 2021 15:51:23 +0200 X-Now-Playing: Soft as Snow's _#savefabric (8)_: "I Adore (Troy Gunner Remix)" In-Reply-To: <83o8jsysm8.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 20 Nov 2020 17:07:11 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:210440 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > I hope this gets cleaned up, because I think it would be good to have > this fixed for Emacs 27.2. I've reworked Glenn's patch for Emacs 28... but this is only for installed Emacsen? (And his comments about it needing more work is still true.) So that bit of the patch isn't directly relevant for the subject of this bug report, but I guess the addition of the "--fingerprint" bit is? (So that we can write to emacs-FINGERPRINT.pdmp before moving to the numbered version?) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=hex.patch diff --git a/Makefile.in b/Makefile.in index 97d954b6ce..edca0e7cf3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -307,6 +307,7 @@ TRANSFORM = EMACS_NAME = `echo emacs | sed '$(TRANSFORM)'` EMACS = ${EMACS_NAME}${EXEEXT} EMACSFULL = `echo emacs-${version} | sed '$(TRANSFORM)'`${EXEEXT} +EMACS_PDMP = `./src/emacs${EXEEXT} --fingerprint 2>&1 | sed 's/.* //'`.pdmp # Subdirectories to make recursively. SUBDIR = $(NTDIR) lib lib-src src lisp @@ -515,7 +516,7 @@ install-arch-dep: ifeq (${ns_self_contained},no) ${INSTALL_PROGRAM} $(INSTALL_STRIP) src/emacs${EXEEXT} "$(DESTDIR)${bindir}/$(EMACSFULL)" ifeq (${DUMPING},pdumper) - ${INSTALL_DATA} src/emacs.pdmp "$(DESTDIR)${libexecdir}/emacs/${version}/${configuration}"/emacs.pdmp + ${INSTALL_DATA} src/emacs.pdmp "$(DESTDIR)${libexecdir}/emacs/${version}/${configuration}"/${EMACS_PDMP} endif -chmod 755 "$(DESTDIR)${bindir}/$(EMACSFULL)" ifndef NO_BIN_LINK diff --git a/src/emacs.c b/src/emacs.c index 866e43fda9..2f971880cc 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -133,6 +133,7 @@ #define MAIN_PROGRAM #endif #include "pdumper.h" +#include "fingerprint.h" #include "epaths.h" static const char emacs_version[] = PACKAGE_VERSION; @@ -255,6 +256,7 @@ #define MAIN_PROGRAM #ifdef HAVE_PDUMPER "\ --dump-file FILE read dumped state from FILE\n\ +--fingerprint output fingerprint and exit\n\ ", #endif #if SECCOMP_USABLE @@ -830,6 +832,8 @@ load_pdump (int argc, char **argv) const char *const suffix = ".pdmp"; int result; char *emacs_executable = argv[0]; + ptrdiff_t hexbuf_size; + char *hexbuf; const char *strip_suffix = #if defined DOS_NT || defined CYGWIN ".exe" @@ -927,9 +931,13 @@ load_pdump (int argc, char **argv) /* Look for "emacs.pdmp" in PATH_EXEC. We hardcode "emacs" in "emacs.pdmp" so that the Emacs binary still works if the user copies and renames it. */ + hexbuf_size = 2 * sizeof fingerprint + 1; + hexbuf = xmalloc (hexbuf_size); + hexbuf_digest (hexbuf, (char *)fingerprint, sizeof fingerprint); + hexbuf[sizeof hexbuf] = '\0'; needed = (strlen (path_exec) + 1 - + strlen (argv0_base) + + strlen (hexbuf) + strlen (suffix) + 1); if (bufsize < needed) @@ -938,7 +946,7 @@ load_pdump (int argc, char **argv) dump_file = xpalloc (NULL, &bufsize, needed - bufsize, -1, 1); } sprintf (dump_file, "%s%c%s%s", - path_exec, DIRECTORY_SEP, argv0_base, suffix); + path_exec, DIRECTORY_SEP, hexbuf, suffix); #if !defined (NS_SELF_CONTAINED) /* Assume the Emacs binary lives in a sibling directory as set up by the default installation configuration. */ @@ -1387,6 +1395,23 @@ main (int argc, char **argv) exit (0); } +#ifdef HAVE_PDUMPER + if (argmatch (argv, argc, "-fingerprint", "--fingerprint", 4, + NULL, &skip_args)) + { + if (initialized) + { + dump_fingerprint ("fingerprint", (unsigned char *)fingerprint); + exit (0); + } + else + { + fputs ("Not initialized\n", stderr); + exit (1); + } + } +#endif + emacs_wd = emacs_get_current_dir_name (); #ifdef HAVE_PDUMPER if (dumped_with_pdumper_p ()) diff --git a/src/pdumper.c b/src/pdumper.c index 7730ea3d06..0a97849047 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -312,7 +312,7 @@ dump_reloc_set_offset (struct dump_reloc *reloc, dump_off offset) error ("dump relocation out of range"); } -static void +void dump_fingerprint (char const *label, unsigned char const xfingerprint[sizeof fingerprint]) { diff --git a/src/pdumper.h b/src/pdumper.h index deec9af046..bc339c42da 100644 --- a/src/pdumper.h +++ b/src/pdumper.h @@ -50,6 +50,9 @@ #define PDUMPER_IGNORE(thing) ((void) &(thing)) #define PDUMPER_REMEMBER_SCALAR(thing) \ pdumper_remember_scalar (&(thing), sizeof (thing)) +extern void dump_fingerprint (const char *label, + const unsigned char *xfingerprint); + extern void pdumper_remember_scalar_impl (void *data, ptrdiff_t nbytes); INLINE void --=-=-=--