* Makefile.in (GNULIB_H): New. Trigger all-lib.
[deliverable/binutils-gdb.git] / bfd / tekhex.c
index afe42cc948a91b6f3bfbab057d7e8b668fd2ec7e..2df774fc00fce971450f6de0817f82d4c774ede0 100644 (file)
@@ -1,13 +1,13 @@
 /* BFD backend for Extended Tektronix Hex Format  objects.
    Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002,
 /* BFD backend for Extended Tektronix Hex Format  objects.
    Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004 Free Software Foundation, Inc.
+   2003, 2004, 2007 Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program 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 Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -17,7 +17,9 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
 
 /* SUBSECTION
        Tektronix Hex Format handling
 
 /* SUBSECTION
        Tektronix Hex Format handling
@@ -65,8 +67,8 @@
   The data can come out of order, and may be discontigous. This is a
   serial protocol, so big files are unlikely, so we keep a list of 8k chunks.  */
 
   The data can come out of order, and may be discontigous. This is a
   serial protocol, so big files are unlikely, so we keep a list of 8k chunks.  */
 
-#include "bfd.h"
 #include "sysdep.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 #include "libiberty.h"
 
 #include "libbfd.h"
 #include "libiberty.h"
 
@@ -387,6 +389,8 @@ first_phase (bfd *abfd, int type, char *src)
            return FALSE;
          memcpy (n, sym, len + 1);
          section = bfd_make_section (abfd, n);
            return FALSE;
          memcpy (n, sym, len + 1);
          section = bfd_make_section (abfd, n);
+         if (section == NULL)
+           return FALSE;
        }
       while (*src)
        {
        }
       while (*src)
        {
@@ -436,6 +440,7 @@ first_phase (bfd *abfd, int type, char *src)
                if (!getvalue (&src, &val))
                  return FALSE;
                new->symbol.value = val - section->vma;
                if (!getvalue (&src, &val))
                  return FALSE;
                new->symbol.value = val - section->vma;
+               break;
              }
            default:
              return FALSE;
              }
            default:
              return FALSE;
@@ -457,11 +462,10 @@ pass_over (bfd *abfd, bfd_boolean (*func) (bfd *, int, char *))
 
   /* To the front of the file.  */
   if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
 
   /* To the front of the file.  */
   if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
-    abort ();
+    return FALSE;
   while (! eof)
     {
   while (! eof)
     {
-      char buffer[MAXCHUNK];
-      char *src = buffer;
+      char src[MAXCHUNK];
       char type;
 
       /* Find first '%'.  */
       char type;
 
       /* Find first '%'.  */
@@ -471,22 +475,24 @@ pass_over (bfd *abfd, bfd_boolean (*func) (bfd *, int, char *))
 
       if (eof)
        break;
 
       if (eof)
        break;
-      src++;
 
       /* Fetch the type and the length and the checksum.  */
       if (bfd_bread (src, (bfd_size_type) 5, abfd) != 5)
 
       /* Fetch the type and the length and the checksum.  */
       if (bfd_bread (src, (bfd_size_type) 5, abfd) != 5)
-       abort (); /* FIXME.  */
+       return FALSE;
 
       type = src[2];
 
       if (!ISHEX (src[0]) || !ISHEX (src[1]))
        break;
 
 
       type = src[2];
 
       if (!ISHEX (src[0]) || !ISHEX (src[1]))
        break;
 
-      /* Already read five char.  */
+      /* Already read five chars.  */
       chars_on_line = HEX (src) - 5;
 
       chars_on_line = HEX (src) - 5;
 
+      if (chars_on_line >= MAXCHUNK)
+       return FALSE;
+
       if (bfd_bread (src, (bfd_size_type) chars_on_line, abfd) != chars_on_line)
       if (bfd_bread (src, (bfd_size_type) chars_on_line, abfd) != chars_on_line)
-       abort (); /* FIXME.  */
+       return FALSE;
 
       /* Put a null at the end.  */
       src[chars_on_line] = 0;
 
       /* Put a null at the end.  */
       src[chars_on_line] = 0;
@@ -751,7 +757,6 @@ out (bfd *abfd, int type, char *start, char *end)
 static bfd_boolean
 tekhex_write_object_contents (bfd *abfd)
 {
 static bfd_boolean
 tekhex_write_object_contents (bfd *abfd)
 {
-  int bytes_written;
   char buffer[100];
   asymbol **p;
   asection *s;
   char buffer[100];
   asymbol **p;
   asection *s;
@@ -759,8 +764,6 @@ tekhex_write_object_contents (bfd *abfd)
 
   tekhex_init ();
 
 
   tekhex_init ();
 
-  bytes_written = 0;
-
   /* And the raw data.  */
   for (d = abfd->tdata.tekhex_data->data;
        d != NULL;
   /* And the raw data.  */
   for (d = abfd->tdata.tekhex_data->data;
        d != NULL;
@@ -868,7 +871,7 @@ tekhex_write_object_contents (bfd *abfd)
 
 static int
 tekhex_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 
 static int
 tekhex_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
-                      bfd_boolean exec ATTRIBUTE_UNUSED)
+                      struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
   return 0;
 }
 {
   return 0;
 }
This page took 0.025153 seconds and 4 git commands to generate.