* libbfd.c (bfd_read): Set bfd_error as appropriate for a short
authorJeff Law <law@redhat.com>
Sat, 26 Mar 1994 18:28:29 +0000 (18:28 +0000)
committerJeff Law <law@redhat.com>
Sat, 26 Mar 1994 18:28:29 +0000 (18:28 +0000)
        read. (bfd_error_system_call or bfd_error_file_truncated).

        * som.c: Do not blindly set bfd_error_system_call after a
        failing bfd_read, bfd_write, or bfd_seek.  In a few places
        (like som_object_p) override the error status set by bfd_read.

        * aix386-core.c, aout-encap,c archive.c, bout.c: Likewise.
        * coff-rs6000.c, coffgen.c ecoff.c, elf.c: Likewise.
        * elf32-hppa.c, elfcode.h, hp300hpux.c, i386lynx.c: Likewise.
        * nlm32-alpha.c, nlm32-i386.c, nlm32-sparc.c: Likewise.

        * som.c: Check return values from several bfd_{seek,read,write}
        calls that we just assumed were not failing.

16 files changed:
bfd/ChangeLog
bfd/aix386-core.c
bfd/aout-encap.c
bfd/archive.c
bfd/bout.c
bfd/coff-rs6000.c
bfd/coffgen.c
bfd/ecoff.c
bfd/elf32-hppa.c
bfd/elfcode.h
bfd/hp300hpux.c
bfd/i386lynx.c
bfd/nlm32-alpha.c
bfd/nlm32-i386.c
bfd/nlm32-sparc.c
bfd/som.c

index 47204e256c9583db5977b525120be05f3b992685..1896682fba1df8af541b4e6acaeae63429c801d2 100644 (file)
@@ -1,3 +1,20 @@
+Sat Mar 26 10:25:43 1994  Jeffrey A. Law  (law@snake.cs.utah.edu)
+
+        * libbfd.c (bfd_read): Set bfd_error as appropriate for a short
+       read. (bfd_error_system_call or bfd_error_file_truncated).
+
+       * som.c: Do not blindly set bfd_error_system_call after a
+       failing bfd_read, bfd_write, or bfd_seek.  In a few places
+       (like som_object_p) override the error status set by bfd_read.
+
+       * aix386-core.c, aout-encap,c archive.c, bout.c: Likewise.
+       * coff-rs6000.c, coffgen.c ecoff.c, elf.c: Likewise.
+       * elf32-hppa.c, elfcode.h, hp300hpux.c, i386lynx.c: Likewise.
+       * nlm32-alpha.c, nlm32-i386.c, nlm32-sparc.c: Likewise.
+
+       * som.c: Check return values from several bfd_{seek,read,write}
+       calls that we just assumed were not failing.
+
 Fri Mar 25 11:44:06 1994  Jim Kingdon  (kingdon@lioth.cygnus.com)
 
        * hosts/sysv4.h (HAVE_PROCFS): Add comments about ptx4.
index 5d031b0f4734541e29c7622e0077a7224ce7623d..d55b74726618f174ccdaf69ce6e115e668b9b1a3 100644 (file)
@@ -88,10 +88,12 @@ aix386_core_file_p (abfd)
     struct corehdr internal_core;
   } *mergem;
 
-  bfd_set_error (bfd_error_system_call);
-
   if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != sizeof (longbuf))
-    return 0;
+    {
+      if (bfd_get_error () != bfd_error_system_call)
+       bfd_set_error (bfd_error_wrong_format);
+      return 0;
+    }
 
   if (strncmp(longbuf,COR_MAGIC,4)) return 0;
 
@@ -108,7 +110,8 @@ aix386_core_file_p (abfd)
 
   if ((bfd_read ((PTR) core, 1, core_size, abfd)) != core_size)
     {
-      bfd_set_error (bfd_error_system_call);
+      if (bfd_get_error () != bfd_error_system_call)
+       bfd_set_error (bfd_error_wrong_format);
       bfd_release (abfd, (char *)mergem);
       return 0;
     }
@@ -300,6 +303,12 @@ aix386_core_file_matches_executable_p (core_bfd, exec_bfd)
   ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
 #define aix386_bfd_final_link \
   ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
+#define aix386_bfd_copy_private_section_data \
+  ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_false)
+#define aix386_bfd_copy_private_bfd_data \
+  ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_false)
+#define aix386_bfd_is_local_label \
+  ((boolean (*) PARAMS ((bfd *, asection *))) bfd_false)
 
 /* If somebody calls any byte-swapping routines, shoot them.  */
 void
index 20c44bfa56cc51894453795089484d90c547119c..0d468f2a48e46cf8640b52620eecadee5d2f3e05 100644 (file)
@@ -47,11 +47,13 @@ encap_object_p (abfd)
   struct external_exec exec_bytes;
   struct internal_exec exec;
 
-  bfd_set_error (bfd_error_system_call);
-
   if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
       sizeof (magicbuf))
-    return 0;
+    {
+      if (bfd_get_error () != bfd_error_system_call)
+       bfd_set_error (bfd_error_wrong_format);
+      return 0;
+    }
   
   coff_magic = bfd_h_get_16 (abfd, magicbuf);
   if (coff_magic != COFF_MAGIC)
index b96a2b88710554c2ae105971771fc15d409c0d60..50421ca32bfdd975d728b58c028358deacdc3906 100644 (file)
@@ -194,7 +194,7 @@ _bfd_generic_mkarchive (abfd)
 
   if (bfd_ardata (abfd) == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
@@ -236,7 +236,7 @@ bfd_get_next_mapent (abfd, prev, entry)
 {
   if (!bfd_has_map (abfd))
     {
-      bfd_error = invalid_operation;
+      bfd_set_error (bfd_error_invalid_operation);
       return BFD_NO_MORE_SYMBOLS;
     }
 
@@ -260,7 +260,7 @@ _bfd_create_empty_archive_element_shell (obfd)
   nbfd = _bfd_new_bfd_contained_in (obfd);
   if (nbfd == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return NULL;
     }
   return nbfd;
@@ -315,7 +315,7 @@ _bfd_add_bfd_to_archive_cache (arch_bfd, filepos, new_elt)
 
   if (new_cache == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
@@ -353,7 +353,7 @@ get_extended_arelt_filename (arch, name)
   index = strtol (name + 1, NULL, 10);
   if (errno != 0)
     {
-      bfd_error = malformed_archive;
+      bfd_set_error (bfd_error_malformed_archive);
       return NULL;
     }
 
@@ -389,12 +389,12 @@ _bfd_snarf_ar_hdr (abfd)
   if (bfd_read ((PTR) hdrp, 1, sizeof (struct ar_hdr), abfd)
       != sizeof (struct ar_hdr))
     {
-      bfd_error = no_more_archived_files;
+      bfd_set_error (bfd_error_no_more_archived_files);
       return NULL;
     }
   if (strncmp (hdr.ar_fmag, ARFMAG, 2))
     {
-      bfd_error = malformed_archive;
+      bfd_set_error (bfd_error_malformed_archive);
       return NULL;
     }
 
@@ -402,7 +402,7 @@ _bfd_snarf_ar_hdr (abfd)
   parsed_size = strtol (hdr.ar_size, NULL, 10);
   if (errno != 0)
     {
-      bfd_error = malformed_archive;
+      bfd_set_error (bfd_error_malformed_archive);
       return NULL;
     }
 
@@ -417,7 +417,7 @@ _bfd_snarf_ar_hdr (abfd)
       filename = get_extended_arelt_filename (abfd, hdr.ar_name);
       if (filename == NULL)
        {
-         bfd_error = malformed_archive;
+         bfd_set_error (bfd_error_malformed_archive);
          return NULL;
        }
     }
@@ -434,7 +434,7 @@ _bfd_snarf_ar_hdr (abfd)
       allocptr = bfd_zalloc (abfd, allocsize);
       if (allocptr == NULL)
        {
-         bfd_error = no_memory;
+         bfd_set_error (bfd_error_no_memory);
          return NULL;
        }
       filename = (allocptr
@@ -442,7 +442,7 @@ _bfd_snarf_ar_hdr (abfd)
                  + sizeof (struct ar_hdr));
       if (bfd_read (filename, 1, namelen, abfd) != namelen)
        {
-         bfd_error = no_more_archived_files;
+         bfd_set_error (bfd_error_no_more_archived_files);
          return NULL;
        }
       filename[namelen] = '\0';
@@ -476,7 +476,7 @@ _bfd_snarf_ar_hdr (abfd)
       allocptr = bfd_zalloc (abfd, allocsize);
       if (allocptr == NULL)
        {
-         bfd_error = no_memory;
+         bfd_set_error (bfd_error_no_memory);
          return NULL;
        }
     }
@@ -518,10 +518,7 @@ _bfd_get_elt_at_filepos (archive, filepos)
     return n_nfd;
 
   if (0 > bfd_seek (archive, filepos, SEEK_SET))
-    {
-      bfd_error = system_call_error;
-      return NULL;
-    }
+    return NULL;
 
   if ((new_areldata = _bfd_snarf_ar_hdr (archive)) == NULL)
     return NULL;
@@ -595,7 +592,7 @@ bfd_openr_next_archived_file (archive, last_file)
   if ((bfd_get_format (archive) != bfd_archive) ||
       (archive->direction == write_direction))
     {
-      bfd_error = invalid_operation;
+      bfd_set_error (bfd_error_invalid_operation);
       return NULL;
     }
 
@@ -636,7 +633,7 @@ bfd_generic_archive_p (abfd)
 
   if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)
     {
-      bfd_error = wrong_format;
+      bfd_set_error (bfd_error_wrong_format);
       return NULL;
     }
 
@@ -656,7 +653,7 @@ bfd_generic_archive_p (abfd)
 
   if (bfd_ardata (abfd) == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return NULL;
     }
 
@@ -724,13 +721,13 @@ do_slurp_bsd_armap (abfd)
   raw_armap = (bfd_byte *) bfd_zalloc (abfd, parsed_size);
   if (raw_armap == (bfd_byte *) NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
   if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
     {
-      bfd_error = malformed_archive;
+      bfd_set_error (bfd_error_malformed_archive);
     byebye:
       bfd_release (abfd, (PTR) raw_armap);
       return false;
@@ -742,7 +739,7 @@ do_slurp_bsd_armap (abfd)
       parsed_size - BSD_SYMDEF_COUNT_SIZE)
     {
       /* Probably we're using the wrong byte ordering.  */
-      bfd_error = wrong_format;
+      bfd_set_error (bfd_error_wrong_format);
       goto byebye;
     }
 
@@ -756,7 +753,7 @@ do_slurp_bsd_armap (abfd)
                                           * sizeof (carsym)));
   if (!ardata->symdefs)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
@@ -803,7 +800,7 @@ do_slurp_coff_armap (abfd)
 
   if (bfd_read ((PTR) int_buf, 1, 4, abfd) != 4)
     {
-      bfd_error = malformed_archive;
+      bfd_set_error (bfd_error_malformed_archive);
       return false;
     }
   /* It seems that all numeric information in a coff archive is always
@@ -836,7 +833,7 @@ do_slurp_coff_armap (abfd)
   ardata->symdefs = (carsym *) bfd_zalloc (abfd, carsym_size + stringsize + 1);
   if (ardata->symdefs == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   carsyms = ardata->symdefs;
@@ -846,13 +843,13 @@ do_slurp_coff_armap (abfd)
   raw_armap = (int *) bfd_alloc (abfd, ptrsize);
   if (raw_armap == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       goto release_symdefs;
     }
   if (bfd_read ((PTR) raw_armap, 1, ptrsize, abfd) != ptrsize
       || bfd_read ((PTR) stringbase, 1, stringsize, abfd) != stringsize)
     {
-      bfd_error = malformed_archive;
+      bfd_set_error (bfd_error_malformed_archive);
       goto release_raw_armap;
     }
 
@@ -954,7 +951,7 @@ bfd_slurp_bsd_armap_f2 (abfd)
   raw_armap = (bfd_byte *) bfd_zalloc (abfd, mapdata->parsed_size);
   if (raw_armap == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
     byebye:
       bfd_release (abfd, (PTR) mapdata);
       return false;
@@ -963,7 +960,7 @@ bfd_slurp_bsd_armap_f2 (abfd)
   if (bfd_read ((PTR) raw_armap, 1, mapdata->parsed_size, abfd) !=
       mapdata->parsed_size)
     {
-      bfd_error = malformed_archive;
+      bfd_set_error (bfd_error_malformed_archive);
     byebyebye:
       bfd_release (abfd, (PTR) raw_armap);
       goto byebye;
@@ -975,7 +972,7 @@ bfd_slurp_bsd_armap_f2 (abfd)
       > mapdata->parsed_size - HPUX_SYMDEF_COUNT_SIZE)
     {
       /* Probably we're using the wrong byte ordering.  */
-      bfd_error = wrong_format;
+      bfd_set_error (bfd_error_wrong_format);
       goto byebyebye;
     }
 
@@ -992,7 +989,7 @@ bfd_slurp_bsd_armap_f2 (abfd)
                                           * BSD_SYMDEF_SIZE));
   if (!ardata->symdefs)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
@@ -1054,7 +1051,7 @@ _bfd_slurp_extended_name_table (abfd)
        bfd_zalloc (abfd, namedata->parsed_size);
       if (bfd_ardata (abfd)->extended_names == NULL)
        {
-         bfd_error = no_memory;
+         bfd_set_error (bfd_error_no_memory);
        byebye:
          bfd_release (abfd, (PTR) namedata);
          return false;
@@ -1063,7 +1060,7 @@ _bfd_slurp_extended_name_table (abfd)
       if (bfd_read ((PTR) bfd_ardata (abfd)->extended_names, 1,
                    namedata->parsed_size, abfd) != namedata->parsed_size)
        {
-         bfd_error = malformed_archive;
+         bfd_set_error (bfd_error_malformed_archive);
          bfd_release (abfd, (PTR) (bfd_ardata (abfd)->extended_names));
          bfd_ardata (abfd)->extended_names = NULL;
          goto byebye;
@@ -1175,7 +1172,7 @@ bfd_construct_extended_name_table (abfd, tabloc, tablen)
 
       if (!normal)
        {
-         bfd_error = no_memory;
+         bfd_set_error (bfd_error_no_memory);
          return false;
        }
       thislen = strlen (normal);
@@ -1189,7 +1186,7 @@ bfd_construct_extended_name_table (abfd, tabloc, tablen)
   *tabloc = bfd_zalloc (abfd, total_namelen);
   if (*tabloc == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
@@ -1204,7 +1201,7 @@ bfd_construct_extended_name_table (abfd, tabloc, tablen)
 
       if (!normal)
        {
-         bfd_error = no_memory;
+         bfd_set_error (bfd_error_no_memory);
          return false;
        }
       thislen = strlen (normal);
@@ -1216,7 +1213,7 @@ bfd_construct_extended_name_table (abfd, tabloc, tablen)
          struct ar_hdr *hdr = arch_hdr (current);
          strcpy (strptr, normal);
          strptr[thislen] = '\012';
-         hdr->ar_name[0] = ' ';
+         hdr->ar_name[0] = ar_padchar (current);
          /* We know there will always be enough room (one of the few
             cases where you may safely use sprintf). */
          sprintf ((hdr->ar_name) + 1, "%-d", (unsigned) (strptr - *tabloc));
@@ -1253,7 +1250,7 @@ bfd_ar_hdr_from_filesystem (abfd, filename)
 
   if (stat (filename, &status) != 0)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return NULL;
     }
 
@@ -1261,13 +1258,13 @@ bfd_ar_hdr_from_filesystem (abfd, filename)
                                          sizeof (struct areltdata));
   if (ared == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return NULL;
     }
   hdr = (struct ar_hdr *) (((char *) ared) + sizeof (struct areltdata));
 
   /* ar headers are space padded, not null padded! */
-  memset (hdr, ' ', sizeof (struct ar_hdr));
+  memset ((PTR) hdr, ' ', sizeof (struct ar_hdr));
 
   strncpy (hdr->ar_fmag, ARFMAG, 2);
 
@@ -1322,7 +1319,7 @@ bfd_generic_stat_arch_elt (abfd, buf)
 
   if (abfd->arelt_data == NULL)
     {
-      bfd_error = invalid_operation;
+      bfd_set_error (bfd_error_invalid_operation);
       return -1;
     }
 
@@ -1463,7 +1460,7 @@ _bfd_write_archive_contents (arch)
     {
       if (bfd_write_p (current))
        {
-         bfd_error = invalid_operation;
+         bfd_set_error (bfd_error_invalid_operation);
          return false;
        }
       if (!current->arelt_data)
@@ -1511,7 +1508,10 @@ _bfd_write_archive_contents (arch)
       struct ar_hdr hdr;
 
       memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
-      sprintf (&(hdr.ar_name[0]), "ARFILENAMES/");
+      if (ar_padchar (arch) == '/')
+       sprintf (&(hdr.ar_name[0]), "//");
+      else
+       sprintf (&(hdr.ar_name[0]), "ARFILENAMES/");
       sprintf (&(hdr.ar_size[0]), "%-10d", (int) elength);
       hdr.ar_fmag[0] = '`';
       hdr.ar_fmag[1] = '\012';
@@ -1532,13 +1532,9 @@ _bfd_write_archive_contents (arch)
 
       /* write ar header */
       if (bfd_write ((char *) hdr, 1, sizeof (*hdr), arch) != sizeof (*hdr))
-       {
-       syserr:
-         bfd_error = system_call_error;
-         return false;
-       }
+       return false;
       if (bfd_seek (current, (file_ptr) 0, SEEK_SET) != 0)
-       goto syserr;
+       return false;
       while (remaining)
        {
          unsigned int amt = DEFAULT_BUFFERSIZE;
@@ -1547,14 +1543,12 @@ _bfd_write_archive_contents (arch)
          errno = 0;
          if (bfd_read (buffer, amt, 1, current) != amt)
            {
-             if (errno)
-               goto syserr;
-             /* Looks like a truncated archive. */
-             bfd_error = malformed_archive;
+             if (bfd_get_error () != bfd_error_system_call)
+               bfd_set_error (bfd_error_malformed_archive);
              return false;
            }
          if (bfd_write (buffer, amt, 1, arch) != amt)
-           goto syserr;
+           return false;
          remaining -= amt;
        }
       if ((arelt_size (current) % 2) == 1)
@@ -1621,7 +1615,7 @@ compute_and_write_armap (arch, elength)
   map = (struct orl *) malloc (orl_max * sizeof (struct orl));
   if (map == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
@@ -1631,7 +1625,7 @@ compute_and_write_armap (arch, elength)
   if (first_name == NULL)
     {
       free (map);
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
@@ -1666,7 +1660,7 @@ compute_and_write_armap (arch, elength)
                    {
                      free (map);
                      bfd_release (arch, first_name);
-                     bfd_error = no_memory;
+                     bfd_set_error (bfd_error_no_memory);
                      return false;
                    }
                }
@@ -1700,7 +1694,7 @@ compute_and_write_armap (arch, elength)
                              free (syms);
                              free (map);
                              bfd_release (arch, first_name);
-                             bfd_error = no_memory;
+                             bfd_set_error (bfd_error_no_memory);
                              return false;
                            }
 
index fbe51a337ab80c2a5379f2e8438e4fb51b8ea34b..1109c5da6a1a2a44e45674366f77140c65b88d12 100644 (file)
@@ -23,12 +23,17 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "sysdep.h"
 #include "libbfd.h"
 #include "bfdlink.h"
+#include "genlink.h"
 #include "bout.h"
 
 #include "aout/stab_gnu.h"
 #include "libaout.h"           /* BFD a.out internal data structures */
 
 
+static int aligncode PARAMS ((bfd *abfd, asection *input_section,
+                             arelent *r, unsigned int shrink));
+static void perform_slip PARAMS ((bfd *abfd, unsigned int slip,
+                                 asection *input_section, bfd_vma value));
 static boolean b_out_squirt_out_relocs PARAMS ((bfd *abfd, asection *section));
 static bfd_target *b_out_callback PARAMS ((bfd *));
 static bfd_reloc_status_type calljx_callback
@@ -39,11 +44,11 @@ static bfd_reloc_status_type callj_callback
           unsigned int srcidx, unsigned int dstidx, asection *));
 static bfd_vma get_value PARAMS ((arelent *, struct bfd_link_info *,
                                  asection *));
