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.
This commit is contained in:
parent
4fd9048e94
commit
ebecafbd19
1 changed files with 17 additions and 21 deletions
|
@ -140,31 +140,27 @@ main (int argc, char **argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
char *finger = memmem (buf, chunksz, fingerprint, sizeof fingerprint);
|
||||
if (!finger)
|
||||
bool fingered = false;
|
||||
|
||||
for (char *finger = buf;
|
||||
(finger = memmem (finger, buf + chunksz - finger,
|
||||
fingerprint, sizeof fingerprint));
|
||||
finger++)
|
||||
{
|
||||
if (! (fseeko (f, finger - buf, SEEK_SET) == 0
|
||||
&& fwrite (digest, 1, sizeof digest, f) == sizeof digest))
|
||||
{
|
||||
perror (file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
fingered = true;
|
||||
}
|
||||
|
||||
if (!fingered)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: missing fingerprint\n", prog, file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
else if (memmem (finger + 1, buf + chunksz - (finger + 1),
|
||||
fingerprint, sizeof fingerprint))
|
||||
{
|
||||
fprintf (stderr, "%s: %s: two occurrences of fingerprint\n",
|
||||
prog, file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (fseeko (f, finger - buf, SEEK_SET) != 0)
|
||||
{
|
||||
perror (file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (fwrite (digest, 1, sizeof digest, f) != sizeof digest)
|
||||
{
|
||||
perror (file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (fclose (f) != 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue