[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 4c61975: Defend fingerprint against even-smarter LT
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master 4c61975: Defend fingerprint against even-smarter LTO |
Date: |
Tue, 9 Jul 2019 16:56:50 -0400 (EDT) |
branch: master
commit 4c619758b2806ee6607af7b1d56943e547001e7a
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
Defend fingerprint against even-smarter LTO
* src/pdumper.c (Fdump_emacs_portable, pdumper_load):
Don’t cast volatile to non-volatile pointer, as that does not in
general suffice to prevent a compiler from optimizing away memcmp
and/or memcpy calls. Instead, copy the fingerprint by hand.
---
src/pdumper.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/pdumper.c b/src/pdumper.c
index 7d29d3c..3d8531c 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -4101,8 +4101,8 @@ types. */)
ctx->header.magic[0] = '!'; /* Note that dump is incomplete. */
verify (sizeof (fingerprint) == sizeof (ctx->header.fingerprint));
- memcpy (ctx->header.fingerprint, (unsigned char *) fingerprint,
- sizeof (fingerprint));
+ for (int i = 0; i < sizeof fingerprint; i++)
+ ctx->header.fingerprint[i] = fingerprint[i];
const dump_off header_start = ctx->offset;
dump_fingerprint ("dumping fingerprint", ctx->header.fingerprint);
@@ -5360,10 +5360,12 @@ pdumper_load (const char *dump_filename)
err = PDUMPER_LOAD_VERSION_MISMATCH;
verify (sizeof (header->fingerprint) == sizeof (fingerprint));
- if (memcmp (header->fingerprint, (unsigned char *) fingerprint,
- sizeof (fingerprint)) != 0)
+ unsigned char desired[sizeof fingerprint];
+ for (int i = 0; i < sizeof fingerprint; i++)
+ desired[i] = fingerprint[i];
+ if (memcmp (header->fingerprint, desired, sizeof desired) != 0)
{
- dump_fingerprint ("desired fingerprint", (unsigned char *) fingerprint);
+ dump_fingerprint ("desired fingerprint", desired);
dump_fingerprint ("found fingerprint", header->fingerprint);
goto out;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 4c61975: Defend fingerprint against even-smarter LTO,
Paul Eggert <=