-static int abs32code PARAMS ((asection *, asymbol **, arelent *,
+static int abs32code PARAMS ((bfd *, asection *, arelent *,
                              unsigned int, struct bfd_link_info *));
 static boolean b_out_relax_section PARAMS ((bfd *, asection *,
                                            struct bfd_link_info *,
-                                           asymbol **symbols));
+                                           boolean *));
 static bfd_byte *b_out_get_relocated_section_contents
   PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
           bfd_byte *, boolean, asymbol **));
@@ -52,10 +57,10 @@ static bfd_byte *b_out_get_relocated_section_contents
    stream memory image, into the internal exec_header structure.  */
 
 void
-DEFUN(bout_swap_exec_header_in,(abfd, raw_bytes, execp),
-      bfd *abfd AND
-      struct external_exec *raw_bytes AND
-      struct internal_exec *execp)
+bout_swap_exec_header_in (abfd, raw_bytes, execp)
+     bfd *abfd;
+     struct external_exec *raw_bytes;
+     struct internal_exec *execp;
 {
   struct external_exec *bytes = (struct external_exec *)raw_bytes;
 
@@ -84,10 +89,10 @@ PROTO(void, bout_swap_exec_header_out,
           struct internal_exec *execp,
           struct external_exec *raw_bytes));
 void
