Mercurial > hg > CbC > CbC_gcc
annotate gcc/genchecksum.c @ 63:b7f97abdc517 gcc-4.6-20100522
update gcc from gcc-4.5.0 to gcc-4.6
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 24 May 2010 12:47:05 +0900 |
parents | 77e2b8dfacca |
children | f6334be47118 |
rev | line source |
---|---|
0 | 1 /* Generate checksums of executables for PCH validation |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
2 Copyright (C) 2005, 2007, 2009 |
0 | 3 Free Software Foundation, Inc. |
4 | |
5 This file is part of GCC. | |
6 | |
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 3, or (at your option) any later | |
10 version. | |
11 | |
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 | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GCC; see the file COPYING3. If not see | |
19 <http://www.gnu.org/licenses/>. */ | |
20 | |
21 #include "bconfig.h" | |
22 #include "system.h" | |
23 #include "md5.h" | |
24 | |
25 static void | |
26 usage (void) | |
27 { | |
28 fputs ("Usage: genchecksums <filename>\n", stderr); | |
29 } | |
30 | |
31 static void | |
32 dosum (const char *file) | |
33 { | |
34 FILE *f; | |
35 unsigned char result[16]; | |
36 int i; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
37 |
0 | 38 f = fopen (file, "rb"); |
39 if (!f) | |
40 { | |
41 fprintf (stderr, "opening %s: %s\n", file, xstrerror (errno)); | |
42 exit (1); | |
43 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
44 |
0 | 45 /* Some executable formats have timestamps in the first 16 bytes, yuck. */ |
46 if (fseek (f, 16, SEEK_SET) != 0) | |
47 { | |
48 fprintf (stderr, "seeking in %s: %s\n", file, xstrerror (errno)); | |
49 exit (1); | |
50 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
51 |
0 | 52 if (md5_stream (f, result) != 0 |
53 || fclose (f) != 0) | |
54 { | |
55 fprintf (stderr, "reading %s: %s\n", file, xstrerror (errno)); | |
56 exit (1); | |
57 } | |
58 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
59 puts ("#include \"config.h\""); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
60 puts ("#include \"system.h\""); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
61 fputs ("EXPORTED_CONST unsigned char executable_checksum[16] = { ", stdout); |
0 | 62 for (i = 0; i < 16; i++) |
63
b7f97abdc517
update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
63 printf ("0x%02x%s", result[i], i == 15 ? " };\n" : ", "); |
0 | 64 } |
65 | |
66 int | |
67 main (int argc, char ** argv) | |
68 { | |
69 if (argc != 2) | |
70 { | |
71 usage (); | |
72 return 1; | |
73 } | |
74 | |
75 dosum (argv[1]); | |
76 | |
77 return 0; | |
78 } |