Add `_finalizer' to the list of known GNAT auxilary routines.
[deliverable/binutils-gdb.git] / binutils / srconv.c
index 8b0f2b7b5ee0265af53cf20c9de4e29352a8d3f0..c288fd5df85d19c6863c2d644a4968dad75384ff 100644 (file)
@@ -1,11 +1,12 @@
 /* srconv.c -- Sysroff conversion program
 /* srconv.c -- Sysroff conversion program
-   Copyright (C) 1994, 95, 96, 98, 1999 Free Software Foundation, Inc.
+   Copyright 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+   2005, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This file is part of GNU Binutils.
 
    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
 
    This file is part of GNU Binutils.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -15,8 +16,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
 
 /* Written by Steve Chamberlain (sac@cygnus.com)
 
 
 /* Written by Steve Chamberlain (sac@cygnus.com)
 
 
    All debugging information is preserved */
 
 
    All debugging information is preserved */
 
-#include <bfd.h>
+#include "sysdep.h"
+#include "bfd.h"
 #include "bucomm.h"
 #include "sysroff.h"
 #include "coffgrok.h"
 #include "bucomm.h"
 #include "sysroff.h"
 #include "coffgrok.h"
-#include <libiberty.h>
-#include <getopt.h>
+#include "libiberty.h"
+#include "getopt.h"
 
 #include "coff/internal.h"
 #include "../bfd/libcoff.h"
 
 
 #include "coff/internal.h"
 #include "../bfd/libcoff.h"
 
-#define PROGRAM_VERSION "1.5"
 /*#define FOOP1 1 */
 
 static int addrsize;
 static char *toolname;
 static char **rnames;
 
 /*#define FOOP1 1 */
 
 static int addrsize;
 static char *toolname;
 static char **rnames;
 
-static void wr_cs ();
-static void walk_tree_scope ();
-static void wr_globals ();
-static int find_base ();
+static int get_member_id (int);
+static int get_ordinary_id (int);
+static char *section_translate (char *);
+static char *strip_suffix (const char *);
+static void checksum (FILE *, unsigned char *, int, int);
+static void writeINT (int, unsigned char *, int *, int, FILE *);
+static void writeBITS (int, unsigned char *, int *, int);
+static void writeBARRAY (barray, unsigned char *, int *, int, FILE *);
+static void writeCHARS (char *, unsigned char *, int *, int, FILE *);
+static void wr_tr (void);
+static void wr_un (struct coff_ofile *, struct coff_sfile *, int, int);
+static void wr_hd (struct coff_ofile *);
+static void wr_sh (struct coff_ofile *, struct coff_section *);
+static void wr_ob (struct coff_ofile *, struct coff_section *);
+static void wr_rl (struct coff_ofile *, struct coff_section *);
+static void wr_object_body (struct coff_ofile *);
+static void wr_dps_start
+  (struct coff_sfile *, struct coff_section *, struct coff_scope *, int, int);
+static void wr_dps_end (struct coff_section *, struct coff_scope *, int);
+static int *nints (int);
+static void walk_tree_type_1
+  (struct coff_sfile *, struct coff_symbol *, struct coff_type *, int);
+static void walk_tree_type
+  (struct coff_sfile *, struct coff_symbol *, struct coff_type *, int);
+static void walk_tree_symbol
+  (struct coff_sfile *, struct coff_section *, struct coff_symbol *, int);
+static void walk_tree_scope
+  (struct coff_section *, struct coff_sfile *, struct coff_scope *, int, int);
+static void walk_tree_sfile (struct coff_section *, struct coff_sfile *);
+static void wr_program_structure (struct coff_ofile *, struct coff_sfile *);
+static void wr_du (struct coff_ofile *, struct coff_sfile *, int);
+static void wr_dus (struct coff_ofile *, struct coff_sfile *);
+static int find_base (struct coff_sfile *, struct coff_section *);
+static void wr_dln (struct coff_ofile *, struct coff_sfile *, int);
+static void wr_globals (struct coff_ofile *, struct coff_sfile *, int);
+static void wr_debug (struct coff_ofile *);
+static void wr_cs (void);
+static int wr_sc (struct coff_ofile *, struct coff_sfile *);
+static void wr_er (struct coff_ofile *, struct coff_sfile *, int);
+static void wr_ed (struct coff_ofile *, struct coff_sfile *, int);
+static void wr_unit_info (struct coff_ofile *);
+static void wr_module (struct coff_ofile *);
+static int align (int);
+static void prescan (struct coff_ofile *);
+static void show_usage (FILE *, int);
+extern int main (int, char **);
 
 static FILE *file;
 static bfd *abfd;
 
 static FILE *file;
 static bfd *abfd;
@@ -53,7 +96,7 @@ static int debug = 0;
 static int quick = 0;
 static int noprescan = 0;
 static struct coff_ofile *tree;
 static int quick = 0;
 static int noprescan = 0;
 static struct coff_ofile *tree;
-/* Obsolete ?? 
+/* Obsolete ??
    static int absolute_p;
  */
 
    static int absolute_p;
  */
 
@@ -67,31 +110,26 @@ static int base1 = 0x18;
 static int base2 = 0x2018;
 
 static int
 static int base2 = 0x2018;
 
 static int
-get_member_id (x)
-     int x;
+get_member_id (int x)
 {
   if (ids2[x])
 {
   if (ids2[x])
-    {
-      return ids2[x];
-    }
+    return ids2[x];
+
   ids2[x] = base2++;
   return ids2[x];
 }
 
 static int
   ids2[x] = base2++;
   return ids2[x];
 }
 
 static int
-get_ordinary_id (x)
-     int x;
+get_ordinary_id (int x)
 {
   if (ids1[x])
 {
   if (ids1[x])
-    {
-      return ids1[x];
-    }
+    return ids1[x];
+
   ids1[x] = base1++;
   return ids1[x];
 }
 static char *
   ids1[x] = base1++;
   return ids1[x];
 }
 static char *
-section_translate (n)
-     char *n;
+section_translate (char *n)
 {
   if (strcmp (n, ".text") == 0)
     return "P";
 {
   if (strcmp (n, ".text") == 0)
     return "P";
@@ -102,18 +140,14 @@ section_translate (n)
   return n;
 }
 
   return n;
 }
 
-
-
 #define DATE "940201073000";   /* Just a time on my birthday */
 
 #define DATE "940201073000";   /* Just a time on my birthday */
 
-
-static
-char *
-strip_suffix (name)
-     char *name;
+static char *
+strip_suffix (const char *name)
 {
   int i;
   char *res;
 {
   int i;
   char *res;
+
   for (i = 0; name[i] != 0 && name[i] != '.'; i++)
     ;
   res = (char *) xmalloc (i + 1);
   for (i = 0; name[i] != 0 && name[i] != '.'; i++)
     ;
   res = (char *) xmalloc (i + 1);
@@ -122,44 +156,34 @@ strip_suffix (name)
   return res;
 }
 
   return res;
 }
 
-
 /* IT LEN stuff CS */
 static void
 /* IT LEN stuff CS */
 static void
-checksum (file, ptr, size, code)
-     FILE *file;
-     char *ptr;
-     int size;
-     int code;
+checksum (FILE *ffile, unsigned char *ptr, int size, int ccode)
 {
   int j;
   int last;
   int sum = 0;
   int bytes = size / 8;
 {
   int j;
   int last;
   int sum = 0;
   int bytes = size / 8;
-  last = !(code & 0xff00);
+
+  last = !(ccode & 0xff00);
   if (size & 0x7)
     abort ();
   if (size & 0x7)
     abort ();
-  ptr[0] = code | (last ? 0x80 : 0);
+  ptr[0] = ccode | (last ? 0x80 : 0);
   ptr[1] = bytes + 1;
 
   for (j = 0; j < bytes; j++)
   ptr[1] = bytes + 1;
 
   for (j = 0; j < bytes; j++)
-    {
-      sum += ptr[j];
-    }
-  /* Glue on a checksum too */
+    sum += ptr[j];
+
+  /* Glue on a checksum too.  */
   ptr[bytes] = ~sum;
   ptr[bytes] = ~sum;
-  fwrite (ptr, bytes + 1, 1, file);
+  if (fwrite (ptr, bytes + 1, 1, ffile) != 1)
+    /* FIXME: Return error status.  */
+    abort ();
 }
 
 
 }
 
 
-
-
 static void
 static void
-writeINT (n, ptr, idx, size, file)
-     int n;
-     char *ptr;
-     int *idx;
-     int size;
-     FILE *file;
+writeINT (int n, unsigned char *ptr, int *idx, int size, FILE *ffile)
 {
   int byte = *idx / 8;
 
 {
   int byte = *idx / 8;
 
@@ -170,11 +194,12 @@ writeINT (n, ptr, idx, size, file)
 
   if (byte > 240)
     {
 
   if (byte > 240)
     {
-      /* Lets write out that record and do another one */
-      checksum (file, ptr, *idx, code | 0x1000);
+      /* Lets write out that record and do another one */
+      checksum (ffile, ptr, *idx, code | 0x1000);
       *idx = 16;
       byte = *idx / 8;
     }
       *idx = 16;
       byte = *idx / 8;
     }
+
   switch (size)
     {
     case 0:
   switch (size)
     {
     case 0:
@@ -198,70 +223,55 @@ writeINT (n, ptr, idx, size, file)
   *idx += size * 8;
 }
 
   *idx += size * 8;
 }
 
-
 static void
 static void
-writeBITS (val, ptr, idx, size)
-     int val;
-     char *ptr;
-     int *idx;
-     int size;
+writeBITS (int val, unsigned char *ptr, int *idx, int size)
 {
   int byte = *idx / 8;
   int bit = *idx % 8;
   int old;
 {
   int byte = *idx / 8;
   int bit = *idx % 8;
   int old;
+
   *idx += size;
 
   old = ptr[byte];
   *idx += size;
 
   old = ptr[byte];
-  /* Turn off all about to change bits */
+  /* Turn off all about to change bits */
   old &= ~((~0 >> (8 - bit - size)) & ((1 << size) - 1));
   old &= ~((~0 >> (8 - bit - size)) & ((1 << size) - 1));
-  /* Turn on the bits we want */
+  /* Turn on the bits we want */
   old |= (val & ((1 << size) - 1)) << (8 - bit - size);
   ptr[byte] = old;
 }
 
 static void
   old |= (val & ((1 << size) - 1)) << (8 - bit - size);
   ptr[byte] = old;
 }
 
 static void
-writeBARRAY (data, ptr, idx, size, file)
-     barray data;
-     char *ptr;
-     int *idx;
-     int size;
-     FILE *file;
+writeBARRAY (barray data, unsigned char *ptr, int *idx,
+            int size ATTRIBUTE_UNUSED, FILE *ffile)
 {
   int i;
 {
   int i;
-  writeINT (data.len, ptr, idx, 1, file);
+
+  writeINT (data.len, ptr, idx, 1, ffile);
   for (i = 0; i < data.len; i++)
   for (i = 0; i < data.len; i++)
-    {
-      writeINT (data.data[i], ptr, idx, 1, file);
-    }
+    writeINT (data.data[i], ptr, idx, 1, ffile);
 }
 
 }
 
-
 static void
 static void
-writeCHARS (string, ptr, idx, size, file)
-     char *string;
-     char *ptr;
-     int *idx;
-     int size;
-     FILE *file;
+writeCHARS (char *string, unsigned char *ptr, int *idx, int size, FILE *ffile)
 {
   int i = *idx / 8;
 
   if (i > 240)
     {
 {
   int i = *idx / 8;
 
   if (i > 240)
     {
-      /* Lets write out that record and do another one */
-      checksum (file, ptr, *idx, code | 0x1000);
+      /* Lets write out that record and do another one */
+      checksum (ffile, ptr, *idx, code | 0x1000);
       *idx = 16;
       i = *idx / 8;
     }
 
   if (size == 0)
     {
       *idx = 16;
       i = *idx / 8;
     }
 
   if (size == 0)
     {
-      /* Variable length string */
+      /* Variable length string */
       size = strlen (string);
       ptr[i++] = size;
     }
 
       size = strlen (string);
       ptr[i++] = size;
     }
 
-  /* BUG WAITING TO HAPPEN */
+  /* BUG WAITING TO HAPPEN */
   memcpy (ptr + i, string, size);
   i += size;
   *idx = i * 8;
   memcpy (ptr + i, string, size);
   i += size;
   *idx = i * 8;
@@ -270,7 +280,6 @@ writeCHARS (string, ptr, idx, size, file)
 #define SYSROFF_SWAP_OUT
 #include "sysroff.c"
 
 #define SYSROFF_SWAP_OUT
 #include "sysroff.c"
 
-
 static char *rname_sh[] =
 {
   "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", "R11", "R12", "R13", "R14", "R15"
 static char *rname_sh[] =
 {
   "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", "R11", "R12", "R13", "R14", "R15"
@@ -282,27 +291,27 @@ static char *rname_h8300[] =
 };
 
 static void
 };
 
 static void
-wr_tr ()
+wr_tr (void)
 {
 {
-  /* The TR block is not normal - it doesn't have any contents. */
+  /* The TR block is not normal - it doesn't have any contents.  */
 
 
-  static char b[] = {
-    0xff,                      /* IT */
-    0x03,                      /* RL */
-    0xfd,                      /* CS */
-  };
-  fwrite (b, 1, sizeof (b), file);
+  static char b[] =
+    {
+      0xff,                    /* IT */
+      0x03,                    /* RL */
+      0xfd,                    /* CS */
+    };
+
+  if (fwrite (b, sizeof (b), 1, file) != 1)
+    /* FIXME: Return error status.  */
+    abort ();
 }
 
 static void
 }
 
 static void
-wr_un (ptr, sfile, first, nsecs)
-     struct coff_ofile *ptr;
-     struct coff_sfile *sfile;
-     int first;
-     int nsecs;
+wr_un (struct coff_ofile *ptr, struct coff_sfile *sfile, int first,
+       int nsecs ATTRIBUTE_UNUSED)
 {
   struct IT_un un;
 {
   struct IT_un un;
-
   struct coff_symbol *s;
 
   un.spare1 = 0;
   struct coff_symbol *s;
 
   un.spare1 = 0;
@@ -313,17 +322,12 @@ wr_un (ptr, sfile, first, nsecs)
     un.format = FORMAT_OM;
   un.spare1 = 0;
 
     un.format = FORMAT_OM;
   un.spare1 = 0;
 
-
-#if 1
-  un.nsections = ptr->nsections - 1;   /*  Don't count the abs section */
-#else
-  /*NEW - only count sections with size */
-  un.nsections = nsecs;
-#endif
+  /* Don't count the abs section.  */
+  un.nsections = ptr->nsections - 1;
 
   un.nextdefs = 0;
   un.nextrefs = 0;
 
   un.nextdefs = 0;
   un.nextrefs = 0;
-  /* Count all the undefined and defined variables with global scope */
+  /* Count all the undefined and defined variables with global scope */
 
   if (first)
     {
 
   if (first)
     {
@@ -345,27 +349,23 @@ wr_un (ptr, sfile, first, nsecs)
   sysroff_swap_un_out (file, &un);
 }
 
   sysroff_swap_un_out (file, &un);
 }
 
-
 static void
 static void
-wr_hd (p)
-     struct coff_ofile *p;
+wr_hd (struct coff_ofile *p)
 {
   struct IT_hd hd;
 
   hd.spare1 = 0;
   if (bfd_get_file_flags (abfd) & EXEC_P)
 {
   struct IT_hd hd;
 
   hd.spare1 = 0;
   if (bfd_get_file_flags (abfd) & EXEC_P)
-    {
-      hd.mt = MTYPE_ABS_LM;
-    }
+    hd.mt = MTYPE_ABS_LM;
   else
   else
-    {
-      hd.mt = MTYPE_OMS_OR_LMS;
-    }
+    hd.mt = MTYPE_OMS_OR_LMS;
+
   hd.cd = DATE;
 
   hd.nu = p->nsources;         /* Always one unit */
   hd.code = 0;                 /* Always ASCII */
   hd.ver = "0200";             /* Version 2.00 */
   hd.cd = DATE;
 
   hd.nu = p->nsources;         /* Always one unit */
   hd.code = 0;                 /* Always ASCII */
   hd.ver = "0200";             /* Version 2.00 */
+
   switch (bfd_get_arch (abfd))
     {
     case bfd_arch_h8300:
   switch (bfd_get_arch (abfd))
     {
     case bfd_arch_h8300:
@@ -415,7 +415,7 @@ wr_hd (p)
       abort ();
     }
 
       abort ();
     }
 
-  if (! bfd_get_file_flags(abfd) & EXEC_P)
+  if (! (bfd_get_file_flags(abfd) & EXEC_P))
     {
       hd.ep = 0;
     }
     {
       hd.ep = 0;
     }
@@ -437,9 +437,7 @@ wr_hd (p)
 
 
 static void
 
 
 static void
-wr_sh (p, sec)
-     struct coff_ofile *p;
-     struct coff_section *sec;
+wr_sh (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_section *sec)
 {
   struct IT_sh sh;
   sh.unit = 0;
 {
   struct IT_sh sh;
   sh.unit = 0;
@@ -452,22 +450,21 @@ wr_sh (p, sec)
 
 
 static void
 
 
 static void
-wr_ob (p, section)
-     struct coff_ofile *p;
-     struct coff_section *section;
+wr_ob (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_section *section)
 {
   bfd_size_type i;
   int first = 1;
   unsigned char stuff[200];
 
   i = 0;
 {
   bfd_size_type i;
   int first = 1;
   unsigned char stuff[200];
 
   i = 0;
-  while (i < section->bfd_section->_raw_size)
+  while (i < bfd_get_section_size (section->bfd_section))
     {
       struct IT_ob ob;
     {
       struct IT_ob ob;
-      int todo = 200;          /* Copy in 200 byte lumps */
+      int todo = 200;          /* Copy in 200 byte lumps.  */
+
       ob.spare = 0;
       ob.spare = 0;
-      if (i + todo > section->bfd_section->_raw_size)
-       todo = section->bfd_section->_raw_size - i;
+      if (i + todo > bfd_get_section_size (section->bfd_section))
+       todo = bfd_get_section_size (section->bfd_section) - i;
 
       if (first)
        {
 
       if (first)
        {
@@ -484,46 +481,47 @@ wr_ob (p, section)
          ob.saf = 0;
        }
 
          ob.saf = 0;
        }
 
-      ob.cpf = 0;              /* Never compress */
+      ob.cpf = 0;              /* Never compress */
       ob.data.len = todo;
       bfd_get_section_contents (abfd, section->bfd_section, stuff, i, todo);
       ob.data.data = stuff;
       sysroff_swap_ob_out (file, &ob /*, i + todo < section->size */ );
       i += todo;
     }
       ob.data.len = todo;
       bfd_get_section_contents (abfd, section->bfd_section, stuff, i, todo);
       ob.data.data = stuff;
       sysroff_swap_ob_out (file, &ob /*, i + todo < section->size */ );
       i += todo;
     }
-  /* Now fill the rest with blanks */
+
+  /* Now fill the rest with blanks.  */
   while (i < (bfd_size_type) section->size)
     {
       struct IT_ob ob;
   while (i < (bfd_size_type) section->size)
     {
       struct IT_ob ob;
-      int todo = 200;          /* Copy in 200 byte lumps */
+      int todo = 200;          /* Copy in 200 byte lumps.  */
+
       ob.spare = 0;
       if (i + todo > (bfd_size_type) section->size)
        todo = section->size - i;
       ob.saf = 0;
 
       ob.spare = 0;
       if (i + todo > (bfd_size_type) section->size)
        todo = section->size - i;
       ob.saf = 0;
 
-      ob.cpf = 0;              /* Never compress */
+      ob.cpf = 0;              /* Never compress */
       ob.data.len = todo;
       memset (stuff, 0, todo);
       ob.data.data = stuff;
       sysroff_swap_ob_out (file, &ob);
       i += todo;
     }
       ob.data.len = todo;
       memset (stuff, 0, todo);
       ob.data.data = stuff;
       sysroff_swap_ob_out (file, &ob);
       i += todo;
     }
-  /* Now fill the rest with blanks */
-
+  /* Now fill the rest with blanks.  */
 }
 
 static void
 }
 
 static void
-wr_rl (ptr, sec)
-     struct coff_ofile *ptr;
-     struct coff_section *sec;
+wr_rl (struct coff_ofile *ptr ATTRIBUTE_UNUSED, struct coff_section *sec)
 {
   int nr = sec->nrelocs;
   int i;
 {
   int nr = sec->nrelocs;
   int i;
+
   for (i = 0; i < nr; i++)
     {
       struct coff_reloc *r = sec->relocs + i;
       struct coff_symbol *ref;
       struct IT_rl rl;
   for (i = 0; i < nr; i++)
     {
       struct coff_reloc *r = sec->relocs + i;
       struct coff_symbol *ref;
       struct IT_rl rl;
+
       rl.apol = 0;
       rl.boundary = 0;
       rl.segment = 1;
       rl.apol = 0;
       rl.boundary = 0;
       rl.segment = 1;
@@ -531,18 +529,19 @@ wr_rl (ptr, sec)
       rl.check = 0;
       rl.addr = r->offset;
       rl.bitloc = 0;
       rl.check = 0;
       rl.addr = r->offset;
       rl.bitloc = 0;
-      rl.flen = 32;            /* SH Specific */
-      /* What sort of reloc ? Look in the section to find out */
+      rl.flen = 32;            /* SH Specific.  */
+
+      /* What sort of reloc ? Look in the section to find out.  */
       ref = r->symbol;
       if (ref->visible->type == coff_vis_ext_ref)
        {
       ref = r->symbol;
       if (ref->visible->type == coff_vis_ext_ref)
        {
-         rl.bcount = 4;        /* Always 4 for us */
+         rl.bcount = 4;        /* Always 4 for us */
          rl.op = OP_EXT_REF;
          rl.symn = ref->er_number;
        }
       else if (ref->visible->type == coff_vis_common)
        {
          rl.op = OP_EXT_REF;
          rl.symn = ref->er_number;
        }
       else if (ref->visible->type == coff_vis_common)
        {
-         rl.bcount = 11;       /* Always 11 for us */
+         rl.bcount = 11;       /* Always 11 for us */
          rl.op = OP_SEC_REF;
          rl.secn = ref->where->section->number;
          rl.copcode_is_3 = 3;
          rl.op = OP_SEC_REF;
          rl.secn = ref->where->section->number;
          rl.copcode_is_3 = 3;
@@ -550,10 +549,9 @@ wr_rl (ptr, sec)
          rl.addend = ref->where->offset - ref->where->section->address;
          rl.aopcode_is_0x20 = 0x20;
        }
          rl.addend = ref->where->offset - ref->where->section->address;
          rl.aopcode_is_0x20 = 0x20;
        }
-
       else
        {
       else
        {
-         rl.bcount = 11;       /* Always 11 for us */
+         rl.bcount = 11;       /* Always 11 for us */
          rl.op = OP_SEC_REF;
          rl.secn = ref->where->section->number;
          rl.copcode_is_3 = 3;
          rl.op = OP_SEC_REF;
          rl.secn = ref->where->section->number;
          rl.copcode_is_3 = 3;
@@ -561,20 +559,20 @@ wr_rl (ptr, sec)
          rl.addend = -ref->where->section->address;
          rl.aopcode_is_0x20 = 0x20;
        }
          rl.addend = -ref->where->section->address;
          rl.aopcode_is_0x20 = 0x20;
        }
+
       rl.end = 0xff;
       rl.end = 0xff;
-      if (rl.op == OP_SEC_REF
+
+      if (   rl.op == OP_SEC_REF
          || rl.op == OP_EXT_REF)
          || rl.op == OP_EXT_REF)
-       {
-         sysroff_swap_rl_out (file, &rl);
-       }
+       sysroff_swap_rl_out (file, &rl);
     }
 }
 
 static void
     }
 }
 
 static void
-wr_object_body (p)
-     struct coff_ofile *p;
+wr_object_body (struct coff_ofile *p)
 {
   int i;
 {
   int i;
+
   for (i = 1; i < p->nsections; i++)
     {
       wr_sh (p, p->sections + i);
   for (i = 1; i < p->nsections; i++)
     {
       wr_sh (p, p->sections + i);
@@ -584,29 +582,28 @@ wr_object_body (p)
 }
 
 static void
 }
 
 static void
-wr_dps_start (sfile, section, scope, type, nest)
-     struct coff_sfile *sfile;
-     struct coff_section *section;
-     struct coff_scope *scope;
-     int type;
-     int nest;
+wr_dps_start (struct coff_sfile *sfile,
+             struct coff_section *section ATTRIBUTE_UNUSED,
+             struct coff_scope *scope, int type, int nest)
 {
   struct IT_dps dps;
 {
   struct IT_dps dps;
+
   dps.end = 0;
   dps.opt = 0;
   dps.type = type;
   dps.end = 0;
   dps.opt = 0;
   dps.type = type;
+
   if (scope->sec)
     {
       dps.san = scope->sec->number;
       dps.address = scope->offset - find_base (sfile, scope->sec);
       dps.block_size = scope->size;
   if (scope->sec)
     {
       dps.san = scope->sec->number;
       dps.address = scope->offset - find_base (sfile, scope->sec);
       dps.block_size = scope->size;
+
       if (debug)
        {
          printf ("DPS %s %d %x\n",
                  sfile->name,
                  nest,
                  dps.address);
       if (debug)
        {
          printf ("DPS %s %d %x\n",
                  sfile->name,
                  nest,
                  dps.address);
-
        }
     }
   else
        }
     }
   else
@@ -622,31 +619,25 @@ wr_dps_start (sfile, section, scope, type, nest)
 }
 
 static void
 }
 
 static void
-wr_dps_end (section, scope, type)
-     struct coff_section *section;
-     struct coff_scope *scope;
-     int type;
+wr_dps_end (struct coff_section *section ATTRIBUTE_UNUSED,
+           struct coff_scope *scope ATTRIBUTE_UNUSED, int type)
 {
   struct IT_dps dps;
 {
   struct IT_dps dps;
+
   dps.end = 1;
   dps.type = type;
   sysroff_swap_dps_out (file, &dps);
 }
 
 static int *
   dps.end = 1;
   dps.type = type;
   sysroff_swap_dps_out (file, &dps);
 }
 
 static int *
-nints (x)
-     int x;
+nints (int x)
 {
   return (int *) (xcalloc (sizeof (int), x));
 }
 
 {
   return (int *) (xcalloc (sizeof (int), x));
 }
 
-static void walk_tree_symbol ();
 static void
 static void
-walk_tree_type_1 (sfile, symbol, type, nest)
-     struct coff_sfile *sfile;
-     struct coff_symbol *symbol;
-     struct coff_type *type;
-     int nest;
+walk_tree_type_1 (struct coff_sfile *sfile, struct coff_symbol *symbol,
+                 struct coff_type *type, int nest)
 {
   switch (type->type)
     {
 {
   switch (type->type)
     {
@@ -663,11 +654,13 @@ walk_tree_type_1 (sfile, symbol, type, nest)
            dbt.sign = BTYPE_UNSPEC;
            dbt.fptype = FPTYPE_NOTSPEC;
            break;
            dbt.sign = BTYPE_UNSPEC;
            dbt.fptype = FPTYPE_NOTSPEC;
            break;
+
          case T_CHAR:
            dbt.btype = BTYPE_CHAR;
            dbt.sign = BTYPE_UNSPEC;
            dbt.fptype = FPTYPE_NOTSPEC;
            break;
          case T_CHAR:
            dbt.btype = BTYPE_CHAR;
            dbt.sign = BTYPE_UNSPEC;
            dbt.fptype = FPTYPE_NOTSPEC;
            break;
+
          case T_SHORT:
          case T_INT:
          case T_LONG:
          case T_SHORT:
          case T_INT:
          case T_LONG:
@@ -675,23 +668,28 @@ walk_tree_type_1 (sfile, symbol, type, nest)
            dbt.sign = SIGN_SIGNED;
            dbt.fptype = FPTYPE_NOTSPEC;
            break;
            dbt.sign = SIGN_SIGNED;
            dbt.fptype = FPTYPE_NOTSPEC;
            break;
+
          case T_FLOAT:
            dbt.btype = BTYPE_FLOAT;
            dbt.fptype = FPTYPE_SINGLE;
            break;
          case T_FLOAT:
            dbt.btype = BTYPE_FLOAT;
            dbt.fptype = FPTYPE_SINGLE;
            break;
+
          case T_DOUBLE:
            dbt.btype = BTYPE_FLOAT;
            dbt.fptype = FPTYPE_DOUBLE;
            break;
          case T_DOUBLE:
            dbt.btype = BTYPE_FLOAT;
            dbt.fptype = FPTYPE_DOUBLE;
            break;
+
          case T_LNGDBL:
            dbt.btype = BTYPE_FLOAT;
            dbt.fptype = FPTYPE_EXTENDED;
            break;
          case T_LNGDBL:
            dbt.btype = BTYPE_FLOAT;
            dbt.fptype = FPTYPE_EXTENDED;
            break;
+
          case T_UCHAR:
            dbt.btype = BTYPE_CHAR;
            dbt.sign = SIGN_UNSIGNED;
            dbt.fptype = FPTYPE_NOTSPEC;
            break;
          case T_UCHAR:
            dbt.btype = BTYPE_CHAR;
            dbt.sign = SIGN_UNSIGNED;
            dbt.fptype = FPTYPE_NOTSPEC;
            break;
+
          case T_USHORT:
          case T_UINT:
          case T_ULONG:
          case T_USHORT:
          case T_UINT:
          case T_ULONG:
@@ -700,14 +698,18 @@ walk_tree_type_1 (sfile, symbol, type, nest)
            dbt.fptype = FPTYPE_NOTSPEC;
            break;
          }
            dbt.fptype = FPTYPE_NOTSPEC;
            break;
          }
+
        dbt.bitsize = type->size;
        dbt.neg = 0x1001;
        sysroff_swap_dbt_out (file, &dbt);
        break;
       }
        dbt.bitsize = type->size;
        dbt.neg = 0x1001;
        sysroff_swap_dbt_out (file, &dbt);
        break;
       }
+
     case coff_pointer_type:
       {
        struct IT_dpt dpt;
     case coff_pointer_type:
       {
        struct IT_dpt dpt;
+
+       dpt.dunno = 0;
        walk_tree_type_1 (sfile, symbol, type->u.pointer.points_to, nest + 1);
        dpt.neg = 0x1001;
        sysroff_swap_dpt_out (file, &dpt);
        walk_tree_type_1 (sfile, symbol, type->u.pointer.points_to, nest + 1);
        dpt.neg = 0x1001;
        sysroff_swap_dpt_out (file, &dpt);
@@ -718,6 +720,7 @@ walk_tree_type_1 (sfile, symbol, type, nest)
       {
        struct IT_dfp dfp;
        struct coff_symbol *param;
       {
        struct IT_dfp dfp;
        struct coff_symbol *param;
+
        dfp.end = 0;
        dfp.spare = 0;
        dfp.nparams = type->u.function.parameters->nvars;
        dfp.end = 0;
        dfp.spare = 0;
        dfp.nparams = type->u.function.parameters->nvars;
@@ -730,9 +733,8 @@ walk_tree_type_1 (sfile, symbol, type, nest)
        for (param = type->u.function.parameters->vars_head;
             param;
             param = param->next)
        for (param = type->u.function.parameters->vars_head;
             param;
             param = param->next)
-         {
-           walk_tree_symbol (sfile, 0, param, nest);
-         }
+         walk_tree_symbol (sfile, 0, param, nest);
+
        dfp.end = 1;
        sysroff_swap_dfp_out (file, &dfp);
        break;
        dfp.end = 1;
        sysroff_swap_dfp_out (file, &dfp);
        break;
@@ -743,6 +745,7 @@ walk_tree_type_1 (sfile, symbol, type, nest)
        struct IT_dbt dbt;
        struct IT_dds dds;
        struct coff_symbol *member;
        struct IT_dbt dbt;
        struct IT_dds dds;
        struct coff_symbol *member;
+
        dds.spare = 0;
        dbt.btype = BTYPE_STRUCT;
        dbt.bitsize = type->size;
        dds.spare = 0;
        dbt.btype = BTYPE_STRUCT;
        dbt.bitsize = type->size;
@@ -754,43 +757,43 @@ walk_tree_type_1 (sfile, symbol, type, nest)
        dds.end = 0;
        dds.neg = 0x1001;
        sysroff_swap_dds_out (file, &dds);
        dds.end = 0;
        dds.neg = 0x1001;
        sysroff_swap_dds_out (file, &dds);
+
        for (member = type->u.astructdef.elements->vars_head;
             member;
             member = member->next)
        for (member = type->u.astructdef.elements->vars_head;
             member;
             member = member->next)
-         {
-           walk_tree_symbol (sfile, 0, member, nest + 1);
-         }
+         walk_tree_symbol (sfile, 0, member, nest + 1);
 
        dds.end = 1;
        sysroff_swap_dds_out (file, &dds);
 
       }
       break;
 
        dds.end = 1;
        sysroff_swap_dds_out (file, &dds);
 
       }
       break;
+
     case coff_structref_type:
       {
        struct IT_dbt dbt;
     case coff_structref_type:
       {
        struct IT_dbt dbt;
+
        dbt.btype = BTYPE_TAG;
        dbt.bitsize = type->size;
        dbt.sign = SIGN_UNSPEC;
        dbt.fptype = FPTYPE_NOTSPEC;
        dbt.btype = BTYPE_TAG;
        dbt.bitsize = type->size;
        dbt.sign = SIGN_UNSPEC;
        dbt.fptype = FPTYPE_NOTSPEC;
+
        if (type->u.astructref.ref)
        if (type->u.astructref.ref)
-         {
-           dbt.sid = get_member_id (type->u.astructref.ref->number);
-         }
+         dbt.sid = get_member_id (type->u.astructref.ref->number);
        else
        else
-         {
-           dbt.sid = 0;
-         }
+         dbt.sid = 0;
 
        dbt.neg = 0x1001;
        sysroff_swap_dbt_out (file, &dbt);
       }
       break;
 
        dbt.neg = 0x1001;
        sysroff_swap_dbt_out (file, &dbt);
       }
       break;
+
     case coff_array_type:
       {
        struct IT_dar dar;
        int j;
     case coff_array_type:
       {
        struct IT_dar dar;
        int j;
-       int dims = 1;           /* Only output one dimension at a time */
+       int dims = 1;           /* Only output one dimension at a time.  */
+
        dar.dims = dims;
        dar.variable = nints (dims);
        dar.subtype = nints (dims);
        dar.dims = dims;
        dar.variable = nints (dims);
        dar.subtype = nints (dims);
@@ -803,6 +806,7 @@ walk_tree_type_1 (sfile, symbol, type, nest)
        dar.minspare = nints (dims);
        dar.neg = 0x1001;
        dar.length = type->size / type->u.array.dim;
        dar.minspare = nints (dims);
        dar.neg = 0x1001;
        dar.length = type->size / type->u.array.dim;
+
        for (j = 0; j < dims; j++)
          {
            dar.variable[j] = VARIABLE_FIXED;
        for (j = 0; j < dims; j++)
          {
            dar.variable[j] = VARIABLE_FIXED;
@@ -817,11 +821,13 @@ walk_tree_type_1 (sfile, symbol, type, nest)
        sysroff_swap_dar_out (file, &dar);
       }
       break;
        sysroff_swap_dar_out (file, &dar);
       }
       break;
+
     case coff_enumdef_type:
       {
        struct IT_dbt dbt;
        struct IT_den den;
        struct coff_symbol *member;
     case coff_enumdef_type:
       {
        struct IT_dbt dbt;
        struct IT_den den;
        struct coff_symbol *member;
+
        dbt.btype = BTYPE_ENUM;
        dbt.bitsize = type->size;
        dbt.sign = SIGN_UNSPEC;
        dbt.btype = BTYPE_ENUM;
        dbt.bitsize = type->size;
        dbt.sign = SIGN_UNSPEC;
@@ -834,22 +840,21 @@ walk_tree_type_1 (sfile, symbol, type, nest)
        den.neg = 0x1001;
        den.spare = 0;
        sysroff_swap_den_out (file, &den);
        den.neg = 0x1001;
        den.spare = 0;
        sysroff_swap_den_out (file, &den);
+
        for (member = type->u.aenumdef.elements->vars_head;
             member;
             member = member->next)
        for (member = type->u.aenumdef.elements->vars_head;
             member;
             member = member->next)
-         {
-           walk_tree_symbol (sfile, 0, member, nest + 1);
-         }
+         walk_tree_symbol (sfile, 0, member, nest + 1);
 
        den.end = 1;
        sysroff_swap_den_out (file, &den);
       }
       break;
 
 
        den.end = 1;
        sysroff_swap_den_out (file, &den);
       }
       break;
 
-      break;
     case coff_enumref_type:
       {
        struct IT_dbt dbt;
     case coff_enumref_type:
       {
        struct IT_dbt dbt;
+
        dbt.btype = BTYPE_TAG;
        dbt.bitsize = type->size;
        dbt.sign = SIGN_UNSPEC;
        dbt.btype = BTYPE_TAG;
        dbt.bitsize = type->size;
        dbt.sign = SIGN_UNSPEC;
@@ -859,12 +864,13 @@ walk_tree_type_1 (sfile, symbol, type, nest)
        sysroff_swap_dbt_out (file, &dbt);
       }
       break;
        sysroff_swap_dbt_out (file, &dbt);
       }
       break;
+
     default:
       abort ();
     }
 }
 
     default:
       abort ();
     }
 }
 
-/* Obsolete ? 
+/* Obsolete ?
    static void
    dty_start ()
    {
    static void
    dty_start ()
    {
@@ -903,18 +909,13 @@ walk_tree_type_1 (sfile, symbol, type, nest)
  */
 
 static void
  */
 
 static void
-walk_tree_type (sfile, symbol, type, nest)
-
-     struct
-     coff_sfile *sfile;
-     struct coff_symbol *symbol;
-     struct coff_type *type;
-     int nest;
+walk_tree_type (struct coff_sfile *sfile, struct coff_symbol *symbol,
+               struct coff_type *type, int nest)
 {
   if (symbol->type->type == coff_function_type)
     {
 {
   if (symbol->type->type == coff_function_type)
     {
-
       struct IT_dty dty;
       struct IT_dty dty;
+
       dty.end = 0;
       dty.neg = 0x1001;
 
       dty.end = 0;
       dty.neg = 0x1001;
 
@@ -940,11 +941,11 @@ walk_tree_type (sfile, symbol, type, nest)
                  BLOCK_TYPE_BLOCK);
       wr_dps_end (symbol->where->section,
                  symbol->type->u.function.code, BLOCK_TYPE_FUNCTION);
                  BLOCK_TYPE_BLOCK);
       wr_dps_end (symbol->where->section,
                  symbol->type->u.function.code, BLOCK_TYPE_FUNCTION);
-
     }
   else
     {
       struct IT_dty dty;
     }
   else
     {
       struct IT_dty dty;
+
       dty.end = 0;
       dty.neg = 0x1001;
       sysroff_swap_dty_out (file, &dty);
       dty.end = 0;
       dty.neg = 0x1001;
       sysroff_swap_dty_out (file, &dty);
@@ -952,21 +953,14 @@ walk_tree_type (sfile, symbol, type, nest)
       dty.end = 1;
       sysroff_swap_dty_out (file, &dty);
     }
       dty.end = 1;
       sysroff_swap_dty_out (file, &dty);
     }
-
 }
 
 }
 
-
-
 static void
 static void
-walk_tree_symbol (sfile, section, symbol, nest)
-     struct coff_sfile *sfile;
-     struct coff_section *section;
-     struct coff_symbol *symbol;
-     int nest;
+walk_tree_symbol (struct coff_sfile *sfile, struct coff_section *section ATTRIBUTE_UNUSED, struct coff_symbol *symbol, int nest)
 {
   struct IT_dsy dsy;
 
 {
   struct IT_dsy dsy;
 
-  memset(&dsy, 0, sizeof(dsy));
+  memset (&dsy, 0, sizeof(dsy));
   dsy.nesting = nest;
 
   switch (symbol->type->type)
   dsy.nesting = nest;
 
   switch (symbol->type->type)
@@ -975,6 +969,7 @@ walk_tree_symbol (sfile, section, symbol, nest)
       dsy.type = STYPE_FUNC;
       dsy.assign = 1;
       break;
       dsy.type = STYPE_FUNC;
       dsy.assign = 1;
       break;
+
     case coff_structref_type:
     case coff_pointer_type:
     case coff_array_type:
     case coff_structref_type:
     case coff_pointer_type:
     case coff_array_type:
@@ -983,18 +978,22 @@ walk_tree_symbol (sfile, section, symbol, nest)
       dsy.type = STYPE_VAR;
       dsy.assign = 1;
       break;
       dsy.type = STYPE_VAR;
       dsy.assign = 1;
       break;
+
     case coff_enumdef_type:
       dsy.type = STYPE_TAG;
       dsy.assign = 0;
       dsy.magic = 2;
       break;
     case coff_enumdef_type:
       dsy.type = STYPE_TAG;
       dsy.assign = 0;
       dsy.magic = 2;
       break;
+
     case coff_structdef_type:
       dsy.type = STYPE_TAG;
       dsy.assign = 0;
       dsy.magic = symbol->type->u.astructdef.isstruct ? 0 : 1;
       break;
     case coff_structdef_type:
       dsy.type = STYPE_TAG;
       dsy.assign = 0;
       dsy.magic = symbol->type->u.astructdef.isstruct ? 0 : 1;
       break;
+
     case coff_secdef_type:
       return;
     case coff_secdef_type:
       return;
+
     default:
       abort ();
     }
     default:
       abort ();
     }
@@ -1004,6 +1003,7 @@ walk_tree_symbol (sfile, section, symbol, nest)
       dsy.assign = 0;
       dsy.type = STYPE_MEMBER;
     }
       dsy.assign = 0;
       dsy.type = STYPE_MEMBER;
     }
+
   if (symbol->where->where == coff_where_member_of_enum)
     {
       dsy.type = STYPE_ENUM;
   if (symbol->where->where == coff_where_member_of_enum)
     {
       dsy.type = STYPE_ENUM;
@@ -1023,7 +1023,6 @@ walk_tree_symbol (sfile, section, symbol, nest)
       dsy.snumber = get_ordinary_id (symbol->number);
     }
 
       dsy.snumber = get_ordinary_id (symbol->number);
     }
 
-
   dsy.sname = symbol->name[0] == '_' ? symbol->name + 1 : symbol->name;
 
   switch (symbol->visible->type)
   dsy.sname = symbol->name[0] == '_' ? symbol->name + 1 : symbol->name;
 
   switch (symbol->visible->type)
@@ -1032,30 +1031,37 @@ walk_tree_symbol (sfile, section, symbol, nest)
     case coff_vis_ext_def:
       dsy.ainfo = AINFO_STATIC_EXT_DEF;
       break;
     case coff_vis_ext_def:
       dsy.ainfo = AINFO_STATIC_EXT_DEF;
       break;
+
     case coff_vis_ext_ref:
       dsy.ainfo = AINFO_STATIC_EXT_REF;
       break;
     case coff_vis_ext_ref:
       dsy.ainfo = AINFO_STATIC_EXT_REF;
       break;
+
     case coff_vis_int_def:
       dsy.ainfo = AINFO_STATIC_INT;
       break;
     case coff_vis_int_def:
       dsy.ainfo = AINFO_STATIC_INT;
       break;
+
     case coff_vis_auto:
     case coff_vis_autoparam:
       dsy.ainfo = AINFO_AUTO;
       break;
     case coff_vis_auto:
     case coff_vis_autoparam:
       dsy.ainfo = AINFO_AUTO;
       break;
+
     case coff_vis_register:
     case coff_vis_regparam:
       dsy.ainfo = AINFO_REG;
       break;
       break;
     case coff_vis_register:
     case coff_vis_regparam:
       dsy.ainfo = AINFO_REG;
       break;
       break;
+
     case coff_vis_tag:
     case coff_vis_member_of_struct:
     case coff_vis_member_of_enum:
       break;
     case coff_vis_tag:
     case coff_vis_member_of_struct:
     case coff_vis_member_of_enum:
       break;
+
     default:
       abort ();
     }
 
   dsy.dlength = symbol->type->size;
     default:
       abort ();
     }
 
   dsy.dlength = symbol->type->size;
+
   switch (symbol->where->where)
     {
     case coff_where_memory:
   switch (symbol->where->where)
     {
     case coff_where_memory:
@@ -1065,16 +1071,17 @@ walk_tree_symbol (sfile, section, symbol, nest)
       dsy.section = 0;
 #endif
       break;
       dsy.section = 0;
 #endif
       break;
+
     case coff_where_member_of_struct:
     case coff_where_member_of_enum:
     case coff_where_stack:
     case coff_where_register:
     case coff_where_unknown:
     case coff_where_strtag:
     case coff_where_member_of_struct:
     case coff_where_member_of_enum:
     case coff_where_stack:
     case coff_where_register:
     case coff_where_unknown:
     case coff_where_strtag:
-
     case coff_where_entag:
     case coff_where_typedef:
       break;
     case coff_where_entag:
     case coff_where_typedef:
       break;
+
     default:
       abort ();
     }
     default:
       abort ();
     }
@@ -1084,12 +1091,12 @@ walk_tree_symbol (sfile, section, symbol, nest)
     case coff_where_memory:
       dsy.address = symbol->where->offset - find_base (sfile, symbol->where->section);
       break;
     case coff_where_memory:
       dsy.address = symbol->where->offset - find_base (sfile, symbol->where->section);
       break;
+
     case coff_where_stack:
       dsy.address = symbol->where->offset;
       break;
     case coff_where_stack:
       dsy.address = symbol->where->offset;
       break;
-    case coff_where_member_of_struct:
-
 
 
+    case coff_where_member_of_struct:
       if (symbol->where->bitsize)
        {
          int bits = (symbol->where->offset * 8 + symbol->where->bitoffset);
       if (symbol->where->bitsize)
        {
          int bits = (symbol->where->offset * 8 + symbol->where->bitoffset);
@@ -1106,18 +1113,20 @@ walk_tree_symbol (sfile, section, symbol, nest)
          dsy.field_off = symbol->where->offset;
        }
       break;
          dsy.field_off = symbol->where->offset;
        }
       break;
+
     case coff_where_member_of_enum:
       /*      dsy.bitunit = 0;
          dsy.field_len  = symbol->type->size;
          dsy.field_off = symbol->where->offset; */
       break;
     case coff_where_member_of_enum:
       /*      dsy.bitunit = 0;
          dsy.field_len  = symbol->type->size;
          dsy.field_off = symbol->where->offset; */
       break;
+
     case coff_where_register:
     case coff_where_unknown:
     case coff_where_strtag:
     case coff_where_register:
     case coff_where_unknown:
     case coff_where_strtag:
-
     case coff_where_entag:
     case coff_where_typedef:
       break;
     case coff_where_entag:
     case coff_where_typedef:
       break;
+
     default:
       abort ();
     }
     default:
       abort ();
     }
@@ -1128,10 +1137,9 @@ walk_tree_symbol (sfile, section, symbol, nest)
   switch (symbol->visible->type)
     {
     case coff_vis_common:
   switch (symbol->visible->type)
     {
     case coff_vis_common:
-      /* We do this 'cause common C symbols are treated as extdefs */
+      /* We do this 'cause common C symbols are treated as extdefs */
     case coff_vis_ext_def:
     case coff_vis_ext_ref:
     case coff_vis_ext_def:
     case coff_vis_ext_ref:
-
       dsy.ename = symbol->name;
       break;
 
       dsy.ename = symbol->name;
       break;
 
@@ -1141,36 +1149,28 @@ walk_tree_symbol (sfile, section, symbol, nest)
       break;
 
     case coff_vis_int_def:
       break;
 
     case coff_vis_int_def:
-
     case coff_vis_auto:
     case coff_vis_register:
     case coff_vis_tag:
     case coff_vis_member_of_struct:
     case coff_vis_member_of_enum:
       break;
     case coff_vis_auto:
     case coff_vis_register:
     case coff_vis_tag:
     case coff_vis_member_of_struct:
     case coff_vis_member_of_enum:
       break;
+
     default:
       abort ();
     }
 
   dsy.sfn = 0;
   dsy.sln = 2;
     default:
       abort ();
     }
 
   dsy.sfn = 0;
   dsy.sln = 2;
-
   dsy.neg = 0x1001;
 
   dsy.neg = 0x1001;
 
-
   sysroff_swap_dsy_out (file, &dsy);
 
   walk_tree_type (sfile, symbol, symbol->type, nest);
 }
 
   sysroff_swap_dsy_out (file, &dsy);
 
   walk_tree_type (sfile, symbol, symbol->type, nest);
 }
 
-
 static void
 static void
-walk_tree_scope (section, sfile, scope, nest, type)
-     struct coff_section *section;
-     struct coff_sfile *sfile;
-     struct coff_scope *scope;
-     int nest;
-     int type;
+walk_tree_scope (struct coff_section *section, struct coff_sfile *sfile, struct coff_scope *scope, int nest, int type)
 {
   struct coff_symbol *vars;
   struct coff_scope *child;
 {
   struct coff_symbol *vars;
   struct coff_scope *child;
@@ -1184,54 +1184,37 @@ walk_tree_scope (section, sfile, scope, nest, type)
        wr_globals (tree, sfile, nest + 1);
 
       for (vars = scope->vars_head; vars; vars = vars->next)
        wr_globals (tree, sfile, nest + 1);
 
       for (vars = scope->vars_head; vars; vars = vars->next)
-       {
-         walk_tree_symbol (sfile, section, vars, nest);
-       }
+       walk_tree_symbol (sfile, section, vars, nest);
 
       for (child = scope->list_head; child; child = child->next)
 
       for (child = scope->list_head; child; child = child->next)
-       {
-         walk_tree_scope (section, sfile, child, nest + 1, BLOCK_TYPE_BLOCK);
-       }
+       walk_tree_scope (section, sfile, child, nest + 1, BLOCK_TYPE_BLOCK);
 
       wr_dps_end (section, scope, type);
     }
 }
 
       wr_dps_end (section, scope, type);
     }
 }
+
 static void
 static void
-walk_tree_sfile (section, sfile)
-     struct coff_section *section;
-     struct coff_sfile *sfile;
+walk_tree_sfile (struct coff_section *section, struct coff_sfile *sfile)
 {
   walk_tree_scope (section, sfile, sfile->scope, 0, BLOCK_TYPE_COMPUNIT);
 {
   walk_tree_scope (section, sfile, sfile->scope, 0, BLOCK_TYPE_COMPUNIT);
-
 }
 
 static void
 }
 
 static void
-wr_program_structure (p, sfile)
-     struct coff_ofile *p;
-     struct coff_sfile *sfile;
+wr_program_structure (struct coff_ofile *p, struct coff_sfile *sfile)
 {
 {
-
   walk_tree_sfile (p->sections + 4, sfile);
   walk_tree_sfile (p->sections + 4, sfile);
-
 }
 
 static void
 }
 
 static void
-wr_du (p, sfile, n)
-     struct coff_ofile *p;
-     struct coff_sfile *sfile;
-     int n;
+wr_du (struct coff_ofile *p, struct coff_sfile *sfile, int n)
 {
   struct IT_du du;
   int lim;
 {
   struct IT_du du;
   int lim;
-#if 0
-  struct coff_symbol *symbol;
-  static int incit = 0x500000;
-  int used = 0;
-#endif
   int i;
   int j;
   unsigned int *lowest = (unsigned *) nints (p->nsections);
   unsigned int *highest = (unsigned *) nints (p->nsections);
   int i;
   int j;
   unsigned int *lowest = (unsigned *) nints (p->nsections);
   unsigned int *highest = (unsigned *) nints (p->nsections);
+
   du.format = bfd_get_file_flags (abfd) & EXEC_P ? 0 : 1;
   du.optimized = 0;
   du.stackfrmt = 0;
   du.format = bfd_get_file_flags (abfd) & EXEC_P ? 0 : 1;
   du.optimized = 0;
   du.stackfrmt = 0;
@@ -1248,54 +1231,14 @@ wr_du (p, sfile, n)
       highest[i] = 0;
     }
 
       highest[i] = 0;
     }
 
-  /* Look through all the symbols and try and work out the extents in this
-     source file */
-#if 0
-  for (symbol = sfile->scope->vars_head;
-       symbol;
-       symbol = symbol->next)
-    {
-      if (symbol->type->type == coff_secdef_type)
-       {
-         unsigned int low = symbol->where->offset;
-         unsigned int high = symbol->where->offset + symbol->type->size - 1;
-         struct coff_section *section = symbol->where->section;
-
-         int sn = section->number;
-         if (low < lowest[sn])
-           lowest[sn] = low;
-         if (high > highest[sn])
-           highest[sn] = high;
-       }
-    }
-
-
-  for (i = 0; i < du.sections; i++)
-    {
-      if (highest[i] == 0)
-       {
-         lowest[i] = highest[i] = incit;
-       }
-      du.san[used] = i;
-      du.length[used] = highest[i] - lowest[i];
-      du.address[used] = bfd_get_file_flags (abfd) & EXEC_P ? lowest[i] : 0;
-      if (debug)
-       {
-         printf (" section %6s 0x%08x..0x%08x\n",
-                 p->sections[i + 1].name,
-                 lowest[i],
-                 highest[i]);
-       }
-      used++;
-    }
-
-#endif
   lim = du.sections;
   for (j = 0; j < lim; j++)
     {
       int src = j;
       int dst = j;
   lim = du.sections;
   for (j = 0; j < lim; j++)
     {
       int src = j;
       int dst = j;
+
       du.san[dst] = dst;
       du.san[dst] = dst;
+
       if (sfile->section[src].init)
        {
          du.length[dst]
       if (sfile->section[src].init)
        {
          du.length[dst]
@@ -1308,6 +1251,7 @@ wr_du (p, sfile, n)
          du.length[dst] = 0;
          du.address[dst] = 0;
        }
          du.length[dst] = 0;
          du.address[dst] = 0;
        }
+
       if (debug)
        {
          if (sfile->section[src].parent)
       if (debug)
        {
          if (sfile->section[src].parent)
@@ -1318,6 +1262,7 @@ wr_du (p, sfile, n)
                      du.address[dst] + du.length[dst] - 1);
            }
        }
                      du.address[dst] + du.length[dst] - 1);
            }
        }
+
       du.sections = dst + 1;
     }
 
       du.sections = dst + 1;
     }
 
@@ -1328,11 +1273,8 @@ wr_du (p, sfile, n)
 }
 
 static void
 }
 
 static void
-wr_dus (p, sfile)
-     struct coff_ofile *p;
-     struct coff_sfile *sfile;
+wr_dus (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_sfile *sfile)
 {
 {
-
   struct IT_dus dus;
 
   dus.efn = 0x1001;
   struct IT_dus dus;
 
   dus.efn = 0x1001;
@@ -1341,108 +1283,27 @@ wr_dus (p, sfile)
   dus.fname = (char **) xcalloc (sizeof (char *), dus.ns);
   dus.spare = nints (dus.ns);
   dus.ndir = 0;
   dus.fname = (char **) xcalloc (sizeof (char *), dus.ns);
   dus.spare = nints (dus.ns);
   dus.ndir = 0;
-  /* Find the filenames */
-#if 0
-  i = 0;
-
-  for (sfile = p->source_head;
-       sfile;
-       sfile = sfile->next)
-    {
-      dus.drb[i] = 0;
-      dus.spare[i] = 0;
-      dus.fname[i] = sfile->name;
-      i++;
-    }
-#else
+  /* Find the filenames.  */
   dus.drb[0] = 0;
   dus.fname[0] = sfile->name;
   dus.drb[0] = 0;
   dus.fname[0] = sfile->name;
-#endif
 
   sysroff_swap_dus_out (file, &dus);
 
 }
 
 /* Find the offset of the .text section for this sfile in the
 
   sysroff_swap_dus_out (file, &dus);
 
 }
 
 /* Find the offset of the .text section for this sfile in the
-   .text section for the output file */
+   .text section for the output file */
 
 static int
 
 static int
-find_base (sfile, section)
-     struct coff_sfile *sfile;
-     struct coff_section *section;
+find_base (struct coff_sfile *sfile, struct coff_section *section)
 {
   return sfile->section[section->number].low;
 }
 {
   return sfile->section[section->number].low;
 }
-static void
-wr_dln (p, sfile, n)
-     struct coff_ofile *p;
-     struct coff_sfile *sfile;
-     int n;
 
 
+static void
+wr_dln (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_sfile *sfile,
+       int n ATTRIBUTE_UNUSED)
 {
 {
-#if 0
-  if (n == 0)
-    {
-      /* Count up all the linenumbers */
-      struct coff_symbol *sy;
-      int lc = 0;
-      struct IT_dln dln;
-
-      int idx;
-
-      for (sy = p->symbol_list_head;
-          sy;
-          sy = sy->next_in_ofile_list)
-       {
-         struct coff_type *t = sy->type;
-         if (t->type == coff_function_type)
-           {
-             struct coff_line *l = t->u.function.lines;
-             lc += l->nlines;
-           }
-       }
-
-      dln.sfn = nints (lc);
-      dln.sln = nints (lc);
-      dln.lln = nints (lc);
-      dln.section = nints (lc);
-
-      dln.from_address = nints (lc);
-      dln.to_address = nints (lc);
-
-
-      dln.neg = 0x1001;
-
-      dln.nln = lc;
-
-      /* Run through once more and fill up the structure */
-      idx = 0;
-      for (sy = p->symbol_list_head;
-          sy;
-          sy = sy->next_in_ofile_list)
-       {
-         if (sy->type->type == coff_function_type)
-           {
-             int i;
-             struct coff_line *l = sy->type->u.function.lines;
-             for (i = 0; i < l->nlines; i++)
-               {
-                 dln.section[idx] = sy->where->section->number;
-                 dln.sfn[idx] = n;
-                 dln.sln[idx] = l->lines[i];
-                 dln.from_address[idx] = l->addresses[i];
-                 if (idx)
-                   dln.to_address[idx - 1] = dln.from_address[idx];
-                 idx++;
-               }
-           }
-         n++;
-       }
-      sysroff_swap_dln_out (file, &dln);
-    }
-
-#endif
-#if 1
   /* Count up all the linenumbers */
 
   struct coff_symbol *sy;
   /* Count up all the linenumbers */
 
   struct coff_symbol *sy;
@@ -1509,17 +1370,16 @@ wr_dln (p, sfile, n)
     }
   if (lc)
     sysroff_swap_dln_out (file, &dln);
     }
   if (lc)
     sysroff_swap_dln_out (file, &dln);
-#endif
 }
 
 }
 
-/* Write the global symbols out to the debug info */
+/* Write the global symbols out to the debug info.  */
+
 static void
 static void
-wr_globals (p, sfile, n)
-     struct coff_ofile *p;
-     struct coff_sfile *sfile;
-     int n;
+wr_globals (struct coff_ofile *p, struct coff_sfile *sfile,
+           int n ATTRIBUTE_UNUSED)
 {
   struct coff_symbol *sy;
 {
   struct coff_symbol *sy;
+
   for (sy = p->symbol_list_head;
        sy;
        sy = sy->next_in_ofile_list)
   for (sy = p->symbol_list_head;
        sy;
        sy = sy->next_in_ofile_list)
@@ -1528,29 +1388,26 @@ wr_globals (p, sfile, n)
          || sy->visible->type == coff_vis_ext_ref)
        {
          /* Only write out symbols if they belong to
          || sy->visible->type == coff_vis_ext_ref)
        {
          /* Only write out symbols if they belong to
-            the current source file */
+            the current source file */
          if (sy->sfile == sfile)
            walk_tree_symbol (sfile, 0, sy, 0);
          if (sy->sfile == sfile)
            walk_tree_symbol (sfile, 0, sy, 0);
-
        }
     }
 }
 
 static void
        }
     }
 }
 
 static void
-wr_debug (p)
-     struct coff_ofile *p;
+wr_debug (struct coff_ofile *p)
 {
   struct coff_sfile *sfile;
   int n = 0;
 {
   struct coff_sfile *sfile;
   int n = 0;
+
   for (sfile = p->source_head;
        sfile;
        sfile = sfile->next)
   for (sfile = p->source_head;
        sfile;
        sfile = sfile->next)
-
     {
       if (debug)
     {
       if (debug)
-       {
-         printf ("%s\n", sfile->name);
-       }
+       printf ("%s\n", sfile->name);
+
       wr_du (p, sfile, n);
       wr_dus (p, sfile);
       wr_program_structure (p, sfile);
       wr_du (p, sfile, n);
       wr_dus (p, sfile);
       wr_program_structure (p, sfile);
@@ -1560,25 +1417,26 @@ wr_debug (p)
 }
 
 static void
 }
 
 static void
-wr_cs ()
+wr_cs (void)
 {
   /* It seems that the CS struct is not normal - the size is wrong
 {
   /* It seems that the CS struct is not normal - the size is wrong
-     heres one I prepared earlier.. */
-  static char b[] = {
+     heres one I prepared earlier.  */
+  static char b[] =
+    {
     0x80,                      /* IT */
     0x21,                      /* RL */
     0x00,                      /* number of chars in variable length part */
     0x80,                      /* IT */
     0x21,                      /* RL */
     0x00,                      /* number of chars in variable length part */
-    0x80,                      /* hd */ 
-    0x00,                      /* hs */ 
-    0x80,                      /* un */ 
-    0x00,                      /* us */ 
-    0x80,                      /* sc */ 
-    0x00,                      /* ss */ 
-    0x80,                      /* er */ 
-    0x80,                      /* ed */ 
-    0x80,                      /* sh */ 
-    0x80,                      /* ob */ 
-    0x80,                      /* rl */ 
+    0x80,                      /* hd */
+    0x00,                      /* hs */
+    0x80,                      /* un */
+    0x00,                      /* us */
+    0x80,                      /* sc */
+    0x00,                      /* ss */
+    0x80,                      /* er */
+    0x80,                      /* ed */
+    0x80,                      /* sh */
+    0x80,                      /* ob */
+    0x80,                      /* rl */
     0x80,                      /* du */
     0x80,                      /* dps */
     0x80,                      /* dsy */
     0x80,                      /* du */
     0x80,                      /* dps */
     0x80,                      /* dsy */
@@ -1599,36 +1457,33 @@ wr_cs ()
     0x00,                      /* dot */
     0xDE                       /* CS */
   };
     0x00,                      /* dot */
     0xDE                       /* CS */
   };
-  fwrite (b, 1, sizeof (b), file);
+
+  if (fwrite (b, sizeof (b), 1, file) != 1)
+    /* FIXME: Return error status.  */
+    abort ();
 }
 
 /* Write out the SC records for a unit.  Create an SC
    for all the sections which appear in the output file, even
 }
 
 /* Write out the SC records for a unit.  Create an SC
    for all the sections which appear in the output file, even
-   if there isn't an equivalent one on the input */
+   if there isn't an equivalent one on the input */
 
 static int
 
 static int
-wr_sc (ptr, sfile)
-     struct coff_ofile *ptr;
-     struct coff_sfile *sfile;
+wr_sc (struct coff_ofile *ptr, struct coff_sfile *sfile)
 {
   int i;
 {
   int i;
-int scount = 0;
-  /* First work out the total number of sections */
-
+  int scount = 0;
+  /* First work out the total number of sections.  */
   int total_sec = ptr->nsections;
   int total_sec = ptr->nsections;
-
   struct myinfo
     {
       struct coff_section *sec;
       struct coff_symbol *symbol;
     };
   struct coff_symbol *symbol;
   struct myinfo
     {
       struct coff_section *sec;
       struct coff_symbol *symbol;
     };
   struct coff_symbol *symbol;
-
   struct myinfo *info
     = (struct myinfo *) calloc (total_sec, sizeof (struct myinfo));
 
 
   struct myinfo *info
     = (struct myinfo *) calloc (total_sec, sizeof (struct myinfo));
 
 
-
   for (i = 0; i < total_sec; i++)
     {
       info[i].sec = ptr->sections + i;
   for (i = 0; i < total_sec; i++)
     {
       info[i].sec = ptr->sections + i;
@@ -1654,19 +1509,20 @@ int scount = 0;
     }
 
   /* Now output all the section info, and fake up some stuff for sections
     }
 
   /* Now output all the section info, and fake up some stuff for sections
-     we don't have */
-
+     we don't have.  */
   for (i = 1; i < total_sec; i++)
     {
       struct IT_sc sc;
       char *name;
   for (i = 1; i < total_sec; i++)
     {
       struct IT_sc sc;
       char *name;
+
       symbol = info[i].symbol;
       sc.spare = 0;
       sc.spare1 = 0;
       symbol = info[i].symbol;
       sc.spare = 0;
       sc.spare1 = 0;
+
       if (!symbol)
        {
       if (!symbol)
        {
-         /* Don't have a symbol set aside for this section, which means that nothing
-            in this file does anything for the section. */
+         /* Don't have a symbol set aside for this section, which means
+            that nothing in this file does anything for the section.  */
          sc.format = !(bfd_get_file_flags (abfd) & EXEC_P);
          sc.addr = 0;
          sc.length = 0;
          sc.format = !(bfd_get_file_flags (abfd) & EXEC_P);
          sc.addr = 0;
          sc.length = 0;
@@ -1689,7 +1545,6 @@ int scount = 0;
        }
 
       sc.align = 4;
        }
 
       sc.align = 4;
-
       sc.concat = CONCAT_SIMPLE;
       sc.read = 3;
       sc.write = 3;
       sc.concat = CONCAT_SIMPLE;
       sc.read = 3;
       sc.write = 3;
@@ -1698,8 +1553,9 @@ int scount = 0;
       sc.mode = 3;
       sc.spare = 0;
       sc.segadd = 0;
       sc.mode = 3;
       sc.spare = 0;
       sc.segadd = 0;
-      sc.spare1 = 0;           /* If not zero, then it doesn't work */
+      sc.spare1 = 0;           /* If not zero, then it doesn't work */
       sc.name = section_translate (name);
       sc.name = section_translate (name);
+
       if (strlen (sc.name) == 1)
        {
          switch (sc.name[0])
       if (strlen (sc.name) == 1)
        {
          switch (sc.name[0])
@@ -1708,6 +1564,7 @@ int scount = 0;
            case 'B':
              sc.contents = CONTENTS_DATA;
              break;
            case 'B':
              sc.contents = CONTENTS_DATA;
              break;
+
            default:
              sc.contents = CONTENTS_CODE;
            }
            default:
              sc.contents = CONTENTS_CODE;
            }
@@ -1716,29 +1573,22 @@ int scount = 0;
        {
          sc.contents = CONTENTS_CODE;
        }
        {
          sc.contents = CONTENTS_CODE;
        }
-#if 0
-      /* NEW */
-      if (sc.length) {
-#endif
-       sysroff_swap_sc_out (file, &sc);
-       scount++;
-#if 0
-      }
-#endif
+
+      sysroff_swap_sc_out (file, &sc);
+      scount++;
     }
     }
-return scount;
+  return scount;
 }
 
 }
 
+/* Write out the ER records for a unit.  */
 
 
-/* Write out the ER records for a unit. */
 static void
 static void
-wr_er (ptr, sfile, first)
-     struct coff_ofile *ptr;
-     struct coff_sfile *sfile;
-     int first;
+wr_er (struct coff_ofile *ptr, struct coff_sfile *sfile ATTRIBUTE_UNUSED,
+       int first)
 {
   int idx = 0;
   struct coff_symbol *sym;
 {
   int idx = 0;
   struct coff_symbol *sym;
+
   if (first)
     {
       for (sym = ptr->symbol_list_head; sym; sym = sym->next_in_ofile_list)
   if (first)
     {
       for (sym = ptr->symbol_list_head; sym; sym = sym->next_in_ofile_list)
@@ -1746,6 +1596,7 @@ wr_er (ptr, sfile, first)
          if (sym->visible->type == coff_vis_ext_ref)
            {
              struct IT_er er;
          if (sym->visible->type == coff_vis_ext_ref)
            {
              struct IT_er er;
+
              er.spare = 0;
              er.type = ER_NOTSPEC;
              er.name = sym->name;
              er.spare = 0;
              er.type = ER_NOTSPEC;
              er.name = sym->name;
@@ -1756,14 +1607,14 @@ wr_er (ptr, sfile, first)
     }
 }
 
     }
 }
 
-/* Write out the ED records for a unit. */
+/* Write out the ED records for a unit.  */
+
 static void
 static void
-wr_ed (ptr, sfile, first)
-     struct coff_ofile *ptr;
-     struct coff_sfile *sfile;
-     int first;
+wr_ed (struct coff_ofile *ptr, struct coff_sfile *sfile ATTRIBUTE_UNUSED,
+       int first)
 {
   struct coff_symbol *s;
 {
   struct coff_symbol *s;
+
   if (first)
     {
       for (s = ptr->symbol_list_head; s; s = s->next_in_ofile_list)
   if (first)
     {
       for (s = ptr->symbol_list_head; s; s = s->next_in_ofile_list)
@@ -1775,6 +1626,7 @@ wr_ed (ptr, sfile, first)
 
              ed.section = s->where->section->number;
              ed.spare = 0;
 
              ed.section = s->where->section->number;
              ed.spare = 0;
+
              if (s->where->section->data)
                {
                  ed.type = ED_TYPE_DATA;
              if (s->where->section->data)
                {
                  ed.type = ED_TYPE_DATA;
@@ -1788,6 +1640,7 @@ wr_ed (ptr, sfile, first)
                  ed.type = ED_TYPE_NOTSPEC;
                  ed.type = ED_TYPE_DATA;
                }
                  ed.type = ED_TYPE_NOTSPEC;
                  ed.type = ED_TYPE_DATA;
                }
+
              ed.address = s->where->offset - s->where->section->address;
              ed.name = s->name;
              sysroff_swap_ed_out (file, &ed);
              ed.address = s->where->offset - s->where->section->address;
              ed.name = s->name;
              sysroff_swap_ed_out (file, &ed);
@@ -1797,11 +1650,11 @@ wr_ed (ptr, sfile, first)
 }
 
 static void
 }
 
 static void
-wr_unit_info (ptr)
-     struct coff_ofile *ptr;
+wr_unit_info (struct coff_ofile *ptr)
 {
   struct coff_sfile *sfile;
   int first = 1;
 {
   struct coff_sfile *sfile;
   int first = 1;
+
   for (sfile = ptr->source_head;
        sfile;
        sfile = sfile->next)
   for (sfile = ptr->source_head;
        sfile;
        sfile = sfile->next)
@@ -1809,13 +1662,14 @@ wr_unit_info (ptr)
       long p1;
       long p2;
       int nsecs;
       long p1;
       long p2;
       int nsecs;
+
       p1 = ftell (file);
       wr_un (ptr, sfile, first, 0);
       nsecs = wr_sc (ptr, sfile);
       p2 = ftell (file);
       fseek (file, p1, SEEK_SET);
       wr_un (ptr, sfile, first, nsecs);
       p1 = ftell (file);
       wr_un (ptr, sfile, first, 0);
       nsecs = wr_sc (ptr, sfile);
       p2 = ftell (file);
       fseek (file, p1, SEEK_SET);
       wr_un (ptr, sfile, first, nsecs);
-      fseek (file, p2, SEEK_SET); 
+      fseek (file, p2, SEEK_SET);
       wr_er (ptr, sfile, first);
       wr_ed (ptr, sfile, first);
       first = 0;
       wr_er (ptr, sfile, first);
       wr_ed (ptr, sfile, first);
       first = 0;
@@ -1823,8 +1677,7 @@ wr_unit_info (ptr)
 }
 
 static void
 }
 
 static void
-wr_module (p)
-     struct coff_ofile *p;
+wr_module (struct coff_ofile *p)
 {
   wr_cs ();
   wr_hd (p);
 {
   wr_cs ();
   wr_hd (p);
@@ -1835,30 +1688,31 @@ wr_module (p)
 }
 
 static int
 }
 
 static int
-align (x)
-     int x;
+align (int x)
 {
   return (x + 3) & ~3;
 }
 
 /* Find all the common variables and turn them into
 {
   return (x + 3) & ~3;
 }
 
 /* Find all the common variables and turn them into
-   ordinary defs - dunno why, but thats what hitachi does with 'em */
+   ordinary defs - dunno why, but thats what hitachi does with 'em */
 
 static void
 
 static void
-prescan (tree)
-     struct coff_ofile *tree;
+prescan (struct coff_ofile *otree)
 {
   struct coff_symbol *s;
   struct coff_section *common_section;
 {
   struct coff_symbol *s;
   struct coff_section *common_section;
-  /* Find the common section - always section 3 */
-  common_section = tree->sections + 3;
-  for (s = tree->symbol_list_head;
+
+  /* Find the common section - always section 3.  */
+  common_section = otree->sections + 3;
+
+  for (s = otree->symbol_list_head;
        s;
        s = s->next_in_ofile_list)
     {
       if (s->visible->type == coff_vis_common)
        {
          struct coff_where *w = s->where;
        s;
        s = s->next_in_ofile_list)
     {
       if (s->visible->type == coff_vis_common)
        {
          struct coff_where *w = s->where;
+
          /*      s->visible->type = coff_vis_ext_def; leave it as common */
          common_section->size = align (common_section->size);
          w->offset = common_section->size + common_section->address;
          /*      s->visible->type = coff_vis_ext_def; leave it as common */
          common_section->size = align (common_section->size);
          w->offset = common_section->size + common_section->address;
@@ -1872,28 +1726,25 @@ prescan (tree)
 char *program_name;
 
 static void
 char *program_name;
 
 static void
-show_usage (file, status)
-     FILE *file;
-     int status;
+show_usage (FILE *ffile, int status)
 {
 {
-  fprintf (file, _("Usage: %s [-dhVq] in-file [out-file]\n"), program_name);
+  fprintf (ffile, _("Usage: %s [option(s)] in-file [out-file]\n"), program_name);
+  fprintf (ffile, _("Convert a COFF object file into a SYSROFF object file\n"));
+  fprintf (ffile, _(" The options are:\n\
+  -q --quick       (Obsolete - ignored)\n\
+  -n --noprescan   Do not perform a scan to convert commons into defs\n\
+  -d --debug       Display information about what is being done\n\
+  @<file>          Read options from <file>\n\
+  -h --help        Display this information\n\
+  -v --version     Print the program's version number\n"));
+
+  if (REPORT_BUGS_TO[0] && status == 0)
+    fprintf (ffile, _("Report bugs to %s\n"), REPORT_BUGS_TO);
   exit (status);
 }
 
   exit (status);
 }
 
-static void
-show_help ()
-{
-  printf (_("%s: Convert a COFF object file into a SYSROFF object file\n"),
-         program_name);
-  show_usage (stdout, 0);
-}
-
-
-
 int
 int
-main (ac, av)
-     int ac;
-     char *av[];
+main (int ac, char **av)
 {
   int opt;
   static struct option long_options[] =
 {
   int opt;
   static struct option long_options[] =
@@ -1911,6 +1762,9 @@ main (ac, av)
 
 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
   setlocale (LC_MESSAGES, "");
 
 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
   setlocale (LC_MESSAGES, "");
+#endif
+#if defined (HAVE_SETLOCALE)
+  setlocale (LC_CTYPE, "");
 #endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 #endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
@@ -1918,7 +1772,9 @@ main (ac, av)
   program_name = av[0];
   xmalloc_set_program_name (program_name);
 
   program_name = av[0];
   xmalloc_set_program_name (program_name);
 
-  while ((opt = getopt_long (ac, av, "dhVqn", long_options,
+  expandargv (&ac, &av);
+
+  while ((opt = getopt_long (ac, av, "dHhVvqn", long_options,
                             (int *) NULL))
         != EOF)
     {
                             (int *) NULL))
         != EOF)
     {
@@ -1933,11 +1789,13 @@ main (ac, av)
        case 'd':
          debug = 1;
          break;
        case 'd':
          debug = 1;
          break;
+       case 'H':
        case 'h':
        case 'h':
-         show_help ();
+         show_usage (stdout, 0);
          /*NOTREACHED */
          /*NOTREACHED */
+       case 'v':
        case 'V':
        case 'V':
-         printf (_("GNU %s version %s\n"), program_name, PROGRAM_VERSION);
+         print_version ("srconv");
          exit (0);
          /*NOTREACHED */
        case 0:
          exit (0);
          /*NOTREACHED */
        case 0:
@@ -1962,10 +1820,7 @@ main (ac, av)
            show_usage (stderr, 1);
          if (strcmp (input_file, output_file) == 0)
            {
            show_usage (stderr, 1);
          if (strcmp (input_file, output_file) == 0)
            {
-             fprintf (stderr,
-                      _("%s: input and output files must be different\n"),
-                      program_name);
-             exit (1);
+             fatal (_("input and output files must be different"));
            }
        }
     }
            }
        }
     }
@@ -1974,9 +1829,7 @@ main (ac, av)
 
   if (!input_file)
     {
 
   if (!input_file)
     {
-      fprintf (stderr, _("%s: no input file specified\n"),
-              program_name);
-      exit (1);
+      fatal (_("no input file specified"));
     }
 
   if (!output_file)
     }
 
   if (!output_file)
@@ -1985,8 +1838,10 @@ main (ac, av)
          it doesn't end in .o, then stick a .obj on anyway */
 
       int len = strlen (input_file);
          it doesn't end in .o, then stick a .obj on anyway */
 
       int len = strlen (input_file);
+
       output_file = xmalloc (len + 5);
       strcpy (output_file, input_file);
       output_file = xmalloc (len + 5);
       strcpy (output_file, input_file);
+
       if (len > 3
          && output_file[len - 2] == '.'
          && output_file[len - 1] == 'o')
       if (len > 3
          && output_file[len - 2] == '.'
          && output_file[len - 1] == 'o')
@@ -2009,6 +1864,7 @@ main (ac, av)
   if (!bfd_check_format_matches (abfd, bfd_object, &matching))
     {
       bfd_nonfatal (input_file);
   if (!bfd_check_format_matches (abfd, bfd_object, &matching))
     {
       bfd_nonfatal (input_file);
+
       if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
        {
          list_matching_formats (matching);
       if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
        {
          list_matching_formats (matching);
@@ -2020,17 +1876,16 @@ main (ac, av)
   file = fopen (output_file, FOPEN_WB);
 
   if (!file)
   file = fopen (output_file, FOPEN_WB);
 
   if (!file)
-    {
-      fprintf (stderr, _("%s: unable to open output file %s\n"),
-              program_name, output_file);
-      exit (1);
-    }
+    fatal (_("unable to open output file %s"), output_file);
 
   if (debug)
     printf ("ids %d %d\n", base1, base2);
 
   if (debug)
     printf ("ids %d %d\n", base1, base2);
+
   tree = coff_grok (abfd);
   tree = coff_grok (abfd);
+
   if (!noprescan)
     prescan (tree);
   if (!noprescan)
     prescan (tree);
+
   wr_module (tree);
   return 0;
 }
   wr_module (tree);
   return 0;
 }
This page took 0.044906 seconds and 4 git commands to generate.