-DEFUN(bout_swap_exec_header_out,(abfd, execp, raw_bytes),
-     bfd *abfd AND
-     struct internal_exec *execp AND
-     struct external_exec *raw_bytes)
+bout_swap_exec_header_out (abfd, execp, raw_bytes)
+     bfd *abfd;
+     struct internal_exec *execp;
+     struct external_exec *raw_bytes;
 {
   struct external_exec *bytes = (struct external_exec *)raw_bytes;
 
@@ -473,7 +478,7 @@ b_out_slurp_reloc_table (abfd, asect, symbols)
   count = reloc_size / sizeof (struct relocation_info);
 
   relocs = (struct relocation_info *) malloc (reloc_size);
-  if (!relocs) {
+  if (!relocs && reloc_size != 0) {
     bfd_set_error (bfd_error_no_memory);
     return false;
   }
@@ -485,7 +490,6 @@ b_out_slurp_reloc_table (abfd, asect, symbols)
   }
 
   if (bfd_read ((PTR) relocs, 1, reloc_size, abfd) != reloc_size) {
-    bfd_set_error (bfd_error_system_call);
     free (reloc_cache);
     free (relocs);
     return false;
@@ -669,7 +673,7 @@ b_out_squirt_out_relocs (abfd, section)
   if (count == 0) return true;
   generic   = section->orelocation;
   native = ((struct relocation_info *) malloc (natsize));
-  if (!native) {
+  if (!native && natsize != 0) {
     bfd_set_error (bfd_error_no_memory);
     return false;
   }
@@ -900,9 +904,9 @@ b_out_set_arch_mach (abfd, arch, machine)
 }
 
 static int
-DEFUN(b_out_sizeof_headers,(ignore_abfd, ignore),
-      bfd *ignore_abfd AND
-      boolean ignore)
+b_out_sizeof_headers (ignore_abfd, ignore)
+     bfd *ignore_abfd;
+     boolean ignore;
 {
   return sizeof(struct internal_exec);
 }
@@ -961,12 +965,16 @@ get_value (reloc, link_info, input_section)
 }
 
 static void
-DEFUN(perform_slip,(s, slip, input_section, value),
-      asymbol **s AND
-      unsigned int slip AND
-      asection *input_section AND
-      bfd_vma value)
+perform_slip (abfd, slip, input_section, value)
+     bfd *abfd;
+     unsigned int slip;
+     asection *input_section;
+     bfd_vma value;
 {
+  asymbol **s;
+
+  s = _bfd_generic_link_get_symbols (abfd);
+  BFD_ASSERT (s != (asymbol **) NULL);
 
   /* Find all symbols past this point, and make them know
      what's happened */
@@ -979,6 +987,15 @@ DEFUN(perform_slip,(s, slip, input_section, value),
       if (p->value > value)
       {
        p->value -=slip;
+       if (p->udata != NULL)
+         {
+           struct generic_link_hash_entry *h;
+
+           h = (struct generic_link_hash_entry *) p->udata;
+           BFD_ASSERT (h->root.type == bfd_link_hash_defined);
+           h->root.u.def.value -= slip;
+           BFD_ASSERT (h->root.u.def.value == p->value);
+         }
       }
     }
     s++;
@@ -991,9 +1008,9 @@ DEFUN(perform_slip,(s, slip, input_section, value),
    If it can, then it changes the amode */
 
 static int
-abs32code (input_section, symbols, r, shrink, link_info)
+abs32code (abfd, input_section, r, shrink, link_info)
+     bfd *abfd;
      asection *input_section;
-     asymbol **symbols;
      arelent *r;
      unsigned int shrink;
      struct bfd_link_info *link_info;
@@ -1020,17 +1037,17 @@ abs32code (input_section, symbols, r, shrink, link_info)
 
     /* This will be four bytes smaller in the long run */
     shrink += 4 ;
-    perform_slip(symbols, 4, input_section, r->address-shrink +4);
+    perform_slip (abfd, 4, input_section, r->address-shrink + 4);
   }
   return shrink;
 }
 
 static int
-DEFUN(aligncode,(input_section, symbols, r, shrink),
-      asection *input_section AND
-      asymbol **symbols AND
-      arelent *r AND
-      unsigned int shrink)
+aligncode (abfd, input_section, r, shrink)
+     bfd *abfd;
+     asection *input_section;
+     arelent *r;
+     unsigned int shrink;
 {
   bfd_vma dot = output_addr (input_section) + r->address;
   bfd_vma gap;
@@ -1064,34 +1081,35 @@ DEFUN(aligncode,(input_section, symbols, r, shrink),
     r->addend = old_end - dot + r->address;
 
     /* This will be N bytes smaller in the long run, adjust all the symbols */
-    perform_slip(symbols, shrink_delta, input_section, r->address - shrink );
+    perform_slip (abfd, shrink_delta, input_section, r->address - shrink);
     shrink += shrink_delta;
   }
   return shrink;
 }
 
 static boolean
-b_out_relax_section (abfd, i, link_info, symbols)
+b_out_relax_section (abfd, i, link_info, again)
      bfd *abfd;
      asection *i;
      struct bfd_link_info *link_info;
-     asymbol **symbols;
+     boolean *again;
 {
-
   /* Get enough memory to hold the stuff */
   bfd *input_bfd = i->owner;
   asection *input_section = i;
   int shrink = 0 ;
-  boolean new = false;
   arelent **reloc_vector = NULL;
-
   bfd_size_type reloc_size = bfd_get_reloc_upper_bound(input_bfd,
                                                       input_section);
 
+  /* We only run this relaxation once.  It might work to run it
+     multiple times, but it hasn't been tested.  */
+  *again = false;
+
   if (reloc_size)
     {
       reloc_vector = (arelent **) malloc (reloc_size);
-      if (reloc_vector == NULL)
+      if (reloc_vector == NULL && reloc_size != 0)
        {
          bfd_set_error (bfd_error_no_memory);
          goto error_return;
@@ -1099,7 +1117,7 @@ b_out_relax_section (abfd, i, link_info, symbols)
 
       /* Get the relocs and think about them */
       if (bfd_canonicalize_reloc(input_bfd, input_section, reloc_vector,
-                                symbols))
+                                _bfd_generic_link_get_symbols (input_bfd)))
        {
          arelent **parent;
          for (parent = reloc_vector; *parent; parent++)
@@ -1109,13 +1127,12 @@ b_out_relax_section (abfd, i, link_info, symbols)
                {
                case ALIGNER:
                  /* An alignment reloc */
-                 shrink = aligncode(input_section, symbols, r,shrink);
-                 new=true;
+                 shrink = aligncode (abfd, input_section, r, shrink);
                  break;
                case ABS32CODE:
                  /* A 32bit reloc in an addressing mode */
-                 shrink = abs32code (input_section, symbols, r, shrink, link_info);
-                 new=true;
+                 shrink = abs32code (input_bfd, input_section, r, shrink,
+                                     link_info);
                  break;
                case ABS32CODE_SHRUNK:
                  shrink+=4;
@@ -1128,7 +1145,7 @@ b_out_relax_section (abfd, i, link_info, symbols)
 
   if (reloc_vector != NULL)
     free (reloc_vector);
-  return new;
+  return true;
  error_return:
   if (reloc_vector != NULL)
     free (reloc_vector);
@@ -1160,7 +1177,7 @@ b_out_get_relocated_section_contents (in_abfd, link_info, link_order, data,
                                                       symbols);
 
   reloc_vector = (arelent **) malloc (reloc_size);
-  if (reloc_vector == NULL)
+  if (reloc_vector == NULL && reloc_size != 0)
     {
       bfd_set_error (bfd_error_no_memory);
       goto error_return;
index 10047dea1ac6e008620c68623b1076dc08db7f00..e8610439bcaf242593547b67f088dba82b19da9f 100644 (file)
@@ -499,7 +499,7 @@ static boolean
 rs6000coff_mkarchive (abfd)
      bfd *abfd;
 {
-       bfd_error = invalid_operation;  /* write not supported  */
+       bfd_set_error (bfd_error_invalid_operation);    /* write not supported  */
        return false;
 }
 
@@ -527,19 +527,19 @@ rs6000coff_snarf_ar_hdr (abfd)
 
        size = sizeof (h.hdr);
        if (bfd_read(&h.hdr, 1, size, abfd) != size) {
-               bfd_error = no_more_archived_files;
+               bfd_set_error (bfd_error_no_more_archived_files);
                return NULL;
        }
        size  = atoi(h.hdr.ar_namlen);  /* ar_name[] length     */
        size += size & 1;
 
        if (bfd_read(&h.hdr._ar_name.ar_name[2], 1, size, abfd) != size) {
-               bfd_error = no_more_archived_files;
+               bfd_set_error (bfd_error_no_more_archived_files);
                return NULL;
        }
 
        if (strncmp(h.hdr._ar_name.ar_fmag + size, AIAFMAG, 2)) {
-               bfd_error = malformed_archive;
+               bfd_set_error (bfd_error_malformed_archive);
                return NULL;
        }
 
@@ -549,7 +549,7 @@ rs6000coff_snarf_ar_hdr (abfd)
         * if the filename is NULL, we're (probably) at the end.
         */
        if (size == 0) {
-               bfd_error = no_more_archived_files;
+               bfd_set_error (bfd_error_no_more_archived_files);
                return NULL;
        }
 
@@ -557,7 +557,7 @@ rs6000coff_snarf_ar_hdr (abfd)
        allocptr = bfd_zalloc(abfd, sizeof (*ared) + size);
 
        if (allocptr == NULL) {
-               bfd_error = no_memory;
+               bfd_set_error (bfd_error_no_memory);
                return NULL;
        }
 
@@ -585,10 +585,8 @@ rs6000coff_get_elt_at_filepos (archive, filepos)
   n_nfd = _bfd_look_for_bfd_in_cache (archive, filepos);
   if (n_nfd) return n_nfd;
 
-  if (0 != bfd_seek (archive, filepos, SEEK_SET)) {
-    bfd_error = system_call_error;
+  if (0 != bfd_seek (archive, filepos, SEEK_SET))
     return NULL;
-  }
 
   if ((new_areldata = rs6000coff_snarf_ar_hdr (archive)) == NULL) return NULL;
   
@@ -636,12 +634,12 @@ rs6000coff_archive_p (abfd)
        register struct artdata *art;
 
        if (bfd_read (&hdr, sizeof (hdr), 1, abfd) != sizeof (hdr)) {
-               bfd_error = wrong_format;
+               bfd_set_error (bfd_error_wrong_format);
                return 0;
        }
 
        if (strncmp(hdr.fl_magic, AIAMAG, SAIAMAG)) {
-               bfd_error = wrong_format;
+               bfd_set_error (bfd_error_wrong_format);
                return 0;
        }
 
@@ -651,7 +649,7 @@ rs6000coff_archive_p (abfd)
        abfd->tdata.aout_ar_data =
          (void *) bfd_zalloc(abfd, sizeof (*art) + sizeof (hdr));
        if ((art = bfd_ardata (abfd)) == NULL) {
-               bfd_error = no_memory;
+               bfd_set_error (bfd_error_no_memory);
                return 0;
        }
 
@@ -676,7 +674,7 @@ rs6000coff_stat_arch_elt(abfd, buf)
        char *aloser;
   
        if (abfd->arelt_data == NULL) {
-               bfd_error = invalid_operation;
+               bfd_set_error (bfd_error_invalid_operation);
                return -1;
        }
     
@@ -704,7 +702,7 @@ rs6000coff_write_armap (arch, elength, map, orl_count, stridx)
   unsigned int orl_count;
   int stridx;
 {
-       bfd_error = invalid_operation;
+       bfd_set_error (bfd_error_invalid_operation);
        return false;
 }
 #endif /* HOST_AIX */
index a925767e97a7878abba0cf28e067b72abbc01d29..a7d367a910bfa498bff6df4ae3d782317e46f30e 100644 (file)
@@ -46,10 +46,10 @@ static asection bfd_debug_section = { "*DEBUG*" };
 /* Take a section header read from a coff file (in HOST byte order),
    and make a BFD "section" out of it.  This is used by ECOFF.  */
 static          boolean
-DEFUN(make_a_section_from_file,(abfd, hdr, target_index),
-      bfd            *abfd AND
-      struct internal_scnhdr  *hdr AND
-      unsigned int target_index)
+make_a_section_from_file (abfd, hdr, target_index)
+     bfd            *abfd;
+     struct internal_scnhdr  *hdr;
+     unsigned int target_index;
 {
   asection       *return_section;
   char *name;
@@ -113,11 +113,11 @@ DEFUN(make_a_section_from_file,(abfd, hdr, target_index),
 
 static
 bfd_target     *
-DEFUN(coff_real_object_p,(abfd, nscns, internal_f, internal_a),
-    bfd            *abfd AND
-    unsigned        nscns AND
-  struct internal_filehdr *internal_f AND
-  struct internal_aouthdr *internal_a)
+coff_real_object_p (abfd, nscns, internal_f, internal_a)
+     bfd            *abfd;
+     unsigned        nscns;
+     struct internal_filehdr *internal_f;
+     struct internal_aouthdr *internal_a;
 {
   PTR tdata;
   size_t          readsize;    /* length of file_info */
@@ -187,8 +187,8 @@ DEFUN(coff_real_object_p,(abfd, nscns, internal_f, internal_a),
    not a COFF file.  This is also used by ECOFF.  */
 
 bfd_target *
-DEFUN(coff_object_p,(abfd),
-      bfd            *abfd)
+coff_object_p (abfd)
+     bfd            *abfd;
 {
   unsigned int filhsz;
   unsigned int aoutsz;
@@ -197,8 +197,6 @@ DEFUN(coff_object_p,(abfd),
   struct internal_filehdr internal_f;
   struct internal_aouthdr internal_a;
 
-  bfd_set_error (bfd_error_system_call);
-
   /* figure out how much to read */
   filhsz = bfd_coff_filhsz (abfd);
   aoutsz = bfd_coff_aoutsz (abfd);
@@ -207,7 +205,11 @@ DEFUN(coff_object_p,(abfd),
   if (filehdr == NULL)
     return 0;
   if (bfd_read(filehdr, 1, filhsz, abfd) != filhsz)
-    return 0;
+    {
+      if (bfd_get_error () != bfd_error_system_call)
+       bfd_set_error (bfd_error_wrong_format);
+      return 0;
+    }
   bfd_coff_swap_filehdr_in(abfd, filehdr, &internal_f);
   bfd_release (abfd, filehdr);
 
@@ -241,9 +243,9 @@ DEFUN(coff_object_p,(abfd),
 /* Get the BFD section from a COFF symbol section number.  */
 
 struct sec *
-DEFUN(coff_section_from_bfd_index,(abfd, index),
-      bfd            *abfd AND
-      int             index)
+coff_section_from_bfd_index (abfd, index)
+     bfd            *abfd;
+     int             index;
 {
   struct sec *answer = abfd->sections;
 
@@ -286,9 +288,9 @@ bfd            *abfd;
 /* Canonicalize a COFF symbol table.  */
 
 unsigned int
-DEFUN(coff_get_symtab, (abfd, alocation),
-      bfd            *abfd AND
-      asymbol       **alocation)
+coff_get_symtab (abfd, alocation)
+     bfd            *abfd;
+     asymbol       **alocation;
 {
     unsigned int    counter = 0;
     coff_symbol_type *symbase;
@@ -321,8 +323,8 @@ DEFUN(coff_get_symtab, (abfd, alocation),
 /* Set lineno_count for the output sections of a COFF file.  */
 
 int
-DEFUN(coff_count_linenumbers,(abfd),
-      bfd            *abfd)
+coff_count_linenumbers (abfd)
+     bfd            *abfd;
 {
   unsigned int    limit = bfd_get_symcount(abfd);
   unsigned int    i;
@@ -366,9 +368,9 @@ DEFUN(coff_count_linenumbers,(abfd),
 
 /*ARGSUSED*/
 coff_symbol_type *
-DEFUN(coff_symbol_from,(ignore_abfd, symbol),
-      bfd            *ignore_abfd AND
-      asymbol        *symbol)
+coff_symbol_from (ignore_abfd, symbol)
+     bfd            *ignore_abfd;
+     asymbol        *symbol;
 {
   if (bfd_asymbol_flavour(symbol) != bfd_target_coff_flavour)
     return (coff_symbol_type *)NULL;
@@ -380,9 +382,9 @@ DEFUN(coff_symbol_from,(ignore_abfd, symbol),
 }
 
 static void
-DEFUN(fixup_symbol_value,(coff_symbol_ptr, syment),
-coff_symbol_type *coff_symbol_ptr AND
-struct internal_syment *syment)
+fixup_symbol_value (coff_symbol_ptr, syment)
+     coff_symbol_type *coff_symbol_ptr;
+     struct internal_syment *syment;
 {
 
   /* Normalize the symbol flags */
@@ -426,8 +428,8 @@ struct internal_syment *syment)
 
 */
 boolean
-DEFUN(coff_renumber_symbols,(bfd_ptr),
-      bfd *bfd_ptr)
+coff_renumber_symbols (bfd_ptr)
+     bfd *bfd_ptr;
 {
   unsigned int symbol_count = bfd_get_symcount(bfd_ptr);
   asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols;
@@ -559,10 +561,10 @@ static bfd_size_type debug_string_size;
 static asection *debug_string_section;
 
 static void
-DEFUN(coff_fix_symbol_name,(abfd, symbol, native),
-  bfd *abfd AND
-  asymbol *symbol AND
-  combined_entry_type *native)
+coff_fix_symbol_name (abfd, symbol, native)
+     bfd *abfd;
+     asymbol *symbol;
+     combined_entry_type *native;
 {
   unsigned int    name_length;
   union internal_auxent *auxent;
@@ -646,11 +648,11 @@ DEFUN(coff_fix_symbol_name,(abfd, symbol, native),
 #define        set_index(symbol, idx)  ((symbol)->udata =(PTR) (idx))
 
 static unsigned int
-DEFUN(coff_write_symbol,(abfd, symbol, native, written),
-bfd *abfd AND
-asymbol *symbol AND
-combined_entry_type *native AND
-unsigned int written)
+coff_write_symbol (abfd, symbol, native, written)
+     bfd *abfd;
+     asymbol *symbol;
+     combined_entry_type *native;
+     unsigned int written;
 {
   unsigned int    numaux = native->u.syment.n_numaux;
   int             type = native->u.syment.n_type;
@@ -729,10 +731,10 @@ unsigned int written)
 
 
 static unsigned int
-DEFUN(coff_write_alien_symbol,(abfd, symbol, written),
-      bfd *abfd AND
-      asymbol *symbol AND
-      unsigned int written)
+coff_write_alien_symbol (abfd, symbol, written)
+     bfd *abfd;
+     asymbol *symbol;
+     unsigned int written;
 {
   /*
     This symbol has been created by the loader, or come from a non
@@ -787,10 +789,10 @@ DEFUN(coff_write_alien_symbol,(abfd, symbol, written),
 }
 
 static unsigned int
-DEFUN(coff_write_native_symbol,(abfd, symbol,   written),
-bfd *abfd AND
-coff_symbol_type *symbol AND
-unsigned int written)
+coff_write_native_symbol (abfd, symbol, written)
+     bfd *abfd;
+     coff_symbol_type *symbol;
+     unsigned int written;
 {
   /*
     Does this symbol have an ascociated line number - if so then
@@ -846,8 +848,8 @@ I've been told this, but still need proof:
 }
 
 void
-DEFUN(coff_write_symbols,(abfd),
-      bfd            *abfd)
+coff_write_symbols (abfd)
+     bfd            *abfd;
 {
   unsigned int    i;
   unsigned int    limit = bfd_get_symcount(abfd);
@@ -929,8 +931,8 @@ DEFUN(coff_write_symbols,(abfd),
 }
 
 boolean
-DEFUN(coff_write_linenumbers,(abfd),
-      bfd            *abfd)
+coff_write_linenumbers (abfd)
+     bfd            *abfd;
 {
   asection       *s;
   bfd_size_type linesz;
@@ -941,7 +943,7 @@ DEFUN(coff_write_linenumbers,(abfd),
   if (!buff)
     {
       bfd_set_error (bfd_error_no_memory);
-      return;
+      return false;
     }
   for (s = abfd->sections; s != (asection *) NULL; s = s->next) {
     if (s->lineno_count) {
@@ -981,9 +983,9 @@ DEFUN(coff_write_linenumbers,(abfd),
 
 /*ARGSUSED*/
 alent   *
-DEFUN(coff_get_lineno,(ignore_abfd, symbol),
-      bfd            *ignore_abfd AND
-      asymbol        *symbol)
+coff_get_lineno (ignore_abfd, symbol)
+     bfd            *ignore_abfd;
+     asymbol        *symbol;
 {
   return coffsymbol(symbol)->lineno;
 }
@@ -1037,12 +1039,12 @@ coff_section_symbol (abfd, name)
    pointers to syments.  */
 
 static void
-DEFUN(coff_pointerize_aux,(abfd, table_base, type, class, auxent),
-bfd *abfd AND
-combined_entry_type *table_base AND
-int type AND
-int class AND
-combined_entry_type *auxent)
+coff_pointerize_aux (abfd, table_base, type, class, auxent)
+     bfd *abfd;
+     combined_entry_type *table_base;
+     int type;
+     int class;
+     combined_entry_type *auxent;
 {
   /* Don't bother if this is a file or a section */
   if (class == C_STAT && type == T_NULL) return;
@@ -1066,8 +1068,8 @@ combined_entry_type *auxent)
 }
 
 static char *
-DEFUN(build_string_table,(abfd),
-bfd *abfd)
+build_string_table (abfd)
+     bfd *abfd;
 {
   char string_table_size_buffer[4];
   unsigned int string_table_size;
@@ -1077,10 +1079,8 @@ bfd *abfd)
      symbols === the symbol table size.  */
   if (bfd_read((char *) string_table_size_buffer,
               sizeof(string_table_size_buffer),
-              1, abfd) != sizeof(string_table_size)) {
-    bfd_set_error (bfd_error_system_call);
+              1, abfd) != sizeof(string_table_size))
     return (NULL);
-  }                            /* on error */
 
   string_table_size = bfd_h_get_32(abfd, (bfd_byte *) string_table_size_buffer);
 
@@ -1088,10 +1088,8 @@ bfd *abfd)
     bfd_set_error (bfd_error_no_memory);
     return (NULL);
   }                            /* on mallocation error */
-  if (bfd_read(string_table, string_table_size, 1, abfd) != string_table_size) {
-    bfd_set_error (bfd_error_system_call);
+  if (bfd_read(string_table, string_table_size, 1, abfd) != string_table_size)
     return (NULL);
-  }
   return string_table;
 }
 
@@ -1100,8 +1098,8 @@ bfd *abfd)
    we didn't want to go to the trouble until someone needed it. */
 
 static char *
-DEFUN(build_debug_section,(abfd),
-       bfd *abfd)
+build_debug_section (abfd)
+     bfd *abfd;
 {
   char *debug_section;
   long position;
@@ -1128,10 +1126,8 @@ DEFUN(build_debug_section,(abfd),
   bfd_seek (abfd, sect->filepos, SEEK_SET);
   if (bfd_read (debug_section, 
                bfd_get_section_size_before_reloc (sect), 1, abfd)
-      != bfd_get_section_size_before_reloc(sect)) {
-    bfd_set_error (bfd_error_system_call);
+      != bfd_get_section_size_before_reloc(sect))
     return NULL;
-  }
   bfd_seek (abfd, position, SEEK_SET);
   return debug_section;
 }
@@ -1141,10 +1137,10 @@ DEFUN(build_debug_section,(abfd),
  \0-terminated, but will not exceed 'maxlen' characters.  The copy *will*
  be \0-terminated.  */
 static char *
-DEFUN(copy_name,(abfd, name, maxlen),
-      bfd *abfd AND
-      char *name AND
-      int maxlen)
+copy_name (abfd, name, maxlen)
+     bfd *abfd;
+     char *name;
+     int maxlen;
 {
   int  len;
   char *newname;
@@ -1170,8 +1166,8 @@ DEFUN(copy_name,(abfd, name, maxlen),
    terminated string.  */
 
 combined_entry_type *
-DEFUN(coff_get_normalized_symtab,(abfd),
-bfd            *abfd)
+coff_get_normalized_symtab (abfd)
+     bfd            *abfd;
 {
   combined_entry_type          *internal;
   combined_entry_type          *internal_ptr;
@@ -1212,10 +1208,8 @@ bfd            *abfd)
     }
 
   if (bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET) == -1
-      || bfd_read(raw, raw_size, 1, abfd) != raw_size) {
-      bfd_set_error (bfd_error_system_call);
+      || bfd_read(raw, raw_size, 1, abfd) != raw_size)
       return (NULL);
-    }
   /* mark the end of the symbols */
   raw_end = (char *) raw + bfd_get_symcount(abfd) * symesz;
   /*
@@ -1344,9 +1338,9 @@ bfd            *abfd)
 }                              /* coff_get_normalized_symtab() */
 
 unsigned int
-DEFUN (coff_get_reloc_upper_bound, (abfd, asect),
-       bfd            *abfd AND
-       sec_ptr         asect)
+coff_get_reloc_upper_bound (abfd, asect)
+     bfd            *abfd;
+     sec_ptr         asect;
 {
   if (bfd_get_format(abfd) != bfd_object) {
     bfd_set_error (bfd_error_invalid_operation);
@@ -1356,8 +1350,8 @@ DEFUN (coff_get_reloc_upper_bound, (abfd, asect),
 }
 
 asymbol *
-DEFUN (coff_make_empty_symbol, (abfd),
-       bfd            *abfd)
+coff_make_empty_symbol (abfd)
+     bfd            *abfd;
 {
   coff_symbol_type *new = (coff_symbol_type *) bfd_alloc(abfd, sizeof(coff_symbol_type));
   if (new == NULL) {
@@ -1511,20 +1505,15 @@ coff_print_symbol (abfd, filep, symbol, how)
 
 /*ARGSUSED*/
 boolean
-DEFUN(coff_find_nearest_line,(abfd,
-                             section,
-                             ignore_symbols,
-                             offset,
-                             filename_ptr,
-                             functionname_ptr,
-                             line_ptr),
-      bfd            *abfd AND
-      asection       *section AND
-      asymbol       **ignore_symbols AND
-      bfd_vma         offset AND
-      CONST char      **filename_ptr AND
-      CONST char       **functionname_ptr AND
-      unsigned int   *line_ptr)
+coff_find_nearest_line (abfd, section, ignore_symbols, offset, filename_ptr,
+                       functionname_ptr, line_ptr)
+     bfd            *abfd;
+     asection       *section;
+     asymbol       **ignore_symbols;
+     bfd_vma         offset;
+     CONST char      **filename_ptr;
+     CONST char       **functionname_ptr;
+     unsigned int   *line_ptr;
 {
   static bfd     *cache_abfd;
   static asection *cache_section;
@@ -1619,9 +1608,9 @@ DEFUN(coff_find_nearest_line,(abfd,
 }
 
 int
-DEFUN(coff_sizeof_headers,(abfd, reloc),
-      bfd *abfd AND
-      boolean reloc)
+coff_sizeof_headers (abfd, reloc)
+     bfd *abfd;
+     boolean reloc;
 {
     size_t size;
 
index 5665a993d56a7b6dbd2fbe8ef382ccfcbe79ec55..0fbfc7d73306e3f71ed6b7732ba1ac4e80365499 100644 (file)
@@ -646,10 +646,7 @@ ecoff_slurp_symbolic_header (abfd)
   if (bfd_seek (abfd, ecoff_data (abfd)->sym_filepos, SEEK_SET) == -1
       || (bfd_read (raw, external_hdr_size, 1, abfd)
          != external_hdr_size))
-    {
-      bfd_set_error (bfd_error_system_call);
-      goto error_return;
-    }
+    goto error_return;
   internal_symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
   (*backend->debug_swap.swap_hdr_in) (abfd, raw, internal_symhdr);
 
@@ -755,7 +752,6 @@ ecoff_slurp_symbolic_info (abfd)
                SEEK_SET) != 0
       || bfd_read (raw, raw_size, 1, abfd) != raw_size)
     {
-      bfd_set_error (bfd_error_system_call);
       bfd_release (abfd, raw);
       return false;
     }
@@ -1831,10 +1827,7 @@ ecoff_slurp_reloc_table (abfd, section, symbols)
     return false;
   if (bfd_read (external_relocs, 1, external_relocs_size, abfd)
       != external_relocs_size)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
 
   for (i = 0, rptr = internal_relocs; i < section->reloc_count; i++, rptr++)
     {
@@ -2505,8 +2498,6 @@ ecoff_write_object_contents (abfd)
   struct internal_aouthdr internal_a;
   int i;
 
-  bfd_set_error (bfd_error_system_call);
-
   /* Determine where the sections and relocs will go in the output
      file.  */
   reloc_size = ecoff_compute_reloc_file_positions (abfd);
index 4325e26f4b411ef9a0cfc283fb424650ddc39159..0da3f238dff3a51cc5176daefda01f541f4fa8b8 100644 (file)
@@ -269,6 +269,8 @@ static boolean elf32_hppa_backend_fake_sections
 static boolean elf32_hppa_backend_section_from_bfd_section
   PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *));
 
+static boolean som_bfd_is_local_label PARAMS ((bfd *, asymbol *));
+
 /* ELF/PA relocation howto entries.  */
 
 static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] =
@@ -1581,6 +1583,15 @@ elf_hppa_reloc_type_lookup (arch, code)
   return NULL;
 }
 
+/* Return true if SYM represents a local label symbol.  */
+
+static boolean
+hppa_elf_is_local_label (abfd, sym)
+     bfd *abfd;
+     asymbol *sym;
+{
+  return (sym->name[0] == 'L' && sym->name[1] == '$');
+}
 
 /* Update the symbol extention chain to include the symbol pointed to
    by SYMBOLP if SYMBOLP is a function symbol.  Used internally and by GAS.  */
@@ -1934,7 +1945,7 @@ hppa_elf_stub_finish (output_bfd)
          /* Make space to hold the relocations for the stub section.  */
          reloc_size = bfd_get_reloc_upper_bound (stub_bfd, stub_sec);
          reloc_vector = (arelent **) malloc (reloc_size);
-         if (reloc_vector == NULL)
+         if (reloc_vector == NULL && reloc_size != 0)
            {
              /* FIXME: should be returning an error so the caller can
                 clean up */
@@ -3133,16 +3144,10 @@ elf32_hppa_backend_symbol_table_processing (abfd, esyms,symcnt)
        
   /* Read in the symextn section.  */
   if (bfd_seek (abfd, symextn_hdr->sh_offset, SEEK_SET) == -1)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return (false);
-    }
+    return false;
   if (bfd_read ((PTR) symextn_hdr->contents, 1, symextn_hdr->size, abfd) 
       != symextn_hdr->size)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return (false);
-    }  
+    return false;
 
   /* Parse entries in the symbol extension section, updating the symtab
      entries as we go */
@@ -3373,6 +3378,7 @@ elf32_hppa_backend_section_from_bfd_section (abfd, hdr, asect, ignored)
 
 #define bfd_generic_get_section_contents       hppa_elf_get_section_contents
 #define bfd_elf32_set_section_contents         hppa_elf_set_section_contents
+#define bfd_elf32_bfd_is_local_label           hppa_elf_is_local_label
 
 #define elf_backend_section_processing elf32_hppa_backend_section_processing
 
index 9fe0655b7f241df19bbd8e1b99a3fbe4e6e2086d..3d79e0b2b67a2581a7aaead48078f601152f85e4 100644 (file)
@@ -853,7 +853,12 @@ elf_object_p (abfd)
   /* Read in the ELF header in external format.  */
 
   if (bfd_read ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr))
-    goto got_system_call;
+    {
+      if (bfd_get_error () != bfd_error_system_call)
+       goto got_wrong_format_error;
+      else
+       goto got_no_match;
+    }
 
   /* Now check to see if we have a valid ELF file, and one that BFD can
      make use of.  The magic number must match, the address size ('class')
@@ -967,11 +972,11 @@ elf_object_p (abfd)
   if (!i_shdrp || !elf_elfsections (abfd))
     goto got_no_memory_error;
   if (bfd_seek (abfd, i_ehdrp->e_shoff, SEEK_SET) == -1)
-    goto got_system_call;
+    goto got_no_match;
   for (shindex = 0; shindex < i_ehdrp->e_shnum; shindex++)
     {
       if (bfd_read ((PTR) & x_shdr, sizeof x_shdr, 1, abfd) != sizeof (x_shdr))
-       goto got_system_call;
+       goto got_no_match;
       elf_swap_shdr_in (abfd, &x_shdr, i_shdrp + shindex);
       elf_elfsections (abfd)[shindex] = i_shdrp + shindex;
 
@@ -1013,9 +1018,6 @@ elf_object_p (abfd)
   /* If we are going to use goto's to avoid duplicating error setting
      and return(NULL) code, then this at least makes it more maintainable. */
 
-got_system_call:
-  bfd_set_error (bfd_error_system_call);
-  goto got_no_match;
 got_wrong_format_error:
   bfd_set_error (bfd_error_wrong_format);
   goto got_no_match;
@@ -1692,7 +1694,7 @@ map_program_segments (abfd)
   struct seg_info *seg = NULL;
 
   done = (char *) malloc (i_ehdrp->e_shnum);
-  if (done == NULL)
+  if (done == NULL && i_ehdrp->e_shnum != 0)
     {
       bfd_set_error (bfd_error_no_memory);
       goto error_return;
@@ -2587,10 +2589,7 @@ elf_slurp_symbol_table (abfd, symptrs)
      build the caller's pointer vector. */
 
   if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) == -1)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
 
   symcount = hdr->sh_size / sizeof (Elf_External_Sym);
 
@@ -2601,10 +2600,7 @@ elf_slurp_symbol_table (abfd, symptrs)
       long i;
 
       if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) == -1)
-       {
-         bfd_set_error (bfd_error_system_call);
-         return false;
-       }
+       return false;
 
       symbase = ((elf_symbol_type *)
                 bfd_zalloc (abfd, symcount * sizeof (elf_symbol_type)));
@@ -2618,7 +2614,7 @@ elf_slurp_symbol_table (abfd, symptrs)
       /* Temporarily allocate room for the raw ELF symbols.  */
       x_symp = ((Elf_External_Sym *)
                malloc (symcount * sizeof (Elf_External_Sym)));
-      if (x_symp == NULL)
+      if (x_symp == NULL && symcount != 0)
        {
          bfd_set_error (bfd_error_no_memory);
          goto error_return;
@@ -2626,10 +2622,7 @@ elf_slurp_symbol_table (abfd, symptrs)
 
       if (bfd_read ((PTR) x_symp, sizeof (Elf_External_Sym), symcount, abfd)
          != symcount * sizeof (Elf_External_Sym))
-       {
-         bfd_set_error (bfd_error_system_call);
-         goto error_return;
-       }
+       goto error_return;
       /* Skip first symbol, which is a null dummy.  */
       for (i = 1; i < symcount; i++)
        {
@@ -3569,7 +3562,8 @@ elf_core_file_p (abfd)
 
   if (bfd_read ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr))
     {
-      bfd_set_error (bfd_error_system_call);
+      if (bfd_get_error () != bfd_error_system_call)
+       bfd_set_error (bfd_error_wrong_format);
       return NULL;
     }
 
@@ -3686,18 +3680,12 @@ elf_core_file_p (abfd)
       return NULL;
     }
   if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) == -1)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return NULL;
-    }
+    return NULL;
   for (phindex = 0; phindex < i_ehdrp->e_phnum; phindex++)
     {
       if (bfd_read ((PTR) & x_phdr, sizeof (x_phdr), 1, abfd)
          != sizeof (x_phdr))
-       {
-         bfd_set_error (bfd_error_system_call);
-         return NULL;
-       }
+       return NULL;
       elf_swap_phdr_in (abfd, &x_phdr, i_phdrp + phindex);
     }
 
index 08f74739c2f43eb9e817e3e13b90087b5bb89001..5be01e30c246105341e9ad6ac473ad147eddfe2c 100644 (file)
@@ -187,26 +187,26 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 /* Set parameters about this a.out file that are machine-dependent.
    This routine is called from some_aout_object_p just before it returns.  */
 static bfd_target *
-DEFUN(MY(callback),(abfd),
-      bfd *abfd)
+MY (callback) (abfd)
+     bfd *abfd;
 {
   struct internal_exec *execp = exec_hdr (abfd);
 
   /* Calculate the file positions of the parts of a newly read aout header */
-  obj_textsec (abfd)->_raw_size = N_TXTSIZE(*execp);
+  obj_textsec (abfd)->_raw_size = N_TXTSIZE (*execp);
 
   /* The virtual memory addresses of the sections */
-  obj_textsec (abfd)->vma = N_TXTADDR(*execp);
-  obj_datasec (abfd)->vma = N_DATADDR(*execp);
-  obj_bsssec  (abfd)->vma = N_BSSADDR(*execp);
+  obj_textsec (abfd)->vma = N_TXTADDR (*execp);
+  obj_datasec (abfd)->vma = N_DATADDR (*execp);
+  obj_bsssec (abfd)->vma = N_BSSADDR (*execp);
 
   /* The file offsets of the sections */
   obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
   obj_datasec (abfd)->filepos = N_DATOFF (*execp);
 
   /* The file offsets of the relocation info */
-  obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp);
-  obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp);
+  obj_textsec (abfd)->rel_filepos = N_TRELOFF (*execp);
+  obj_datasec (abfd)->rel_filepos = N_DRELOFF (*execp);
 
   /* The file offsets of the string table and symbol table.  */
   obj_sym_filepos (abfd) = N_SYMOFF (*execp);
@@ -214,161 +214,163 @@ DEFUN(MY(callback),(abfd),
 
   /* Determine the architecture and machine type of the object file.  */
 #ifdef SET_ARCH_MACH
-  SET_ARCH_MACH(abfd, *execp);
+  SET_ARCH_MACH (abfd, *execp);
 #else
-  bfd_default_set_arch_mach(abfd, DEFAULT_ARCH, 0);
+  bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0);
 #endif
 
 
-  if (obj_aout_subformat(abfd) == gnu_encap_format)
-  {
+  if (obj_aout_subformat (abfd) == gnu_encap_format)
+    {
       /* The file offsets of the relocation info */
-      obj_textsec (abfd)->rel_filepos = N_GNU_TRELOFF(*execp);
-      obj_datasec (abfd)->rel_filepos = N_GNU_DRELOFF(*execp);
+      obj_textsec (abfd)->rel_filepos = N_GNU_TRELOFF (*execp);
+      obj_datasec (abfd)->rel_filepos = N_GNU_DRELOFF (*execp);
 
       /* The file offsets of the string table and symbol table.  */
-      obj_sym_filepos (abfd) = N_GNU_SYMOFF(*execp);
+      obj_sym_filepos (abfd) = N_GNU_SYMOFF (*execp);
       obj_str_filepos (abfd) = (obj_sym_filepos (abfd) + execp->a_syms);
 
       abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
       bfd_get_symcount (abfd) = execp->a_syms / 12;
       obj_symbol_entry_size (abfd) = 12;
       obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
-  }
+    }
 
   return abfd->xvec;
 }
 
-extern boolean aout_32_write_syms PARAMS ((bfd *abfd));
+extern boolean aout_32_write_syms PARAMS ((bfd * abfd));
 
 static boolean
-DEFUN(MY(write_object_contents),(abfd),
-      bfd *abfd)
+MY (write_object_contents) (abfd)
+     bfd *abfd;
 {
-    struct external_exec exec_bytes;
-    struct internal_exec *execp = exec_hdr (abfd);
-    bfd_size_type text_size; /* dummy vars */                  
-    file_ptr text_end;
+  struct external_exec exec_bytes;
+  struct internal_exec *execp = exec_hdr (abfd);
+  bfd_size_type text_size;     /* dummy vars */
+  file_ptr text_end;
 
-    memset (&exec_bytes, 0, sizeof (exec_bytes));
+  memset (&exec_bytes, 0, sizeof (exec_bytes));
 #if CHOOSE_RELOC_SIZE
-    CHOOSE_RELOC_SIZE(abfd);
+  CHOOSE_RELOC_SIZE (abfd);
 #else
-    obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+  obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
 #endif
 
-    if (adata(abfd).magic == undecided_magic)                  
-        NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end);
-    execp->a_syms = 0;
+  if (adata (abfd).magic == undecided_magic)
+    NAME (aout, adjust_sizes_and_vmas) (abfd, &text_size, &text_end);
+  execp->a_syms = 0;
 
-    execp->a_entry = bfd_get_start_address (abfd);                     
+  execp->a_entry = bfd_get_start_address (abfd);
 
-    execp->a_trsize = ((obj_textsec (abfd)->reloc_count) *             
-                       obj_reloc_entry_size (abfd));           
-    execp->a_drsize = ((obj_datasec (abfd)->reloc_count) *             
-                       obj_reloc_entry_size (abfd));           
+  execp->a_trsize = ((obj_textsec (abfd)->reloc_count) *
+                    obj_reloc_entry_size (abfd));
+  execp->a_drsize = ((obj_datasec (abfd)->reloc_count) *
+                    obj_reloc_entry_size (abfd));
 
-    N_SET_MACHTYPE(*execp, 0xc);
-    N_SET_FLAGS (*execp, 0x2);
+  N_SET_MACHTYPE (*execp, 0xc);
+  N_SET_FLAGS (*execp, 0x2);
 
-    NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes);        
+  NAME (aout, swap_exec_header_out) (abfd, execp, &exec_bytes);
 
-    /* update fields not covered by default swap_exec_header_out */
+  /* update fields not covered by default swap_exec_header_out */
 
-    /* this is really the sym table size but we store it in drelocs */
-    bfd_h_put_32 (abfd,  bfd_get_symcount (abfd) * 12, exec_bytes.e_drelocs);
+  /* this is really the sym table size but we store it in drelocs */
+  bfd_h_put_32 (abfd, bfd_get_symcount (abfd) * 12, exec_bytes.e_drelocs);
 
-    bfd_seek (abfd, 0L, false);                                        
-    bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd);
+  bfd_seek (abfd, 0L, false);
+  bfd_write ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd);
 
-    /* Write out the symbols, and then the relocs.  We must write out
+  /* Write out the symbols, and then the relocs.  We must write out
        the symbols first so that we know the symbol indices.  */
 
-    if (bfd_get_symcount (abfd) != 0)
-      {
-       /* Skip the relocs to where we want to put the symbols.  */
-       if (bfd_seek (abfd, (file_ptr) N_DRELOFF (*execp) + execp->a_drsize,
-                     SEEK_SET) != 0)
-         return false;
-      }
+  if (bfd_get_symcount (abfd) != 0)
+    {
+      /* Skip the relocs to where we want to put the symbols.  */
+      if (bfd_seek (abfd, (file_ptr) N_DRELOFF (*execp) + execp->a_drsize,
+                   SEEK_SET) != 0)
+       return false;
+    }
 
-    if (! MY(write_syms) (abfd))
-      return false;
+  if (!MY (write_syms) (abfd))
+    return false;
 
-    if (bfd_get_symcount (abfd) != 0)                          
-    {                                                          
-        bfd_seek (abfd,        (long)(N_TRELOFF(*execp)), false);      
+  if (bfd_get_symcount (abfd) != 0)
+    {
+      bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false);
 
-        if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd))) return false;
-        bfd_seek (abfd, (long)(N_DRELOFF(*execp)), false);     
+      if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd)))
+       return false;
+      bfd_seek (abfd, (long) (N_DRELOFF (*execp)), false);
 
