ChangeLog rotation
[deliverable/binutils-gdb.git] / binutils / coffdump.c
index 7b6ead4af3886a11ee40e40e4a1fa9fff0edcfac..13f885ce327576d98c055240dcbf563a32be084b 100644 (file)
@@ -1,12 +1,11 @@
 /* Coff file dumper.
 /* Coff file dumper.
-   Copyright 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007
-   Free Software Foundation, Inc.
+   Copyright (C) 1994-2018 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 (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,
    your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -16,7 +15,9 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
 
 /* Written by Steve Chamberlain <sac@cygnus.com>
 
 
 /* Written by Steve Chamberlain <sac@cygnus.com>
 
@@ -25,6 +26,7 @@
 
 #include "sysdep.h"
 #include "bfd.h"
 
 #include "sysdep.h"
 #include "bfd.h"
+#include "bfd_stdint.h"
 #include "libiberty.h"
 #include "bucomm.h"
 
 #include "libiberty.h"
 #include "bucomm.h"
 
@@ -124,56 +126,56 @@ static void
 dump_coff_type (struct coff_type *p)
 {
   tab (1);
 dump_coff_type (struct coff_type *p)
 {
   tab (1);
-  printf ("size %d ", p->size);
+  printf (_("size %d "), p->size);
 
   switch (p->type)
     {
     case coff_secdef_type:
 
   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 ();
       break;
     case coff_pointer_type:
              p->u.asecdef.address,
              p->u.asecdef.size);
       nl ();
       break;
     case coff_pointer_type:
-      printf ("pointer to");
+      printf (_("pointer to"));
       nl ();
       dump_coff_type (p->u.pointer.points_to);
       break;
     case coff_array_type:
       nl ();
       dump_coff_type (p->u.pointer.points_to);
       break;
     case coff_array_type:
-      printf ("array [%d] of", p->u.array.dim);
+      printf (_("array [%d] of"), p->u.array.dim);
       nl ();
       dump_coff_type (p->u.array.array_of);
       break;
     case coff_function_type:
       nl ();
       dump_coff_type (p->u.array.array_of);
       break;
     case coff_function_type:
-      printf ("function returning");
+      printf (_("function returning"));
       nl ();
       dump_coff_type (p->u.function.function_returns);
       dump_coff_lines (p->u.function.lines);
       nl ();
       dump_coff_type (p->u.function.function_returns);
       dump_coff_lines (p->u.function.lines);
-      printf ("arguments");
+      printf (_("arguments"));
       nl ();
       dump_coff_scope (p->u.function.parameters);
       tab (0);
       nl ();
       dump_coff_scope (p->u.function.parameters);
       tab (0);
-      printf ("code");
+      printf (_("code"));
       nl ();
       dump_coff_scope (p->u.function.code);
       tab(0);
       break;
     case coff_structdef_type:
       nl ();
       dump_coff_scope (p->u.function.code);
       tab(0);
       break;
     case coff_structdef_type:
-      printf ("structure definition");
+      printf (_("structure definition"));
       nl ();
       dump_coff_scope (p->u.astructdef.elements);
       break;
     case coff_structref_type:
       if (!p->u.aenumref.ref)
       nl ();
       dump_coff_scope (p->u.astructdef.elements);
       break;
     case coff_structref_type:
       if (!p->u.aenumref.ref)
-       printf ("structure ref to UNKNOWN struct");
+       printf (_("structure ref to UNKNOWN struct"));
       else
       else
-       printf ("structure ref to %s", p->u.aenumref.ref->name);
+       printf (_("structure ref to %s"), p->u.aenumref.ref->name);
       break;
     case coff_enumref_type:
       break;
     case coff_enumref_type:
-      printf ("enum ref to %s", p->u.astructref.ref->name);
+      printf (_("enum ref to %s"), p->u.astructref.ref->name);
       break;
     case coff_enumdef_type:
       break;
     case coff_enumdef_type:
-      printf ("enum definition");
+      printf (_("enum definition"));
       nl ();
       dump_coff_scope (p->u.aenumdef.elements);
       break;
       nl ();
       dump_coff_scope (p->u.aenumdef.elements);
       break;
@@ -246,25 +248,26 @@ dump_coff_where (struct coff_where *p)
   switch (p->where)
     {
     case coff_where_stack:
   switch (p->where)
     {
     case coff_where_stack:
-      printf ("Stack offset %x", p->offset);
+      printf (_("Stack offset %x"), p->offset);
       break;
     case coff_where_memory:
       break;
     case coff_where_memory:
-      printf ("Memory section %s+%x", p->section->name, p->offset);
+      printf (_("Memory section %s+%x"), p->section->name, p->offset);
       break;
     case coff_where_register:
       break;
     case coff_where_register:
-      printf ("Register %d", p->offset);
+      printf (_("Register %d"), p->offset);
       break;
     case coff_where_member_of_struct:
       break;
     case coff_where_member_of_struct:
-      printf ("Struct Member offset %x", p->offset);
+      printf (_("Struct Member offset %x"), p->offset);
       break;
     case coff_where_member_of_enum:
       break;
     case coff_where_member_of_enum:
-      printf ("Enum Member offset %x", p->offset);
+      printf (_("Enum Member offset %x"), p->offset);
       break;
     case coff_where_unknown:
       break;
     case coff_where_unknown:
-      printf ("Undefined symbol");
+      printf (_("Undefined symbol"));
       break;
     case coff_where_strtag:
       printf ("STRTAG");
       break;
     case coff_where_strtag:
       printf ("STRTAG");
+      break;
     case coff_where_entag:
       printf ("ENTAG");
       break;
     case coff_where_entag:
       printf ("ENTAG");
       break;
@@ -328,27 +331,27 @@ static void
 dump_coff_symbol (struct coff_symbol *p)
 {
   tab (1);
 dump_coff_symbol (struct coff_symbol *p)
 {
   tab (1);
-  printf ("List of symbols");
+  printf (_("List of symbols"));
   nl ();
 
   while (p)
     {
       tab (1);
       tab (1);
   nl ();
 
   while (p)
     {
       tab (1);
       tab (1);
-      printf ("Symbol  %s, tag %d, number %d", p->name, p->tag, p->number);
+      printf (_("Symbol  %s, tag %d, number %d"), p->name, p->tag, p->number);
       nl ();
       tab (-1);
       tab (1);
       nl ();
       tab (-1);
       tab (1);
-      printf ("Type");
+      printf (_("Type"));
       nl ();
       dump_coff_type (p->type);
       tab (-1);
       tab (1);
       nl ();
       dump_coff_type (p->type);
       tab (-1);
       tab (1);
-      printf ("Where");
+      printf (_("Where"));
       dump_coff_where (p->where);
       tab (-1);
       tab (1);
       dump_coff_where (p->where);
       tab (-1);
       tab (1);
-      printf ("Visible");
+      printf (_("Visible"));
       dump_coff_visible (p->visible);
       tab (-1);
       p = p->next;
       dump_coff_visible (p->visible);
       tab (-1);
       p = p->next;
@@ -363,7 +366,8 @@ dump_coff_scope (struct coff_scope *p)
   if (p)
     {
       tab (1);
   if (p)
     {
       tab (1);
-      printf ("List of blocks %lx ",(unsigned long) p);
+      printf ("%s %" BFD_VMA_FMT "x ",
+             _("List of blocks "), (bfd_vma) (uintptr_t) p);
 
       if (p->sec)
        printf( "  %s %x..%x",  p->sec->name,p->offset, p->offset + p->size -1);
 
       if (p->sec)
        printf( "  %s %x..%x",  p->sec->name,p->offset, p->offset + p->size -1);
@@ -376,10 +380,10 @@ dump_coff_scope (struct coff_scope *p)
       while (p)
        {
          tab (0);
       while (p)
        {
          tab (0);
-         printf ("vars %d", p->nvars);
+         printf (_("vars %d"), p->nvars);
          nl ();
          dump_coff_symbol (p->vars_head);
          nl ();
          dump_coff_symbol (p->vars_head);
-         printf ("blocks");
+         printf (_("blocks"));
          nl ();
          dump_coff_scope (p->list_head);
          nl ();
          nl ();
          dump_coff_scope (p->list_head);
          nl ();
@@ -397,13 +401,13 @@ static void
 dump_coff_sfile (struct coff_sfile *p)
 {
   tab (1);
 dump_coff_sfile (struct coff_sfile *p)
 {
   tab (1);
-  printf ("List of source files");
+  printf (_("List of source files"));
   nl ();
 
   while (p)
     {
       tab (0);
   nl ();
 
   while (p)
     {
       tab (0);
-      printf ("Source file %s", p->name);
+      printf (_("Source file %s"), p->name);
       nl ();
       dump_coff_scope (p->scope);
       p = p->next;
       nl ();
       dump_coff_scope (p->scope);
       p = p->next;
@@ -414,21 +418,23 @@ dump_coff_sfile (struct coff_sfile *p)
 static void
 dump_coff_section (struct coff_section *ptr)
 {
 static void
 dump_coff_section (struct coff_section *ptr)
 {
-  int i;
+  unsigned int i;
 
   tab (1);
 
   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 %u"),
          ptr->name, ptr->code, ptr->data, ptr->address,ptr->size,
          ptr->number, ptr->nrelocs);
   nl ();
 
   for (i = 0; i < ptr->nrelocs; i++)
     {
          ptr->name, ptr->code, ptr->data, ptr->address,ptr->size,
          ptr->number, ptr->nrelocs);
   nl ();
 
   for (i = 0; i < ptr->nrelocs; i++)
     {
+      struct coff_reloc * r = ptr->relocs + i;
       tab (0);
       printf ("(%x %s %x)",
       tab (0);
       printf ("(%x %s %x)",
-             ptr->relocs[i].offset,
-             ptr->relocs[i].symbol->name,
-             ptr->relocs[i].addend);
+             r->offset,
+             /* PR 17512: file: 0a38fb7c.  */
+             r->symbol == NULL ? _("<no sym>") : r->symbol->name,
+             r->addend);
       nl ();
     }
 
       nl ();
     }
 
