aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schwab2019-07-09 21:12:14 +0200
committerAndreas Schwab2019-07-09 21:41:24 +0200
commitfc41b0610e5bb204dd9905f89e235ea801e7a4ea (patch)
tree5905a009530bda821688434a936bbf3fa96bad15
parentbff64115a0ad081282e0f99305f41c8dd1917d67 (diff)
downloademacs-fc41b0610e5bb204dd9905f89e235ea801e7a4ea.tar.gz
emacs-fc41b0610e5bb204dd9905f89e235ea801e7a4ea.zip
Make fingerprint handling compatible with LTO
Tell the compiler that the fingerprint variable is modified unpredictably. * lib/fingerprint.h (fingerprint): Remove const. * lib/fingerprint.c (fingerprint): Likewise. * src/pdumper.c (Fdump_emacs_portable): Cast fingerprint variable. (pdumper_load): Likewise. * lib-src/make-fingerprint.c (main): Likewise.
-rw-r--r--lib-src/make-fingerprint.c3
-rw-r--r--lib/fingerprint.c2
-rw-r--r--lib/fingerprint.h2
-rw-r--r--src/pdumper.c8
4 files changed, 9 insertions, 6 deletions
diff --git a/lib-src/make-fingerprint.c b/lib-src/make-fingerprint.c
index 5779e0d2746..2417548d8ca 100644
--- a/lib-src/make-fingerprint.c
+++ b/lib-src/make-fingerprint.c
@@ -144,7 +144,8 @@ main (int argc, char **argv)
144 144
145 for (char *finger = buf; 145 for (char *finger = buf;
146 (finger = memmem (finger, buf + chunksz - finger, 146 (finger = memmem (finger, buf + chunksz - finger,
147 fingerprint, sizeof fingerprint)); 147 (unsigned char *) fingerprint,
148 sizeof fingerprint));
148 finger++) 149 finger++)
149 { 150 {
150 if (! (fseeko (f, finger - buf, SEEK_SET) == 0 151 if (! (fseeko (f, finger - buf, SEEK_SET) == 0
diff --git a/lib/fingerprint.c b/lib/fingerprint.c
index e55de9c6da3..2cc1973428f 100644
--- a/lib/fingerprint.c
+++ b/lib/fingerprint.c
@@ -29,7 +29,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29 by a fingerprint of the temporary Emacs executable that was built 29 by a fingerprint of the temporary Emacs executable that was built
30 along the way. */ 30 along the way. */
31 31
32unsigned char const fingerprint[] = 32volatile unsigned char fingerprint[] =
33 { 33 {
34 0xDE, 34 0xDE,
35 0x86, 35 0x86,
diff --git a/lib/fingerprint.h b/lib/fingerprint.h
index 0b195fd0ca7..ba2e740cd9e 100644
--- a/lib/fingerprint.h
+++ b/lib/fingerprint.h
@@ -24,6 +24,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
24 Emacs. This way, we have a unique value that we can use to pair 24 Emacs. This way, we have a unique value that we can use to pair
25 data files (like a portable dump image) with a specific build of 25 data files (like a portable dump image) with a specific build of
26 Emacs. */ 26 Emacs. */
27extern unsigned char const fingerprint[32]; 27extern volatile unsigned char fingerprint[32];
28 28
29#endif 29#endif
diff --git a/src/pdumper.c b/src/pdumper.c
index 8b630d221b1..7d29d3c0c83 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -4101,7 +4101,8 @@ types. */)
4101 ctx->header.magic[0] = '!'; /* Note that dump is incomplete. */ 4101 ctx->header.magic[0] = '!'; /* Note that dump is incomplete. */
4102 4102
4103 verify (sizeof (fingerprint) == sizeof (ctx->header.fingerprint)); 4103 verify (sizeof (fingerprint) == sizeof (ctx->header.fingerprint));
4104 memcpy (ctx->header.fingerprint, fingerprint, sizeof (fingerprint)); 4104 memcpy (ctx->header.fingerprint, (unsigned char *) fingerprint,
4105 sizeof (fingerprint));
4105 4106
4106 const dump_off header_start = ctx->offset; 4107 const dump_off header_start = ctx->offset;
4107 dump_fingerprint ("dumping fingerprint", ctx->header.fingerprint); 4108 dump_fingerprint ("dumping fingerprint", ctx->header.fingerprint);
@@ -5359,9 +5360,10 @@ pdumper_load (const char *dump_filename)
5359 5360
5360 err = PDUMPER_LOAD_VERSION_MISMATCH; 5361 err = PDUMPER_LOAD_VERSION_MISMATCH;
5361 verify (sizeof (header->fingerprint) == sizeof (fingerprint)); 5362 verify (sizeof (header->fingerprint) == sizeof (fingerprint));
5362 if (memcmp (header->fingerprint, fingerprint, sizeof (fingerprint)) != 0) 5363 if (memcmp (header->fingerprint, (unsigned char *) fingerprint,
5364 sizeof (fingerprint)) != 0)
5363 { 5365 {
5364 dump_fingerprint ("desired fingerprint", fingerprint); 5366 dump_fingerprint ("desired fingerprint", (unsigned char *) fingerprint);
5365 dump_fingerprint ("found fingerprint", header->fingerprint); 5367 dump_fingerprint ("found fingerprint", header->fingerprint);
5366 goto out; 5368 goto out;
5367 } 5369 }