-        if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) return false;
+      if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd)))
+       return false;
     }
 
-    return true;
-}                                                                      
+  return true;
+}
 
 /* convert the hp symbol type to be the same as aout64.h usage so we */
 /* can piggyback routines in aoutx.h.                                */
 
 static void
-DEFUN(convert_sym_type,(sym_pointer, cache_ptr, abfd),
-      struct external_nlist *sym_pointer AND
-      aout_symbol_type *cache_ptr AND
-      bfd *abfd)
+convert_sym_type (sym_pointer, cache_ptr, abfd)
+     struct external_nlist *sym_pointer;
+     aout_symbol_type *cache_ptr;
+     bfd *abfd;
 {
-    int name_type;
-    int new_type;
+  int name_type;
+  int new_type;
 
-    name_type = (cache_ptr->type);
-    new_type  = 0;
+  name_type = (cache_ptr->type);
+  new_type = 0;
 
-    if ((name_type & HP_SYMTYPE_ALIGN) != 0)
+  if ((name_type & HP_SYMTYPE_ALIGN) != 0)
     {
-        /* iou_error ("aligned symbol encountered: %s", name);*/
-        name_type = 0;
+      /* iou_error ("aligned symbol encountered: %s", name);*/
+      name_type = 0;
     }
 
-    if (name_type == HP_SYMTYPE_FILENAME)
-      new_type = N_FN;
-    else
-      {
-       switch (name_type & HP_SYMTYPE_TYPE)
-         {
-         case HP_SYMTYPE_UNDEFINED:
-           new_type = N_UNDF;
-           break;
-
-         case HP_SYMTYPE_ABSOLUTE:
-           new_type = N_ABS;
-           break;
-
-         case HP_SYMTYPE_TEXT:
-           new_type = N_TEXT;
-           break;
-
-         case HP_SYMTYPE_DATA:
-           new_type = N_DATA;
-           break;
-
-         case HP_SYMTYPE_BSS:
-           new_type = N_BSS;
-           break;
-
-         case HP_SYMTYPE_COMMON:
-           new_type = N_COMM;
-           break;
-
-         default:
-           fprintf (stderr, "unknown symbol type encountered: %x", name_type);
-         }
-       if (name_type & HP_SYMTYPE_EXTERNAL)
-         new_type |= N_EXT;
-
-        if (name_type & HP_SECONDARY_SYMBOL)
-            new_type = (new_type & ~N_TYPE) | N_INDR;
-      }
-    cache_ptr->type = new_type;
+  if (name_type == HP_SYMTYPE_FILENAME)
+    new_type = N_FN;
+  else
+    {
+      switch (name_type & HP_SYMTYPE_TYPE)
+       {
+       case HP_SYMTYPE_UNDEFINED:
+         new_type = N_UNDF;
+         break;
+
+       case HP_SYMTYPE_ABSOLUTE:
+         new_type = N_ABS;
+         break;
+
+       case HP_SYMTYPE_TEXT:
+         new_type = N_TEXT;
+         break;
+
+       case HP_SYMTYPE_DATA:
+         new_type = N_DATA;
+         break;
+
+       case HP_SYMTYPE_BSS:
+         new_type = N_BSS;
+         break;
+
+       case HP_SYMTYPE_COMMON:
+         new_type = N_COMM;
+         break;
+
+       default:
+         fprintf (stderr, "unknown symbol type encountered: %x", name_type);
+       }
+      if (name_type & HP_SYMTYPE_EXTERNAL)
+       new_type |= N_EXT;
+
+      if (name_type & HP_SECONDARY_SYMBOL)
+       new_type = (new_type & ~N_TYPE) | N_INDR;
+    }
+  cache_ptr->type = new_type;
 
 }
 
@@ -381,12 +383,12 @@ DESCRIPTION
 */
 
 void
-DEFUN(NAME(aout,swap_exec_header_in),(abfd, raw_bytes, execp),
-      bfd *abfd AND
-      struct external_exec *raw_bytes AND
-      struct internal_exec *execp)
+  NAME (aout, swap_exec_header_in) (abfd, raw_bytes, execp)
+     bfd *abfd;
+     struct external_exec *raw_bytes;
+     struct internal_exec *execp;
 {
-  struct external_exec *bytes = (struct external_exec *)raw_bytes;
+  struct external_exec *bytes = (struct external_exec *) raw_bytes;
 
   /* The internal_exec structure has some fields that are unused in this
      configuration (IE for i960), so ensure that all such uninitialized
@@ -394,12 +396,12 @@ DEFUN(NAME(aout,swap_exec_header_in),(abfd, raw_bytes, execp),
      are memcmp'd, and thus the contents do matter. */
   memset (execp, 0, sizeof (struct internal_exec));
   /* Now fill in fields in the execp, from the bytes in the raw data.  */
-  execp->a_info   = bfd_h_get_32 (abfd, bytes->e_info);
-  execp->a_text   = GET_WORD (abfd, bytes->e_text);
-  execp->a_data   = GET_WORD (abfd, bytes->e_data);
-  execp->a_bss    = GET_WORD (abfd, bytes->e_bss);
-  execp->a_syms   = GET_WORD (abfd, bytes->e_syms);
-  execp->a_entry  = GET_WORD (abfd, bytes->e_entry);
+  execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
+  execp->a_text = GET_WORD (abfd, bytes->e_text);
+  execp->a_data = GET_WORD (abfd, bytes->e_data);
+  execp->a_bss = GET_WORD (abfd, bytes->e_bss);
+  execp->a_syms = GET_WORD (abfd, bytes->e_syms);
+  execp->a_entry = GET_WORD (abfd, bytes->e_entry);
   execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
   execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
 
@@ -410,29 +412,35 @@ DEFUN(NAME(aout,swap_exec_header_in),(abfd, raw_bytes, execp),
   /* to be set.                                                  */
   /***************************************************************/
   do
-  {
+    {
       long syms;
-      struct aout_data_struct  *rawptr;
-      if (bfd_h_get_32 (abfd, bytes->e_passize) != 0) break;
-      if (bfd_h_get_32 (abfd, bytes->e_syms) != 0) break;
-      if (bfd_h_get_32 (abfd, bytes->e_supsize) != 0) break;
+      struct aout_data_struct *rawptr;
+      if (bfd_h_get_32 (abfd, bytes->e_passize) != 0)
+       break;
+      if (bfd_h_get_32 (abfd, bytes->e_syms) != 0)
+       break;
+      if (bfd_h_get_32 (abfd, bytes->e_supsize) != 0)
+       break;
 
       syms = bfd_h_get_32 (abfd, bytes->e_drelocs);
-      if (syms == 0) break;
+      if (syms == 0)
+       break;
 
       /* OK, we've passed the test as best as we can determine */
       execp->a_syms = syms;
 
       /* allocate storage for where we will store this result */
-      rawptr = (struct aout_data_struct  *) bfd_zalloc (abfd, sizeof (*rawptr));
+      rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (*rawptr));
 
-      if (rawptr == NULL) {
-          bfd_error = no_memory;
-          return;
-      }
+      if (rawptr == NULL)
+       {
+         bfd_set_error (bfd_error_no_memory);
+         return;
+       }
       abfd->tdata.aout_data = rawptr;
-      obj_aout_subformat(abfd) = gnu_encap_format;
-  } while (0);
+      obj_aout_subformat (abfd) = gnu_encap_format;
+    }
+  while (0);
 }
 
 
