Update to ISO-C90 and fix formatting
[external/binutils.git] / bfd / coffcode.h
index 1b6ef0b..cd4a371 100644 (file)
@@ -1,31 +1,28 @@
 /* Support for the generic parts of most COFF variants, for BFD.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002
+   2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
-This file is part of BFD, the Binary File Descriptor library.
+   This file is part of BFD, the Binary File Descriptor library.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
+/* Most of this hacked by  Steve Chamberlain,
+                       sac@cygnus.com.  */
 /*
-Most of this hacked by  Steve Chamberlain,
-                       sac@cygnus.com
-*/
-/*
-
 SECTION
        coff backends
 
@@ -225,7 +222,7 @@ SUBSUBSECTION
        This routine runs though the provided symbol table and uses
        the offsets generated by the previous pass and the pointers
        generated when the symbol table was read in to create the
-       structured hierachy required by coff. It changes each pointer
+       structured hierarchy required by coff. It changes each pointer
        to a symbol into the index into the symbol table of the asymbol.
 
        o <<coff_write_symbols>>
@@ -307,60 +304,69 @@ CODE_FRAGMENT
 #include "coffswap.h"
 #endif
 
-#define STRING_SIZE_SIZE (4)
+#define STRING_SIZE_SIZE 4
+
+#define DOT_DEBUG      ".debug"
+#define GNU_LINKONCE_WI ".gnu.linkonce.wi."
 
 static long sec_to_styp_flags
-  PARAMS ((const char *, flagword));
+  (const char *, flagword);
 static bfd_boolean styp_to_sec_flags
-  PARAMS ((bfd *, PTR, const char *, asection *, flagword *));
+  (bfd *, void *, const char *, asection *, flagword *);
 static bfd_boolean coff_bad_format_hook
-  PARAMS ((bfd *, PTR));
+  (bfd *, void *);
 static void coff_set_custom_section_alignment
-  PARAMS ((bfd *, asection *, const struct coff_section_alignment_entry *,
-          const unsigned int));
+  (bfd *, asection *, const struct coff_section_alignment_entry *,
+   const unsigned int);
 static bfd_boolean coff_new_section_hook
-  PARAMS ((bfd *, asection *));
+  (bfd *, asection *);
 static bfd_boolean coff_set_arch_mach_hook
-  PARAMS ((bfd *, PTR));
+  (bfd *, void *);
 static bfd_boolean coff_write_relocs
-  PARAMS ((bfd *, int));
+  (bfd *, int);
 static bfd_boolean coff_set_flags
-  PARAMS ((bfd *, unsigned int *, unsigned short *));
+  (bfd *, unsigned int *, unsigned short *);
 static bfd_boolean coff_set_arch_mach
-  PARAMS ((bfd *, enum bfd_architecture, unsigned long)) ATTRIBUTE_UNUSED;
+  (bfd *, enum bfd_architecture, unsigned long) ATTRIBUTE_UNUSED;
 static bfd_boolean coff_compute_section_file_positions
-  PARAMS ((bfd *));
+  (bfd *);
 static bfd_boolean coff_write_object_contents
-  PARAMS ((bfd *)) ATTRIBUTE_UNUSED;
+  (bfd *) ATTRIBUTE_UNUSED;
 static bfd_boolean coff_set_section_contents
-  PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-static PTR buy_and_read
-  PARAMS ((bfd *, file_ptr, bfd_size_type));
+  (bfd *, asection *, const void *, file_ptr, bfd_size_type);
+static void * buy_and_read
+  (bfd *, file_ptr, bfd_size_type);
 static bfd_boolean coff_slurp_line_table
-  PARAMS ((bfd *, asection *));
+  (bfd *, asection *);
 static bfd_boolean coff_slurp_symbol_table
-  PARAMS ((bfd *));
+  (bfd *);
 static enum coff_symbol_classification coff_classify_symbol
-  PARAMS ((bfd *, struct internal_syment *));
+  (bfd *, struct internal_syment *);
 static bfd_boolean coff_slurp_reloc_table
-  PARAMS ((bfd *, asection *, asymbol **));
+  (bfd *, asection *, asymbol **);
 static long coff_canonicalize_reloc
-  PARAMS ((bfd *, asection *, arelent **, asymbol **));
+  (bfd *, asection *, arelent **, asymbol **);
 #ifndef coff_mkobject_hook
-static PTR coff_mkobject_hook
-  PARAMS ((bfd *, PTR,  PTR));
+static void * coff_mkobject_hook
+  (bfd *, void *,  void *);
 #endif
 #ifdef COFF_WITH_PE
 static flagword handle_COMDAT
-  PARAMS ((bfd *, flagword, PTR, const char *, asection *));
+  (bfd *, flagword, void *, const char *, asection *);
 #endif
 #ifdef COFF_IMAGE_WITH_PE
 static bfd_boolean coff_read_word
-  PARAMS ((bfd *, unsigned int *));
+  (bfd *, unsigned int *);
 static unsigned int coff_compute_checksum
-  PARAMS ((bfd *));
+  (bfd *);
 static bfd_boolean coff_apply_checksum
-  PARAMS ((bfd *));
+  (bfd *);
+#endif
+#ifdef TICOFF
+static bfd_boolean ticoff0_bad_format_hook
+  (bfd *, void * );
+static bfd_boolean ticoff1_bad_format_hook
+  (bfd *, void * );
 #endif
 \f
 /* void warning(); */
@@ -373,6 +379,7 @@ static bfd_boolean coff_apply_checksum
 #ifndef COFF_WITH_PE
 
 /* Macros for setting debugging flags.  */
+
 #ifdef STYP_DEBUG
 #define STYP_XCOFF_DEBUG STYP_DEBUG
 #else
@@ -386,9 +393,7 @@ static bfd_boolean coff_apply_checksum
 #endif
 
 static long
-sec_to_styp_flags (sec_name, sec_flags)
-     const char *sec_name;
-     flagword sec_flags;
+sec_to_styp_flags (const char *sec_name, flagword sec_flags)
 {
   long styp_flags = 0;
 
@@ -422,7 +427,7 @@ sec_to_styp_flags (sec_name, sec_flags)
       styp_flags = STYP_LIT;
 #endif /* _LIT */
     }
-  else if (!strncmp (sec_name, ".debug", 6))
+  else if (!strncmp (sec_name, DOT_DEBUG, sizeof (DOT_DEBUG) - 1))
     {
       /* Handle the XCOFF debug section and DWARF2 debug sections.  */
       if (!sec_name[6])
@@ -435,7 +440,7 @@ sec_to_styp_flags (sec_name, sec_flags)
       styp_flags = STYP_DEBUG_INFO;
     }
 #ifdef COFF_LONG_SECTION_NAMES
-  else if (!strncmp (sec_name, ".gnu.linkonce.wi.", 17))
+  else if (!strncmp (sec_name, GNU_LINKONCE_WI, sizeof (GNU_LINKONCE_WI) - 1))
     {
       styp_flags = STYP_DEBUG_INFO;
     }
@@ -485,12 +490,12 @@ sec_to_styp_flags (sec_name, sec_flags)
     }
 
 #ifdef STYP_CLINK
-  if (sec_flags & SEC_CLINK)
+  if (sec_flags & SEC_TIC54X_CLINK)
     styp_flags |= STYP_CLINK;
 #endif
 
 #ifdef STYP_BLOCK
-  if (sec_flags & SEC_BLOCK)
+  if (sec_flags & SEC_TIC54X_BLOCK)
     styp_flags |= STYP_BLOCK;
 #endif
 
@@ -511,9 +516,7 @@ sec_to_styp_flags (sec_name, sec_flags)
    and honor whatever objcopy/strip, etc. sent us as input.  */
 
 static long
-sec_to_styp_flags (sec_name, sec_flags)
-     const char *sec_name ATTRIBUTE_UNUSED;
-     flagword sec_flags;
+sec_to_styp_flags (const char *sec_name, flagword sec_flags)
 {
   long styp_flags = 0;
 
@@ -525,6 +528,11 @@ sec_to_styp_flags (sec_name, sec_flags)
      PE files.  The STYP_* flags and the IMAGE_SCN_* flags overlap,
      but there are more IMAGE_SCN_* flags.  */
 
+  /* FIXME: There is no gas syntax to specify the debug section flag.  */
+  if (strncmp (sec_name, DOT_DEBUG, sizeof (DOT_DEBUG) - 1) == 0
+      || strncmp (sec_name, GNU_LINKONCE_WI, sizeof (GNU_LINKONCE_WI) - 1) == 0)
+    sec_flags = SEC_READONLY | SEC_DEBUGGING;
+
   /* skip LOAD */
   /* READONLY later */
   /* skip RELOC */
@@ -558,15 +566,15 @@ sec_to_styp_flags (sec_name, sec_flags)
 
   /* For now, the read/write bits are mapped onto SEC_READONLY, even
      though the semantics don't quite match.  The bits from the input
-     are retained in pei_section_data(abfd, section)->pe_flags */
+     are retained in pei_section_data(abfd, section)->pe_flags */
 
-  styp_flags |= IMAGE_SCN_MEM_READ;       /* always readable.  */
+  styp_flags |= IMAGE_SCN_MEM_READ;       /* Always readable.  */
   if ((sec_flags & SEC_READONLY) == 0)
-    styp_flags |= IMAGE_SCN_MEM_WRITE;    /* Invert READONLY for write */
+    styp_flags |= IMAGE_SCN_MEM_WRITE;    /* Invert READONLY for write */
   if (sec_flags & SEC_CODE)
-    styp_flags |= IMAGE_SCN_MEM_EXECUTE;  /* CODE->EXECUTE */
-  if (sec_flags & SEC_SHARED)
-    styp_flags |= IMAGE_SCN_MEM_SHARED;   /* Shared remains meaningful */
+    styp_flags |= IMAGE_SCN_MEM_EXECUTE;  /* CODE->EXECUTE */
+  if (sec_flags & SEC_COFF_SHARED)
+    styp_flags |= IMAGE_SCN_MEM_SHARED;   /* Shared remains meaningful */
 
   return styp_flags;
 }
@@ -581,12 +589,11 @@ sec_to_styp_flags (sec_name, sec_flags)
 #ifndef COFF_WITH_PE
 
 static bfd_boolean
-styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     PTR hdr;
-     const char *name;
-     asection *section ATTRIBUTE_UNUSED;
-     flagword *flags_ptr;
+styp_to_sec_flags (bfd *abfd ATTRIBUTE_UNUSED,
+                  void * hdr,
+                  const char *name,
+                  asection *section ATTRIBUTE_UNUSED,
+                  flagword *flags_ptr)
 {
   struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
   long styp_flags = internal_s->s_flags;
@@ -594,12 +601,12 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
 
 #ifdef STYP_BLOCK
   if (styp_flags & STYP_BLOCK)
-    sec_flags |= SEC_BLOCK;
+    sec_flags |= SEC_TIC54X_BLOCK;
 #endif
 
 #ifdef STYP_CLINK
   if (styp_flags & STYP_CLINK)
-    sec_flags |= SEC_CLINK;
+    sec_flags |= SEC_TIC54X_CLINK;
 #endif
 
 #ifdef STYP_NOLOAD
@@ -669,12 +676,12 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
 #endif
        sec_flags |= SEC_ALLOC;
     }
