2011-05-24 Pedro Alves <pedro@codesourcery.com>
[deliverable/binutils-gdb.git] / binutils / coffdump.c
index 065e9e16a8f6e6caf4a21717e13b34f7d86d80ea..428f598bc68d374b05870fc38802fadc61c7ec1e 100644 (file)
@@ -1,12 +1,12 @@
 /* Coff file dumper.
-   Copyright 1994, 1995, 1998, 1999, 2000, 2001, 2002
-   Free Software Foundation, Inc.
+   Copyright 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007,
+   2011 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
-   the Free Software Foundation; either version 2 of the License, or (at
+   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,
 
    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>
 
    This module reads a type tree generated by coffgrok and prints
    it out so we can test the grokker.  */
 
-#include <bfd.h>
-#include <libiberty.h>
+#include "sysdep.h"
+#include "bfd.h"
+#include "bfd_stdint.h"
+#include "libiberty.h"
+#include "bucomm.h"
 
 #include "coffgrok.h"
-#include "bucomm.h"
 #include "getopt.h"
 
 static int atnl;
 
-static void tab PARAMS ((int));
-static void nl PARAMS ((void));
-static void dump_coff_lines PARAMS ((struct coff_line *));
-static void dump_coff_type PARAMS ((struct coff_type *));
-static void dump_coff_where PARAMS ((struct coff_where *));
-static void dump_coff_visible PARAMS ((struct coff_visible *));
-extern void dump_coff_symbol PARAMS ((struct coff_symbol *));
-static void dump_coff_scope PARAMS ((struct coff_scope *));
-static void dump_coff_sfile PARAMS ((struct coff_sfile *));
-static void dump_coff_section PARAMS ((struct coff_section *));
-extern void coff_dump PARAMS ((struct coff_ofile *));
-static void show_usage PARAMS ((FILE *, int));
-extern int main PARAMS ((int, char **));
+static void tab (int);
+static void nl (void);
+static void dump_coff_lines (struct coff_line *);
+static void dump_coff_type (struct coff_type *);
+static void dump_coff_where (struct coff_where *);
+static void dump_coff_visible (struct coff_visible *);
+static void dump_coff_scope (struct coff_scope *);
+static void dump_coff_sfile (struct coff_sfile *);
+static void dump_coff_section (struct coff_section *);
+static void show_usage (FILE *, int);
+extern int main (int, char **);
 
 static void
-tab (x)
-     int x;
+tab (int x)
 {
   static int indent;
   int i;
@@ -91,14 +92,13 @@ tab (x)
 }
 
 static void
-nl ()
+nl (void)
 {
   atnl = 1;
 }
 
 static void