@@ -460,8 +468,8 @@ DEFUN(NAME(aout,swap_exec_header_in),(abfd, raw_bytes, execp),
 */
 
 boolean
-DEFUN(MY(slurp_symbol_table),(abfd),
-      bfd *abfd)
+MY (slurp_symbol_table) (abfd)
+     bfd *abfd;
 {
   bfd_size_type symbol_bytes;
   struct external_nlist *syms;
@@ -473,50 +481,52 @@ DEFUN(MY(slurp_symbol_table),(abfd),
   unsigned num_secondary = 0;
 
   /* If there's no work to be done, don't do any */
-  if (obj_aout_symbols (abfd) != (aout_symbol_type *)NULL) return true;
-  symbol_bytes = exec_hdr(abfd)->a_syms;
-  if (symbol_bytes == 0) {
-    bfd_error = no_symbols;
-    return false;
-  }
+  if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
+    return true;
+  symbol_bytes = exec_hdr (abfd)->a_syms;
+  if (symbol_bytes == 0)
+    {
+      bfd_set_error (bfd_error_no_symbols);
+      return false;
+    }
 
-  strings = (char *) bfd_alloc(abfd,
-                               symbol_bytes + SYM_EXTRA_BYTES);
+  strings = (char *) bfd_alloc (abfd,
+                               symbol_bytes + SYM_EXTRA_BYTES);
   if (!strings)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   syms = (struct external_nlist *) (strings + SYM_EXTRA_BYTES);
   bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET);
-  if (bfd_read ((PTR)syms, symbol_bytes, 1, abfd) != symbol_bytes)
-  {
+  if (bfd_read ((PTR) syms, symbol_bytes, 1, abfd) != symbol_bytes)
+    {
       bfd_release (abfd, syms);
       return false;
-  }
+    }
 
 
-  sym_end = (struct external_nlist *) (((char *)syms) + symbol_bytes);
+  sym_end = (struct external_nlist *) (((char *) syms) + symbol_bytes);
 
   /* first, march thru the table and figure out how many symbols there are */
   for (sym_pointer = syms; sym_pointer < sym_end; sym_pointer++, num_syms++)
-  {
-      if (bfd_get_8(abfd,  sym_pointer->e_type) & HP_SECONDARY_SYMBOL)
-          num_secondary++;
+    {
+      if (bfd_get_8 (abfd, sym_pointer->e_type) & HP_SECONDARY_SYMBOL)
+       num_secondary++;
       /* skip over the embedded symbol. */
-      sym_pointer = (struct external_nlist *) (((char *)sym_pointer) +
-                                                     sym_pointer->e_length[0]);
-  }
+      sym_pointer = (struct external_nlist *) (((char *) sym_pointer) +
+                                              sym_pointer->e_length[0]);
+    }
 
   /* now that we know the symbol count, update the bfd header */
-  bfd_get_symcount (abfd) = num_syms+num_secondary;
+  bfd_get_symcount (abfd) = num_syms + num_secondary;
 
   cached = (aout_symbol_type *)
-    bfd_zalloc(abfd, (bfd_size_type)(bfd_get_symcount (abfd) *
-                                     sizeof(aout_symbol_type)));
+    bfd_zalloc (abfd, (bfd_size_type) (bfd_get_symcount (abfd) *
+                                      sizeof (aout_symbol_type)));
   if (!cached)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
@@ -527,82 +537,82 @@ DEFUN(MY(slurp_symbol_table),(abfd),
   num_secondary = 0;
 
   /* OK, now walk the new symtable, cacheing symbol properties */
-    {
-      aout_symbol_type *cache_ptr = cached;
-      aout_symbol_type cache_save;
-      /* Run through table and copy values */
-      for (sym_pointer = syms, cache_ptr = cached;
-          sym_pointer < sym_end; sym_pointer++, cache_ptr++)
+  {
+    aout_symbol_type *cache_ptr = cached;
+    aout_symbol_type cache_save;
+    /* Run through table and copy values */
+    for (sym_pointer = syms, cache_ptr = cached;
+        sym_pointer < sym_end; sym_pointer++, cache_ptr++)
+      {
+       unsigned int length;
+       cache_ptr->symbol.the_bfd = abfd;
+       cache_ptr->symbol.value = GET_SWORD (abfd, sym_pointer->e_value);
+       cache_ptr->desc = bfd_get_16 (abfd, sym_pointer->e_almod);
+       cache_ptr->type = bfd_get_8 (abfd, sym_pointer->e_type);
+       cache_ptr->symbol.udata = 0;
+       length = bfd_get_8 (abfd, sym_pointer->e_length);
+       cache_ptr->other = length;      /* other not used, save length here */
+
+       cache_save = *cache_ptr;
+       convert_sym_type (sym_pointer, cache_ptr, abfd);
+       if (!translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd))
+         return false;
+
+       /********************************************************/
+       /* for hpux, the 'lenght' value indicates the length of */
+       /* the symbol name which follows the nlist entry.       */
+       /********************************************************/
+       if (length)
          {
-            unsigned int length;
-           cache_ptr->symbol.the_bfd = abfd;
-           cache_ptr->symbol.value = GET_SWORD(abfd,  sym_pointer->e_value);
-           cache_ptr->desc = bfd_get_16(abfd, sym_pointer->e_almod);
-           cache_ptr->type = bfd_get_8(abfd,  sym_pointer->e_type);
-           cache_ptr->symbol.udata = 0;
-            length = bfd_get_8(abfd, sym_pointer->e_length);
-           cache_ptr->other = length;  /* other not used, save length here */
-
-            cache_save = *cache_ptr;
-            convert_sym_type(sym_pointer, cache_ptr, abfd);
-           if (!translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd))
+           /**************************************************************/
+           /* the hp string is not null terminated so we create a new one*/
+           /* by copying the string to overlap the just vacated nlist    */
+           /* structure before it in memory.                             */
+           /**************************************************************/
+           cache_ptr->symbol.name = strings;
+           memcpy (strings, sym_pointer + 1, length);
+           strings[length] = '\0';
+           strings += length + 1;
+         }
+       else
+         cache_ptr->symbol.name = (char *) NULL;
+
+       /**********************************************************/
+       /* this is a bit of a kludge, but a secondary hp symbol   */
+       /* gets translated into a gnu indirect symbol.  When this */
+       /* happens, we need to create a "dummy" record to which   */
+       /* we can point the indirect symbol to.                   */
+       /**********************************************************/
+       if ((cache_ptr->type | N_EXT) == (N_INDR | N_EXT))
+         {
+           aout_symbol_type *cache_ptr2 = cached + num_syms + num_secondary;
+
+           num_secondary++;
+
+           /* aoutx.h assumes the "next" value is the indirect sym  */
+           /* since we don't want to disturb the order by inserting */
+           /* a new symbol, we tack on the created secondary syms   */
+           /* at the end.                                           */
+           cache_ptr->symbol.value = (bfd_vma) (cache_ptr2);
+           *cache_ptr2 = cache_save;
+           cache_ptr2->symbol.name = strings;
+           memcpy (strings, cache_ptr->symbol.name, length);
+           strcpy (strings + length, ":secondry");     /* 9 max chars + null */
+           strings += length + 10;
+           cache_ptr2->type &= ~HP_SECONDARY_SYMBOL;   /* clear secondary */
+           convert_sym_type (sym_pointer, cache_ptr2, abfd);
+           if (!translate_from_native_sym_flags (sym_pointer, cache_ptr2,
+                                                 abfd))
              return false;
-
-            /********************************************************/
-            /* for hpux, the 'lenght' value indicates the length of */
-            /* the symbol name which follows the nlist entry.       */
-            /********************************************************/
-            if (length)
-            {
-                /**************************************************************/
-                /* the hp string is not null terminated so we create a new one*/
-                /* by copying the string to overlap the just vacated nlist    */
-                /* structure before it in memory.                             */
-                /**************************************************************/
-                cache_ptr->symbol.name = strings;
-                memcpy(strings, sym_pointer+1, length);
-                strings[length] = '\0';
-                strings += length + 1;
-            }
-           else
-             cache_ptr->symbol.name = (char *)NULL;
-
-            /**********************************************************/
-            /* this is a bit of a kludge, but a secondary hp symbol   */
-            /* gets translated into a gnu indirect symbol.  When this */
-            /* happens, we need to create a "dummy" record to which   */
-            /* we can point the indirect symbol to.                   */
-            /**********************************************************/
-            if ((cache_ptr->type | N_EXT) == (N_INDR | N_EXT))
-            {
-                aout_symbol_type *cache_ptr2 = cached + num_syms+num_secondary;
-
-                num_secondary++;
-
-                /* aoutx.h assumes the "next" value is the indirect sym  */
-                /* since we don't want to disturb the order by inserting */
-                /* a new symbol, we tack on the created secondary syms   */
-                /* at the end.                                           */
-                cache_ptr->symbol.value = (bfd_vma)(cache_ptr2);
-                *cache_ptr2 = cache_save;
-                cache_ptr2->symbol.name = strings;
-                memcpy(strings, cache_ptr->symbol.name, length);
-                strcpy(strings+length,":secondry"); /* 9 max chars + null */
-                strings += length+10;
-                cache_ptr2->type &= ~HP_SECONDARY_SYMBOL;  /* clear secondary */
-                convert_sym_type(sym_pointer, cache_ptr2, abfd);
-                if (!translate_from_native_sym_flags (sym_pointer, cache_ptr2,
-                                                     abfd))
-                 return false;
-            }
-
-            /* skip over the embedded symbol. */
-            sym_pointer = (struct external_nlist *) (((char *)sym_pointer) +
-                                                 length);
          }
-    }
 
-  obj_aout_symbols (abfd) =  cached;
+       /* skip over the embedded symbol. */
+       sym_pointer = (struct external_nlist *) (((char *) sym_pointer) +
+                                                length);
+      }
+  }
+
+  obj_aout_symbols (abfd) = cached;
 
   return true;
 }
@@ -610,49 +620,49 @@ DEFUN(MY(slurp_symbol_table),(abfd),
 
 
 void
-DEFUN(MY(swap_std_reloc_in), (abfd, bytes, cache_ptr, symbols),
-  bfd *abfd AND
-  struct hp300hpux_reloc *bytes AND
-  arelent *cache_ptr AND
-  asymbol **symbols)
+MY (swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols)
+     bfd *abfd;
+     struct hp300hpux_reloc *bytes;
+     arelent *cache_ptr;
+     asymbol **symbols;
 {
   int r_index;
   int r_extern = 0;
   unsigned int r_length;
   int r_pcrel = 0;
-  struct aoutdata  *su = &(abfd->tdata.aout_data->a);
+  struct aoutdata *su = &(abfd->tdata.aout_data->a);
 
   cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
-  r_index = bfd_h_get_16(abfd, bytes->r_index);
+  r_index = bfd_h_get_16 (abfd, bytes->r_index);
 
   switch (bytes->r_type[0])
-  {
-  case HP_RSEGMENT_TEXT:
+    {
+    case HP_RSEGMENT_TEXT:
       r_index = N_TEXT;
       break;
-  case HP_RSEGMENT_DATA:
+    case HP_RSEGMENT_DATA:
       r_index = N_DATA;
       break;
-  case HP_RSEGMENT_BSS:
+    case HP_RSEGMENT_BSS:
       r_index = N_BSS;
       break;
-  case HP_RSEGMENT_EXTERNAL:
+    case HP_RSEGMENT_EXTERNAL:
       r_extern = 1;
       break;
-  case HP_RSEGMENT_PCREL:
+    case HP_RSEGMENT_PCREL:
       r_extern = 1;
       r_pcrel = 1;
       break;
-  case HP_RSEGMENT_RDLT:
+    case HP_RSEGMENT_RDLT:
       break;
-  case HP_RSEGMENT_RPLT:
+    case HP_RSEGMENT_RPLT:
       break;
-  case HP_RSEGMENT_NOOP:
+    case HP_RSEGMENT_NOOP:
       break;
-  default:
+    default:
       fprintf (stderr, "illegal relocation segment type: %x\n",
               (bytes->r_type[0]));
-  }
+    }
 
   switch (bytes->r_length[0])
     {
@@ -666,32 +676,32 @@ DEFUN(MY(swap_std_reloc_in), (abfd, bytes, cache_ptr, symbols),
       r_length = 2;
       break;
     default:
-      fprintf (stderr, "illegal relocation length: %x\n",bytes->r_length[0] );
+      fprintf (stderr, "illegal relocation length: %x\n", bytes->r_length[0]);
       r_length = 0;
     }
 
-  cache_ptr->howto =  howto_table_std + r_length + 4 * r_pcrel;
+  cache_ptr->howto = howto_table_std + r_length + 4 * r_pcrel;
   /* FIXME-soon:  Roll baserel, jmptable, relative bits into howto setting */
 
   /* This macro uses the r_index value computed above */
   if (r_pcrel && r_extern)
-  {
-    /* The GNU linker assumes any offset from beginning of section */
-    /* is already incorporated into the image while the HP linker  */
-    /* adds this in later.  Add it in now...                       */
-    MOVE_ADDRESS( - cache_ptr->address);
-  }
+    {
+      /* The GNU linker assumes any offset from beginning of section */
+      /* is already incorporated into the image while the HP linker  */
+      /* adds this in later.  Add it in now...                       */
+      MOVE_ADDRESS (-cache_ptr->address);
+    }
   else
-  {
-    MOVE_ADDRESS(0);
-  }
+    {
+      MOVE_ADDRESS (0);
+    }
 }
 
 boolean
-DEFUN(MY(slurp_reloc_table),(abfd, asect, symbols),
-      bfd *abfd AND
-      sec_ptr asect AND
-      asymbol **symbols)
+MY (slurp_reloc_table) (abfd, asect, symbols)
+     bfd *abfd;
+     sec_ptr asect;
+     asymbol **symbols;
 {
   unsigned int count;
   bfd_size_type reloc_size;
@@ -702,61 +712,68 @@ DEFUN(MY(slurp_reloc_table),(abfd, asect, symbols),
   unsigned int counter;
   arelent *cache_ptr;
 
-  if (asect->relocation) return true;
+  if (asect->relocation)
+    return true;
 
-  if (asect->flags & SEC_CONSTRUCTOR) return true;
+  if (asect->flags & SEC_CONSTRUCTOR)
+    return true;
 
-  if (asect == obj_datasec (abfd)) {
-    reloc_size = exec_hdr(abfd)->a_drsize;
-    goto doit;
-  }
+  if (asect == obj_datasec (abfd))
+    {
+      reloc_size = exec_hdr (abfd)->a_drsize;
+      goto doit;
+    }
 
-  if (asect == obj_textsec (abfd)) {
-    reloc_size = exec_hdr(abfd)->a_trsize;
-    goto doit;
-  }
+  if (asect == obj_textsec (abfd))
+    {
+      reloc_size = exec_hdr (abfd)->a_trsize;
+      goto doit;
+    }
 
-  bfd_error = invalid_operation;
+  bfd_set_error (bfd_error_invalid_operation);
   return false;
 
- doit:
+doit:
   bfd_seek (abfd, asect->rel_filepos, SEEK_SET);
   each_size = obj_reloc_entry_size (abfd);
 
   count = reloc_size / each_size;
 
 
-  reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t)(count * sizeof
-                                                      (arelent)));
-  if (!reloc_cache) {
-nomem:
-    bfd_error = no_memory;
-    return false;
-  }
+  reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t) (count * sizeof
+                                                       (arelent)));
+  if (!reloc_cache)
+    {
+    nomem:
+      bfd_set_error (bfd_error_no_memory);
+      return false;
+    }
 
   relocs = (PTR) bfd_alloc (abfd, reloc_size);
-  if (!relocs) {
-    bfd_release (abfd, reloc_cache);
-    goto nomem;
-  }
+  if (!relocs)
+    {
+      bfd_release (abfd, reloc_cache);
+      goto nomem;
+    }
 
-  if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size) {
-    bfd_release (abfd, relocs);
-    bfd_release (abfd, reloc_cache);
-    bfd_error = system_call_error;
-    return false;
-  }
+  if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
+    {
+      bfd_release (abfd, relocs);
+      bfd_release (abfd, reloc_cache);
+      return false;
+    }
 
-    rptr = (struct hp300hpux_reloc*) relocs;
-    counter = 0;
-    cache_ptr = reloc_cache;
+  rptr = (struct hp300hpux_reloc *) relocs;
+  counter = 0;
+  cache_ptr = reloc_cache;
 