-  else if (strncmp (name, ".debug", 6) == 0
+  else if (strncmp (name, DOT_DEBUG, sizeof (DOT_DEBUG) - 1) == 0
 #ifdef _COMMENT
           || strcmp (name, _COMMENT) == 0
 #endif
 #ifdef COFF_LONG_SECTION_NAMES
-          || strncmp (name, ".gnu.linkonce.wi.", 17) == 0
+          || strncmp (name, GNU_LINKONCE_WI, sizeof (GNU_LINKONCE_WI) - 1) == 0
 #endif
           || strncmp (name, ".stab", 5) == 0)
     {
@@ -693,12 +700,12 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
   else
     sec_flags |= SEC_ALLOC | SEC_LOAD;
 
-#ifdef STYP_LIT                        /* A29k readonly text/data section type */
+#ifdef STYP_LIT                        /* A29k readonly text/data section type */
   if ((styp_flags & STYP_LIT) == STYP_LIT)
     sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
 #endif /* STYP_LIT */
 
-#ifdef STYP_OTHER_LOAD         /* Other loaded sections */
+#ifdef STYP_OTHER_LOAD         /* Other loaded sections */
   if (styp_flags & STYP_OTHER_LOAD)
     sec_flags = (SEC_LOAD | SEC_ALLOC);
 #endif /* STYP_SDATA */
@@ -724,12 +731,11 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
 #else /* COFF_WITH_PE */
 
 static flagword
-handle_COMDAT (abfd, sec_flags, hdr, name, section)
-     bfd * abfd;
-     flagword sec_flags;
-     PTR hdr;
-     const char *name;
-     asection *section;
+handle_COMDAT (bfd * abfd,
+              flagword sec_flags,
+              void * hdr,
+              const char *name,
+              asection *section)
 {
   struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
   bfd_byte *esymstart, *esym, *esymend;
@@ -767,7 +773,7 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
       char buf[SYMNMLEN + 1];
       const char *symname;
 
-      bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &isym);
+      bfd_coff_swap_sym_in (abfd, esym, & isym);
 
       if (sizeof (internal_s->s_name) > SYMNMLEN)
        {
@@ -802,7 +808,7 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
             gas-generated, and look for <something> (whatever
             follows the $) as the comdat symbol.  */
 
-         /* All 3 branches use this */
+         /* All 3 branches use this */
          symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
 
          if (symname == NULL)
@@ -815,8 +821,6 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
                /* The first time we've seen the symbol.  */
                union internal_auxent aux;
 
-               seen_state = 1;
-
                /* If it isn't the stuff we're expecting, die;
                   The MS documentation is vague, but it
                   appears that the second entry serves BOTH
@@ -844,12 +848,15 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
                   function).  See comment above for more.  */
 
                if (strcmp (name, symname) != 0)
-                 abort ();
+                 _bfd_error_handler (_("%B: warning: COMDAT symbol '%s' does not match section name '%s'"),
+                                     abfd, symname, name);
+
+               seen_state = 1;
 
                /* This is the section symbol.  */
-               bfd_coff_swap_aux_in (abfd, (PTR) (esym + bfd_coff_symesz (abfd)),
+               bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
                                      isym.n_type, isym.n_sclass,
-                                     0, isym.n_numaux, (PTR) &aux);
+                                     0, isym.n_numaux, aux);
 
                target_name = strchr (name, '$');
                if (target_name != NULL)
@@ -930,7 +937,7 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
 #ifndef TARGET_UNDERSCORE
 #define TARGET_UNDERSCORE 0
 #endif
-             /* Is this the name we're looking for? */
+             /* Is this the name we're looking for ?  */
              if (strcmp (target_name,
                          symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
                {
@@ -951,12 +958,13 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
                   Intel puts the two adjacent, but Alpha (at
                   least) spreads them out.  */
 
-               amt = sizeof (struct bfd_comdat_info);
-               section->comdat = bfd_alloc (abfd, amt);
-               if (section->comdat == NULL)
+               amt = sizeof (struct coff_comdat_info);
+               coff_section_data (abfd, section)->comdat
+                 = bfd_alloc (abfd, amt);
+               if (coff_section_data (abfd, section)->comdat == NULL)
                  abort ();
 
-               section->comdat->symbol =
+               coff_section_data (abfd, section)->comdat->symbol =
                  (esym - esymstart) / bfd_coff_symesz (abfd);
 
                amt = strlen (symname) + 1;
@@ -965,7 +973,8 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
                  abort ();
 
                strcpy (newname, symname);
-               section->comdat->name = newname;
+               coff_section_data (abfd, section)->comdat->name
+                 = newname;
              }
 
              goto breakloop;
@@ -990,12 +999,11 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
    any purpose other than objdump?  */
 
 static bfd_boolean
-styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
-     bfd *abfd;
-     PTR hdr;
-     const char *name;
-     asection *section;
-     flagword *flags_ptr;
+styp_to_sec_flags (bfd *abfd,
+                  void * hdr,
+                  const char *name,
+                  asection *section,
+                  flagword *flags_ptr)
 {
   struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
   long styp_flags = internal_s->s_flags;
@@ -1049,7 +1057,11 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
          unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
          break;
        case IMAGE_SCN_MEM_NOT_PAGED:
-         unhandled = "IMAGE_SCN_MEM_NOT_PAGED";
+         /* Generate a warning message rather using the 'unhandled'
+            variable as this will allow some .sys files generate by
+            other toolchains to be processed.  See bugzilla issue 196.  */
+         _bfd_error_handler (_("%B: Warning: Ignoring section flag IMAGE_SCN_MEM_NOT_PAGED in section %s"),
+                             abfd, name);
          break;
        case IMAGE_SCN_MEM_EXECUTE:
          sec_flags |= SEC_CODE;
@@ -1058,10 +1070,14 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
          sec_flags &= ~ SEC_READONLY;
          break;
        case IMAGE_SCN_MEM_DISCARDABLE:
-         sec_flags |= SEC_DEBUGGING;
+         /* The MS PE spec sets the DISCARDABLE flag on .reloc sections
+            but we do not want them to be labelled as debug section, since
+            then strip would remove them.  */
+         if (strncmp (name, ".reloc", sizeof ".reloc" - 1) != 0)
+           sec_flags |= SEC_DEBUGGING;
          break;
        case IMAGE_SCN_MEM_SHARED:
-         sec_flags |= SEC_SHARED;
+         sec_flags |= SEC_COFF_SHARED;
          break;
        case IMAGE_SCN_LNK_REMOVE:
          sec_flags |= SEC_EXCLUDE;
@@ -1099,8 +1115,8 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
       if (unhandled != NULL)
        {
          (*_bfd_error_handler)
-           (_("%s (%s): Section flag %s (0x%x) ignored"),
-            bfd_archive_filename (abfd), name, unhandled, flag);
+           (_("%B (%s): Section flag %s (0x%x) ignored"),
+            abfd, name, unhandled, flag);
          result = FALSE;
        }
     }
@@ -1152,34 +1168,34 @@ Special entry points for gdb to swap in coff symbol table parts:
 .typedef struct
 .{
 .  void (*_bfd_coff_swap_aux_in)
-.    PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+.    (bfd *, void *, int, int, int, int, void *);
 .
 .  void (*_bfd_coff_swap_sym_in)
-.    PARAMS ((bfd *, PTR, PTR));
+.    (bfd *, void *, void *);
 .
 .  void (*_bfd_coff_swap_lineno_in)
-.    PARAMS ((bfd *, PTR, PTR));
+.    (bfd *, void *, void *);
 .
 .  unsigned int (*_bfd_coff_swap_aux_out)
-.    PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+.    (bfd *, void *, int, int, int, int, void *);
 .
 .  unsigned int (*_bfd_coff_swap_sym_out)
-.    PARAMS ((bfd *, PTR, PTR));
+.    (bfd *, void *, void *);
 .
 .  unsigned int (*_bfd_coff_swap_lineno_out)
-.    PARAMS ((bfd *, PTR, PTR));
+.    (bfd *, void *, void *);
 .
 .  unsigned int (*_bfd_coff_swap_reloc_out)
-.    PARAMS ((bfd *, PTR, PTR));
+.    (bfd *, void *, void *);
 .
 .  unsigned int (*_bfd_coff_swap_filehdr_out)
-.    PARAMS ((bfd *, PTR, PTR));
+.    (bfd *, void *, void *);
 .
 .  unsigned int (*_bfd_coff_swap_aouthdr_out)
-.    PARAMS ((bfd *, PTR, PTR));
+.    (bfd *, void *, void *);
 .
 .  unsigned int (*_bfd_coff_swap_scnhdr_out)
-.    PARAMS ((bfd *, PTR, PTR));
+.    (bfd *, void *, void *);
 .
 .  unsigned int _bfd_filhsz;
 .  unsigned int _bfd_aoutsz;
@@ -1196,86 +1212,86 @@ Special entry points for gdb to swap in coff symbol table parts:
 .  unsigned int _bfd_coff_debug_string_prefix_length;
 .
 .  void (*_bfd_coff_swap_filehdr_in)
-.    PARAMS ((bfd *, PTR, PTR));
+.    (bfd *, void *, void *);
 .
 .  void (*_bfd_coff_swap_aouthdr_in)
-.    PARAMS ((bfd *, PTR, PTR));
+.    (bfd *, void *, void *);
 .
 .  void (*_bfd_coff_swap_scnhdr_in)
-.    PARAMS ((bfd *, PTR, PTR));
+.    (bfd *, void *, void *);
 .
 .  void (*_bfd_coff_swap_reloc_in)
-.    PARAMS ((bfd *abfd, PTR, PTR));
+.    (bfd *abfd, void *, void *);
 .
 .  bfd_boolean (*_bfd_coff_bad_format_hook)
-.    PARAMS ((bfd *, PTR));
+.    (bfd *, void *);
 .
 .  bfd_boolean (*_bfd_coff_set_arch_mach_hook)
-.    PARAMS ((bfd *, PTR));
+.    (bfd *, void *);
 .
-.  PTR (*_bfd_coff_mkobject_hook)
-.    PARAMS ((bfd *, PTR, PTR));
+.  void * (*_bfd_coff_mkobject_hook)
+.    (bfd *, void *, void *);
 .
 .  bfd_boolean (*_bfd_styp_to_sec_flags_hook)
-.    PARAMS ((bfd *, PTR, const char *, asection *, flagword *));
+.    (bfd *, void *, const char *, asection *, flagword *);
 .
 .  void (*_bfd_set_alignment_hook)
-.    PARAMS ((bfd *, asection *, PTR));
+.    (bfd *, asection *, void *);
 .
 .  bfd_boolean (*_bfd_coff_slurp_symbol_table)
-.    PARAMS ((bfd *));
+.    (bfd *);
 .
 .  bfd_boolean (*_bfd_coff_symname_in_debug)
-.    PARAMS ((bfd *, struct internal_syment *));
+.    (bfd *, struct internal_syment *);
 .
 .  bfd_boolean (*_bfd_coff_pointerize_aux_hook)
-.    PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
-.           unsigned int, combined_entry_type *));
+.    (bfd *, combined_entry_type *, combined_entry_type *,
+.           unsigned int, combined_entry_type *);
 .
 .  bfd_boolean (*_bfd_coff_print_aux)
-.    PARAMS ((bfd *, FILE *, combined_entry_type *, combined_entry_type *,
-.           combined_entry_type *, unsigned int));
+.    (bfd *, FILE *, combined_entry_type *, combined_entry_type *,
+.           combined_entry_type *, unsigned int);
 .
 .  void (*_bfd_coff_reloc16_extra_cases)
-.    PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
-.          bfd_byte *, unsigned int *, unsigned int *));
+.    (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
+.          bfd_byte *, unsigned int *, unsigned int *);
 .
 .  int (*_bfd_coff_reloc16_estimate)
-.    PARAMS ((bfd *, asection *, arelent *, unsigned int,
-.           struct bfd_link_info *));
+.    (bfd *, asection *, arelent *, unsigned int,
+.           struct bfd_link_info *);
 .
 .  enum coff_symbol_classification (*_bfd_coff_classify_symbol)
-.    PARAMS ((bfd *, struct internal_syment *));
+.    (bfd *, struct internal_syment *);
 .
 .  bfd_boolean (*_bfd_coff_compute_section_file_positions)
-.    PARAMS ((bfd *));
+.    (bfd *);
 .
 .  bfd_boolean (*_bfd_coff_start_final_link)
-.    PARAMS ((bfd *, struct bfd_link_info *));
+.    (bfd *, struct bfd_link_info *);
 .
 .  bfd_boolean (*_bfd_coff_relocate_section)
-.    PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-.           struct internal_reloc *, struct internal_syment *, asection **));
+.    (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+.           struct internal_reloc *, struct internal_syment *, asection **);
 .
 .  reloc_howto_type *(*_bfd_coff_rtype_to_howto)
-.    PARAMS ((bfd *, asection *, struct internal_reloc *,
+.    (bfd *, asection *, struct internal_reloc *,
 .           struct coff_link_hash_entry *, struct internal_syment *,
-.           bfd_vma *));
+.           bfd_vma *);
 .
 .  bfd_boolean (*_bfd_coff_adjust_symndx)
-.    PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
-.           struct internal_reloc *, bfd_boolean *));
+.    (bfd *, struct bfd_link_info *, bfd *, asection *,
+.           struct internal_reloc *, bfd_boolean *);
 .
 .  bfd_boolean (*_bfd_coff_link_add_one_symbol)
-.    PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword,
+.    (struct bfd_link_info *, bfd *, const char *, flagword,
 .           asection *, bfd_vma, const char *, bfd_boolean, bfd_boolean,
-.           struct bfd_link_hash_entry **));
+.           struct bfd_link_hash_entry **);
 .
 .  bfd_boolean (*_bfd_coff_link_output_has_begun)
-.    PARAMS ((bfd *, struct coff_final_link_info *));
+.    (bfd *, struct coff_final_link_info *);
 .
 .  bfd_boolean (*_bfd_coff_final_link_postscript)
-.    PARAMS ((bfd *, struct coff_final_link_info *));
+.    (bfd *, struct coff_final_link_info *);
 .
 .} bfd_coff_backend_data;
 .
@@ -1344,7 +1360,8 @@ Special entry points for gdb to swap in coff symbol table parts:
 .#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
 .  ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
 .#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
-.  ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
+.  ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook)\
+.   (abfd, filehdr, aouthdr))
 .
 .#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\
 .  ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
@@ -1369,7 +1386,8 @@ Special entry points for gdb to swap in coff symbol table parts:
 .  ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
 .   (abfd, file, base, symbol, aux, indaux))
 .
-.#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
+.#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order,\
+.                                     reloc, data, src_ptr, dst_ptr)\
 .  ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
 .   (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
 .
@@ -1397,37 +1415,35 @@ Special entry points for gdb to swap in coff symbol table parts:
 .#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
 .  ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
 .   (obfd, info, ibfd, sec, rel, adjustedp))
-.#define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\
+.#define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\
+.                                     value, string, cp, coll, hashp)\
 .  ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
 .   (info, abfd, name, flags, section, value, string, cp, coll, hashp))
 .
 .#define bfd_coff_link_output_has_begun(a,p) \
-.  ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a,p))
+.  ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p))
 .#define bfd_coff_final_link_postscript(a,p) \
-.  ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a,p))
+.  ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a, p))
 .
 */
 
 /* See whether the magic number matches.  */
 
 static bfd_boolean
-coff_bad_format_hook (abfd, filehdr)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     PTR filehdr;
+coff_bad_format_hook (bfd * abfd ATTRIBUTE_UNUSED, void * filehdr)
 {
   struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
 
   if (BADMAG (*internal_f))
     return FALSE;
 
-  /* if the optional header is NULL or not the correct size then
+  /* If the optional header is NULL or not the correct size then
      quit; the only difference I can see between m88k dgux headers (MC88DMAGIC)
      and Intel 960 readwrite headers (I960WRMAGIC) is that the
      optional header is of a different size.
 
      But the mips keeps extra stuff in it's opthdr, so dont check
-     when doing that
-     */
+     when doing that.  */
 
 #if defined(M88) || defined(I960)
   if (internal_f->f_opthdr != 0 && bfd_coff_aoutsz (abfd) != internal_f->f_opthdr)
@@ -1437,15 +1453,40 @@ coff_bad_format_hook (abfd, filehdr)
   return TRUE;
 }
 
+#ifdef TICOFF
+static bfd_boolean
+ticoff0_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, void * filehdr)
+{
+  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+
+  if (COFF0_BADMAG (*internal_f))
+    return FALSE;
+
+  return TRUE;
+}
+#endif
+
+#ifdef TICOFF
+static bfd_boolean
+ticoff1_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, void * filehdr)
+{
+  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+
+  if (COFF1_BADMAG (*internal_f))
+    return FALSE;
+
+  return TRUE;
+}
+#endif
+
 /* Check whether this section uses an alignment other than the
    default.  */
 
 static void
