1 /* Generate checksums of executables for PCH validation
3 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
29 fputs ("Usage: genchecksums <filename>\n", stderr
);
33 dosum (const char *file
)
36 unsigned char result
[16];
39 f
= fopen (file
, "rb");
42 fprintf (stderr
, "opening %s: %s\n", file
, xstrerror (errno
));
46 /* Some executable formats have timestamps in the first 16 bytes, yuck. */
47 if (fseek (f
, 16, SEEK_SET
) != 0)
49 fprintf (stderr
, "seeking in %s: %s\n", file
, xstrerror (errno
));
53 if (md5_stream (f
, result
) != 0
56 fprintf (stderr
, "reading %s: %s\n", file
, xstrerror (errno
));
60 fputs ("const unsigned char executable_checksum[16] = { ", stdout
);
61 for (i
= 0; i
< 16; i
++)
62 printf ("%#02x%s", result
[i
], i
== 15 ? " };\n" : ", ");
66 main (int argc
, char ** argv
)