-    for (; counter < count; counter++, rptr++, cache_ptr++) {
-       MY(swap_std_reloc_in)(abfd, rptr, cache_ptr, symbols);
+  for (; counter < count; counter++, rptr++, cache_ptr++)
+    {
+      MY (swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols);
     }
 
 
-  bfd_release (abfd,relocs);
+  bfd_release (abfd, relocs);
   asect->relocation = reloc_cache;
   asect->reloc_count = count;
   return true;
@@ -769,77 +786,83 @@ nomem:
 /* call aout_32 versions if the input file was generated by gcc         */
 /************************************************************************/
 
-unsigned int aout_32_get_symtab PARAMS((bfd *abfd, asymbol **location));
-unsigned int aout_32_get_symtab_upper_bound PARAMS ((bfd *abfd));
+unsigned int aout_32_get_symtab PARAMS ((bfd * abfd, asymbol ** location));
+unsigned int aout_32_get_symtab_upper_bound PARAMS ((bfd * abfd));
 
-unsigned int aout_32_canonicalize_reloc PARAMS((bfd *abfd, sec_ptr section,
-                                                arelent **relptr,
-                                                asymbol **symbols));
+unsigned int aout_32_canonicalize_reloc PARAMS ((bfd * abfd, sec_ptr section,
+                                                arelent ** relptr,
+                                                asymbol ** symbols));
 
 unsigned int
-DEFUN(MY(get_symtab),(abfd, location),
-      bfd *abfd AND
-      asymbol **location)
+MY (get_symtab) (abfd, location)
+     bfd *abfd;
+     asymbol **location;
 {
-    unsigned int counter = 0;
-    aout_symbol_type *symbase;
+  unsigned int counter = 0;
+  aout_symbol_type *symbase;
 
-    if (obj_aout_subformat(abfd) == gnu_encap_format)
-        return aout_32_get_symtab(abfd,location);
+  if (obj_aout_subformat (abfd) == gnu_encap_format)
+    return aout_32_get_symtab (abfd, location);
 
-    if (!MY(slurp_symbol_table)(abfd)) return 0;
+  if (!MY (slurp_symbol_table) (abfd))
+    return 0;
 
-    for (symbase = obj_aout_symbols(abfd); counter++ < bfd_get_symcount (abfd);)
-      *(location++) = (asymbol *)( symbase++);
-    *location++ =0;
-    return bfd_get_symcount (abfd);
+  for (symbase = obj_aout_symbols (abfd); counter++ < bfd_get_symcount (abfd);)
+    *(location++) = (asymbol *) (symbase++);
+  *location++ = 0;
+  return bfd_get_symcount (abfd);
 }
 
- unsigned int
-DEFUN(MY(get_symtab_upper_bound),(abfd),
-     bfd *abfd)
+unsigned int
+MY (get_symtab_upper_bound) (abfd)
+     bfd *abfd;
 {
-    if (obj_aout_subformat(abfd) == gnu_encap_format)
-        return aout_32_get_symtab_upper_bound(abfd);
-    if (!MY(slurp_symbol_table)(abfd)) return 0;
+  if (obj_aout_subformat (abfd) == gnu_encap_format)
+    return aout_32_get_symtab_upper_bound (abfd);
+  if (!MY (slurp_symbol_table) (abfd))
+    return 0;
 
-    return (bfd_get_symcount (abfd)+1) * (sizeof (aout_symbol_type *));
+  return (bfd_get_symcount (abfd) + 1) * (sizeof (aout_symbol_type *));
 }
 
 
 
 
 unsigned int
-DEFUN(MY(canonicalize_reloc),(abfd, section, relptr, symbols),
-      bfd *abfd AND
-      sec_ptr section AND
-      arelent **relptr AND
-      asymbol **symbols)
+MY (canonicalize_reloc) (abfd, section, relptr, symbols)
+     bfd *abfd;
+     sec_ptr section;
+     arelent **relptr;
+     asymbol **symbols;
 {
   arelent *tblptr = section->relocation;
   unsigned int count;
-  if (obj_aout_subformat(abfd) == gnu_encap_format)
-      return aout_32_canonicalize_reloc(abfd,section,relptr,symbols);
+  if (obj_aout_subformat (abfd) == gnu_encap_format)
+    return aout_32_canonicalize_reloc (abfd, section, relptr, symbols);
 
-  if (!(tblptr || MY(slurp_reloc_table)(abfd, section, symbols)))
+  if (!(tblptr || MY (slurp_reloc_table) (abfd, section, symbols)))
     return 0;
 
-  if (section->flags & SEC_CONSTRUCTOR) {
-    arelent_chain *chain = section->constructor_chain;
-    for (count = 0; count < section->reloc_count; count ++) {
-      *relptr ++ = &chain->relent;
-      chain = chain->next;
+  if (section->flags & SEC_CONSTRUCTOR)
+    {
+      arelent_chain *chain = section->constructor_chain;
+      for (count = 0; count < section->reloc_count; count++)
+       {
+         *relptr++ = &chain->relent;
+         chain = chain->next;
+       }
+    }
+  else
+    {
+      tblptr = section->relocation;
+      if (!tblptr)
+       return 0;
+
+      for (count = 0; count++ < section->reloc_count;)
+       {
+         *relptr++ = tblptr++;
+       }
     }
-  }
-  else {
-    tblptr = section->relocation;
-    if (!tblptr) return 0;
-
-    for (count = 0; count++ < section->reloc_count;)
-      {
-       *relptr++ = tblptr++;
-      }
-  }
   *relptr = 0;
 
   return section->reloc_count;
index 04af2b73021ebb3cc55c765b4a32f14360743cc7..9a47e0061d2f4b0197e4fd3dd499d3e5877084ff 100644 (file)
@@ -1,4 +1,4 @@
-/* BFD back-end for i386 a.out binaries under Lynx.
+/* BFD back-end for i386 a.out binaries under LynxOS.
    Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -58,7 +58,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
            {                                                                 \
              bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET);        \
                                                                              \
-             NAME(aout,write_syms)(abfd);                                    \
+             if (! NAME(aout,write_syms)(abfd)) return false;                \
                                                                              \
              bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET);       \
                                                                              \
@@ -67,7 +67,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
                                                                              \
              if (!NAME(lynx,squirt_out_relocs)(abfd, obj_datasec (abfd))) return false; \
            }                                                                 \
-      }                                                                              
+      }
 #endif
 
 #include "libaout.h"
@@ -75,10 +75,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifdef HOST_LYNX
 
-char *lynx_core_file_failing_command();
-int lynx_core_file_failing_signal();
-boolean lynx_core_file_matches_executable_p();
-bfd_target *lynx_core_file_p();
+char *lynx_core_file_failing_command ();
+int lynx_core_file_failing_signal ();
+boolean lynx_core_file_matches_executable_p ();
+bfd_target *lynx_core_file_p ();
 
 #define        MY_core_file_failing_command lynx_core_file_failing_command
 #define        MY_core_file_failing_signal lynx_core_file_failing_signal
@@ -86,8 +86,8 @@ bfd_target *lynx_core_file_p();
 #define        MY_core_file_p lynx_core_file_p
 
 #endif /* HOST_LYNX */
-
 \f
+
 #define KEEPIT flags
 
 extern reloc_howto_type aout_32_ext_howto_table[];
@@ -97,10 +97,10 @@ extern reloc_howto_type aout_32_std_howto_table[];
 /* Output standard relocation information to a file in target byte order. */
 
 void
-DEFUN(NAME(lynx,swap_std_reloc_out),(abfd, g, natptr),
-      bfd *abfd AND
-      arelent *g AND
-      struct reloc_std_external *natptr)
+NAME (lynx, swap_std_reloc_out) (abfd, g, natptr)
+     bfd *abfd;
+     arelent *g;
+     struct reloc_std_external *natptr;
 {
   int r_index;
   asymbol *sym = *(g->sym_ptr_ptr);
@@ -111,78 +111,81 @@ DEFUN(NAME(lynx,swap_std_reloc_out),(abfd, g, natptr),
   unsigned int r_addend;
   asection *output_section = sym->section->output_section;
 
-  PUT_WORD(abfd, g->address, natptr->r_address);
+  PUT_WORD (abfd, g->address, natptr->r_address);
 
-  r_length = g->howto->size ;  /* Size as a power of two */
-  r_pcrel  = (int) g->howto->pc_relative; /* Relative to PC? */
+  r_length = g->howto->size  /* Size as a power of two */
+  r_pcrel = (int) g->howto->pc_relative;       /* Relative to PC? */
   /* r_baserel, r_jmptable, r_relative???  FIXME-soon */
   r_baserel = 0;
   r_jmptable = 0;
   r_relative = 0;
-    
+
   r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
-    
+
   /* name was clobbered by aout_write_syms to be symbol index */
 
-  /* If this relocation is relative to a symbol then set the 
+  /* If this relocation is relative to a symbol then set the
      r_index to the symbols index, and the r_extern bit.
 
      Absolute symbols can come in in two ways, either as an offset
      from the abs section, or as a symbol which has an abs value.
      check for that here
      */
-     
+
 
   if (bfd_is_com_section (output_section)
       || output_section == &bfd_abs_section
-      || output_section == &bfd_und_section) 
+      || output_section == &bfd_und_section)
     {
       if (bfd_abs_section.symbol == sym)
-      {
-       /* Whoops, looked like an abs symbol, but is really an offset
+       {
+         /* Whoops, looked like an abs symbol, but is really an offset
           from the abs section */
-       r_index = 0;
-       r_extern = 0;
-       }
-      else 
-      {
-       /* Fill in symbol */
-       r_extern = 1;
-       r_index =  stoi((*(g->sym_ptr_ptr))->KEEPIT);
-     
-      }
+         r_index = 0;
+         r_extern = 0;
+       }
+      else
+       {
+         /* Fill in symbol */
+         r_extern = 1;
+         r_index = stoi ((*(g->sym_ptr_ptr))->KEEPIT);
+
+       }
     }
-  else 
+  else
     {
       /* Just an ordinary section */
       r_extern = 0;
-      r_index  = output_section->target_index;      
+      r_index = output_section->target_index;
     }
 
   /* now the fun stuff */
-  if (abfd->xvec->header_byteorder_big_p != false) {
+  if (abfd->xvec->header_byteorder_big_p != false)
+    {
       natptr->r_index[0] = r_index >> 16;
       natptr->r_index[1] = r_index >> 8;
       natptr->r_index[2] = r_index;
       natptr->r_type[0] =
-       (r_extern?    RELOC_STD_BITS_EXTERN_BIG: 0)
-       | (r_pcrel?     RELOC_STD_BITS_PCREL_BIG: 0)
-        | (r_baserel?   RELOC_STD_BITS_BASEREL_BIG: 0)
-         | (r_jmptable?  RELOC_STD_BITS_JMPTABLE_BIG: 0)
-          | (r_relative?  RELOC_STD_BITS_RELATIVE_BIG: 0)
-           | (r_length <<  RELOC_STD_BITS_LENGTH_SH_BIG);
-    } else {
-       natptr->r_index[2] = r_index >> 16;
-       natptr->r_index[1] = r_index >> 8;
-       natptr->r_index[0] = r_index;
-       natptr->r_type[0] =
-        (r_extern?    RELOC_STD_BITS_EXTERN_LITTLE: 0)
-         | (r_pcrel?     RELOC_STD_BITS_PCREL_LITTLE: 0)
-          | (r_baserel?   RELOC_STD_BITS_BASEREL_LITTLE: 0)
-           | (r_jmptable?  RELOC_STD_BITS_JMPTABLE_LITTLE: 0)
-            | (r_relative?  RELOC_STD_BITS_RELATIVE_LITTLE: 0)
-             | (r_length <<  RELOC_STD_BITS_LENGTH_SH_LITTLE);
-      }
+       (r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
+       | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
+       | (r_baserel ? RELOC_STD_BITS_BASEREL_BIG : 0)
+       | (r_jmptable ? RELOC_STD_BITS_JMPTABLE_BIG : 0)
+       | (r_relative ? RELOC_STD_BITS_RELATIVE_BIG : 0)
+       | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG);
+    }
+  else
+    {
+      natptr->r_index[2] = r_index >> 16;
+      natptr->r_index[1] = r_index >> 8;
+      natptr->r_index[0] = r_index;
+      natptr->r_type[0] =
+       (r_extern ? RELOC_STD_BITS_EXTERN_LITTLE : 0)
+       | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0)
+       | (r_baserel ? RELOC_STD_BITS_BASEREL_LITTLE : 0)
+       | (r_jmptable ? RELOC_STD_BITS_JMPTABLE_LITTLE : 0)
+       | (r_relative ? RELOC_STD_BITS_RELATIVE_LITTLE : 0)
+       | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE);
+    }
 }
 
 
@@ -190,81 +193,84 @@ DEFUN(NAME(lynx,swap_std_reloc_out),(abfd, g, natptr),
 /* Output extended relocation information to a file in target byte order. */
 
 void
-DEFUN(NAME(lynx,swap_ext_reloc_out),(abfd, g, natptr),
-      bfd *abfd AND
-      arelent *g AND
-      register struct reloc_ext_external *natptr)
+NAME (lynx, swap_ext_reloc_out) (abfd, g, natptr)
+     bfd *abfd;
+     arelent *g;
+     register struct reloc_ext_external *natptr;
 {
   int r_index;
   int r_extern;
   unsigned int r_type;
   unsigned int r_addend;
-  asymbol *sym = *(g->sym_ptr_ptr);    
+  asymbol *sym = *(g->sym_ptr_ptr);
   asection *output_section = sym->section->output_section;
-  
+
   PUT_WORD (abfd, g->address, natptr->r_address);
-    
+
   r_type = (unsigned int) g->howto->type;
-    
+
   r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
 
 
-  /* If this relocation is relative to a symbol then set the 
+  /* If this relocation is relative to a symbol then set the
      r_index to the symbols index, and the r_extern bit.
 
      Absolute symbols can come in in two ways, either as an offset
      from the abs section, or as a symbol which has an abs value.
      check for that here
      */
-     
+
   if (bfd_is_com_section (output_section)
       || output_section == &bfd_abs_section
       || output_section == &bfd_und_section)
-  {
-    if (bfd_abs_section.symbol == sym)
     {
-      /* Whoops, looked like an abs symbol, but is really an offset
+      if (bfd_abs_section.symbol == sym)
+       {
+         /* Whoops, looked like an abs symbol, but is really an offset
         from the abs section */
-      r_index = 0;
-      r_extern = 0;
-     }
-    else 
+         r_index = 0;
+         r_extern = 0;
+       }
+      else
+       {
+         r_extern = 1;
+         r_index = stoi ((*(g->sym_ptr_ptr))->KEEPIT);
+       }
+    }
+  else
     {
-      r_extern = 1;
-      r_index =  stoi((*(g->sym_ptr_ptr))->KEEPIT);
+      /* Just an ordinary section */
+      r_extern = 0;
+      r_index = output_section->target_index;
     }
-  }
-  else 
-  {
-    /* Just an ordinary section */
-    r_extern = 0;
-    r_index  = output_section->target_index;      
-  }
-        
-        
+
+
   /* now the fun stuff */
-  if (abfd->xvec->header_byteorder_big_p != false) {
-    natptr->r_index[0] = r_index >> 16;
-    natptr->r_index[1] = r_index >> 8;
-    natptr->r_index[2] = r_index;
-    natptr->r_type[0] =
-     (r_extern? RELOC_EXT_BITS_EXTERN_BIG: 0)
-      | (r_type << RELOC_EXT_BITS_TYPE_SH_BIG);
-  } else {
-    natptr->r_index[2] = r_index >> 16;
-    natptr->r_index[1] = r_index >> 8;
-    natptr->r_index[0] = r_index;
-    natptr->r_type[0] =
-     (r_extern? RELOC_EXT_BITS_EXTERN_LITTLE: 0)
-      | (r_type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
-  }
+  if (abfd->xvec->header_byteorder_big_p != false)
+    {
+      natptr->r_index[0] = r_index >> 16;
+      natptr->r_index[1] = r_index >> 8;
+      natptr->r_index[2] = r_index;
+      natptr->r_type[0] =
+       (r_extern ? RELOC_EXT_BITS_EXTERN_BIG : 0)
+       | (r_type << RELOC_EXT_BITS_TYPE_SH_BIG);
+    }
+  else
+    {
+      natptr->r_index[2] = r_index >> 16;
+      natptr->r_index[1] = r_index >> 8;
+      natptr->r_index[0] = r_index;
+      natptr->r_type[0] =
+       (r_extern ? RELOC_EXT_BITS_EXTERN_LITTLE : 0)
+       | (r_type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
+    }
 
   PUT_WORD (abfd, r_addend, natptr->r_addend);
 }
 
 /* BFD deals internally with all things based from the section they're
    in. so, something in 10 bytes into a text section  with a base of
-   50 would have a symbol (.text+10) and know .text vma was 50. 
+   50 would have a symbol (.text+10) and know .text vma was 50.
 
    Aout keeps all it's symbols based from zero, so the symbol would
    contain 60. This macro subs the base of each section from the value
@@ -305,11 +311,11 @@ DEFUN(NAME(lynx,swap_ext_reloc_out),(abfd, g, natptr),
   }                                                                    \
 
 void
-DEFUN(NAME(lynx,swap_ext_reloc_in), (abfd, bytes, cache_ptr, symbols),
-      bfd *abfd AND
-      struct reloc_ext_external *bytes AND
-      arelent *cache_ptr AND
-      asymbol **symbols)
+NAME (lynx, swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols)
+     bfd *abfd;
+     struct reloc_ext_external *bytes;
+     arelent *cache_ptr;
+     asymbol **symbols;
 {
   int r_index;
   int r_extern;
@@ -318,68 +324,53 @@ DEFUN(NAME(lynx,swap_ext_reloc_in), (abfd, bytes, cache_ptr, symbols),
 
   cache_ptr->address = (GET_SWORD (abfd, bytes->r_address));
 
-  /* now the fun stuff */
-  if (1 /* abfd->xvec->header_byteorder_big_p != false */) {
-    r_index =  (bytes->r_index[0] << 16)
-            | (bytes->r_index[1] << 8)
-            |  bytes->r_index[2];
-    r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_BIG));
-    r_type   =       (bytes->r_type[0] & RELOC_EXT_BITS_TYPE_BIG)
-                                     >> RELOC_EXT_BITS_TYPE_SH_BIG;
-  } else {
-    r_index =  (bytes->r_index[2] << 16)
-            | (bytes->r_index[1] << 8)
-            |  bytes->r_index[0];
-    r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_LITTLE));
-    r_type   =       (bytes->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE)
-                                     >> RELOC_EXT_BITS_TYPE_SH_LITTLE;
-  }
-
-  cache_ptr->howto =  aout_32_ext_howto_table + r_type;
-  MOVE_ADDRESS(GET_SWORD(abfd, bytes->r_addend));
+  r_index = bytes->r_index[1];
+  r_extern = (0 != (bytes->r_index[0] & RELOC_EXT_BITS_EXTERN_BIG));
+  r_type = (bytes->r_index[0] & RELOC_EXT_BITS_TYPE_BIG)
+    >> RELOC_EXT_BITS_TYPE_SH_BIG;
+
+  cache_ptr->howto = aout_32_ext_howto_table + r_type;
+  MOVE_ADDRESS (GET_SWORD (abfd, bytes->r_addend));
 }
 
 void
-DEFUN(NAME(lynx,swap_std_reloc_in), (abfd, bytes, cache_ptr, symbols),
-  bfd *abfd AND
-  struct reloc_std_external *bytes AND
-  arelent *cache_ptr AND
-  asymbol **symbols)
+NAME (lynx, swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols)
+     bfd *abfd;
+     struct reloc_std_external *bytes;
+     arelent *cache_ptr;
+     asymbol **symbols;
 {
-  char tmp;
   int r_index;
   int r_extern;
   unsigned int r_length;
   int r_pcrel;
   int r_baserel, r_jmptable, r_relative;
-  struct aoutdata  *su = &(abfd->tdata.aout_data->a);
+  struct aoutdata *su = &(abfd->tdata.aout_data->a);
 
   cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
 
-  r_index = (bytes->r_type[0] << 16)
-    | (bytes->r_index[2] << 8)
-      |  bytes->r_index[1];
-  r_extern  = (0 != (bytes->r_index[0] & RELOC_STD_BITS_EXTERN_BIG));
-  r_pcrel   = (0 != (bytes->r_index[0] & RELOC_STD_BITS_PCREL_BIG));
+  r_index = bytes->r_index[1];
+  r_extern = (0 != (bytes->r_index[0] & RELOC_STD_BITS_EXTERN_BIG));
+  r_pcrel = (0 != (bytes->r_index[0] & RELOC_STD_BITS_PCREL_BIG));
   r_baserel = (0 != (bytes->r_index[0] & RELOC_STD_BITS_BASEREL_BIG));
-  r_jmptable= (0 != (bytes->r_index[0] & RELOC_STD_BITS_JMPTABLE_BIG));
-  r_relative= (0 != (bytes->r_index[0] & RELOC_STD_BITS_RELATIVE_BIG));
-  r_length  =       (bytes->r_index[0] & RELOC_STD_BITS_LENGTH_BIG) 
+  r_jmptable = (0 != (bytes->r_index[0] & RELOC_STD_BITS_JMPTABLE_BIG));
+  r_relative = (0 != (bytes->r_index[0] & RELOC_STD_BITS_RELATIVE_BIG));
+  r_length = (bytes->r_index[0] & RELOC_STD_BITS_LENGTH_BIG)
     >> RELOC_STD_BITS_LENGTH_SH_BIG;
 
-  cache_ptr->howto =  aout_32_std_howto_table + r_length + 4 * r_pcrel;
+  cache_ptr->howto = aout_32_std_howto_table + r_length + 4 * r_pcrel;
   /* FIXME-soon:  Roll baserel, jmptable, relative bits into howto setting */
 
-  MOVE_ADDRESS(0);
+  MOVE_ADDRESS (0);
 }
 
 /* Reloc hackery */
 
 boolean