-dump_coff_lines (p)
-     struct coff_line *p;
+dump_coff_lines (struct coff_line *p)
 {
   int i;
   int online = 0;
@@ -106,7 +106,7 @@ dump_coff_lines (p)
   tab (1);
   printf (_("#lines %d "),p->nlines);
 
-  for (i = 0; i < p->nlines; i++) 
+  for (i = 0; i < p->nlines; i++)
     {
       printf ("(%d 0x%x)", p->lines[i], p->addresses[i]);
 
@@ -124,8 +124,7 @@ dump_coff_lines (p)
 }
 
 static void
-dump_coff_type (p)
-     struct coff_type *p;
+dump_coff_type (struct coff_type *p)
 {
   tab (1);
   printf ("size %d ", p->size);
@@ -133,7 +132,7 @@ dump_coff_type (p)
   switch (p->type)
     {
     case coff_secdef_type:
-      printf ("section definition at %x size %x\n", 
+      printf ("section definition at %x size %x\n",
              p->u.asecdef.address,
              p->u.asecdef.size);
       nl ();
@@ -244,8 +243,7 @@ dump_coff_type (p)
 }
 
 static void
-dump_coff_where (p)
-     struct coff_where *p;
+dump_coff_where (struct coff_where *p)
 {
   tab (1);
   switch (p->where)
@@ -284,8 +282,7 @@ dump_coff_where (p)
 }
 
 static void
-dump_coff_visible (p)
-     struct coff_visible *p;
+dump_coff_visible (struct coff_visible *p)
 {
   tab (1);
   switch (p->type)
@@ -330,9 +327,8 @@ dump_coff_visible (p)
   tab (-1);
 }
 
-void
-dump_coff_symbol (p)
-     struct coff_symbol *p;
+static void
+dump_coff_symbol (struct coff_symbol *p)
 {
   tab (1);
   printf ("List of symbols");
@@ -365,13 +361,12 @@ dump_coff_symbol (p)
 }
 
 static void
-dump_coff_scope (p)
-     struct coff_scope *p;
+dump_coff_scope (struct coff_scope *p)
 {
   if (p)
     {
       tab (1);
-      printf ("List of blocks %lx ",(unsigned long) p);
+      printf ("List of blocks %" BFD_VMA_FMT "x ",(bfd_vma) (uintptr_t) p);
 
       if (p->sec)
        printf( "  %s %x..%x",  p->sec->name,p->offset, p->offset + p->size -1);
@@ -402,8 +397,7 @@ dump_coff_scope (p)
 }
 
 static void
-dump_coff_sfile (p)
-     struct coff_sfile *p;
+dump_coff_sfile (struct coff_sfile *p)
 {
   tab (1);
   printf ("List of source files");
@@ -421,20 +415,19 @@ dump_coff_sfile (p)
 }
 
 static void
-dump_coff_section(ptr)
-     struct coff_section *ptr;
+dump_coff_section (struct coff_section *ptr)
 {
   int i;
 
   tab (1);
-  printf ("section %s %d %d address %x size %x number %d nrelocs %d", 
+  printf ("section %s %d %d address %x size %x number %d nrelocs %d",
          ptr->name, ptr->code, ptr->data, ptr->address,ptr->size,
          ptr->number, ptr->nrelocs);
   nl ();
 
-  for (i = 0; i < ptr->nrelocs; i++) 
+  for (i = 0; i < ptr->nrelocs; i++)
     {
-      tab (0);    
+      tab (0);
       printf ("(%x %s %x)",
              ptr->relocs[i].offset,
              ptr->relocs[i].symbol->name,
@@ -445,15 +438,14 @@ dump_coff_section(ptr)
   tab (-1);
 }
 
-void
-coff_dump (ptr)
-     struct coff_ofile *ptr;
+static void
+coff_dump (struct coff_ofile *ptr)
 {
   int i;
 
   printf ("Coff dump");
   nl ();
-  printf ("#souces %d", ptr->nsources);
+  printf ("#sources %d", ptr->nsources);
   nl ();
   dump_coff_sfile (ptr->source_head);
 
@@ -464,27 +456,24 @@ coff_dump (ptr)
 char * program_name;
 
 static void
-show_usage (file, status)
-     FILE *file;
-     int status;
+show_usage (FILE *file, int status)
 {
   fprintf (file, _("Usage: %s [option(s)] in-file\n"), program_name);
-  fprintf (file, _(" Print a human readable interpretation of a SYSROFF object file\n"));
+  fprintf (file, _(" Print a human readable interpretation of a COFF object file\n"));
   fprintf (file, _(" The options are:\n\
+  @<file>                Read options from <file>\n\
   -h --help              Display this information\n\
   -v --version           Display the program's version\n\
 \n"));
 
-  if (status == 0)
+  if (REPORT_BUGS_TO[0] && status == 0)
     fprintf (file, _("Report bugs to %s\n"), REPORT_BUGS_TO);
 
   exit (status);
 }
 
 int
-main (ac, av)
-     int ac;
-     char *av[];
+main (int ac, char **av)
 {
   bfd *abfd;
   struct coff_ofile *tree;
@@ -510,6 +499,8 @@ main (ac, av)
   program_name = av[0];
   xmalloc_set_program_name (program_name);
 
+  expandargv (&ac, &av);
+
   while ((opt = getopt_long (ac, av, "HhVv", long_options,
                             (int *) NULL))
         != EOF)
This page took 0.031221 seconds and 4 git commands to generate.