@@ -442,7 +448,7 @@ coff_dump (struct coff_ofile *ptr)
 
   printf ("Coff dump");
   nl ();
 
   printf ("Coff dump");
   nl ();
-  printf ("#souces %d", ptr->nsources);
+  printf (_("#sources %d"), ptr->nsources);
   nl ();
   dump_coff_sfile (ptr->source_head);
 
   nl ();
   dump_coff_sfile (ptr->source_head);
 
@@ -456,7 +462,7 @@ static void
 show_usage (FILE *file, int status)
 {
   fprintf (file, _("Usage: %s [option(s)] in-file\n"), program_name);
 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\
   fprintf (file, _(" The options are:\n\
   @<file>                Read options from <file>\n\
   -h --help              Display this information\n\
@@ -495,6 +501,7 @@ main (int ac, char **av)
 
   program_name = av[0];
   xmalloc_set_program_name (program_name);
 
   program_name = av[0];
   xmalloc_set_program_name (program_name);
+  bfd_set_error_program_name (program_name);
 
   expandargv (&ac, &av);
 
 
   expandargv (&ac, &av);
 
@@ -546,9 +553,11 @@ main (int ac, char **av)
     }
 
   tree = coff_grok (abfd);
     }
 
   tree = coff_grok (abfd);
-
-  coff_dump (tree);
-  printf ("\n");
+  if (tree)
+    {
+      coff_dump (tree);
+      printf ("\n");
+    }
 
   return 0;
 }
 
   return 0;
 }
This page took 0.036167 seconds and 4 git commands to generate.