-DEFUN(NAME(lynx,slurp_reloc_table),(abfd, asect, symbols),
-      bfd *abfd AND
-      sec_ptr asect AND
-      asymbol **symbols)
+NAME (lynx, slurp_reloc_table) (abfd, asect, symbols)
+     bfd *abfd;
+     sec_ptr asect;
+     asymbol **symbols;
 {
   unsigned int count;
   bfd_size_type reloc_size;
@@ -387,71 +378,82 @@ DEFUN(NAME(lynx,slurp_reloc_table),(abfd, asect, symbols),
   arelent *reloc_cache;
   size_t each_size;
 
-  if (asect->relocation) return true;
+  if (asect->relocation)
+    return true;
 
-  if (asect->flags & SEC_CONSTRUCTOR) return true;
+  if (asect->flags & SEC_CONSTRUCTOR)
+    return true;
 
-  if (asect == obj_datasec (abfd)) {
-    reloc_size = exec_hdr(abfd)->a_drsize;
-    goto doit;
-  }
+  if (asect == obj_datasec (abfd))
+    {
+      reloc_size = exec_hdr (abfd)->a_drsize;
+      goto doit;
+    }
 
-  if (asect == obj_textsec (abfd)) {
-    reloc_size = exec_hdr(abfd)->a_trsize;
-    goto doit;
-  }
+  if (asect == obj_textsec (abfd))
+    {
+      reloc_size = exec_hdr (abfd)->a_trsize;
+      goto doit;
+    }
 
-  bfd_error = invalid_operation;
+  bfd_set_error (bfd_error_invalid_operation);
   return false;
 
- doit:
+doit:
   bfd_seek (abfd, asect->rel_filepos, SEEK_SET);
   each_size = obj_reloc_entry_size (abfd);
 
   count = reloc_size / each_size;
 
 
-  reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t)(count * sizeof
-                                                      (arelent)));
-  if (!reloc_cache) {
-nomem:
-    bfd_error = no_memory;
-    return false;
-  }
+  reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t) (count * sizeof
+                                                       (arelent)));
+  if (!reloc_cache)
+    {
+    nomem:
+      bfd_set_error (bfd_error_no_memory);
+      return false;
+    }
 
   relocs = (PTR) bfd_alloc (abfd, reloc_size);
-  if (!relocs) {
-    bfd_release (abfd, reloc_cache);
-    goto nomem;
-  }
-
-  if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size) {
-    bfd_release (abfd, relocs);
-    bfd_release (abfd, reloc_cache);
-    bfd_error = system_call_error;
-    return false;
-  }
-
-  if (each_size == RELOC_EXT_SIZE) {
-    register struct reloc_ext_external *rptr = (struct reloc_ext_external *) relocs;
-    unsigned int counter = 0;
-    arelent *cache_ptr = reloc_cache;
-
-    for (; counter < count; counter++, rptr++, cache_ptr++) {
-      NAME(lynx,swap_ext_reloc_in)(abfd, rptr, cache_ptr, symbols);
+  if (!relocs)
+    {
+      bfd_release (abfd, reloc_cache);
+      goto nomem;
     }
-  } else {
-    register struct reloc_std_external *rptr = (struct reloc_std_external*) relocs;
-    unsigned int counter = 0;
-    arelent *cache_ptr = reloc_cache;
 
-    for (; counter < count; counter++, rptr++, cache_ptr++) {
-       NAME(lynx,swap_std_reloc_in)(abfd, rptr, cache_ptr, symbols);
+  if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
+    {
+      bfd_release (abfd, relocs);
+      bfd_release (abfd, reloc_cache);
+      return false;
+    }
+
+  if (each_size == RELOC_EXT_SIZE)
+    {
+      register struct reloc_ext_external *rptr = (struct reloc_ext_external *) relocs;
+      unsigned int counter = 0;
+      arelent *cache_ptr = reloc_cache;
+
+      for (; counter < count; counter++, rptr++, cache_ptr++)
+       {
+         NAME (lynx, swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols);
+       }
     }
+  else
+    {
+      register struct reloc_std_external *rptr = (struct reloc_std_external *) relocs;
+      unsigned int counter = 0;
+      arelent *cache_ptr = reloc_cache;
+
+      for (; counter < count; counter++, rptr++, cache_ptr++)
+       {
+         NAME (lynx, swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols);
+       }
 
-  }
+    }
 
-  bfd_release (abfd,relocs);
+  bfd_release (abfd, relocs);
   asect->relocation = reloc_cache;
   asect->reloc_count = count;
   return true;
@@ -462,9 +464,9 @@ nomem:
 /* Write out a relocation section into an object file.  */
 
 boolean
-DEFUN(NAME(lynx,squirt_out_relocs),(abfd, section),
-      bfd *abfd AND
-      asection *section)
+NAME (lynx, squirt_out_relocs) (abfd, section)
+     bfd *abfd;
+     asection *section;
 {
   arelent **generic;
   unsigned char *native, *natptr;
@@ -473,37 +475,40 @@ DEFUN(NAME(lynx,squirt_out_relocs),(abfd, section),
   unsigned int count = section->reloc_count;
   size_t natsize;
 
-  if (count == 0) return true;
+  if (count == 0)
+    return true;
 
   each_size = obj_reloc_entry_size (abfd);
   natsize = each_size * count;
   native = (unsigned char *) bfd_zalloc (abfd, natsize);
-  if (!native) {
-    bfd_error = no_memory;
-    return false;
-  }
+  if (!native)
+    {
+      bfd_set_error (bfd_error_no_memory);
+      return false;
+    }
 
   generic = section->orelocation;
 
-  if (each_size == RELOC_EXT_SIZE) 
+  if (each_size == RELOC_EXT_SIZE)
     {
       for (natptr = native;
           count != 0;
           --count, natptr += each_size, ++generic)
-       NAME(lynx,swap_ext_reloc_out) (abfd, *generic, (struct reloc_ext_external *)natptr);
+       NAME (lynx, swap_ext_reloc_out) (abfd, *generic, (struct reloc_ext_external *) natptr);
     }
-  else 
+  else
     {
       for (natptr = native;
           count != 0;
           --count, natptr += each_size, ++generic)
-       NAME(lynx,swap_std_reloc_out)(abfd, *generic, (struct reloc_std_external *)natptr);
+       NAME (lynx, swap_std_reloc_out) (abfd, *generic, (struct reloc_std_external *) natptr);
     }
 
-  if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize) {
-    bfd_release(abfd, native);
-    return false;
-  }
+  if (bfd_write ((PTR) native, 1, natsize, abfd) != natsize)
+    {
+      bfd_release (abfd, native);
+      return false;
+    }
   bfd_release (abfd, native);
 
   return true;
@@ -511,34 +516,38 @@ DEFUN(NAME(lynx,squirt_out_relocs),(abfd, section),
 
 /* This is stupid.  This function should be a boolean predicate */
 unsigned int
-DEFUN(NAME(lynx,canonicalize_reloc),(abfd, section, relptr, symbols),
-      bfd *abfd AND
-      sec_ptr section AND
-      arelent **relptr AND
-      asymbol **symbols)
+NAME (lynx, canonicalize_reloc) (abfd, section, relptr, symbols)
+     bfd *abfd;
+     sec_ptr section;
+     arelent **relptr;
+     asymbol **symbols;
 {
   arelent *tblptr = section->relocation;
   unsigned int count;
 
-  if (!(tblptr || NAME(lynx,slurp_reloc_table)(abfd, section, symbols)))
+  if (!(tblptr || NAME (lynx, slurp_reloc_table) (abfd, section, symbols)))
     return 0;
 
-  if (section->flags & SEC_CONSTRUCTOR) {
-    arelent_chain *chain = section->constructor_chain;
-    for (count = 0; count < section->reloc_count; count ++) {
-      *relptr ++ = &chain->relent;
-      chain = chain->next;
+  if (section->flags & SEC_CONSTRUCTOR)
+    {
+      arelent_chain *chain = section->constructor_chain;
+      for (count = 0; count < section->reloc_count; count++)
+       {
+         *relptr++ = &chain->relent;
+         chain = chain->next;
+       }
+    }
+  else
+    {
+      tblptr = section->relocation;
+      if (!tblptr)
+       return 0;
+
+      for (count = 0; count++ < section->reloc_count;)
+       {
+         *relptr++ = tblptr++;
+       }
     }
-  }
-  else {
-    tblptr = section->relocation;
-    if (!tblptr) return 0;
-
-    for (count = 0; count++ < section->reloc_count;) 
-      {
-       *relptr++ = tblptr++;
-      }
-  }
   *relptr = 0;
 
   return section->reloc_count;
index 17d3a1a9ee9ba3b27768f9190455ee34603f878e..95cf34b05bda1322fe9d73e4f02eaaa03cfbabfe 100644 (file)
@@ -92,10 +92,7 @@ nlm_alpha_write_prefix (abfd)
   bfd_h_put_32 (abfd, (bfd_vma) 2, s.format);
   bfd_h_put_32 (abfd, (bfd_vma) sizeof s, s.size);
   if (bfd_write ((PTR) &s, sizeof s, 1, abfd) != sizeof s)
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
   return true;
 }
 \f
@@ -425,10 +422,7 @@ nlm_alpha_read_reloc (abfd, sym, secp, rel)
 
   /* Read the reloc from the file.  */
   if (bfd_read (&ext, sizeof ext, 1, abfd) != sizeof ext)
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   /* Swap in the reloc information.  */
   r_vaddr = bfd_h_get_64 (abfd, (bfd_byte *) ext.r_vaddr);
@@ -632,37 +626,28 @@ nlm_alpha_read_import (abfd, sym)
 
   if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
       != sizeof (symlength))
-    {
-      bfd_error = system_call_error;
-      return (false);
-    }
+    return false;
   sym -> symbol.the_bfd = abfd;
   sym -> symbol.name = bfd_alloc (abfd, symlength + 1);
   if (!sym -> symbol.name)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd)
       != symlength)
-    {
-      bfd_error = system_call_error;
-      return (false);
-    }
+    return false;
   sym -> symbol.flags = 0;
   sym -> symbol.value = 0;
   sym -> symbol.section = &bfd_und_section;
   if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
-    {
-      bfd_error = system_call_error;
-      return (false);
-    }
+    return faflse;
   rcount = bfd_h_get_32 (abfd, temp);
   nlm_relocs = ((struct nlm_relent *)
                bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
   if (!nlm_relocs)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   sym -> relocs = nlm_relocs;
@@ -785,10 +770,7 @@ nlm_alpha_write_import (abfd, sec, rel)
 
   /* Write out the relocation.  */
   if (bfd_write (&ext, sizeof ext, 1, abfd) != sizeof ext)
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   return true;
 }
@@ -852,17 +834,11 @@ nlm_alpha_write_external (abfd, count, sym, relocs)
   len = strlen (sym->name);
   if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
       || bfd_write (sym->name, len, 1, abfd) != len)
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   bfd_put_32 (abfd, count + 2, temp);
   if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   /* The first two relocs for each external symbol are the .lita
      address and the GP value.  */
index f3fd7cef8d8d4d6b4c7a4299c2bef5e142033d9d..0fc991cff459d5d2798302afcf6d12e8eddd17fc 100644 (file)
@@ -87,10 +87,7 @@ nlm_i386_read_reloc (abfd, sym, secp, rel)
   const char *name;
 
   if (bfd_read (temp, sizeof (temp), 1, abfd) != sizeof (temp))
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   val = bfd_get_32 (abfd, temp);
 
@@ -176,7 +173,7 @@ nlm_i386_write_import (abfd, sec, rel)
       || rel->howto->src_mask != 0xffffffff
       || rel->howto->dst_mask != 0xffffffff)
     {
-      bfd_error = invalid_operation;
+      bfd_set_error (bfd_error_invalid_operation);
       return false;
     }
 
@@ -204,7 +201,7 @@ nlm_i386_write_import (abfd, sec, rel)
       /* NetWare only supports absolute internal relocs.  */
       if (rel->howto->pc_relative)
        {
-         bfd_error = invalid_operation;
+         bfd_set_error (bfd_error_invalid_operation);
          return false;
        }
 
@@ -224,7 +221,7 @@ nlm_i386_write_import (abfd, sec, rel)
          /* PC relative relocs on NetWare must be pcrel_offset.  */
          if (! rel->howto->pcrel_offset)
            {
-             bfd_error = invalid_operation;
+             bfd_set_error (bfd_error_invalid_operation);
              return false;
            }
        }
@@ -232,10 +229,7 @@ nlm_i386_write_import (abfd, sec, rel)
   
   bfd_put_32 (abfd, val, temp);
   if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   return true;
 }
@@ -357,37 +351,28 @@ nlm_i386_read_import (abfd, sym)
 
   if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
       != sizeof (symlength))
-    {
-      bfd_error = system_call_error;
-      return (false);
-    }
+    return false;
   sym -> symbol.the_bfd = abfd;
   sym -> symbol.name = bfd_alloc (abfd, symlength + 1);
   if (!sym -> symbol.name)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd)
       != symlength)
-    {
-      bfd_error = system_call_error;
-      return (false);
-    }
+    return false;
   sym -> symbol.flags = 0;
   sym -> symbol.value = 0;
   sym -> symbol.section = &bfd_und_section;
   if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
-    {
-      bfd_error = system_call_error;
-      return (false);
-    }
+    return false;
   rcount = bfd_h_get_32 (abfd, temp);
   nlm_relocs = ((struct nlm_relent *)
                bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
   if (!nlm_relocs)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   sym -> relocs = nlm_relocs;
@@ -423,17 +408,11 @@ nlm_i386_write_external (abfd, count, sym, relocs)
   len = strlen (sym->name);
   if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
       || bfd_write (sym->name, len, 1, abfd) != len)
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   bfd_put_32 (abfd, count, temp);
   if (bfd_write (temp, sizeof(temp), 1, abfd) != sizeof (temp))
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   for (i = 0; i < count; i++)
     {
index 220ebd60ae79237c70131c3b330d51e7e8cc45a6..b7e5543b4d2f2f68bf4c559d9aa07f865d7acb61 100644 (file)
@@ -130,10 +130,8 @@ nlm_sparc_read_reloc (abfd, sym, secp, rel)
   struct nlm32_sparc_reloc_ext tmp_reloc;
   asection *code_sec, *data_sec;
 
-  if (bfd_read (&tmp_reloc, 12, 1, abfd) != 12) {
-    bfd_error = system_call_error;
+  if (bfd_read (&tmp_reloc, 12, 1, abfd) != 12)
     return false;
-  }
 
   code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
   data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
@@ -262,12 +260,8 @@ nlm_sparc_read_import (abfd, sym)
    * First, read in the number of relocation
    * entries for this symbol
    */
-  if (bfd_read ((PTR) temp, 4, 1, abfd)
-      != 4)
-    {
-      bfd_error = system_call_error;
-      return (false);
-    }
+  if (bfd_read ((PTR) temp, 4, 1, abfd) != 4)
+    return false;
   
   rcount = bfd_get_32 (abfd, temp);
   
@@ -277,15 +271,12 @@ nlm_sparc_read_import (abfd, sym)
   
   if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
       != sizeof (symlength))
-    {
-      bfd_error = system_call_error;
-      return (false);
-    }
+    return false;
   sym -> symbol.the_bfd = abfd;
   sym -> symbol.name = bfd_alloc (abfd, symlength + 1);
   if (!sym -> symbol.name)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   
@@ -295,10 +286,7 @@ nlm_sparc_read_import (abfd, sym)
   
   if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd)
       != symlength)
-    {
-      bfd_error = system_call_error;
-      return (false);
-    }
+    return false;
   sym -> symbol.flags = 0;
   sym -> symbol.value = 0;
   sym -> symbol.section = &bfd_und_section;
@@ -311,7 +299,7 @@ nlm_sparc_read_import (abfd, sym)
                bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
   if (!nlm_relocs)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   sym -> relocs = nlm_relocs;
@@ -383,18 +371,12 @@ nlm_sparc_write_external (abfd, count, sym, relocs)
 
   bfd_put_32 (abfd, count, temp);
   if (bfd_write (temp, sizeof(temp), 1, abfd) != sizeof (temp))
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   len = strlen (sym->name);
   if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
       || bfd_write (sym->name, len, 1, abfd) != len)
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   for (i = 0; i < count; i++)
     {
@@ -425,10 +407,7 @@ nlm_sparc_write_export (abfd, sym, value)
   if (bfd_write (temp, 4, 1, abfd) != 4
       || bfd_write (&len, 1, 1, abfd) != 1
       || bfd_write (sym->name, len, 1, abfd) != len)
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   return true;
 }
index 43f29f567d763ac052a1899f9fd857f4a4f8d4f2..62812f5e3fc42a83a176d6f7053fb193944778be 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -1845,7 +1845,8 @@ som_object_p (abfd)
 
   if (bfd_read ((PTR) & file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE)
     {
-      bfd_set_error (bfd_error_system_call);
+      if (bfd_get_error () != bfd_error_system_call)
+       bfd_set_error (bfd_error_wrong_format);
       return 0;
     }
 
@@ -1894,7 +1895,8 @@ som_object_p (abfd)
     {
       if (bfd_read ((PTR) & aux_hdr, 1, AUX_HDR_SIZE, abfd) != AUX_HDR_SIZE)
        {
-         bfd_set_error (bfd_error_wrong_format);
+         if (bfd_get_error () != bfd_error_system_call)
+           bfd_set_error (bfd_error_wrong_format);
          return 0;
        }
     }
@@ -2339,11 +2341,8 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
             each subspace.  Seek to the start of the relocation stream
             for this subspace in preparation for writing out its fixup
             stream.  */
-         if (bfd_seek (abfd, current_offset + total_reloc_size, SEEK_SET) != 0)
-           {
-             bfd_set_error (bfd_error_system_call);
-             return false;
-           }
+         if (bfd_seek (abfd, current_offset + total_reloc_size, SEEK_SET) < 0)
+           return false;
 
          /* Buffer space has already been allocated.  Just perform some
             initialization here.  */
@@ -2379,10 +2378,8 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
                {
                  if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
                      != p - tmp_space)
-                   {
-                     bfd_set_error (bfd_error_system_call);
-                     return false;
-                   }
+                   return false;
+
                  p = tmp_space;
                  som_initialize_reloc_queue (reloc_queue);
                }
@@ -2549,10 +2546,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
          /* Scribble out the relocations.  */
          if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
              != p - tmp_space)
-           {
-             bfd_set_error (bfd_error_system_call);
-             return false;
-           }
+           return false;
          p = tmp_space;
 
          total_reloc_size += subspace_reloc_size;
@@ -2585,11 +2579,8 @@ som_write_space_strings (abfd, current_offset, string_sizep)
 
   /* Seek to the start of the space strings in preparation for writing
      them out.  */
-  if (bfd_seek (abfd, current_offset, SEEK_SET) != 0)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+  if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+    return false;
 
   /* Walk through all the spaces and subspaces (order is not important)
      building up and writing string table entries for their names.  */
@@ -2612,10 +2603,7 @@ som_write_space_strings (abfd, current_offset, string_sizep)
        {
          if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd)
              != p - tmp_space) 
-           {
-             bfd_set_error (bfd_error_system_call);
-             return false;
-           }
+           return false;
          /* Reset to beginning of the buffer space.  */
          p = tmp_space;
        }
@@ -2649,10 +2637,7 @@ som_write_space_strings (abfd, current_offset, string_sizep)
   /* Done with the space/subspace strings.  Write out any information
      contained in a partial block.  */
   if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd) != p - tmp_space)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
   *string_sizep = strings_size;
   return true;
 }
