OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [genchecksum.c] - Diff between revs 816 and 826

Only display areas with differences | Details | Blame | View Log

Rev 816 Rev 826
/* Generate checksums of executables for PCH validation
/* Generate checksums of executables for PCH validation
   Copyright (C) 2005, 2007, 2009
   Copyright (C) 2005, 2007, 2009
   Free Software Foundation, Inc.
   Free Software Foundation, Inc.
 
 
This file is part of GCC.
This file is part of GCC.
 
 
GCC is free software; you can redistribute it and/or modify it under
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
Software Foundation; either version 3, or (at your option) any later
version.
version.
 
 
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.
for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */
<http://www.gnu.org/licenses/>.  */
 
 
#include "bconfig.h"
#include "bconfig.h"
#include "system.h"
#include "system.h"
#include "md5.h"
#include "md5.h"
 
 
static void
static void
usage (void)
usage (void)
{
{
  fputs ("Usage: genchecksums <filename>\n", stderr);
  fputs ("Usage: genchecksums <filename>\n", stderr);
}
}
 
 
static void
static void
dosum (const char *file)
dosum (const char *file)
{
{
  FILE *f;
  FILE *f;
  unsigned char result[16];
  unsigned char result[16];
  int i;
  int i;
 
 
  f = fopen (file, "rb");
  f = fopen (file, "rb");
  if (!f)
  if (!f)
    {
    {
      fprintf (stderr, "opening %s: %s\n", file, xstrerror (errno));
      fprintf (stderr, "opening %s: %s\n", file, xstrerror (errno));
      exit (1);
      exit (1);
    }
    }
 
 
  /* Some executable formats have timestamps in the first 16 bytes, yuck.  */
  /* Some executable formats have timestamps in the first 16 bytes, yuck.  */
  if (fseek (f, 16, SEEK_SET) != 0)
  if (fseek (f, 16, SEEK_SET) != 0)
     {
     {
      fprintf (stderr, "seeking in %s: %s\n", file, xstrerror (errno));
      fprintf (stderr, "seeking in %s: %s\n", file, xstrerror (errno));
      exit (1);
      exit (1);
    }
    }
 
 
  if (md5_stream (f, result) != 0
  if (md5_stream (f, result) != 0
      || fclose (f) != 0)
      || fclose (f) != 0)
     {
     {
      fprintf (stderr, "reading %s: %s\n", file, xstrerror (errno));
      fprintf (stderr, "reading %s: %s\n", file, xstrerror (errno));
      exit (1);
      exit (1);
    }
    }
 
 
  puts ("#include \"config.h\"");
  puts ("#include \"config.h\"");
  puts ("#include \"system.h\"");
  puts ("#include \"system.h\"");
  fputs ("EXPORTED_CONST unsigned char executable_checksum[16] = { ", stdout);
  fputs ("EXPORTED_CONST unsigned char executable_checksum[16] = { ", stdout);
  for (i = 0; i < 16; i++)
  for (i = 0; i < 16; i++)
    printf ("%#02x%s", result[i], i == 15 ? " };\n" : ", ");
    printf ("%#02x%s", result[i], i == 15 ? " };\n" : ", ");
}
}
 
 
int
int
main (int argc, char ** argv)
main (int argc, char ** argv)
{
{
  if (argc != 2)
  if (argc != 2)
    {
    {
      usage ();
      usage ();
      return 1;
      return 1;
    }
    }
 
 
  dosum (argv[1]);
  dosum (argv[1]);
 
 
  return 0;
  return 0;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.