-coff_set_custom_section_alignment (abfd, section, alignment_table, table_size)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *section;
-     const struct coff_section_alignment_entry *alignment_table;
-     const unsigned int table_size;
+coff_set_custom_section_alignment (bfd *abfd ATTRIBUTE_UNUSED,
+                                  asection *section,
+                                  const struct coff_section_alignment_entry *alignment_table,
+                                  const unsigned int table_size)
 {
   const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
   unsigned int i;
@@ -1453,6 +1494,7 @@ coff_set_custom_section_alignment (abfd, section, alignment_table, table_size)
   for (i = 0; i < table_size; ++i)
     {
       const char *secname = bfd_get_section_name (abfd, section);
+
       if (alignment_table[i].comparison_length == (unsigned int) -1
          ? strcmp (alignment_table[i].name, secname) == 0
          : strncmp (alignment_table[i].name, secname,
@@ -1504,9 +1546,7 @@ static const unsigned int coff_section_alignment_table_size =
    particular implementation of COFF.  */
 
 static bfd_boolean
-coff_new_section_hook (abfd, section)
-     bfd * abfd;
-     asection * section;
+coff_new_section_hook (bfd * abfd, asection * section)
 {
   combined_entry_type *native;
   bfd_size_type amt;
@@ -1528,12 +1568,12 @@ coff_new_section_hook (abfd, section)
      @@ The 10 is a guess at a plausible maximum number of aux entries
      (but shouldn't be a constant).  */
   amt = sizeof (combined_entry_type) * 10;
-  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
+  native = bfd_zalloc (abfd, amt);
   if (native == NULL)
     return FALSE;
 
   /* We don't need to set up n_name, n_value, or n_scnum in the native
-     symbol information, since they'll be overriden by the BFD symbol
+     symbol information, since they'll be overridden by the BFD symbol
      anyhow.  However, we do need to set the type and storage class,
      in case this symbol winds up getting written out.  The value 0
      for n_numaux is already correct.  */
@@ -1554,25 +1594,22 @@ coff_new_section_hook (abfd, section)
 
 /* Set the alignment of a BFD section.  */
 
-static void coff_set_alignment_hook PARAMS ((bfd *, asection *, PTR));
-
 static void
-coff_set_alignment_hook (abfd, section, scnhdr)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     asection * section;
-     PTR scnhdr;
+coff_set_alignment_hook (bfd * abfd ATTRIBUTE_UNUSED,
+                        asection * section,
+                        void * scnhdr)
 {
   struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
   unsigned int i;
 
 #ifdef I960
-  /* Extract ALIGN from 2**ALIGN stored in section header */
+  /* Extract ALIGN from 2**ALIGN stored in section header */
   for (i = 0; i < 32; i++)
     if ((1 << i) >= hdr->s_align)
       break;
 #endif
 #ifdef TIC80COFF
-  /* TI tools puts the alignment power in bits 8-11 */
+  /* TI tools puts the alignment power in bits 8-11 */
   i = (hdr->s_flags >> 8) & 0xF ;
 #endif
 #ifdef COFF_DECODE_ALIGNMENT
@@ -1588,26 +1625,23 @@ coff_set_alignment_hook (abfd, section, scnhdr)
 #else /* ! COFF_ALIGN_IN_SECTION_HEADER */
 #ifdef COFF_WITH_PE
 
-/* a couple of macros to help setting the alignment power field */
-#define ALIGN_SET(field,x,y) \
-  if (((field) & IMAGE_SCN_ALIGN_64BYTES) == x )\
-  {\
-     section->alignment_power = y;\
-  }
-
-#define ELIFALIGN_SET(field,x,y) \
-  else if (( (field) & IMAGE_SCN_ALIGN_64BYTES) == x ) \
-  {\
-     section->alignment_power = y;\
-  }
+/* A couple of macros to help setting the alignment power field.  */
+#define ALIGN_SET(field, x, y) \
+  if (((field) & IMAGE_SCN_ALIGN_64BYTES) == x)\
+    {\
+      section->alignment_power = y;\
+    }
 
-static void coff_set_alignment_hook PARAMS ((bfd *, asection *, PTR));
+#define ELIFALIGN_SET(field, x, y) \
+  else if (((field) & IMAGE_SCN_ALIGN_64BYTES) == x) \
+    {\
+      section->alignment_power = y;\
+    }
 
 static void
-coff_set_alignment_hook (abfd, section, scnhdr)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     asection * section;
-     PTR scnhdr;
+coff_set_alignment_hook (bfd * abfd ATTRIBUTE_UNUSED,
+                        asection * section,
+                        void * scnhdr)
 {
   struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
   bfd_size_type amt;
@@ -1627,43 +1661,46 @@ coff_set_alignment_hook (abfd, section, scnhdr)
   if (coff_section_data (abfd, section) == NULL)
     {
       amt = sizeof (struct coff_section_tdata);
-      section->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
+      section->used_by_bfd = bfd_zalloc (abfd, amt);
       if (section->used_by_bfd == NULL)
-       {
-         /* FIXME: Return error.  */
-         abort ();
-       }
+       /* FIXME: Return error.  */
+       abort ();
     }
+
   if (pei_section_data (abfd, section) == NULL)
     {
       amt = sizeof (struct pei_section_tdata);
-      coff_section_data (abfd, section)->tdata = (PTR) bfd_zalloc (abfd, amt);
+      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
       if (coff_section_data (abfd, section)->tdata == NULL)
-       {
-         /* FIXME: Return error.  */
-         abort ();
-       }
+       /* FIXME: Return error.  */
+       abort ();
     }
   pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
   pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
 
   section->lma = hdr->s_vaddr;
 
-  /* check for extended relocs */
+  /* Check for extended relocs.  */
   if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
     {
       struct external_reloc dst;
       struct internal_reloc n;
       file_ptr oldpos = bfd_tell (abfd);
+      bfd_size_type relsz = bfd_coff_relsz (abfd);
+      
       bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0);
-      if (bfd_bread ((PTR) &dst, (bfd_size_type) bfd_coff_relsz (abfd), abfd)
-         != bfd_coff_relsz (abfd))
+      if (bfd_bread (& dst, relsz, abfd) != relsz)
        return;
 
       coff_swap_reloc_in (abfd, &dst, &n);
       bfd_seek (abfd, oldpos, 0);
-      section->reloc_count = hdr->s_nreloc = n.r_vaddr;
+      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
+      section->rel_filepos += relsz;
     }
+  else if (hdr->s_nreloc == 0xffff)
+    (*_bfd_error_handler)
+      ("%s: warning: claims to have 0xffff relocs, without overflow",
+       bfd_get_filename (abfd));
 }
 #undef ALIGN_SET
 #undef ELIFALIGN_SET
@@ -1675,13 +1712,8 @@ coff_set_alignment_hook (abfd, section, scnhdr)
    When we see one, we correct the reloc and line number counts in the
    real header, and remove the section we just created.  */
 
-static void coff_set_alignment_hook PARAMS ((bfd *, asection *, PTR));
-
 static void
-coff_set_alignment_hook (abfd, section, scnhdr)
-     bfd *abfd;
-     asection *section;
-     PTR scnhdr;
+coff_set_alignment_hook (bfd *abfd, asection *section, void * scnhdr)
 {
   struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
   asection *real_sec;
@@ -1711,7 +1743,7 @@ coff_set_alignment_hook (abfd, section, scnhdr)
 #else /* ! RS6000COFF_C */
 
 #define coff_set_alignment_hook \
-  ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
+  ((void (*) (bfd *, asection *, void *)) bfd_void)
 
 #endif /* ! RS6000COFF_C */
 #endif /* ! COFF_WITH_PE */
@@ -1719,22 +1751,19 @@ coff_set_alignment_hook (abfd, section, scnhdr)
 
 #ifndef coff_mkobject
 
-static bfd_boolean coff_mkobject PARAMS ((bfd *));
-
 static bfd_boolean
-coff_mkobject (abfd)
-     bfd * abfd;
+coff_mkobject (bfd * abfd)
 {
   coff_data_type *coff;
   bfd_size_type amt = sizeof (coff_data_type);
 
-  abfd->tdata.coff_obj_data = (struct coff_tdata *) bfd_zalloc (abfd, amt);
-  if (abfd->tdata.coff_obj_data == 0)
+  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
+  if (abfd->tdata.coff_obj_data == NULL)
     return FALSE;
   coff = coff_data (abfd);
-  coff->symbols = (coff_symbol_type *) NULL;
-  coff->conversion_table = (unsigned int *) NULL;
-  coff->raw_syments = (struct coff_ptr_struct *) NULL;
+  coff->symbols = NULL;
+  coff->conversion_table = NULL;
+  coff->raw_syments = NULL;
   coff->relocbase = 0;
   coff->local_toc_sym_map = 0;
 
@@ -1745,12 +1774,12 @@ coff_mkobject (abfd)
 #endif
 
 /* Create the COFF backend specific information.  */
+
 #ifndef coff_mkobject_hook
-static PTR
-coff_mkobject_hook (abfd, filehdr, aouthdr)
-     bfd * abfd;
-     PTR filehdr;
-     PTR aouthdr ATTRIBUTE_UNUSED;
+static void *
+coff_mkobject_hook (bfd * abfd,
+                   void * filehdr,
+                   void * aouthdr ATTRIBUTE_UNUSED)
 {
   struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
   coff_data_type *coff;
@@ -1820,7 +1849,7 @@ coff_mkobject_hook (abfd, filehdr, aouthdr)
     abfd->flags |= HAS_DEBUG;
 #endif
 
-  return (PTR) coff;
+  return coff;
 }
 #endif
 
@@ -1832,9 +1861,7 @@ coff_mkobject_hook (abfd, filehdr, aouthdr)
    at linking together COFF files for different architectures.  */
 
 static bfd_boolean
-coff_set_arch_mach_hook (abfd, filehdr)
-     bfd *abfd;
-     PTR filehdr;
+coff_set_arch_mach_hook (bfd *abfd, void * filehdr)
 {
   unsigned long machine;
   enum bfd_architecture arch;
@@ -1879,21 +1906,25 @@ coff_set_arch_mach_hook (abfd, filehdr)
     case ARMPEMAGIC:
     case THUMBPEMAGIC:
       arch = bfd_arch_arm;
-      switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
+      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
+      if (machine == bfd_mach_arm_unknown)
        {
-        case F_ARM_2:  machine = bfd_mach_arm_2;  break;
-        case F_ARM_2a: machine = bfd_mach_arm_2a; break;
-        case F_ARM_3:  machine = bfd_mach_arm_3;  break;
-        default:
-        case F_ARM_3M: machine = bfd_mach_arm_3M; break;
-        case F_ARM_4:  machine = bfd_mach_arm_4;  break;
-        case F_ARM_4T: machine = bfd_mach_arm_4T; break;
-         /* The COFF header does not have enough bits available
-            to cover all the different ARM architectures.  So
-            we interpret F_ARM_5, the highest flag value to mean
-            "the highest ARM architecture known to BFD" which is
-            currently the XScale.  */
-        case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
+         switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
+           {
+           case F_ARM_2:  machine = bfd_mach_arm_2;  break;
+           case F_ARM_2a: machine = bfd_mach_arm_2a; break;
+           case F_ARM_3:  machine = bfd_mach_arm_3;  break;
+           default:
+           case F_ARM_3M: machine = bfd_mach_arm_3M; break;
+           case F_ARM_4:  machine = bfd_mach_arm_4;  break;
+           case F_ARM_4T: machine = bfd_mach_arm_4T; break;
+             /* The COFF header does not have enough bits available
+                to cover all the different ARM architectures.  So
+                we interpret F_ARM_5, the highest flag value to mean
+                "the highest ARM architecture known to BFD" which is
+                currently the XScale.  */
+           case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
+           }
        }
       break;
 #endif
@@ -1913,6 +1944,22 @@ coff_set_arch_mach_hook (abfd, filehdr)
       machine = bfd_mach_m68020;
       break;
 #endif
+#ifdef MAXQ20MAGIC
+    case MAXQ20MAGIC:
+      arch = bfd_arch_maxq;
+      switch (internal_f->f_flags & F_MACHMASK)
+       { 
+        case F_MAXQ10:
+          machine = bfd_mach_maxq10;
+          break;
+        case F_MAXQ20:
+          machine = bfd_mach_maxq20;
+          break;
+        default:
+          return FALSE;
+       }
+      break;
+#endif
 #ifdef MC88MAGIC
     case MC88MAGIC:
     case MC88DMAGIC:
@@ -2007,14 +2054,14 @@ coff_set_arch_mach_hook (abfd, filehdr)
                struct internal_syment sym;
                bfd_size_type amt = bfd_coff_symesz (abfd);
 
-               buf = (bfd_byte *) bfd_malloc (amt);
+               buf = bfd_malloc (amt);
                if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
                    || bfd_bread (buf, amt, abfd) != amt)
                  {
                    free (buf);
                    return FALSE;
                  }
-               bfd_coff_swap_sym_in (abfd, (PTR) buf, (PTR) &sym);
+               bfd_coff_swap_sym_in (abfd, buf, & sym);
                if (sym.n_sclass == C_FILE)
                  cputype = sym.n_type & 0xff;
                else
@@ -2063,7 +2110,7 @@ coff_set_arch_mach_hook (abfd, filehdr)
     case H8300MAGIC:
       arch = bfd_arch_h8300;
       machine = bfd_mach_h8300;
-      /* !! FIXME this probably isn't the right place for this */
+      /* !! FIXME this probably isn't the right place for this */
       abfd->flags |= BFD_IS_RELAXABLE;
       break;
 #endif
@@ -2072,7 +2119,7 @@ coff_set_arch_mach_hook (abfd, filehdr)
     case H8300HMAGIC:
       arch = bfd_arch_h8300;
       machine = bfd_mach_h8300h;
-      /* !! FIXME this probably isn't the right place for this */
+      /* !! FIXME this probably isn't the right place for this */
       abfd->flags |= BFD_IS_RELAXABLE;
       break;
 #endif
@@ -2081,7 +2128,25 @@ coff_set_arch_mach_hook (abfd, filehdr)
     case H8300SMAGIC:
       arch = bfd_arch_h8300;
       machine = bfd_mach_h8300s;
-      /* !! FIXME this probably isn't the right place for this */
+      /* !! FIXME this probably isn't the right place for this.  */
+      abfd->flags |= BFD_IS_RELAXABLE;
+      break;
+#endif
+
+#ifdef H8300HNMAGIC
+    case H8300HNMAGIC:
+      arch = bfd_arch_h8300;
+      machine = bfd_mach_h8300hn;
+      /* !! FIXME this probably isn't the right place for this.  */
+      abfd->flags |= BFD_IS_RELAXABLE;
+      break;
+#endif
+
+#ifdef H8300SNMAGIC
+    case H8300SNMAGIC:
+      arch = bfd_arch_h8300;
+      machine = bfd_mach_h8300sn;
+      /* !! FIXME this probably isn't the right place for this.  */
       abfd->flags |= BFD_IS_RELAXABLE;
       break;
 #endif
@@ -2125,16 +2190,17 @@ coff_set_arch_mach_hook (abfd, filehdr)
 
 #ifdef TICOFF0MAGIC
 #ifdef TICOFF_TARGET_ARCH
-      /* this TI COFF section should be used by all new TI COFF v0 targets */
+      /* This TI COFF section should be used by all new TI COFF v0 targets.  */
     case TICOFF0MAGIC:
       arch = TICOFF_TARGET_ARCH;
+      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
       break;
 #endif
 #endif
 
 #ifdef TICOFF1MAGIC
-      /* this TI COFF section should be used by all new TI COFF v1/2 targets */
-      /* TI COFF1 and COFF2 use the target_id field to specify which arch */
+      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
+      /* TI COFF1 and COFF2 use the target_id field to specify which arch */
     case TICOFF1MAGIC:
     case TICOFF2MAGIC:
       switch (internal_f->f_target_id)
@@ -2142,6 +2208,7 @@ coff_set_arch_mach_hook (abfd, filehdr)
 #ifdef TI_TARGET_ID
         case TI_TARGET_ID:
           arch = TICOFF_TARGET_ARCH;
+         machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
           break;
 #endif
         default:
@@ -2172,7 +2239,7 @@ coff_set_arch_mach_hook (abfd, filehdr)
       break;
 #endif
 
-    default:                   /* Unreadable input file type */
+    default:                   /* Unreadable input file type */
       arch = bfd_arch_obscure;
       break;
     }
@@ -2183,13 +2250,8 @@ coff_set_arch_mach_hook (abfd, filehdr)
 
 #ifdef SYMNAME_IN_DEBUG
 
-static bfd_boolean symname_in_debug_hook
-  PARAMS ((bfd *, struct internal_syment *));
-
 static bfd_boolean
-symname_in_debug_hook (abfd, sym)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     struct internal_syment *sym;
+symname_in_debug_hook (bfd * abfd ATTRIBUTE_UNUSED, struct internal_syment *sym)
 {
   return SYMNAME_IN_DEBUG (sym) != 0;
 }
@@ -2197,7 +2259,7 @@ symname_in_debug_hook (abfd, sym)
 #else
 
 #define symname_in_debug_hook \
-  (bfd_boolean (*) PARAMS ((bfd *, struct internal_syment *))) bfd_false
+  (bfd_boolean (*) (bfd *, struct internal_syment *)) bfd_false
 
 #endif
 
@@ -2209,18 +2271,12 @@ symname_in_debug_hook (abfd, sym)
 
 /* Handle the csect auxent of a C_EXT or C_HIDEXT symbol.  */
 
-static bfd_boolean coff_pointerize_aux_hook
-  PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
-          unsigned int, combined_entry_type *));
-
-/*ARGSUSED*/
 static bfd_boolean
-coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     combined_entry_type *table_base;
-     combined_entry_type *symbol;
-     unsigned int indaux;
-     combined_entry_type *aux;
+coff_pointerize_aux_hook (bfd *abfd ATTRIBUTE_UNUSED,
+                         combined_entry_type *table_base,
+                         combined_entry_type *symbol,
+                         unsigned int indaux,
+                         combined_entry_type *aux)
 {
   int class = symbol->u.syment.n_sclass;
 
@@ -2249,18 +2305,12 @@ coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux)
 
 /* We don't want to pointerize bal entries.  */
 
-static bfd_boolean coff_pointerize_aux_hook
-  PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
-          unsigned int, combined_entry_type *));
-
-/*ARGSUSED*/
 static bfd_boolean
-coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     combined_entry_type *table_base ATTRIBUTE_UNUSED;
-     combined_entry_type *symbol;
-     unsigned int indaux;
-     combined_entry_type *aux ATTRIBUTE_UNUSED;
+coff_pointerize_aux_hook (bfd *abfd ATTRIBUTE_UNUSED,
+                         combined_entry_type *table_base ATTRIBUTE_UNUSED,
+                         combined_entry_type *symbol,
+                         unsigned int indaux,
+                         combined_entry_type *aux ATTRIBUTE_UNUSED)
 {
   /* Return TRUE if we don't want to pointerize this aux entry, which
      is the case for the lastfirst aux entry for a C_LEAFPROC symbol.  */
@@ -2279,18 +2329,13 @@ coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux)
 
 /* Print an aux entry.  This returns TRUE if it has printed it.  */
 
-static bfd_boolean coff_print_aux
-  PARAMS ((bfd *, FILE *, combined_entry_type *, combined_entry_type *,
-          combined_entry_type *, unsigned int));
-
 static bfd_boolean
-coff_print_aux (abfd, file, table_base, symbol, aux, indaux)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     FILE *file ATTRIBUTE_UNUSED;
-     combined_entry_type *table_base ATTRIBUTE_UNUSED;
-     combined_entry_type *symbol ATTRIBUTE_UNUSED;
-     combined_entry_type *aux ATTRIBUTE_UNUSED;
-     unsigned int indaux ATTRIBUTE_UNUSED;
+coff_print_aux (bfd *abfd ATTRIBUTE_UNUSED,
+               FILE *file ATTRIBUTE_UNUSED,
+               combined_entry_type *table_base ATTRIBUTE_UNUSED,
+               combined_entry_type *symbol ATTRIBUTE_UNUSED,
+               combined_entry_type *aux ATTRIBUTE_UNUSED,
+               unsigned int indaux ATTRIBUTE_UNUSED)
 {
 #ifdef RS6000COFF_C
   if ((symbol->u.syment.n_sclass == C_EXT
@@ -2303,7 +2348,8 @@ coff_print_aux (abfd, file, table_base, symbol, aux, indaux)
        {
          BFD_ASSERT (! aux->fix_scnlen);
 #ifdef XCOFF64
-         fprintf (file, "val %5lld", aux->u.auxent.x_csect.x_scnlen.l);
+         fprintf (file, "val %5lld",
+                  (long long) aux->u.auxent.x_csect.x_scnlen.l);
 #else
          fprintf (file, "val %5ld", (long) aux->u.auxent.x_csect.x_scnlen.l);
 #endif
@@ -2313,7 +2359,8 @@ coff_print_aux (abfd, file, table_base, symbol, aux, indaux)
          fprintf (file, "indx ");
          if (! aux->fix_scnlen)
 #ifdef XCOFF64
-           fprintf (file, "%4lld", aux->u.auxent.x_csect.x_scnlen.l);
+           fprintf (file, "%4lld",
+                    (long long) aux->u.auxent.x_csect.x_scnlen.l);
 #else
            fprintf (file, "%4ld", (long) aux->u.auxent.x_csect.x_scnlen.l);
 #endif
@@ -2356,13 +2403,10 @@ SUBSUBSECTION
 
 #ifdef TARG_AUX
 
-static int compare_arelent_ptr PARAMS ((const PTR, const PTR));
 
-/* AUX's ld wants relocations to be sorted */
+/* AUX's ld wants relocations to be sorted */
 static int
-compare_arelent_ptr (x, y)
-     const PTR x;
-     const PTR y;
+compare_arelent_ptr (const void * x, const void * y)
 {
   const arelent **a = (const arelent **) x;
   const arelent **b = (const arelent **) y;
@@ -2375,13 +2419,11 @@ compare_arelent_ptr (x, y)
 #endif /* TARG_AUX */
 
 static bfd_boolean
-coff_write_relocs (abfd, first_undef)
-     bfd * abfd;
-     int first_undef;
+coff_write_relocs (bfd * abfd, int first_undef)
 {
   asection *s;
 
-  for (s = abfd->sections; s != (asection *) NULL; s = s->next)
+  for (s = abfd->sections; s != NULL; s = s->next)
     {
       unsigned int i;
       struct external_reloc dst;
@@ -2391,12 +2433,12 @@ coff_write_relocs (abfd, first_undef)
       p = s->orelocation;
 #else
       {
-       /* sort relocations before we write them out */
+       /* Sort relocations before we write them out.  */
        bfd_size_type amt;
 
        amt = s->reloc_count;
        amt *= sizeof (arelent *);
-       p = (arelent **) bfd_malloc (amt);
+       p = bfd_malloc (amt);
        if (p == NULL && s->reloc_count > 0)
          return FALSE;
        memcpy (p, s->orelocation, (size_t) amt);
@@ -2410,14 +2452,15 @@ coff_write_relocs (abfd, first_undef)
 #ifdef COFF_WITH_PE
       if (obj_pe (abfd) && s->reloc_count >= 0xffff)
        {
-         /* encode real count here as first reloc */
+         /* Encode real count here as first reloc.  */
          struct internal_reloc n;
-         memset ((PTR) & n, 0, sizeof (n));
-         /* add one to count *this* reloc (grr) */
+
+         memset (& n, 0, sizeof (n));
+         /* Add one to count *this* reloc (grr).  */
          n.r_vaddr = s->reloc_count + 1;
          coff_swap_reloc_out (abfd, &n, &dst);
-         if (bfd_bwrite ((PTR) & dst, (bfd_size_type) bfd_coff_relsz (abfd),
-                        abfd) != bfd_coff_relsz (abfd))
+         if (bfd_bwrite (& dst, (bfd_size_type) bfd_coff_relsz (abfd),
+                         abfd) != bfd_coff_relsz (abfd))
            return FALSE;
        }
 #endif
@@ -2426,7 +2469,8 @@ coff_write_relocs (abfd, first_undef)
        {
          struct internal_reloc n;
          arelent *q = p[i];
-         memset ((PTR) & n, 0, sizeof (n));
+
+         memset (& n, 0, sizeof (n));
 
          /* Now we've renumbered the symbols we know where the
             undefined symbols live in the table.  Check the reloc
@@ -2443,14 +2487,17 @@ coff_write_relocs (abfd, first_undef)
              int j;
              const char *sname = q->sym_ptr_ptr[0]->name;
              asymbol **outsyms = abfd->outsymbols;
+
              for (j = first_undef; outsyms[j]; j++)
                {
                  const char *intable = outsyms[j]->name;
-                 if (strcmp (intable, sname) == 0) {
-                   /* got a hit, so repoint the reloc */
-                   q->sym_ptr_ptr = outsyms + j;
-                   break;
-                 }
+
+                 if (strcmp (intable, sname) == 0)
+                   {
+                     /* Got a hit, so repoint the reloc.  */
+                     q->sym_ptr_ptr = outsyms + j;
+                     break;
+                   }
                }
            }
 
@@ -2467,7 +2514,7 @@ coff_write_relocs (abfd, first_undef)
            if (q->sym_ptr_ptr)
              {
 #ifdef SECTION_RELATIVE_ABSOLUTE_SYMBOL_P
-                if (SECTION_RELATIVE_ABSOLUTE_SYMBOL_P (q,s))
+                if (SECTION_RELATIVE_ABSOLUTE_SYMBOL_P (q, s))
 #else
                if ((*q->sym_ptr_ptr)->section == bfd_abs_section_ptr
                    && ((*q->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0)
@@ -2490,13 +2537,14 @@ coff_write_relocs (abfd, first_undef)
 #endif
 
 #ifdef SELECT_RELOC
-         /* Work out reloc type from what is required */
+         /* Work out reloc type from what is required */
          SELECT_RELOC (n, q->howto);
 #else
          n.r_type = q->howto->type;
 #endif
          coff_swap_reloc_out (abfd, &n, &dst);
-         if (bfd_bwrite ((PTR) & dst, (bfd_size_type) bfd_coff_relsz (abfd),
+
+         if (bfd_bwrite (& dst, (bfd_size_type) bfd_coff_relsz (abfd),
                         abfd) != bfd_coff_relsz (abfd))
            return FALSE;
        }
@@ -2514,68 +2562,44 @@ coff_write_relocs (abfd, first_undef)
    type.  Result is TRUE if we can represent the arch&type, FALSE if not.  */
 
 static bfd_boolean
-coff_set_flags (abfd, magicp, flagsp)
-     bfd * abfd;
-     unsigned int *magicp ATTRIBUTE_UNUSED;
-     unsigned short *flagsp ATTRIBUTE_UNUSED;
+coff_set_flags (bfd * abfd,
+               unsigned int *magicp ATTRIBUTE_UNUSED,
+               unsigned short *flagsp ATTRIBUTE_UNUSED)
 {
   switch (bfd_get_arch (abfd))
     {
 #ifdef Z8KMAGIC
     case bfd_arch_z8k:
       *magicp = Z8KMAGIC;
+
       switch (bfd_get_mach (abfd))
        {
-       case bfd_mach_z8001:
-         *flagsp = F_Z8001;
-         break;
-       case bfd_mach_z8002:
-         *flagsp = F_Z8002;
-         break;
-       default:
-         return FALSE;
+       case bfd_mach_z8001: *flagsp = F_Z8001; break;
+       case bfd_mach_z8002: *flagsp = F_Z8002; break;
+       default:             return FALSE;
        }
       return TRUE;
 #endif
-#ifdef I960ROMAGIC
 
+#ifdef I960ROMAGIC
     case bfd_arch_i960:
 
       {
        unsigned flags;
+
        *magicp = I960ROMAGIC;
-       /*
-         ((bfd_get_file_flags(abfd) & WP_TEXT) ? I960ROMAGIC :
-         I960RWMAGIC);   FIXME???
-         */
+
        switch (bfd_get_mach (abfd))
          {
-         case bfd_mach_i960_core:
-           flags = F_I960CORE;
-           break;
-         case bfd_mach_i960_kb_sb:
-           flags = F_I960KB;
-           break;
-         case bfd_mach_i960_mc:
-           flags = F_I960MC;
-           break;
-         case bfd_mach_i960_xa:
-           flags = F_I960XA;
-           break;
-         case bfd_mach_i960_ca:
-           flags = F_I960CA;
-           break;
-         case bfd_mach_i960_ka_sa:
-           flags = F_I960KA;
-           break;
-         case bfd_mach_i960_jx:
-           flags = F_I960JX;
-           break;
-         case bfd_mach_i960_hx:
-           flags = F_I960HX;
-           break;
-         default:
-           return FALSE;
+         case bfd_mach_i960_core:  flags = F_I960CORE; break;
+         case bfd_mach_i960_kb_sb: flags = F_I960KB;   break;
+         case bfd_mach_i960_mc:    flags = F_I960MC;   break;
+         case bfd_mach_i960_xa:    flags = F_I960XA;   break;
+         case bfd_mach_i960_ca:    flags = F_I960CA;   break;
+         case bfd_mach_i960_ka_sa: flags = F_I960KA;   break;
+         case bfd_mach_i960_jx:    flags = F_I960JX;   break;
+         case bfd_mach_i960_hx:    flags = F_I960HX;   break;
+         default:                  return FALSE;
          }
        *flagsp = flags;
        return TRUE;
@@ -2591,12 +2615,12 @@ coff_set_flags (abfd, magicp, flagsp)
 
 #ifdef TICOFF_DEFAULT_MAGIC
     case TICOFF_TARGET_ARCH:
-      /* if there's no indication of which version we want, use the default */
+      /* If there's no indication of which version we want, use the default.  */
       if (!abfd->xvec )
         *magicp = TICOFF_DEFAULT_MAGIC;
       else
         {
-          /* we may want to output in a different COFF version */
+          /* We may want to output in a different COFF version.  */
           switch (abfd->xvec->name[4])
             {
             case '0':
@@ -2612,6 +2636,7 @@ coff_set_flags (abfd, magicp, flagsp)
               return FALSE;
             }
         }
+      TICOFF_TARGET_MACHINE_SET (flagsp, bfd_get_mach (abfd));
       return TRUE;
 #endif
 
@@ -2620,6 +2645,7 @@ coff_set_flags (abfd, magicp, flagsp)
       *magicp = TIC80_ARCH_MAGIC;
       return TRUE;
 #endif
+
 #ifdef ARMMAGIC
     case bfd_arch_arm:
 #ifdef ARM_WINCE
@@ -2658,12 +2684,13 @@ coff_set_flags (abfd, magicp, flagsp)
        }
       return TRUE;
 #endif
+
 #ifdef PPCMAGIC
     case bfd_arch_powerpc:
       *magicp = PPCMAGIC;
       return TRUE;
-      break;
 #endif
+
 #ifdef I386MAGIC
     case bfd_arch_i386:
       *magicp = I386MAGIC;
@@ -2672,20 +2699,20 @@ coff_set_flags (abfd, magicp, flagsp)
       *magicp = LYNXCOFFMAGIC;
 #endif
       return TRUE;
-      break;
 #endif
+
 #ifdef I860MAGIC
     case bfd_arch_i860:
       *magicp = I860MAGIC;
       return TRUE;
-      break;
 #endif
+
 #ifdef IA64MAGIC
     case bfd_arch_ia64:
       *magicp = IA64MAGIC;
       return TRUE;
-      break;
 #endif
+
 #ifdef MC68MAGIC
     case bfd_arch_m68k:
 #ifdef APOLLOM68KMAGIC
@@ -2703,28 +2730,24 @@ coff_set_flags (abfd, magicp, flagsp)
       *magicp = LYNXCOFFMAGIC;
 #endif
       return TRUE;
-      break;
 #endif
 
 #ifdef MC88MAGIC
     case bfd_arch_m88k:
       *magicp = MC88OMAGIC;
       return TRUE;
-      break;
 #endif
+
 #ifdef H8300MAGIC
     case bfd_arch_h8300:
       switch (bfd_get_mach (abfd))
        {
-       case bfd_mach_h8300:
-         *magicp = H8300MAGIC;
-         return TRUE;
-       case bfd_mach_h8300h:
-         *magicp = H8300HMAGIC;
-         return TRUE;
-       case bfd_mach_h8300s:
-         *magicp = H8300SMAGIC;
-         return TRUE;
+       case bfd_mach_h8300:   *magicp = H8300MAGIC;   return TRUE;
+       case bfd_mach_h8300h:  *magicp = H8300HMAGIC;  return TRUE;
+       case bfd_mach_h8300s:  *magicp = H8300SMAGIC;  return TRUE;
+       case bfd_mach_h8300hn: *magicp = H8300HNMAGIC; return TRUE;
+       case bfd_mach_h8300sn: *magicp = H8300SNMAGIC; return TRUE;
+       default: break;
        }
       break;
 #endif
@@ -2740,14 +2763,12 @@ coff_set_flags (abfd, magicp, flagsp)
        *magicp = SH_ARCH_MAGIC_LITTLE;
 #endif
       return TRUE;
-      break;
 #endif
 
 #ifdef MIPS_ARCH_MAGIC_WINCE
     case bfd_arch_mips:
       *magicp = MIPS_ARCH_MAGIC_WINCE;
       return TRUE;
-      break;
 #endif
 
 #ifdef SPARCMAGIC
@@ -2758,7 +2779,6 @@ coff_set_flags (abfd, magicp, flagsp)
       *magicp = LYNXCOFFMAGIC;
 #endif
       return TRUE;
-      break;
 #endif
 
 #ifdef H8500MAGIC
@@ -2767,6 +2787,7 @@ coff_set_flags (abfd, magicp, flagsp)
       return TRUE;
       break;
 #endif
+
 #ifdef A29K_MAGIC_BIG
     case bfd_arch_a29k:
       if (bfd_big_endian (abfd))
@@ -2774,14 +2795,12 @@ coff_set_flags (abfd, magicp, flagsp)
       else
        *magicp = A29K_MAGIC_LITTLE;
       return TRUE;
-      break;
 #endif
 
 #ifdef WE32KMAGIC
     case bfd_arch_we32k:
       *magicp = WE32KMAGIC;
       return TRUE;
-      break;
 #endif
 
 #ifdef RS6000COFF_C
@@ -2792,7 +2811,6 @@ coff_set_flags (abfd, magicp, flagsp)
       BFD_ASSERT (bfd_get_flavour (abfd) == bfd_target_xcoff_flavour);
       *magicp = bfd_xcoff_magic_number (abfd);
       return TRUE;
-      break;
 #endif
 
 #ifdef MCOREMAGIC
@@ -2816,6 +2834,17 @@ coff_set_flags (abfd, magicp, flagsp)
       return TRUE;
 #endif
 
+#ifdef MAXQ20MAGIC
+    case bfd_arch_maxq:
+      * magicp = MAXQ20MAGIC;
+      switch (bfd_get_mach (abfd))
+       {
+       case bfd_mach_maxq10: * flagsp = F_MAXQ10; return TRUE;
+       case bfd_mach_maxq20: * flagsp = F_MAXQ20; return TRUE;
+       default:              return FALSE;
+       }
+#endif
+
     default:                   /* Unknown architecture.  */
       /* Fall through to "return FALSE" below, to avoid
         "statement never reached" errors on the one below.  */
@@ -2826,10 +2855,9 @@ coff_set_flags (abfd, magicp, flagsp)
 }
 
 static bfd_boolean
-coff_set_arch_mach (abfd, arch, machine)
-     bfd * abfd;
-     enum bfd_architecture arch;
-     unsigned long machine;
+coff_set_arch_mach (bfd * abfd,
+                   enum bfd_architecture arch,
+                   unsigned long machine)
 {
   unsigned dummy1;
   unsigned short dummy2;
@@ -2839,9 +2867,9 @@ coff_set_arch_mach (abfd, arch, machine)
 
   if (arch != bfd_arch_unknown
       && ! coff_set_flags (abfd, &dummy1, &dummy2))
-    return FALSE;              /* We can't represent this type */
+    return FALSE;              /* We can't represent this type */
 
-  return TRUE;                 /* We're easy ...  */
+  return TRUE;                 /* We're easy...  */
 }
 
 #ifdef COFF_IMAGE_WITH_PE
@@ -2849,12 +2877,8 @@ coff_set_arch_mach (abfd, arch, machine)
 /* This is used to sort sections by VMA, as required by PE image
    files.  */
 
-static int sort_by_secaddr PARAMS ((const PTR, const PTR));
-
 static int
-sort_by_secaddr (arg1, arg2)
-     const PTR arg1;
-     const PTR arg2;
+sort_by_secaddr (const void * arg1, const void * arg2)
 {
   const asection *a = *(const asection **) arg1;
   const asection *b = *(const asection **) arg2;
@@ -2863,8 +2887,8 @@ sort_by_secaddr (arg1, arg2)
     return -1;
   else if (a->vma > b->vma)
     return 1;
-  else
-    return 0;
+
+  return 0;
 }
 
 #endif /* COFF_IMAGE_WITH_PE */
@@ -2879,11 +2903,10 @@ sort_by_secaddr (arg1, arg2)
 #endif
 
 static bfd_boolean
-coff_compute_section_file_positions (abfd)
-     bfd * abfd;
+coff_compute_section_file_positions (bfd * abfd)
 {
   asection *current;
-  asection *previous = (asection *) NULL;
+  asection *previous = NULL;
   file_ptr sofar = bfd_coff_filhsz (abfd);
   bfd_boolean align_adjust;
 #ifdef ALIGN_SECTIONS_IN_FILE
@@ -2920,10 +2943,10 @@ coff_compute_section_file_positions (abfd)
        {
          asection *dsec;
 
-         dsec = bfd_make_section_old_way (abfd, ".debug");
+         dsec = bfd_make_section_old_way (abfd, DOT_DEBUG);
          if (dsec == NULL)
            abort ();
-         dsec->_raw_size = sz;
+         dsec->size = sz;
          dsec->flags |= SEC_HAS_CONTENTS;
        }
     }
@@ -2931,9 +2954,15 @@ coff_compute_section_file_positions (abfd)
 
 #ifdef COFF_IMAGE_WITH_PE
   int page_size;
+
   if (coff_data (abfd)->link_info)
     {
       page_size = pe_data (abfd)->pe_opthdr.FileAlignment;
+
+      /* If no file alignment has been set, default to one.
+        This repairs 'ld -r' for arm-wince-pe target.  */
+      if (page_size == 0)
+        page_size = 1;
     }
   else
     page_size = PE_DEF_FILE_ALIGNMENT;
@@ -2944,11 +2973,9 @@ coff_compute_section_file_positions (abfd)
 #endif
 
   if (bfd_get_start_address (abfd))
-    {
-      /*  A start address may have been added to the original file. In this
-         case it will need an optional header to record it.  */
-      abfd->flags |= EXEC_P;
-    }
+    /*  A start address may have been added to the original file. In this
+       case it will need an optional header to record it.  */
+    abfd->flags |= EXEC_P;
 
   if (abfd->flags & EXEC_P)
     sofar += bfd_coff_aoutsz (abfd);
@@ -3017,7 +3044,7 @@ coff_compute_section_file_positions (abfd)
           a zero size and having real contents are different
           concepts: .bss has no contents, but (usually) non-zero
           size.  */
-       if (current->_raw_size == 0)
+       if (current->size == 0)
          {
            /* Discard.  However, it still might have (valid) symbols
               in it, so arbitrarily set it to section 1 (indexing is
@@ -3046,7 +3073,7 @@ coff_compute_section_file_positions (abfd)
 
   align_adjust = FALSE;
   for (current = abfd->sections;
-       current != (asection *) NULL;
+       current != NULL;
        current = current->next)
     {
 #ifdef COFF_IMAGE_WITH_PE
@@ -3055,20 +3082,21 @@ coff_compute_section_file_positions (abfd)
       if (coff_section_data (abfd, current) == NULL)
        {
          bfd_size_type amt = sizeof (struct coff_section_tdata);
-         current->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
+
+         current->used_by_bfd = bfd_zalloc (abfd, amt);
          if (current->used_by_bfd == NULL)
            return FALSE;
        }
       if (pei_section_data (abfd, current) == NULL)
        {
          bfd_size_type amt = sizeof (struct pei_section_tdata);
-         coff_section_data (abfd, current)->tdata
-           = (PTR) bfd_zalloc (abfd, amt);
+
+         coff_section_data (abfd, current)->tdata = bfd_zalloc (abfd, amt);
          if (coff_section_data (abfd, current)->tdata == NULL)
            return FALSE;
        }
       if (pei_section_data (abfd, current)->virt_size == 0)
-       pei_section_data (abfd, current)->virt_size = current->_raw_size;
+       pei_section_data (abfd, current)->virt_size = current->size;
 #endif
 
       /* Only deal with sections which have contents.  */
@@ -3077,7 +3105,7 @@ coff_compute_section_file_positions (abfd)
 
 #ifdef COFF_IMAGE_WITH_PE
       /* Make sure we skip empty sections in a PE image.  */
-      if (current->_raw_size == 0)
+      if (current->size == 0)
        continue;
 #endif
 
@@ -3088,14 +3116,14 @@ coff_compute_section_file_positions (abfd)
 #ifdef ALIGN_SECTIONS_IN_FILE
       if ((abfd->flags & EXEC_P) != 0)
        {
-         /* make sure this section is aligned on the right boundary - by
-            padding the previous section up if necessary */
-
+         /* Make sure this section is aligned on the right boundary - by
+            padding the previous section up if necessary.  */
          old_sofar = sofar;
+
 #ifdef RS6000COFF_C
          /* AIX loader checks the text section alignment of (vma - filepos)
             So even though the filepos may be aligned wrt the o_algntext, for
-            AIX executables, this check fails. This shows up when an native
+            AIX executables, this check fails. This shows up when a native
             AIX executable is stripped with gnu strip because the default vma
             of native is 0x10000150 but default for gnu is 0x10000140.  Gnu
             stripped gnu excutable passes this check because the filepos is
@@ -3124,10 +3152,8 @@ coff_compute_section_file_positions (abfd)
              sofar = BFD_ALIGN (sofar, 1 << current->alignment_power);
            }
 #endif
-         if (previous != (asection *) NULL)
-           {
-             previous->_raw_size += sofar - old_sofar;
-           }
+         if (previous != NULL)
+           previous->size += sofar - old_sofar;
        }
 
 #endif
@@ -3137,43 +3163,43 @@ coff_compute_section_file_positions (abfd)
 #ifdef COFF_PAGE_SIZE
       if ((abfd->flags & D_PAGED) != 0
          && (current->flags & SEC_ALLOC) != 0)
-       sofar += (current->vma - sofar) % page_size;
+       sofar += (current->vma - (bfd_vma) sofar) % page_size;
 #endif
       current->filepos = sofar;
 
 #ifdef COFF_IMAGE_WITH_PE
       /* Set the padded size.  */
-      current->_raw_size = (current->_raw_size + page_size -1) & -page_size;
+      current->size = (current->size + page_size -1) & -page_size;
 #endif
 
-      sofar += current->_raw_size;
+      sofar += current->size;
 
 #ifdef ALIGN_SECTIONS_IN_FILE
-      /* make sure that this section is of the right size too */
+      /* Make sure that this section is of the right size too.  */
       if ((abfd->flags & EXEC_P) == 0)
        {
          bfd_size_type old_size;
 
-         old_size = current->_raw_size;
-         current->_raw_size = BFD_ALIGN (current->_raw_size,
-                                         1 << current->alignment_power);
-         align_adjust = current->_raw_size != old_size;
-         sofar += current->_raw_size - old_size;
+         old_size = current->size;
+         current->size = BFD_ALIGN (current->size,
+                                    1 << current->alignment_power);
+         align_adjust = current->size != old_size;
+         sofar += current->size - old_size;
        }
       else
        {
          old_sofar = sofar;
          sofar = BFD_ALIGN (sofar, 1 << current->alignment_power);
          align_adjust = sofar != old_sofar;
-         current->_raw_size += sofar - old_sofar;
+         current->size += sofar - old_sofar;
        }
 #endif
 
 #ifdef COFF_IMAGE_WITH_PE
       /* For PE we need to make sure we pad out to the aligned
-         _raw_size, in case the caller only writes out data to the
-         unaligned _raw_size.  */
-      if (pei_section_data (abfd, current)->virt_size < current->_raw_size)
+         size, in case the caller only writes out data to the
+         unaligned size.  */
+      if (pei_section_data (abfd, current)->virt_size < current->size)
        align_adjust = TRUE;
 #endif
 
@@ -3214,94 +3240,13 @@ coff_compute_section_file_positions (abfd)
   return TRUE;
 }
 
-#if 0
-
-/* This can never work, because it is called too late--after the
-   section positions have been set.  I can't figure out what it is
-   for, so I am going to disable it--Ian Taylor 20 March 1996.  */
-
-/* If .file, .text, .data, .bss symbols are missing, add them.  */
-/* @@ Should we only be adding missing symbols, or overriding the aux
-   values for existing section symbols?  */
-static bfd_boolean
-coff_add_missing_symbols (abfd)
-     bfd *abfd;
-{
-  unsigned int nsyms = bfd_get_symcount (abfd);
-  asymbol **sympp = abfd->outsymbols;
-  asymbol **sympp2;
-  unsigned int i;
-  int need_text = 1, need_data = 1, need_bss = 1, need_file = 1;
-  bfd_size_type amt;
-
-  for (i = 0; i < nsyms; i++)
-    {
-      coff_symbol_type *csym = coff_symbol_from (abfd, sympp[i]);
-      const char *name;
-      if (csym)
-       {
-         /* only do this if there is a coff representation of the input
-          symbol */
-         if (csym->native && csym->native->u.syment.n_sclass == C_FILE)
-           {
-             need_file = 0;
-             continue;
-           }
-         name = csym->symbol.name;
-         if (!name)
-           continue;
-         if (!strcmp (name, _TEXT))
-           need_text = 0;
-#ifdef APOLLO_M68
-         else if (!strcmp (name, ".wtext"))
-           need_text = 0;
-#endif
-         else if (!strcmp (name, _DATA))
-           need_data = 0;
-         else if (!strcmp (name, _BSS))
-           need_bss = 0;
-       }
-    }
-  /* Now i == bfd_get_symcount (abfd).  */
-  /* @@ For now, don't deal with .file symbol.  */
-  need_file = 0;
-
-  if (!need_text && !need_data && !need_bss && !need_file)
-    return TRUE;
-  nsyms += need_text + need_data + need_bss + need_file;
-  amt = nsyms;
-  amt *= sizeof (asymbol *);
-  sympp2 = (asymbol **) bfd_alloc (abfd, amt);
-  if (!sympp2)
-    return FALSE;
-  memcpy (sympp2, sympp, i * sizeof (asymbol *));
-  if (need_file)
-    {
-      /* @@ Generate fake .file symbol, in sympp2[i], and increment i.  */
-      abort ();
-    }
-  if (need_text)
-    sympp2[i++] = coff_section_symbol (abfd, _TEXT);
-  if (need_data)
-    sympp2[i++] = coff_section_symbol (abfd, _DATA);
-  if (need_bss)
-    sympp2[i++] = coff_section_symbol (abfd, _BSS);
-  BFD_ASSERT (i == nsyms);
-  bfd_set_symtab (abfd, sympp2, nsyms);
-  return TRUE;
-}
-
-#endif /* 0 */
-
 #ifdef COFF_IMAGE_WITH_PE
 
 static unsigned int pelength;
 static unsigned int peheader;
 
 static bfd_boolean
-coff_read_word (abfd, value)
-  bfd *abfd;
-  unsigned int *value;
+coff_read_word (bfd *abfd, unsigned int *value)
 {
   unsigned char b[2];
   int status;
@@ -3324,8 +3269,7 @@ coff_read_word (abfd, value)
 }
 
 static unsigned int
-coff_compute_checksum (abfd)
-  bfd *abfd;
+coff_compute_checksum (bfd *abfd)
 {
   bfd_boolean more_data;
   file_ptr filepos;
@@ -3352,8 +3296,7 @@ coff_compute_checksum (abfd)
 }
 
 static bfd_boolean
-coff_apply_checksum (abfd)
-  bfd *abfd;
+coff_apply_checksum (bfd *abfd)
 {
   unsigned int computed;
   unsigned int checksum = 0;
@@ -3387,11 +3330,8 @@ coff_apply_checksum (abfd)
 
 #endif /* COFF_IMAGE_WITH_PE */
 
-/* SUPPRESS 558 */
-/* SUPPRESS 529 */
 static bfd_boolean
-coff_write_object_contents (abfd)
-     bfd * abfd;
+coff_write_object_contents (bfd * abfd)
 {
   asection *current;
   bfd_boolean hasrelocs = FALSE;
@@ -3416,8 +3356,7 @@ coff_write_object_contents (abfd)
   bfd_set_error (bfd_error_system_call);
 
   /* Make a pass through the symbol table to count line number entries and
-     put them into the correct asections */
-
+     put them into the correct asections.  */
   lnno_size = coff_count_linenumbers (abfd) * bfd_coff_linesz (abfd);
 
   if (! abfd->output_has_begun)
@@ -3428,13 +3367,13 @@ coff_write_object_contents (abfd)
 
   reloc_base = obj_relocbase (abfd);
 
-  /* Work out the size of the reloc and linno areas */
+  /* Work out the size of the reloc and linno areas */
 
   for (current = abfd->sections; current != NULL; current =
        current->next)
     {
 #ifdef COFF_WITH_PE
-      /* we store the actual reloc count in the first reloc's addr */
+      /* We store the actual reloc count in the first reloc's addr.  */
       if (obj_pe (abfd) && current->reloc_count >= 0xffff)
        reloc_count ++;
 #endif
@@ -3446,7 +3385,7 @@ coff_write_object_contents (abfd)
   lineno_base = reloc_base + reloc_size;
   sym_base = lineno_base + lnno_size;
 
-  /* Indicate in each section->line_filepos its actual file address */
+  /* Indicate in each section->line_filepos its actual file address */
   for (current = abfd->sections; current != NULL; current =
        current->next)
     {
@@ -3457,23 +3396,20 @@ coff_write_object_contents (abfd)
          lineno_base += current->lineno_count * bfd_coff_linesz (abfd);
        }
       else
-       {
-         current->line_filepos = 0;
-       }
+       current->line_filepos = 0;
+
       if (current->reloc_count)
        {
          current->rel_filepos = reloc_base;
          reloc_base += current->reloc_count * bfd_coff_relsz (abfd);
 #ifdef COFF_WITH_PE
-         /* extra reloc to hold real count */
+         /* Extra reloc to hold real count.  */
          if (obj_pe (abfd) && current->reloc_count >= 0xffff)
            reloc_base += bfd_coff_relsz (abfd);
 #endif
        }
       else
-       {
-         current->rel_filepos = 0;
-       }
+       current->rel_filepos = 0;
     }
 
   /* Write section headers to the file.  */
@@ -3544,7 +3480,7 @@ coff_write_object_contents (abfd)
 #endif
       section.s_vaddr = current->vma;
       section.s_paddr = current->lma;
-      section.s_size =  current->_raw_size;
+      section.s_size =  current->size;
 #ifdef coff_get_section_load_page
       section.s_page = coff_get_section_load_page (current);
 #endif
@@ -3561,19 +3497,14 @@ coff_write_object_contents (abfd)
        section.s_paddr = 0;
 #endif
 
-      /*
-        If this section has no size or is unloadable then the scnptr
-        will be 0 too
-        */
-      if (current->_raw_size == 0 ||
-         (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
-       {
-         section.s_scnptr = 0;
-       }
+      /* If this section has no size or is unloadable then the scnptr
+        will be 0 too.  */
+      if (current->size == 0
+         || (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
+       section.s_scnptr = 0;
       else
-       {
-         section.s_scnptr = current->filepos;
-       }
+       section.s_scnptr = current->filepos;
+
       section.s_relptr = current->rel_filepos;
       section.s_lnnoptr = current->line_filepos;
       section.s_nreloc = current->reloc_count;
@@ -3603,17 +3534,11 @@ coff_write_object_contents (abfd)
       section.s_flags = sec_to_styp_flags (current->name, current->flags);
 
       if (!strcmp (current->name, _TEXT))
-       {
-         text_sec = current;
-       }
+       text_sec = current;
       else if (!strcmp (current->name, _DATA))
-       {
-         data_sec = current;
-       }
+       data_sec = current;
       else if (!strcmp (current->name, _BSS))
-       {
-         bss_sec = current;
-       }
+       bss_sec = current;
 
 #ifdef I960
       section.s_align = (current->alignment_power
@@ -3621,7 +3546,7 @@ coff_write_object_contents (abfd)
                         : 0);
 #endif
 #ifdef TIC80COFF
-      /* TI COFF puts the alignment power in bits 8-11 of the flags */
+      /* TI COFF puts the alignment power in bits 8-11 of the flags */
       section.s_flags |= (current->alignment_power & 0xF) << 8;
 #endif
 #ifdef COFF_ENCODE_ALIGNMENT
@@ -3643,7 +3568,7 @@ coff_write_object_contents (abfd)
          bfd_size_type amt = bfd_coff_scnhsz (abfd);
 
          if (coff_swap_scnhdr_out (abfd, &section, &buff) == 0
-             || bfd_bwrite ((PTR) &buff, amt, abfd) != amt)
+             || bfd_bwrite (buff, amt, abfd) != amt)
            return FALSE;
        }
 
@@ -3767,7 +3692,7 @@ coff_write_object_contents (abfd)
          scnhdr.s_flags = STYP_OVRFLO;
          amt = bfd_coff_scnhsz (abfd);
          if (coff_swap_scnhdr_out (abfd, &scnhdr, &buff) == 0
-             || bfd_bwrite ((PTR) &buff, amt, abfd) != amt)
+             || bfd_bwrite (buff, amt, abfd) != amt)
            return FALSE;
        }
     }
@@ -3778,14 +3703,11 @@ coff_write_object_contents (abfd)
 
   /* Don't include the internal abs section in the section count */
 
-  /*
-     We will NOT put a fucking timestamp in the header here. Every time you
+  /* We will NOT put a fucking timestamp in the header here. Every time you
      put it back, I will come in and take it out again.  I'm sorry.  This
      field does not belong here.  We fill it with a 0 so it compares the
-     same but is not a reasonable time. -- gnu@cygnus.com
-     */
+     same but is not a reasonable time. -- gnu@cygnus.com  */
   internal_f.f_timdat = 0;
-
   internal_f.f_flags = 0;
 
   if (abfd->flags & EXEC_P)
@@ -3812,9 +3734,13 @@ coff_write_object_contents (abfd)
 #ifdef COFF_IMAGE_WITH_PE
   if (! hasdebug)
     internal_f.f_flags |= IMAGE_FILE_DEBUG_STRIPPED;
+  if (pe_data (abfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE)
+    internal_f.f_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
 #endif
 
-#ifndef COFF_WITH_PE
+#ifdef COFF_WITH_PE
+  internal_f.f_flags |= IMAGE_FILE_32BIT_MACHINE;
+#else
   if (bfd_little_endian (abfd))
     internal_f.f_flags |= F_AR32WR;
   else
@@ -3822,18 +3748,16 @@ coff_write_object_contents (abfd)
 #endif
 
 #ifdef TI_TARGET_ID
-  /* target id is used in TI COFF v1 and later; COFF0 won't use this field,
-     but it doesn't hurt to set it internally */
+  /* Target id is used in TI COFF v1 and later; COFF0 won't use this field,
+     but it doesn't hurt to set it internally */
   internal_f.f_target_id = TI_TARGET_ID;
 #endif
 #ifdef TIC80_TARGET_ID
   internal_f.f_target_id = TIC80_TARGET_ID;
 #endif
 
-  /*
-     FIXME, should do something about the other byte orders and
-     architectures.
-     */
+  /* FIXME, should do something about the other byte orders and
+     architectures.  */
 
 #ifdef RS6000COFF_C
   if ((abfd->flags & DYNAMIC) != 0)
@@ -3844,11 +3768,11 @@ coff_write_object_contents (abfd)
 
   memset (&internal_a, 0, sizeof internal_a);
 
-  /* Set up architecture-dependent stuff */
-
+  /* Set up architecture-dependent stuff.  */
   {
     unsigned int magic = 0;
     unsigned short flags = 0;
+
     coff_set_flags (abfd, &magic, &flags);
     internal_f.f_magic = magic;
     internal_f.f_flags |= flags;
@@ -3857,14 +3781,13 @@ coff_write_object_contents (abfd)
 #ifdef A29K
 #ifdef ULTRA3                  /* NYU's machine */
     /* FIXME: This is a bogus check.  I really want to see if there
-     * is a .shbss or a .shdata section, if so then set the magic
-     * number to indicate a shared data executable.
-     */
+       is a .shbss or a .shdata section, if so then set the magic
+       number to indicate a shared data executable.  */
     if (internal_f.f_nscns >= 7)
-      internal_a.magic = SHMAGIC; /* Shared magic */
+      internal_a.magic = SHMAGIC; /* Shared magic */
     else
 #endif /* ULTRA3 */
-      internal_a.magic = NMAGIC; /* Assume separate i/d */
+      internal_a.magic = NMAGIC; /* Assume separate i/d */
 #define __A_MAGIC_SET__
 #endif /* A29K */
 #ifdef TICOFF_AOUT_MAGIC
@@ -3969,6 +3892,11 @@ coff_write_object_contents (abfd)
     internal_a.magic = NMAGIC; /* Assume separate i/d.  */
 #endif
 
+#ifdef MAXQ20MAGIC
+#define __A_MAGIC_SET__
+      internal_a.magic = MAXQ20MAGIC;
+#endif
 #ifndef __A_MAGIC_SET__
 #include "Your aouthdr magic number is not being set!"
 #else
@@ -3979,16 +3907,13 @@ coff_write_object_contents (abfd)
   /* FIXME: Does anybody ever set this to another value?  */
   internal_a.vstamp = 0;
 
-  /* Now should write relocs, strings, syms */
+  /* Now should write relocs, strings, syms */
   obj_sym_filepos (abfd) = sym_base;
 
   if (bfd_get_symcount (abfd) != 0)
     {
       int firstundef;
-#if 0
-      if (!coff_add_missing_symbols (abfd))
-       return FALSE;
-#endif
+
       if (!coff_renumber_symbols (abfd, &firstundef))
        return FALSE;
       coff_mangle_symbols (abfd);
@@ -4049,17 +3974,17 @@ coff_write_object_contents (abfd)
 
   if (text_sec)
     {
-      internal_a.tsize = bfd_get_section_size_before_reloc (text_sec);
+      internal_a.tsize = text_sec->size;
       internal_a.text_start = internal_a.tsize ? text_sec->vma : 0;
     }
   if (data_sec)
     {
-      internal_a.dsize = bfd_get_section_size_before_reloc (data_sec);
+      internal_a.dsize = data_sec->size;
       internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
     }
   if (bss_sec)
     {
-      internal_a.bsize = bfd_get_section_size_before_reloc (bss_sec);
+      internal_a.bsize = bss_sec->size;
       if (internal_a.bsize && bss_sec->vma < internal_a.data_start)
        internal_a.data_start = bss_sec->vma;
     }
@@ -4138,7 +4063,7 @@ coff_write_object_contents (abfd)
     }
 #endif
 
-  /* now write them */
+  /* Now write them.  */
   if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
     return FALSE;
 
@@ -4150,8 +4075,8 @@ coff_write_object_contents (abfd)
     if (buff == NULL)
       return FALSE;
 
-    bfd_coff_swap_filehdr_out (abfd, (PTR) &internal_f, (PTR) buff);
-    amount = bfd_bwrite ((PTR) buff, amount, abfd);
+    bfd_coff_swap_filehdr_out (abfd, & internal_f, buff);
+    amount = bfd_bwrite (buff, amount, abfd);
 
     free (buff);
 
@@ -4162,7 +4087,7 @@ coff_write_object_contents (abfd)
   if (abfd->flags & EXEC_P)
     {
       /* Note that peicode.h fills in a PEAOUTHDR, not an AOUTHDR.
-        include/coff/pe.h sets AOUTSZ == sizeof (PEAOUTHDR)) */
+        include/coff/pe.h sets AOUTSZ == sizeof (PEAOUTHDR)) */
       char * buff;
       bfd_size_type amount = bfd_coff_aoutsz (abfd);
 
@@ -4170,8 +4095,8 @@ coff_write_object_contents (abfd)
       if (buff == NULL)
        return FALSE;
 
-      coff_swap_aouthdr_out (abfd, (PTR) &internal_a, (PTR) buff);
-      amount = bfd_bwrite ((PTR) buff, amount, abfd);
+      coff_swap_aouthdr_out (abfd, & internal_a, buff);
+      amount = bfd_bwrite (buff, amount, abfd);
 
       free (buff);
 
@@ -4190,12 +4115,12 @@ coff_write_object_contents (abfd)
       size_t size;
 
       /* XCOFF seems to always write at least a small a.out header.  */
-      coff_swap_aouthdr_out (abfd, (PTR) &internal_a, (PTR) &buff);
+      coff_swap_aouthdr_out (abfd, & internal_a, & buff);
       if (xcoff_data (abfd)->full_aouthdr)
        size = bfd_coff_aoutsz (abfd);
       else
        size = SMALL_AOUTSZ;
-      if (bfd_bwrite ((PTR) &buff, (bfd_size_type) size, abfd) != size)
+      if (bfd_bwrite (buff, (bfd_size_type) size, abfd) != size)
        return FALSE;
     }
 #endif
@@ -4204,21 +4129,19 @@ coff_write_object_contents (abfd)
 }
 
 static bfd_boolean
-coff_set_section_contents (abfd, section, location, offset, count)
-     bfd * abfd;
-     sec_ptr section;
-     PTR location;
-     file_ptr offset;
-     bfd_size_type count;
+coff_set_section_contents (bfd * abfd,
+                          sec_ptr section,
+                          const void * location,
+                          file_ptr offset,
+                          bfd_size_type count)
 {
-  if (! abfd->output_has_begun)        /* set by bfd.c handler */
+  if (! abfd->output_has_begun)        /* Set by bfd.c handler.  */
     {
       if (! coff_compute_section_file_positions (abfd))
        return FALSE;
     }
 
 #if defined(_LIB) && !defined(TARG_AUX)
-
    /* The physical address field of a .lib section is used to hold the
       number of shared libraries in the section.  This code counts the
       number of sections being written, and increments the lma field
@@ -4238,8 +4161,7 @@ coff_set_section_contents (abfd, section, location, offset, count)
       code has been tested on ISC 4.1 by me, and on SCO by Robert Lipe
       <robertl@arnet.com> (Thanks!).
 
-      Gvran Uddeborg <gvran@uddeborg.pp.se> */
-
+      Gvran Uddeborg <gvran@uddeborg.pp.se>.  */
     if (strcmp (section->name, _LIB) == 0)
       {
        bfd_byte *rec, *recend;
@@ -4254,7 +4176,6 @@ coff_set_section_contents (abfd, section, location, offset, count)
 
        BFD_ASSERT (rec == recend);
       }
-
 #endif
 
   /* Don't write out bss sections - one way to do this is to
@@ -4270,47 +4191,19 @@ coff_set_section_contents (abfd, section, location, offset, count)
 
   return bfd_bwrite (location, count, abfd) == count;
 }
-#if 0
-static bfd_boolean
-coff_close_and_cleanup (abfd)
-     bfd *abfd;
-{
-  if (!bfd_read_p (abfd))
-    switch (abfd->format)
-      {
-      case bfd_archive:
-       if (!_bfd_write_archive_contents (abfd))
-         return FALSE;
-       break;
-      case bfd_object:
-       if (!coff_write_object_contents (abfd))
-         return FALSE;
-       break;
-      default:
-       bfd_set_error (bfd_error_invalid_operation);
-       return FALSE;
-      }
-
-  /* We depend on bfd_close to free all the memory on the objalloc.  */
-  return TRUE;
-}
-
-#endif
 
-static PTR
-buy_and_read (abfd, where, size)
-     bfd *abfd;
-     file_ptr where;
-     bfd_size_type size;
+static void *
+buy_and_read (bfd *abfd, file_ptr where, bfd_size_type size)
 {
-  PTR area = (PTR) bfd_alloc (abfd, size);
+  void * area = bfd_alloc (abfd, size);
+
   if (!area)
     return (NULL);
   if (bfd_seek (abfd, where, SEEK_SET) != 0
       || bfd_bread (area, size, abfd) != size)
     return (NULL);
   return (area);
-}                              /* buy_and_read() */
+}
 
 /*
 SUBSUBSECTION
@@ -4333,24 +4226,27 @@ SUBSUBSECTION
        pointing its...
 
        How does this work ?
-
 */
 
 static bfd_boolean
-coff_slurp_line_table (abfd, asect)
-     bfd *abfd;
-     asection *asect;
+coff_slurp_line_table (bfd *abfd, asection *asect)
 {
   LINENO *native_lineno;
   alent *lineno_cache;
   bfd_size_type amt;
 
-  BFD_ASSERT (asect->lineno == (alent *) NULL);
+  BFD_ASSERT (asect->lineno == NULL);
 
   amt = (bfd_size_type) bfd_coff_linesz (abfd) * asect->lineno_count;
   native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, amt);
+  if (native_lineno == NULL)
+    {
+      (*_bfd_error_handler)
+        (_("%B: warning: line number table read failed"), abfd);
+      return FALSE;
+    }
   amt = ((bfd_size_type) asect->lineno_count + 1) * sizeof (alent);
-  lineno_cache = (alent *) bfd_alloc (abfd, amt);
+  lineno_cache = bfd_alloc (abfd, amt);
   if (lineno_cache == NULL)
     return FALSE;
   else
@@ -4362,6 +4258,7 @@ coff_slurp_line_table (abfd, asect)
       while (counter < asect->lineno_count)
        {
          struct internal_lineno dst;
+
          bfd_coff_swap_lineno_in (abfd, src, &dst);
          cache_ptr->line_number = dst.l_lnno;
 
@@ -4377,8 +4274,8 @@ coff_slurp_line_table (abfd, asect)
                  || (bfd_vma) symndx >= obj_raw_syment_count (abfd))
                {
                  (*_bfd_error_handler)
-                   (_("%s: warning: illegal symbol index %ld in line numbers"),
-                    bfd_archive_filename (abfd), dst.l_addr.l_symndx);
+                   (_("%B: warning: illegal symbol index %ld in line numbers"),
+                    abfd, dst.l_addr.l_symndx);
                  symndx = 0;
                  warned = TRUE;
                }
@@ -4391,17 +4288,14 @@ coff_slurp_line_table (abfd, asect)
              if (sym->lineno != NULL && ! warned)
                {
                  (*_bfd_error_handler)
-                   (_("%s: warning: duplicate line number information for `%s'"),
-                    bfd_archive_filename (abfd),
-                    bfd_asymbol_name (&sym->symbol));
+                   (_("%B: warning: duplicate line number information for `%s'"),
+                    abfd, bfd_asymbol_name (&sym->symbol));
                }
              sym->lineno = cache_ptr;
            }
          else
-           {
-             cache_ptr->u.offset = dst.l_addr.l_paddr
-               - bfd_section_vma (abfd, asect);
-           }                   /* If no linenumber expect a symbol index */
+           cache_ptr->u.offset = dst.l_addr.l_paddr
+             - bfd_section_vma (abfd, asect);
 
          cache_ptr++;
          src++;
@@ -4420,35 +4314,31 @@ coff_slurp_line_table (abfd, asect)
    symbols via coff_link_add_symbols, rather than via this routine.  */
 
 static bfd_boolean
-coff_slurp_symbol_table (abfd)
-     bfd * abfd;
+coff_slurp_symbol_table (bfd * abfd)
 {
   combined_entry_type *native_symbols;
   coff_symbol_type *cached_area;
   unsigned int *table_ptr;
   bfd_size_type amt;
-
   unsigned int number_of_symbols = 0;
 
   if (obj_symbols (abfd))
     return TRUE;
 
-  /* Read in the symbol table */
+  /* Read in the symbol table */
   if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
-    {
-      return FALSE;
-    }                          /* on error */
+    return FALSE;
 
-  /* Allocate enough room for all the symbols in cached form */
+  /* Allocate enough room for all the symbols in cached form */
   amt = obj_raw_syment_count (abfd);
   amt *= sizeof (coff_symbol_type);
-  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
+  cached_area = bfd_alloc (abfd, amt);
   if (cached_area == NULL)
     return FALSE;
 
   amt = obj_raw_syment_count (abfd);
   amt *= sizeof (unsigned int);
-  table_ptr = (unsigned int *) bfd_alloc (abfd, amt);
+  table_ptr = bfd_alloc (abfd, amt);
 
   if (table_ptr == NULL)
     return FALSE;
@@ -4457,6 +4347,7 @@ coff_slurp_symbol_table (abfd)
       coff_symbol_type *dst = cached_area;
       unsigned int last_native_index = obj_raw_syment_count (abfd);
       unsigned int this_index = 0;
+
       while (this_index < last_native_index)
        {
          combined_entry_type *src = native_symbols + this_index;
@@ -4475,13 +4366,7 @@ coff_slurp_symbol_table (abfd)
            {
 #ifdef I960
            case C_LEAFEXT:
-#if 0
-             dst->symbol.value = src->u.syment.n_value - dst->symbol.section->vma;
-             dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
-             dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
-#endif
-             /* Fall through to next case */
-
+             /* Fall through to next case.  */
 #endif
 
            case C_EXT:
@@ -4494,10 +4379,10 @@ coff_slurp_symbol_table (abfd)
            case C_HIDEXT:
 #endif
 #ifdef C_SYSTEM
-           case C_SYSTEM:      /* System Wide variable */
+           case C_SYSTEM:      /* System Wide variable */
 #endif
 #ifdef COFF_WITH_PE
-            /* In PE, 0x68 (104) denotes a section symbol */
+            /* In PE, 0x68 (104) denotes a section symbol */
             case C_SECTION:
            /* In PE, 0x69 (105) denotes a weak external symbol.  */
            case C_NT_WEAK:
@@ -4515,11 +4400,9 @@ coff_slurp_symbol_table (abfd)
                                       - dst->symbol.section->vma);
 #endif
                  if (ISFCN ((src->u.syment.n_type)))
-                   {
-                     /* A function ext does not go at the end of a
-                        file.  */
-                     dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
-                   }
+                   /* A function ext does not go at the end of a
+                      file.  */
+                   dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
                  break;
 
                case COFF_SYMBOL_COMMON:
@@ -4571,16 +4454,16 @@ coff_slurp_symbol_table (abfd)
 
              break;
 
-           case C_STAT:        /* static                        */
+           case C_STAT:         /* Static.  */
 #ifdef I960
-           case C_LEAFSTAT:    /* static leaf procedure        */
+           case C_LEAFSTAT:     /* Static leaf procedure.  */
 #endif
 #if defined ARM
-            case C_THUMBSTAT:   /* Thumb static                  */
-            case C_THUMBLABEL:  /* Thumb label                   */
-            case C_THUMBSTATFUNC:/* Thumb static function        */
+            case C_THUMBSTAT:    /* Thumb static.  */
+            case C_THUMBLABEL:   /* Thumb label.  */
+            case C_THUMBSTATFUNC:/* Thumb static function.  */
 #endif
-           case C_LABEL:       /* label                         */
+           case C_LABEL:        /* Label.  */
              if (src->u.syment.n_scnum == N_DEBUG)
                dst->symbol.flags = BSF_DEBUGGING;
              else
@@ -4603,35 +4486,35 @@ coff_slurp_symbol_table (abfd)
                dst->symbol.value = src->u.syment.n_value;
              break;
 
-           case C_MOS: /* member of structure   */
-           case C_EOS: /* end of structure              */
-#ifdef NOTDEF                  /* C_AUTOARG has the same value */
+           case C_MOS:         /* Member of structure.  */
+           case C_EOS:         /* End of structure.  */
+#ifdef NOTDEF                  /* C_AUTOARG has the same value */
 #ifdef C_GLBLREG
-           case C_GLBLREG:     /* A29k-specific storage class */
+           case C_GLBLREG:     /* A29k-specific storage class */
 #endif
 #endif
-           case C_REGPARM:     /* register parameter            */
-           case C_REG: /* register variable             */
-              /* C_AUTOARG conflictes with TI COFF C_UEXT */
+           case C_REGPARM:     /* Register parameter.  */
+           case C_REG:         /* register variable.  */
+              /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
 #if !defined (TIC80COFF) && !defined (TICOFF)
 #ifdef C_AUTOARG
-           case C_AUTOARG:     /* 960-specific storage class */
+           case C_AUTOARG:     /* 960-specific storage class */
 #endif
 #endif
-           case C_TPDEF:       /* type definition               */
+           case C_TPDEF:       /* Type definition.  */
            case C_ARG:
-           case C_AUTO:        /* automatic variable */
-           case C_FIELD:       /* bit field */
-           case C_ENTAG:       /* enumeration tag               */
-           case C_MOE: /* member of enumeration         */
-           case C_MOU: /* member of union               */
-           case C_UNTAG:       /* union tag                     */
+           case C_AUTO:        /* Automatic variable.  */
+           case C_FIELD:       /* Bit field.  */
+           case C_ENTAG:       /* Enumeration tag.  */
+           case C_MOE:         /* Member of enumeration.  */
+           case C_MOU:         /* Member of union.  */
+           case C_UNTAG:       /* Union tag.  */
              dst->symbol.flags = BSF_DEBUGGING;
              dst->symbol.value = (src->u.syment.n_value);
              break;
 
-           case C_FILE:        /* file name                     */
-           case C_STRTAG:      /* structure tag                 */
+           case C_FILE:        /* File name.  */
+           case C_STRTAG:      /* Structure tag.  */
 #ifdef RS6000COFF_C
            case C_GSYM:
            case C_LSYM:
@@ -4639,7 +4522,9 @@ coff_slurp_symbol_table (abfd)
            case C_RSYM:
            case C_RPSYM:
            case C_STSYM:
+           case C_TCSYM:
            case C_BCOMM:
+           case C_ECOML:
            case C_ECOMM:
            case C_DECL:
            case C_ENTRY:
@@ -4651,8 +4536,8 @@ coff_slurp_symbol_table (abfd)
              break;
 
 #ifdef RS6000COFF_C
-           case C_BINCL:       /* beginning of include file     */
-           case C_EINCL:       /* ending of include file        */
+           case C_BINCL:       /* Beginning of include file.  */
+           case C_EINCL:       /* Ending of include file.  */
              /* The value is actually a pointer into the line numbers
                  of the file.  We locate the line number entry, and
                  set the section to the section which contains it, and
@@ -4693,9 +4578,9 @@ coff_slurp_symbol_table (abfd)
              break;
 #endif
 
-           case C_BLOCK:       /* ".bb" or ".eb"                */
-           case C_FCN:         /* ".bf" or ".ef" (or PE ".lf")  */
-           case C_EFCN:        /* physical end of function      */
+           case C_BLOCK:       /* ".bb" or ".eb".  */
+           case C_FCN:         /* ".bf" or ".ef" (or PE ".lf").  */
+           case C_EFCN:        /* Physical end of function.  */
 #if defined COFF_WITH_PE
              /* PE sets the symbol to a value relative to the start
                 of the section.  */
@@ -4717,7 +4602,7 @@ coff_slurp_symbol_table (abfd)
 #endif
              break;
 
-           case C_STATLAB:     /* Static load time label */
+           case C_STATLAB:     /* Static load time label */
               dst->symbol.value = src->u.syment.n_value;
               dst->symbol.flags = BSF_GLOBAL;
               break;
@@ -4730,52 +4615,51 @@ coff_slurp_symbol_table (abfd)
                  && src->u.syment.n_scnum == 0)
                break;
              /* Fall through.  */
-           case C_EXTDEF:      /* external definition           */
-           case C_ULABEL:      /* undefined label               */
-           case C_USTATIC:     /* undefined static              */
+           case C_EXTDEF:      /* External definition.  */
+           case C_ULABEL:      /* Undefined label.  */
+           case C_USTATIC:     /* Undefined static.  */
 #ifndef COFF_WITH_PE
             /* C_LINE in regular coff is 0x68.  NT has taken over this storage
-               class to represent a section symbol */
-           case C_LINE:        /* line # reformatted as symbol table entry */
+               class to represent a section symbol */
+           case C_LINE:        /* line # reformatted as symbol table entry */
              /* NT uses 0x67 for a weak symbol, not C_ALIAS.  */
-           case C_ALIAS:       /* duplicate tag                 */
+           case C_ALIAS:       /* Duplicate tag.  */
 #endif
-             /* New storage classes for TI COFF */
+             /* New storage classes for TI COFF */
 #if defined(TIC80COFF) || defined(TICOFF)
-           case C_UEXT:        /* Tentative external definition */
+           case C_UEXT:        /* Tentative external definition */
 #endif
-           case C_EXTLAB:      /* External load time label */
-           case C_HIDDEN:      /* ext symbol in dmert public lib */
+           case C_EXTLAB:      /* External load time label */
+           case C_HIDDEN:      /* Ext symbol in dmert public lib.  */
            default:
              (*_bfd_error_handler)
-               (_("%s: Unrecognized storage class %d for %s symbol `%s'"),
-                bfd_archive_filename (abfd), src->u.syment.n_sclass,
+               (_("%B: Unrecognized storage class %d for %s symbol `%s'"),
+                abfd, src->u.syment.n_sclass,
                 dst->symbol.section->name, dst->symbol.name);
              dst->symbol.flags = BSF_DEBUGGING;
              dst->symbol.value = (src->u.syment.n_value);
              break;
            }
 
-/*      BFD_ASSERT(dst->symbol.flags != 0);*/
-
          dst->native = src;
 
          dst->symbol.udata.i = 0;
-         dst->lineno = (alent *) NULL;
+         dst->lineno = NULL;
          this_index += (src->u.syment.n_numaux) + 1;
          dst++;
          number_of_symbols++;
-       }                       /* walk the native symtab */
-    }                          /* bfdize the native symtab */
+       }
+    }
 
   obj_symbols (abfd) = cached_area;
   obj_raw_syments (abfd) = native_symbols;
 
   bfd_get_symcount (abfd) = number_of_symbols;
   obj_convert (abfd) = table_ptr;
-  /* Slurp the line tables for each section too */
+  /* Slurp the line tables for each section too */
   {
     asection *p;
+
     p = abfd->sections;
     while (p)
       {
@@ -4783,17 +4667,17 @@ coff_slurp_symbol_table (abfd)
        p = p->next;
       }
   }
+
   return TRUE;
-}                              /* coff_slurp_symbol_table() */
+}
 
 /* Classify a COFF symbol.  A couple of targets have globally visible
    symbols which are not class C_EXT, and this handles those.  It also
    recognizes some special PE cases.  */
 
 static enum coff_symbol_classification
-coff_classify_symbol (abfd, syment)
-     bfd *abfd;
-     struct internal_syment *syment;
+coff_classify_symbol (bfd *abfd,
+                     struct internal_syment *syment)
 {
   /* FIXME: This partially duplicates the switch in
      coff_slurp_symbol_table.  */
@@ -4831,18 +4715,15 @@ coff_classify_symbol (abfd, syment)
   if (syment->n_sclass == C_STAT)
     {
       if (syment->n_scnum == 0)
-       {
-         /* The Microsoft compiler sometimes generates these if a
-             small static function is inlined every time it is used.
-             The function is discarded, but the symbol table entry
-             remains.  */
-         return COFF_SYMBOL_LOCAL;
-       }
+       /* The Microsoft compiler sometimes generates these if a
+          small static function is inlined every time it is used.
+          The function is discarded, but the symbol table entry
+          remains.  */
+       return COFF_SYMBOL_LOCAL;
 
 #ifdef STRICT_PE_FORMAT
       /* This is correct for Microsoft generated objects, but it
          breaks gas generated objects.  */
-
       if (syment->n_value == 0)
        {
          asection *sec;
@@ -4873,15 +4754,13 @@ coff_classify_symbol (abfd, syment)
 #endif /* COFF_WITH_PE */
 
   /* If it is not a global symbol, we presume it is a local symbol.  */
-
   if (syment->n_scnum == 0)
     {
       char buf[SYMNMLEN + 1];
 
       (*_bfd_error_handler)
-       (_("warning: %s: local symbol `%s' has no section"),
-        bfd_archive_filename (abfd),
-        _bfd_coff_internal_syment_name (abfd, syment, buf));
+       (_("warning: %B: local symbol `%s' has no section"),
+        abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
     }
 
   return COFF_SYMBOL_LOCAL;
@@ -4912,23 +4791,23 @@ SUBSUBSECTION
        and 960 use the @code{r_type} to directly produce an index
        into a howto table vector; the 88k subtracts a number from the
        @code{r_type} field and creates an addend field.
-
 */
 
 #ifndef CALC_ADDEND
 #define CALC_ADDEND(abfd, ptr, reloc, cache_ptr)                \
   {                                                             \
-    coff_symbol_type *coffsym = (coff_symbol_type *) NULL;      \
+    coff_symbol_type *coffsym = NULL;                          \
+                                                                \
     if (ptr && bfd_asymbol_bfd (ptr) != abfd)                   \
       coffsym = (obj_symbols (abfd)                             \
                  + (cache_ptr->sym_ptr_ptr - symbols));         \
     else if (ptr)                                               \
       coffsym = coff_symbol_from (abfd, ptr);                   \
-    if (coffsym != (coff_symbol_type *) NULL                    \
+    if (coffsym != NULL                                                \
         && coffsym->native->u.syment.n_scnum == 0)              \
       cache_ptr->addend = 0;                                    \
     else if (ptr && bfd_asymbol_bfd (ptr) == abfd               \
-             && ptr->section != (asection *) NULL)              \
+             && ptr->section != NULL)                          \
       cache_ptr->addend = - (ptr->section->vma + ptr->value);   \
     else                                                        \
       cache_ptr->addend = 0;                                    \
@@ -4936,10 +4815,7 @@ SUBSUBSECTION
 #endif
 
 static bfd_boolean
-coff_slurp_reloc_table (abfd, asect, symbols)
-     bfd * abfd;
-     sec_ptr asect;
-     asymbol ** symbols;
+coff_slurp_reloc_table (bfd * abfd, sec_ptr asect, asymbol ** symbols)
 {
   RELOC *native_relocs;
   arelent *reloc_cache;
@@ -4955,10 +4831,11 @@ coff_slurp_reloc_table (abfd, asect, symbols)
     return TRUE;
   if (!coff_slurp_symbol_table (abfd))
     return FALSE;
+
   amt = (bfd_size_type) bfd_coff_relsz (abfd) * asect->reloc_count;
   native_relocs = (RELOC *) buy_and_read (abfd, asect->rel_filepos, amt);
   amt = (bfd_size_type) asect->reloc_count * sizeof (arelent);
-  reloc_cache = (arelent *) bfd_alloc (abfd, amt);
+  reloc_cache = bfd_alloc (abfd, amt);
 
   if (reloc_cache == NULL)
     return FALSE;
@@ -4986,8 +4863,8 @@ coff_slurp_reloc_table (abfd, asect, symbols)
          if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd))
            {
              (*_bfd_error_handler)
-               (_("%s: warning: illegal symbol index %ld in relocs"),
-                bfd_archive_filename (abfd), dst.r_symndx);
+               (_("%B: warning: illegal symbol index %ld in relocs"),
+                abfd, dst.r_symndx);
              cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
              ptr = NULL;
            }
@@ -5009,23 +4886,23 @@ coff_slurp_reloc_table (abfd, asect, symbols)
         refering to the symbols in the raw data have not been
         modified, so we have to have a negative addend to compensate.
 
-        Note that symbols which used to be common must be left alone */
+        Note that symbols which used to be common must be left alone */
 
-      /* Calculate any reloc addend by looking at the symbol */
+      /* Calculate any reloc addend by looking at the symbol */
       CALC_ADDEND (abfd, ptr, dst, cache_ptr);
 
       cache_ptr->address -= asect->vma;
-/* !!     cache_ptr->section = (asection *) NULL;*/
+      /* !! cache_ptr->section = NULL;*/
 
-      /* Fill in the cache_ptr->howto field from dst.r_type */
+      /* Fill in the cache_ptr->howto field from dst.r_type */
       RTYPE2HOWTO (cache_ptr, &dst);
 #endif /* RELOC_PROCESSING */
 
       if (cache_ptr->howto == NULL)
        {
          (*_bfd_error_handler)
-           (_("%s: illegal relocation type %d at address 0x%lx"),
-            bfd_archive_filename (abfd), dst.r_type, (long) dst.r_vaddr);
+           (_("%B: illegal relocation type %d at address 0x%lx"),
+            abfd, dst.r_type, (long) dst.r_vaddr);
          bfd_set_error (bfd_error_bad_value);
          return FALSE;
        }
@@ -5044,20 +4921,13 @@ coff_slurp_reloc_table (abfd, asect, symbols)
    always work.  It is the responsibility of the including file to
    make sure it is reasonable if it is needed.  */
 
-static reloc_howto_type *coff_rtype_to_howto
-  PARAMS ((bfd *, asection *, struct internal_reloc *,
-          struct coff_link_hash_entry *, struct internal_syment *,
-          bfd_vma *));
-
-/*ARGSUSED*/
 static reloc_howto_type *
-coff_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec ATTRIBUTE_UNUSED;
-     struct internal_reloc *rel;
-     struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
-     struct internal_syment *sym ATTRIBUTE_UNUSED;
-     bfd_vma *addendp ATTRIBUTE_UNUSED;
+coff_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+                    asection *sec ATTRIBUTE_UNUSED,
+                    struct internal_reloc *rel,
+                    struct coff_link_hash_entry *h ATTRIBUTE_UNUSED,
+                    struct internal_syment *sym ATTRIBUTE_UNUSED,
+                    bfd_vma *addendp ATTRIBUTE_UNUSED)
 {
   arelent genrel;
 
@@ -5073,28 +4943,28 @@ coff_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
 #endif /* ! defined (coff_rtype_to_howto) */
 
 /* This is stupid.  This function should be a boolean predicate.  */
+
 static long
-coff_canonicalize_reloc (abfd, section, relptr, symbols)
-     bfd * abfd;
-     sec_ptr section;
-     arelent ** relptr;
-     asymbol ** symbols;
+coff_canonicalize_reloc (bfd * abfd,
+                        sec_ptr section,
+                        arelent ** relptr,
+                        asymbol ** symbols)
 {
   arelent *tblptr = section->relocation;
   unsigned int count = 0;
 
   if (section->flags & SEC_CONSTRUCTOR)
     {
-      /* this section has relocs made up by us, they are not in the
-       file, so take them out of their chain and place them into
-       the data area provided */
+      /* This section has relocs made up by us, they are not in the
+        file, so take them out of their chain and place them into
+        the data area provided.  */
       arelent_chain *chain = section->constructor_chain;
+
       for (count = 0; count < section->reloc_count; count++)
        {
          *relptr++ = &chain->relent;
          chain = chain->next;
        }
-
     }
   else
     {
@@ -5110,29 +4980,15 @@ coff_canonicalize_reloc (abfd, section, relptr, symbols)
   return section->reloc_count;
 }
 
-#ifdef GNU960
-file_ptr
-coff_sym_filepos (abfd)
-     bfd *abfd;
-{
-  return obj_sym_filepos (abfd);
-}
-#endif
-
 #ifndef coff_reloc16_estimate
 #define coff_reloc16_estimate dummy_reloc16_estimate
 
-static int dummy_reloc16_estimate
-  PARAMS ((bfd *, asection *, arelent *, unsigned int,
-          struct bfd_link_info *));
-
 static int
-dummy_reloc16_estimate (abfd, input_section, reloc, shrink, link_info)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *input_section ATTRIBUTE_UNUSED;
-     arelent *reloc ATTRIBUTE_UNUSED;
-     unsigned int shrink ATTRIBUTE_UNUSED;
-     struct bfd_link_info *link_info ATTRIBUTE_UNUSED;
+dummy_reloc16_estimate (bfd *abfd ATTRIBUTE_UNUSED,
+                       asection *input_section ATTRIBUTE_UNUSED,
+                       arelent *reloc ATTRIBUTE_UNUSED,
+                       unsigned int shrink ATTRIBUTE_UNUSED,
+                       struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
 {
   abort ();
   return 0;
@@ -5146,20 +5002,14 @@ dummy_reloc16_estimate (abfd, input_section, reloc, shrink, link_info)
 
 /* This works even if abort is not declared in any header file.  */
 
-static void dummy_reloc16_extra_cases
-  PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
-          bfd_byte *, unsigned int *, unsigned int *));
-
 static void
-dummy_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
-                          dst_ptr)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *link_info ATTRIBUTE_UNUSED;
-     struct bfd_link_order *link_order ATTRIBUTE_UNUSED;
-     arelent *reloc ATTRIBUTE_UNUSED;
-     bfd_byte *data ATTRIBUTE_UNUSED;
-     unsigned int *src_ptr ATTRIBUTE_UNUSED;
-     unsigned int *dst_ptr ATTRIBUTE_UNUSED;
+dummy_reloc16_extra_cases (bfd *abfd ATTRIBUTE_UNUSED,
+                          struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
+                          struct bfd_link_order *link_order ATTRIBUTE_UNUSED,
+                          arelent *reloc ATTRIBUTE_UNUSED,
+                          bfd_byte *data ATTRIBUTE_UNUSED,
+                          unsigned int *src_ptr ATTRIBUTE_UNUSED,
+                          unsigned int *dst_ptr ATTRIBUTE_UNUSED)
 {
   abort ();
 }
@@ -5171,7 +5021,9 @@ dummy_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
 
 /* If coff_relocate_section is defined, we can use the optimized COFF
    backend linker.  Otherwise we must continue to use the old linker.  */
+
 #ifdef coff_relocate_section
+
 #ifndef coff_bfd_link_hash_table_create
 #define coff_bfd_link_hash_table_create _bfd_coff_link_hash_table_create
 #endif
@@ -5181,7 +5033,9 @@ dummy_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
 #ifndef coff_bfd_final_link
 #define coff_bfd_final_link _bfd_coff_final_link
 #endif
+
 #else /* ! defined (coff_relocate_section) */
+
 #define coff_relocate_section NULL
 #ifndef coff_bfd_link_hash_table_create
 #define coff_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
@@ -5190,9 +5044,10 @@ dummy_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
 #define coff_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #endif
 #define coff_bfd_final_link _bfd_generic_final_link
+
 #endif /* ! defined (coff_relocate_section) */
 
-#define coff_bfd_link_just_syms _bfd_generic_link_just_syms
+#define coff_bfd_link_just_syms      _bfd_generic_link_just_syms
 #define coff_bfd_link_split_section  _bfd_generic_link_split_section
 
 #ifndef coff_start_final_link
@@ -5209,13 +5064,9 @@ dummy_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
 
 #ifndef coff_link_output_has_begun
 
-static bfd_boolean coff_link_output_has_begun
-  PARAMS ((bfd *, struct coff_final_link_info *));
-
 static bfd_boolean
-coff_link_output_has_begun (abfd, info)
-     bfd * abfd;
-     struct coff_final_link_info * info ATTRIBUTE_UNUSED;
+coff_link_output_has_begun (bfd * abfd,
+                           struct coff_final_link_info * info ATTRIBUTE_UNUSED)
 {
   return abfd->output_has_begun;
 }
@@ -5223,13 +5074,9 @@ coff_link_output_has_begun (abfd, info)
 
 #ifndef coff_final_link_postscript
 
-static bfd_boolean coff_final_link_postscript
-  PARAMS ((bfd *, struct coff_final_link_info *));
-
 static bfd_boolean
-coff_final_link_postscript (abfd, pfinfo)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     struct coff_final_link_info * pfinfo ATTRIBUTE_UNUSED;
+coff_final_link_postscript (bfd * abfd ATTRIBUTE_UNUSED,
+                           struct coff_final_link_info * pfinfo ATTRIBUTE_UNUSED)
 {
   return TRUE;
 }
@@ -5278,7 +5125,7 @@ coff_final_link_postscript (abfd, pfinfo)
 #define coff_SWAP_scnhdr_in coff_swap_scnhdr_in
 #endif
 
-static const bfd_coff_backend_data bfd_coff_std_swap_table =
+static const bfd_coff_backend_data bfd_coff_std_swap_table ATTRIBUTE_UNUSED =
 {
   coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
   coff_SWAP_aux_out, coff_SWAP_sym_out,
@@ -5318,6 +5165,94 @@ static const bfd_coff_backend_data bfd_coff_std_swap_table =
   coff_link_output_has_begun, coff_final_link_postscript
 };
 
+#ifdef TICOFF
+/* COFF0 differs in file/section header size and relocation entry size.  */
+
+static const bfd_coff_backend_data ticoff0_swap_table =
+{
+  coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
+  coff_SWAP_aux_out, coff_SWAP_sym_out,
+  coff_SWAP_lineno_out, coff_SWAP_reloc_out,
+  coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out,
+  coff_SWAP_scnhdr_out,
+  FILHSZ_V0, AOUTSZ, SCNHSZ_V01, SYMESZ, AUXESZ, RELSZ_V0, LINESZ, FILNMLEN,
+#ifdef COFF_LONG_FILENAMES
+  TRUE,
+#else
+  FALSE,
+#endif
+#ifdef COFF_LONG_SECTION_NAMES
+  TRUE,
+#else
+  FALSE,
+#endif
+  COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
+#ifdef COFF_FORCE_SYMBOLS_IN_STRINGS
+  TRUE,
+#else
+  FALSE,
+#endif
+#ifdef COFF_DEBUG_STRING_WIDE_PREFIX
+  4,
+#else
+  2,
+#endif
+  coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in,
+  coff_SWAP_reloc_in, ticoff0_bad_format_hook, coff_set_arch_mach_hook,
+  coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
+  coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
+  coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
+  coff_classify_symbol, coff_compute_section_file_positions,
+  coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
+  coff_adjust_symndx, coff_link_add_one_symbol,
+  coff_link_output_has_begun, coff_final_link_postscript
+};
+#endif
+
+#ifdef TICOFF
+/* COFF1 differs in section header size.  */
+
+static const bfd_coff_backend_data ticoff1_swap_table =
+{
+  coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
+  coff_SWAP_aux_out, coff_SWAP_sym_out,
+  coff_SWAP_lineno_out, coff_SWAP_reloc_out,
+  coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out,
+  coff_SWAP_scnhdr_out,
+  FILHSZ, AOUTSZ, SCNHSZ_V01, SYMESZ, AUXESZ, RELSZ, LINESZ, FILNMLEN,
+#ifdef COFF_LONG_FILENAMES
+  TRUE,
+#else
+  FALSE,
+#endif
+#ifdef COFF_LONG_SECTION_NAMES
+  TRUE,
+#else
+  FALSE,
+#endif
+  COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
+#ifdef COFF_FORCE_SYMBOLS_IN_STRINGS
+  TRUE,
+#else
+  FALSE,
+#endif
+#ifdef COFF_DEBUG_STRING_WIDE_PREFIX
+  4,
+#else
+  2,
+#endif
+  coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in,
+  coff_SWAP_reloc_in, ticoff1_bad_format_hook, coff_set_arch_mach_hook,
+  coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
+  coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
+  coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
+  coff_classify_symbol, coff_compute_section_file_positions,
+  coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
+  coff_adjust_symndx, coff_link_add_one_symbol,
+  coff_link_output_has_begun, coff_final_link_postscript
+};
+#endif
+
 #ifndef coff_close_and_cleanup
 #define        coff_close_and_cleanup              _bfd_generic_close_and_cleanup
 #endif
@@ -5334,6 +5269,10 @@ static const bfd_coff_backend_data bfd_coff_std_swap_table =
 #define coff_bfd_copy_private_symbol_data   _bfd_generic_bfd_copy_private_symbol_data
 #endif
 
+#ifndef coff_bfd_copy_private_header_data
+#define coff_bfd_copy_private_header_data   _bfd_generic_bfd_copy_private_header_data
+#endif
+
 #ifndef coff_bfd_copy_private_section_data
 #define coff_bfd_copy_private_section_data  _bfd_generic_bfd_copy_private_section_data
 #endif
@@ -5358,6 +5297,10 @@ static const bfd_coff_backend_data bfd_coff_std_swap_table =
 #define coff_bfd_is_local_label_name       _bfd_coff_is_local_label_name
 #endif
 
+#ifndef coff_bfd_is_target_special_symbol
+#define coff_bfd_is_target_special_symbol   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#endif
+
 #ifndef coff_read_minisymbols
 #define coff_read_minisymbols              _bfd_generic_read_minisymbols
 #endif
@@ -5389,25 +5332,84 @@ static const bfd_coff_backend_data bfd_coff_std_swap_table =
 #define coff_bfd_merge_sections                    bfd_generic_merge_sections
 #endif
 
+#ifndef coff_bfd_is_group_section
+#define coff_bfd_is_group_section          bfd_generic_is_group_section
+#endif
+
 #ifndef coff_bfd_discard_group
 #define coff_bfd_discard_group             bfd_generic_discard_group
 #endif
 
-#define CREATE_BIG_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE)        \
+#ifndef coff_section_already_linked
+#define coff_section_already_linked \
+  _bfd_generic_section_already_linked
+#endif
+
+#define CREATE_BIG_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE)    \
+const bfd_target VAR =                                                 \
+{                                                                      \
+  NAME ,                                                               \
+  bfd_target_coff_flavour,                                             \
+  BFD_ENDIAN_BIG,              /* Data byte order is big.  */          \
+  BFD_ENDIAN_BIG,              /* Header byte order is big.  */        \
+  /* object flags */                                                   \
+  (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG |                       \
+   HAS_SYMS | HAS_LOCALS | WP_TEXT | EXTRA_O_FLAGS),                   \
+  /* section flags */                                                  \
+  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | EXTRA_S_FLAGS),\
+  UNDER,                       /* Leading symbol underscore.  */       \
+  '/',                         /* AR_pad_char.  */                     \
+  15,                          /* AR_max_namelen.  */                  \
+                                                                       \
+  /* Data conversion functions.  */                                    \
+  bfd_getb64, bfd_getb_signed_64, bfd_putb64,                          \
+  bfd_getb32, bfd_getb_signed_32, bfd_putb32,                          \
+  bfd_getb16, bfd_getb_signed_16, bfd_putb16,                          \
+                                                                       \
+  /* Header conversion functions.  */                                  \
+  bfd_getb64, bfd_getb_signed_64, bfd_putb64,                          \
+  bfd_getb32, bfd_getb_signed_32, bfd_putb32,                          \
+  bfd_getb16, bfd_getb_signed_16, bfd_putb16,                          \
+                                                                       \
+       /* bfd_check_format.  */                                        \
+  { _bfd_dummy_target, coff_object_p, bfd_generic_archive_p,           \
+    _bfd_dummy_target },                                               \
+       /* bfd_set_format.  */                                          \
+  { bfd_false, coff_mkobject, _bfd_generic_mkarchive, bfd_false },     \
+       /* bfd_write_contents.  */                                      \
+  { bfd_false, coff_write_object_contents, _bfd_write_archive_contents,        \
+    bfd_false },                                                       \
+                                                                       \
+  BFD_JUMP_TABLE_GENERIC (coff),                                       \
+  BFD_JUMP_TABLE_COPY (coff),                                          \
+  BFD_JUMP_TABLE_CORE (_bfd_nocore),                                   \
+  BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),                          \
+  BFD_JUMP_TABLE_SYMBOLS (coff),                                       \
+  BFD_JUMP_TABLE_RELOCS (coff),                                                \
+  BFD_JUMP_TABLE_WRITE (coff),                                         \
+  BFD_JUMP_TABLE_LINK (coff),                                          \
+  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),                             \
+                                                                       \
+  ALTERNATIVE,                                                         \
+                                                                       \
+  SWAP_TABLE                                                           \
+};
+
+#define CREATE_BIGHDR_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE) \
 const bfd_target VAR =                                                 \
 {                                                                      \
   NAME ,                                                               \
   bfd_target_coff_flavour,                                             \
-  BFD_ENDIAN_BIG,              /* data byte order is big */            \
-  BFD_ENDIAN_BIG,              /* header byte order is big */          \
+  BFD_ENDIAN_LITTLE,           /* Data byte order is little.  */       \
+  BFD_ENDIAN_BIG,              /* Header byte order is big.  */        \
   /* object flags */                                                   \
   (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG |                       \
    HAS_SYMS | HAS_LOCALS | WP_TEXT | EXTRA_O_FLAGS),                   \
   /* section flags */                                                  \
   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | EXTRA_S_FLAGS),\
-  UNDER,                       /* leading symbol underscore */         \
-  '/',                         /* ar_pad_char */                       \
-  15,                          /* ar_max_namelen */                    \
+  UNDER,                       /* Leading symbol underscore.  */       \
+  '/',                         /* AR_pad_char.  */                     \
+  15,                          /* AR_max_namelen.  */                  \
                                                                        \
   /* Data conversion functions.  */                                    \
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,                          \
@@ -5419,12 +5421,12 @@ const bfd_target VAR =                                                  \
   bfd_getb32, bfd_getb_signed_32, bfd_putb32,                          \
   bfd_getb16, bfd_getb_signed_16, bfd_putb16,                          \
                                                                        \
-       /* bfd_check_format */                                          \
+       /* bfd_check_format.  */                                        \
   { _bfd_dummy_target, coff_object_p, bfd_generic_archive_p,           \
     _bfd_dummy_target },                                               \
-       /* bfd_set_format */                                            \
+       /* bfd_set_format.  */                                          \
   { bfd_false, coff_mkobject, _bfd_generic_mkarchive, bfd_false },     \
-       /* bfd_write_contents */                                        \
+       /* bfd_write_contents.  */                                      \
   { bfd_false, coff_write_object_contents, _bfd_write_archive_contents,        \
     bfd_false },                                                       \
                                                                        \
@@ -5440,24 +5442,24 @@ const bfd_target VAR =                                                  \
                                                                        \
   ALTERNATIVE,                                                         \
                                                                        \
-  COFF_SWAP_TABLE                                                      \
+  SWAP_TABLE                                                           \
 };
 
-#define CREATE_LITTLE_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE)     \
+#define CREATE_LITTLE_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE) \
 const bfd_target VAR =                                                 \
 {                                                                      \
   NAME ,                                                               \
   bfd_target_coff_flavour,                                             \
-  BFD_ENDIAN_LITTLE,           /* data byte order is little */         \
-  BFD_ENDIAN_LITTLE,           /* header byte order is little */       \
+  BFD_ENDIAN_LITTLE,           /* Data byte order is little.  */       \
+  BFD_ENDIAN_LITTLE,           /* Header byte order is little.  */     \
        /* object flags */                                              \
   (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG |                       \
    HAS_SYMS | HAS_LOCALS | WP_TEXT | EXTRA_O_FLAGS),                   \
        /* section flags */                                             \
   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | EXTRA_S_FLAGS),\
-  UNDER,                       /* leading symbol underscore */         \
-  '/',                         /* ar_pad_char */                       \
-  15,                          /* ar_max_namelen */                    \
+  UNDER,                       /* Leading symbol underscore.  */       \
+  '/',                         /* AR_pad_char.  */                     \
+  15,                          /* AR_max_namelen.  */                  \
                                                                        \
   /* Data conversion functions.  */                                    \
   bfd_getl64, bfd_getl_signed_64, bfd_putl64,                          \
@@ -5467,12 +5469,12 @@ const bfd_target VAR =                                                  \
   bfd_getl64, bfd_getl_signed_64, bfd_putl64,                          \
   bfd_getl32, bfd_getl_signed_32, bfd_putl32,                          \
   bfd_getl16, bfd_getl_signed_16, bfd_putl16,                          \
-       /* bfd_check_format */                                          \
+       /* bfd_check_format.  */                                        \
   { _bfd_dummy_target, coff_object_p, bfd_generic_archive_p,           \
     _bfd_dummy_target },                                               \
-       /* bfd_set_format */                                            \
+       /* bfd_set_format.  */                                          \
   { bfd_false, coff_mkobject, _bfd_generic_mkarchive, bfd_false },     \
-       /* bfd_write_contents */                                        \
+       /* bfd_write_contents.  */                                      \
   { bfd_false, coff_write_object_contents, _bfd_write_archive_contents,        \
     bfd_false },                                                       \
                                                                        \
@@ -5488,5 +5490,5 @@ const bfd_target VAR =                                                    \
                                                                        \
   ALTERNATIVE,                                                         \
                                                                        \
-  COFF_SWAP_TABLE                                                      \
+  SWAP_TABLE                                                           \
 };