@@ -2680,11 +2665,8 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep)
 
   /* Seek to the start of the space strings in preparation for writing
      them out.  */
-  if (bfd_seek (abfd, current_offset, SEEK_SET) != 0)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+  if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+    return false;
 
   for (i = 0; i < num_syms; i++)
     {
@@ -2696,10 +2678,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep)
        {
          if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd)
              != p - tmp_space)
-           {
-             bfd_set_error (bfd_error_system_call);
-             return false;
-           }
+           return false;
          /* Reset to beginning of the buffer space.  */
          p = tmp_space;
        }
@@ -2731,10 +2710,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep)
 
   /* Scribble out any partial block.  */
   if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd) != p - tmp_space)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
 
   *string_sizep = strings_size;
   return true;
@@ -2790,17 +2766,15 @@ som_begin_writing (abfd)
     {
       unsigned int len;
 
-      bfd_seek (abfd, current_offset, SEEK_SET);
+      if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+       return false;
 
       /* Write the aux_id structure and the string length.  */
       len = sizeof (struct aux_id) + sizeof (unsigned int);
       obj_som_file_hdr (abfd)->aux_header_size += len;
       current_offset += len;
       if (bfd_write ((PTR) obj_som_version_hdr (abfd), len, 1, abfd) != len)
-       {
-         bfd_set_error (bfd_error_system_call);
-         return false;
-       }
+       return false;
 
       /* Write the version string.  */
       len = obj_som_version_hdr (abfd)->header_id.length - sizeof (int);
@@ -2808,27 +2782,22 @@ som_begin_writing (abfd)
       current_offset += len;
       if (bfd_write ((PTR) obj_som_version_hdr (abfd)->user_string,
                     len, 1, abfd) != len)
-       {
-         bfd_set_error (bfd_error_system_call);
-         return false;
-       }
+       return false;
     }
 
   if (obj_som_copyright_hdr (abfd) != NULL)
     {
       unsigned int len;
 
-      bfd_seek (abfd, current_offset, SEEK_SET);
+      if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+       return false;
 
       /* Write the aux_id structure and the string length.  */
       len = sizeof (struct aux_id) + sizeof (unsigned int);
       obj_som_file_hdr (abfd)->aux_header_size += len;
       current_offset += len;
       if (bfd_write ((PTR) obj_som_copyright_hdr (abfd), len, 1, abfd) != len)
-       {
-         bfd_set_error (bfd_error_system_call);
-         return false;
-       }
+       return false;
 
       /* Write the copyright string.  */
       len = obj_som_copyright_hdr (abfd)->header_id.length - sizeof (int);
@@ -2836,10 +2805,7 @@ som_begin_writing (abfd)
       current_offset += len;
       if (bfd_write ((PTR) obj_som_copyright_hdr (abfd)->copyright,
                     len, 1, abfd) != len)
-       {
-         bfd_set_error (bfd_error_system_call);
-         return false;
-       }
+       return false;
     }
 
   /* Next comes the initialization pointers; we have no initialization
@@ -3119,15 +3085,9 @@ som_begin_writing (abfd)
   if (abfd->flags & EXEC_P)
     current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE);
   if (bfd_seek (abfd, current_offset - 1, SEEK_SET) < 0)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
   if (bfd_write ((PTR) "", 1, 1, abfd) != 1)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
 
   obj_som_file_hdr (abfd)->unloadable_sp_size
     = current_offset - obj_som_file_hdr (abfd)->unloadable_sp_location;
@@ -3157,14 +3117,13 @@ som_begin_writing (abfd)
        exec_header.exec_bsize = 0;
       exec_header.exec_dsize = tmp;
 
-      bfd_seek (abfd, obj_som_file_hdr (abfd)->aux_header_location, SEEK_SET);
+      if (bfd_seek (abfd, obj_som_file_hdr (abfd)->aux_header_location,
+                   SEEK_SET) < 0)
+       return false;
 
       if (bfd_write ((PTR) &exec_header, AUX_HDR_SIZE, 1, abfd)
          != AUX_HDR_SIZE)
-       {
-         bfd_set_error (bfd_error_system_call);
-         return false;
-       }
+       return false;
     }
   return true;
 }
@@ -3186,7 +3145,9 @@ som_write_headers (abfd)
 
   /* Seek to the start of the subspace dictionary records.  */
   location = obj_som_file_hdr (abfd)->subspace_location;
-  bfd_seek (abfd, location, SEEK_SET);
+  if (bfd_seek (abfd, location, SEEK_SET) < 0)
+    return false;
+
   section = abfd->sections;
   /* Now for each loadable space write out records for its subspaces.  */
   for (i = 0; i < num_spaces; i++)
@@ -3235,10 +3196,7 @@ som_write_headers (abfd)
          if (bfd_write ((PTR) som_section_data (subsection)->subspace_dict,
                         sizeof (struct subspace_dictionary_record), 1, abfd)
              != sizeof (struct subspace_dictionary_record))
-           {
-             bfd_set_error (bfd_error_system_call);
-             return false;
-           }
+           return false;
        }
       /* Goto the next section.  */
       section = section->next; 
@@ -3294,10 +3252,7 @@ som_write_headers (abfd)
          if (bfd_write ((PTR) som_section_data (subsection)->subspace_dict,
                         sizeof (struct subspace_dictionary_record), 1, abfd)
              != sizeof (struct subspace_dictionary_record))
-           {
-             bfd_set_error (bfd_error_system_call);
-             return false;
-           }
+           return false;
        }
       /* Goto the next section.  */
       section = section->next; 
@@ -3309,7 +3264,8 @@ som_write_headers (abfd)
      Seek to the right location and start writing the space
      dictionary records.  */
   location = obj_som_file_hdr (abfd)->space_location;
-  bfd_seek (abfd, location, SEEK_SET);
+  if (bfd_seek (abfd, location, SEEK_SET) < 0)
+    return false;
 
   section = abfd->sections;
   for (i = 0; i < num_spaces; i++)
@@ -3323,10 +3279,7 @@ som_write_headers (abfd)
       if (bfd_write ((PTR) som_section_data (section)->space_dict,
                     sizeof (struct space_dictionary_record), 1, abfd)
          != sizeof (struct space_dictionary_record))
-       {
-         bfd_set_error (bfd_error_system_call);
-         return false;
-       }
+       return false;
 
       /* Goto the next section.  */
       section = section->next;
@@ -3334,14 +3287,12 @@ som_write_headers (abfd)
 
   /* Only thing left to do is write out the file header.  It is always
      at location zero.  Seek there and write it.  */
-  bfd_seek (abfd, (file_ptr) 0, SEEK_SET);
+  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
+    return false;
   if (bfd_write ((PTR) obj_som_file_hdr (abfd),
                 sizeof (struct header), 1, abfd)
       != sizeof (struct header))
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
   return true;
 }
 
@@ -3513,16 +3464,10 @@ som_build_and_write_symbol_table (abfd)
   /* Everything is ready, seek to the right location and
      scribble out the symbol table.  */
   if (bfd_seek (abfd, symtab_location, SEEK_SET) != 0)
-    {
-      bfd_set_error (bfd_error_system_call);
-      goto error_return;
-    }
+    return false;
 
   if (bfd_write ((PTR) som_symtab, symtab_size, 1, abfd) != symtab_size)
-    {
-      bfd_set_error (bfd_error_system_call);
-      goto error_return;
-    }
+    goto error_return;
 
   if (som_symtab != NULL)
     free (som_symtab);
@@ -3583,17 +3528,11 @@ som_slurp_string_table (abfd)
     }
 
   if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) < 0)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
   
   if (bfd_read (stringtab, obj_som_stringtab_size (abfd), 1, abfd)
       != obj_som_stringtab_size (abfd))
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
 
   /* Save our results and return success. */
   obj_som_stringtab (abfd) = stringtab;
@@ -3699,16 +3638,10 @@ som_slurp_symbol_table (abfd)
       goto error_return;
     }
   if (bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET) < 0)
-    {
-      bfd_set_error (bfd_error_system_call);
-      goto error_return;
-    }
+    goto error_return;
   if (bfd_read (buf, symbol_count * symsize, 1, abfd) 
       != symbol_count * symsize)
-    {
-      bfd_set_error (bfd_error_no_symbols);
-      goto error_return;
-    }
+    goto error_return;
 
   /* Iterate over all the symbols and internalize them.  */
   endbufp = buf + symbol_count;
@@ -4189,16 +4122,11 @@ som_slurp_reloc_table (abfd, section, symbols, just_count)
                    obj_som_reloc_filepos (abfd) + section->rel_filepos,
                    SEEK_SET)
          != 0)
-       {
-         bfd_set_error (bfd_error_system_call);
-         return false;
-       }
+       return false;
       if (bfd_read (external_relocs, 1, fixup_stream_size, abfd)
          != fixup_stream_size)
-       {
-         bfd_set_error (bfd_error_system_call);
-         return false;
-       }
+       return false;
+
       /* Let callers know how many relocations found.
         also save the relocation stream as we will
         need it again.  */
@@ -4501,7 +4429,7 @@ bfd_som_attach_aux_hdr (abfd, type, string)
                            + sizeof (unsigned int) + len + pad);
       if (!obj_som_copyright_hdr (abfd))
        {
-         bfd_set_error (bfd_error_no_error);
+         bfd_set_error (bfd_error_no_memory);
          return false;
        }
       obj_som_copyright_hdr (abfd)->header_id.type = COPYRIGHT_AUX_ID;
@@ -4542,16 +4470,10 @@ som_set_section_contents (abfd, section, location, offset, count)
      data.  */
   offset += som_section_data (section)->subspace_dict->file_loc_init_value; 
   if (bfd_seek (abfd, offset, SEEK_SET) == -1)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
 
   if (bfd_write ((PTR) location, 1, count, abfd) != count)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
   return true;
 }
 
@@ -4678,10 +4600,7 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
      which point to the hash chains.  */
   if (bfd_read ((PTR) hash_table, lst_header->hash_size, 4, abfd)
       != lst_header->hash_size * 4)
-    {
-      bfd_set_error (bfd_error_system_call);
-      goto error_return;
-    }
+    goto error_return;
 
   /* Walk each chain counting the number of symbols found on that particular
      chain.  */
@@ -4695,18 +4614,13 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
 
       /* Seek to the first symbol in this hash chain.  */
       if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) < 0)
-       {
-         bfd_set_error (bfd_error_system_call);
-         goto error_return;
-       }
+       goto error_return;
 
       /* Read in this symbol and update the counter.  */
       if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
          != sizeof (lst_symbol))
-       {
-         bfd_set_error (bfd_error_system_call);
-         goto error_return;
-       }
+       goto error_return;
+
       (*count)++;
 
       /* Now iterate through the rest of the symbols on this chain.  */
@@ -4716,18 +4630,13 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
          /* Seek to the next symbol.  */
          if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET)
              < 0)
-           {
-             bfd_set_error (bfd_error_system_call);
-             goto error_return;
-           }
+           goto error_return;
 
          /* Read the symbol in and update the counter.  */
          if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
              != sizeof (lst_symbol))
-           {
-             bfd_set_error (bfd_error_system_call);
-             goto error_return;
-           }
+           goto error_return;
+
          (*count)++;
        }
     }
@@ -4777,26 +4686,17 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
      which point to the hash chains.  */
   if (bfd_read ((PTR) hash_table, lst_header->hash_size, 4, abfd)
       != lst_header->hash_size * 4)
-    {
-      bfd_set_error (bfd_error_system_call);
-      goto error_return;
-    }
+    goto error_return;
 
   /* Seek to and read in the SOM dictionary.  We will need this to fill
      in the carsym's filepos field.  */
   if (bfd_seek (abfd, lst_filepos + lst_header->dir_loc, SEEK_SET) < 0)
-    {
-      bfd_set_error (bfd_error_system_call);
-      goto error_return;
-    }
+    goto error_return;
 
   if (bfd_read ((PTR) som_dict, lst_header->module_count, 
                sizeof (struct som_entry), abfd)
       != lst_header->module_count * sizeof (struct som_entry))
-    {
-      bfd_set_error (bfd_error_system_call);
-      goto error_return;
-    }
+    goto error_return;
 
   /* Walk each chain filling in the carsyms as we go along.  */
   for (i = 0; i < lst_header->hash_size; i++)
@@ -4809,17 +4709,11 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
 
       /* Seek to and read the first symbol on the chain.  */
       if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) < 0)
-       {
-         bfd_set_error (bfd_error_system_call);
-         goto error_return;
-       }
+       goto error_return;
 
       if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
          != sizeof (lst_symbol))
-       {
-         bfd_set_error (bfd_error_system_call);
-         goto error_return;
-       }
+       goto error_return;
 
       /* Get the name of the symbol, first get the length which is stored
         as a 32bit integer just before the symbol.
@@ -4830,16 +4724,10 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
         using the string table would not be safe.  */
       if (bfd_seek (abfd, lst_filepos + lst_header->string_loc
                            + lst_symbol.name.n_strx - 4, SEEK_SET) < 0)
-       {
-         bfd_set_error (bfd_error_system_call);
-         goto error_return;
-       }
+       goto error_return;
 
       if (bfd_read (&len, 1, 4, abfd) != 4)
-       {
-         bfd_set_error (bfd_error_system_call);
-         goto error_return;
-       }
+       goto error_return;
 
       /* Allocate space for the name and null terminate it too.  */
       set->name = bfd_zalloc (abfd, len + 1);
@@ -4849,10 +4737,8 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
          goto error_return;
        }
       if (bfd_read (set->name, 1, len, abfd) != len)
-       {
-         bfd_set_error (bfd_error_system_call);
-         goto error_return;
-       }
+       goto error_return;
+
       set->name[len] = 0;
 
       /* Fill in the file offset.  Note that the "location" field points
@@ -4867,33 +4753,20 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
       while (lst_symbol.next_entry)
        {
          /* Seek to the next symbol and read it in.  */
-         if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET)
-             < 0)
-           {
-             bfd_set_error (bfd_error_system_call);
-             goto error_return;
-           }
+         if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET) <0)
+           goto error_return;
 
          if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
              != sizeof (lst_symbol))
-           {
-             bfd_set_error (bfd_error_system_call);
-             goto error_return;
-           }
+           goto error_return;
 
          /* Seek to the name length & string and read them in.  */
          if (bfd_seek (abfd, lst_filepos + lst_header->string_loc 
                                + lst_symbol.name.n_strx - 4, SEEK_SET) < 0)
-           {
-             bfd_set_error (bfd_error_system_call);
-             goto error_return;
-           }
+           goto error_return;
 
          if (bfd_read (&len, 1, 4, abfd) != 4)
-           {
-             bfd_set_error (bfd_error_system_call);
-             goto error_return;
-           }
+           goto error_return;
 
          /* Allocate space for the name and null terminate it too.  */
          set->name = bfd_zalloc (abfd, len + 1);
@@ -4902,11 +4775,9 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
              bfd_set_error (bfd_error_no_memory);
              goto error_return;
            }
+
          if (bfd_read (set->name, 1, len, abfd) != len)
-           {
-             bfd_set_error (bfd_error_system_call);
-             goto error_return;
-           }
+           goto error_return;
          set->name[len] = 0;
 
          /* Fill in the file offset.  Note that the "location" field points
@@ -4953,10 +4824,7 @@ som_slurp_armap (abfd)
     return false;
 
   if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) < 0)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
 
   /* For archives without .o files there is no symbol table.  */
   if (strncmp (nextname, "/               ", 16))
@@ -4968,10 +4836,7 @@ som_slurp_armap (abfd)
   /* Read in and sanity check the archive header.  */
   if (bfd_read ((PTR) &ar_header, 1, sizeof (struct ar_hdr), abfd)
       != sizeof (struct ar_hdr))
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
 
   if (strncmp (ar_header.ar_fmag, ARFMAG, 2))
     {
@@ -4995,10 +4860,7 @@ som_slurp_armap (abfd)
      in just a minute.  */
   if (bfd_read ((PTR) & lst_header, 1, sizeof (struct lst_header), abfd)
       != sizeof (struct lst_header))
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
 
   /* Sanity check.  */
   if (lst_header.a_magic != LIBMAGIC)
@@ -5015,10 +4877,7 @@ som_slurp_armap (abfd)
   /* Get back to the start of the library symbol table.  */
   if (bfd_seek (abfd, ardata->first_file_filepos - parsed_size 
                        + sizeof (struct lst_header), SEEK_SET) < 0)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
 
   /* Initializae the cache and allocate space for the library symbols.  */
   ardata->cache = 0;
@@ -5039,10 +4898,7 @@ som_slurp_armap (abfd)
   /* Seek back to the "first" file in the archive.  Note the "first"
      file may be the extended name table.  */
   if (bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET) < 0)
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
 
   /* Notify the generic archive code that we have a symbol map.  */
   bfd_has_map (abfd) = true;
@@ -5393,34 +5249,22 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
   /* Now scribble out the hash table.  */
   if (bfd_write ((PTR) hash_table, lst.hash_size, 4, abfd)
       != lst.hash_size * 4)
-    {
-      bfd_set_error (bfd_error_system_call);
-      goto error_return;
-    }
+    goto error_return;
 
   /* Then the SOM dictionary.  */
   if (bfd_write ((PTR) som_dict, lst.module_count,
                 sizeof (struct som_entry), abfd)
       != lst.module_count * sizeof (struct som_entry))
-    {
-      bfd_set_error (bfd_error_system_call);
-      goto error_return;
-    }
+    goto error_return;
 
   /* The library symbols.  */
   if (bfd_write ((PTR) lst_syms, nsyms, sizeof (struct lst_symbol_record), abfd)
       != nsyms * sizeof (struct lst_symbol_record))
-    {
-      bfd_set_error (bfd_error_system_call);
-      goto error_return;
-    }
+    goto error_return;
 
   /* And finally the strings.  */
   if (bfd_write ((PTR) strings, string_size, 1, abfd) != string_size)
-    {
-      bfd_set_error (bfd_error_system_call);
-      goto error_return;
-    }
+    goto error_return;
 
   if (hash_table != NULL)
     free (hash_table);
@@ -5555,18 +5399,12 @@ som_write_armap (abfd)
   /* Scribble out the ar header.  */
   if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), abfd)
       != sizeof (struct ar_hdr))
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
 
   /* Now scribble out the lst header.  */
   if (bfd_write ((PTR) &lst, 1, sizeof (struct lst_header), abfd)
       != sizeof (struct lst_header))
-    {
-      bfd_set_error (bfd_error_system_call);
-      return false;
-    }
+    return false;
 
   /* Build and write the armap.  */
   if (som_bfd_ar_write_symbol_stuff (abfd, nsyms, stringsize, lst) == false)
This page took 0.09079 seconds and 4 git commands to generate.