]> git.eshelyaron.com Git - emacs.git/commitdiff
Make fingerprint handling compatible with LTO
authorAndreas Schwab <schwab@linux-m68k.org>
Tue, 9 Jul 2019 19:12:14 +0000 (21:12 +0200)
committerAndreas Schwab <schwab@linux-m68k.org>
Tue, 9 Jul 2019 19:41:24 +0000 (21:41 +0200)
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.

lib-src/make-fingerprint.c
lib/fingerprint.c
lib/fingerprint.h
src/pdumper.c

index 5779e0d2746ee830c1e1c5b626461b51c3a13970..2417548d8cacc73d81c22b2b76d12ef664f766cf 100644 (file)
@@ -144,7 +144,8 @@ main (int argc, char **argv)
 
       for (char *finger = buf;
           (finger = memmem (finger, buf + chunksz - finger,
-                            fingerprint, sizeof fingerprint));
+                            (unsigned char *) fingerprint,
+                            sizeof fingerprint));
           finger++)
        {
          if (! (fseeko (f, finger - buf, SEEK_SET) == 0
index e55de9c6da356b1d896a7f75f250edd259bb0796..2cc1973428fee11d0644a42c3b5b354424ed1072 100644 (file)
@@ -29,7 +29,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
    by a fingerprint of the temporary Emacs executable that was built
    along the way.  */
 
-unsigned char const fingerprint[] =
+volatile unsigned char fingerprint[] =
   {
    0xDE,
    0x86,
index 0b195fd0ca742a2bcebf275bcddd7b562db63a92..ba2e740cd9e91eb86b3107cb5752a369f96801d5 100644 (file)
@@ -24,6 +24,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
    Emacs.  This way, we have a unique value that we can use to pair
    data files (like a portable dump image) with a specific build of
    Emacs.  */
-extern unsigned char const fingerprint[32];
+extern volatile unsigned char fingerprint[32];
 
 #endif
index 8b630d221b1f8a92caeab8dc84e70b3c6da45dfb..7d29d3c0c836a750bcc5efb6186a5967a06f71bb 100644 (file)
@@ -4101,7 +4101,8 @@ types.  */)
   ctx->header.magic[0] = '!'; /* Note that dump is incomplete.  */
 
   verify (sizeof (fingerprint) == sizeof (ctx->header.fingerprint));
-  memcpy (ctx->header.fingerprint, fingerprint, sizeof (fingerprint));
+  memcpy (ctx->header.fingerprint, (unsigned char *) fingerprint,
+         sizeof (fingerprint));
 
   const dump_off header_start = ctx->offset;
   dump_fingerprint ("dumping fingerprint", ctx->header.fingerprint);
@@ -5359,9 +5360,10 @@ pdumper_load (const char *dump_filename)
 
   err = PDUMPER_LOAD_VERSION_MISMATCH;
   verify (sizeof (header->fingerprint) == sizeof (fingerprint));
-  if (memcmp (header->fingerprint, fingerprint, sizeof (fingerprint)) != 0)
+  if (memcmp (header->fingerprint, (unsigned char *) fingerprint,
+             sizeof (fingerprint)) != 0)
     {
-      dump_fingerprint ("desired fingerprint", fingerprint);
+      dump_fingerprint ("desired fingerprint", (unsigned char *) fingerprint);
       dump_fingerprint ("found fingerprint", header->fingerprint);
       goto out;
     }