aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2019-05-04 13:15:29 -0700
committerPaul Eggert2019-05-04 13:16:15 -0700
commitebecafbd19e2ba55ba90bfc9f7de88f4742479ad (patch)
tree891c2640137fadcf223664cbf18cefb2479ccaf6
parent4fd9048e940d38364caf4abe9b209f9288c78544 (diff)
downloademacs-ebecafbd19e2ba55ba90bfc9f7de88f4742479ad.tar.gz
emacs-ebecafbd19e2ba55ba90bfc9f7de88f4742479ad.zip
Port new fingerprinting scheme to clang + LTO
* lib-src/make-fingerprint.c (main): Don't consider multiple instances of the fingerprint to be an error, as this can happen with clang and -flto. Instead, replace all instances of the fingerprint. There is a tiny chance that this will silently corrupt the Emacs executable. This patch suggests that we should go back to fingerprinting the inputs to the linker instead of its output, as the new fingerprinting scheme is unnecessarily complicated and this complexity reduces reliability. The old scheme (i.e., before commit 2019-05-14T23:31:24Z!eggert@cs.ucla.edu) was simpler and more portable and good enough, and it's looking like it would be less trouble in practice than the new scheme.
-rw-r--r--lib-src/make-fingerprint.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/lib-src/make-fingerprint.c b/lib-src/make-fingerprint.c
index 79bd007a5f9..5779e0d2746 100644
--- a/lib-src/make-fingerprint.c
+++ b/lib-src/make-fingerprint.c
@@ -140,29 +140,25 @@ main (int argc, char **argv)
140 } 140 }
141 else 141 else
142 { 142 {
143 char *finger = memmem (buf, chunksz, fingerprint, sizeof fingerprint); 143 bool fingered = false;
144 if (!finger)
145 {
146 fprintf (stderr, "%s: %s: missing fingerprint\n", prog, file);
147 return EXIT_FAILURE;
148 }
149 else if (memmem (finger + 1, buf + chunksz - (finger + 1),
150 fingerprint, sizeof fingerprint))
151 {
152 fprintf (stderr, "%s: %s: two occurrences of fingerprint\n",
153 prog, file);
154 return EXIT_FAILURE;
155 }
156 144
157 if (fseeko (f, finger - buf, SEEK_SET) != 0) 145 for (char *finger = buf;
146 (finger = memmem (finger, buf + chunksz - finger,
147 fingerprint, sizeof fingerprint));
148 finger++)
158 { 149 {
159 perror (file); 150 if (! (fseeko (f, finger - buf, SEEK_SET) == 0
160 return EXIT_FAILURE; 151 && fwrite (digest, 1, sizeof digest, f) == sizeof digest))
152 {
153 perror (file);
154 return EXIT_FAILURE;
155 }
156 fingered = true;
161 } 157 }
162 158
163 if (fwrite (digest, 1, sizeof digest, f) != sizeof digest) 159 if (!fingered)
164 { 160 {
165 perror (file); 161 fprintf (stderr, "%s: %s: missing fingerprint\n", prog, file);
166 return EXIT_FAILURE; 162 return EXIT_FAILURE;
167 } 163 }
168 } 164 }