* strings.c (isgraphic): Interpret <TAB> as a printable character,
[external/binutils.git] / binutils / objdump.c
index bfcc143..4adabd2 100644 (file)
@@ -1,5 +1,5 @@
 /* objdump.c -- dump information about an object file.
-   Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+   Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
    Free Software Foundation, Inc.
 
 This file is part of GNU Binutils.
@@ -29,12 +29,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "debug.h"
 #include "budbg.h"
 
-#ifdef ANSI_PROTOTYPES
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
 /* Internal headers for the ELF .stab-dump code - sorry.  */
 #define        BYTES_IN_WORD   32
 #include "aout/aout64.h"
@@ -443,7 +437,7 @@ slurp_symtab (abfd)
 
   if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
     {
-      fprintf (stderr, _("%s: no symbols\n"), bfd_get_filename (abfd));
+      non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
       symcount = 0;
       return NULL;
     }
@@ -460,7 +454,7 @@ slurp_symtab (abfd)
   if (symcount < 0)
     bfd_fatal (bfd_get_filename (abfd));
   if (symcount == 0)
-    fprintf (stderr, _("%s: no symbols\n"), bfd_get_filename (abfd));
+    non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
   return sy;
 }
 
@@ -478,8 +472,7 @@ slurp_dynamic_symtab (abfd)
     {
       if (!(bfd_get_file_flags (abfd) & DYNAMIC))
        {
-         fprintf (stderr, _("%s: %s: not a dynamic object\n"),
-                  program_name, bfd_get_filename (abfd));
+         non_fatal (_("%s: not a dynamic object"), bfd_get_filename (abfd));
          dynsymcount = 0;
          return NULL;
        }
@@ -495,8 +488,7 @@ slurp_dynamic_symtab (abfd)
   if (dynsymcount < 0)
     bfd_fatal (bfd_get_filename (abfd));
   if (dynsymcount == 0)
-    fprintf (stderr, _("%s: %s: No dynamic symbols\n"),
-            program_name, bfd_get_filename (abfd));
+    non_fatal (_("%s: No dynamic symbols"), bfd_get_filename (abfd));
   return sy;
 }
 
@@ -1199,8 +1191,7 @@ objdump_sprintf (va_alist)
 
   if (buf == NULL)
     {
-      fprintf (stderr, _("Out of virtual memory\n"));
-      exit (1);
+      fatal (_("Out of virtual memory"));
     }
 
   n = strlen (buf);
@@ -1581,7 +1572,7 @@ disassemble_data (abfd)
   struct disassemble_info disasm_info;
   struct objdump_disasm_info aux;
   asection *section;
-  unsigned int opb = bfd_octets_per_byte (abfd);
+  unsigned int opb;
 
   print_files = NULL;
   prev_functionname = NULL;
@@ -1603,17 +1594,13 @@ disassemble_data (abfd)
   aux.require_sec = false;
   disasm_info.print_address_func = objdump_print_address;
   disasm_info.symbol_at_address_func = objdump_symbol_at_address;
-  disasm_info.octets_per_byte = opb;
 
   if (machine != (char *) NULL)
     {
       const bfd_arch_info_type *info = bfd_scan_arch (machine);
       if (info == NULL)
        {
-         fprintf (stderr, _("%s: Can't use supplied machine %s\n"),
-                  program_name,
-                  machine);
-         exit (1);
+         fatal (_("Can't use supplied machine %s"), machine);
        }
       abfd->arch_info = info;
     }
@@ -1631,17 +1618,19 @@ disassemble_data (abfd)
   disassemble_fn = disassembler (abfd);
   if (!disassemble_fn)
     {
-      fprintf (stderr, _("%s: Can't disassemble for architecture %s\n"),
-              program_name,
-              bfd_printable_arch_mach (bfd_get_arch (abfd), 0));
+      non_fatal (_("Can't disassemble for architecture %s\n"),
+                bfd_printable_arch_mach (bfd_get_arch (abfd), 0));
       exit_status = 1;
       return;
     }
 
+  opb = bfd_octets_per_byte (abfd);
+
   disasm_info.flavour = bfd_get_flavour (abfd);
   disasm_info.arch = bfd_get_arch (abfd);
   disasm_info.mach = bfd_get_mach (abfd);
   disasm_info.disassembler_options = disassembler_options;
+  disasm_info.octets_per_byte = opb;
   
   if (bfd_big_endian (abfd))
     disasm_info.display_endian = disasm_info.endian = BFD_ENDIAN_BIG;
@@ -1889,8 +1878,8 @@ read_section_stabs (abfd, stabsect_name, strsect_name)
   stabstrsect = bfd_get_section_by_name (abfd, strsect_name);
   if (0 == stabstrsect)
     {
-      fprintf (stderr, _("%s: %s has no %s section\n"), program_name,
-              bfd_get_filename (abfd), strsect_name);
+      non_fatal (_("%s has no %s section"),
+                bfd_get_filename (abfd), strsect_name);
       exit_status = 1;
       return false;
     }
@@ -1903,9 +1892,9 @@ read_section_stabs (abfd, stabsect_name, strsect_name)
   
   if (! bfd_get_section_contents (abfd, stabsect, (PTR) stabs, 0, stab_size))
     {
-      fprintf (stderr, _("%s: Reading %s section of %s failed: %s\n"),
-              program_name, stabsect_name, bfd_get_filename (abfd),
-              bfd_errmsg (bfd_get_error ()));
+      non_fatal (_("Reading %s section of %s failed: %s"),
+                stabsect_name, bfd_get_filename (abfd),
+                bfd_errmsg (bfd_get_error ()));
       free (stabs);
       free (strtab);
       exit_status = 1;
@@ -1915,9 +1904,9 @@ read_section_stabs (abfd, stabsect_name, strsect_name)
   if (! bfd_get_section_contents (abfd, stabstrsect, (PTR) strtab, 0,
                                  stabstr_size))
     {
-      fprintf (stderr, _("%s: Reading %s section of %s failed: %s\n"),
-              program_name, strsect_name, bfd_get_filename (abfd),
-              bfd_errmsg (bfd_get_error ()));
+      non_fatal (_("Reading %s section of %s failed: %s\n"),
+                strsect_name, bfd_get_filename (abfd),
+                bfd_errmsg (bfd_get_error ()));
       free (stabs);
       free (strtab);
       exit_status = 1;
@@ -2148,9 +2137,8 @@ dump_bfd (abfd)
        {
          if (! print_debugging_info (stdout, dhandle))
            {
-             fprintf (stderr,
-                      _("%s: printing debugging information failed\n"),
-                      bfd_get_filename (abfd));
+             non_fatal (_("%s: printing debugging information failed"),
+                        bfd_get_filename (abfd));
              exit_status = 1;
            }
        }
@@ -2644,7 +2632,7 @@ display_target_list ()
   char *dummy_name;
   int t;
 
-  dummy_name = choose_temp_base ();
+  dummy_name = make_temp_file (NULL);
   for (t = 0; bfd_target_vector[t]; t++)
     {
       bfd_target *p = bfd_target_vector[t];
@@ -2665,6 +2653,7 @@ display_target_list ()
        {
          if (bfd_get_error () != bfd_error_invalid_operation)
            nonfatal (p->name);
+         bfd_close_all_done (abfd);
          continue;
        }
 
@@ -2672,6 +2661,7 @@ display_target_list ()
        if (bfd_set_arch_mach (abfd, (enum bfd_architecture) a, 0))
          printf ("  %s\n",
                  bfd_printable_arch_mach ((enum bfd_architecture) a, 0));
+      bfd_close_all_done (abfd);
     }
   unlink (dummy_name);
   free (dummy_name);
@@ -2696,7 +2686,7 @@ display_info_table (first, last)
     printf ("%s ", bfd_target_vector[t]->name);
   putchar ('\n');
 
-  dummy_name = choose_temp_base ();
+  dummy_name = make_temp_file (NULL);
   for (a = (int) bfd_arch_obscure + 1; a < (int) bfd_arch_last; a++)
     if (strcmp (bfd_printable_arch_mach (a, 0), "UNKNOWN!") != 0)
       {
@@ -2739,6 +2729,8 @@ display_info_table (first, last)
                  putchar ('-');
                putchar (' ');
              }
+           if (abfd != NULL)
+             bfd_close_all_done (abfd);
          }
        putchar ('\n');
       }
@@ -2860,8 +2852,7 @@ main (argc, argv)
            endian = BFD_ENDIAN_LITTLE;
          else
            {
-             fprintf (stderr, _("%s: unrecognized -E option\n"),
-                      program_name);
+             non_fatal (_("unrecognized -E option"));
              usage (stderr, 1);
            }
          break;
@@ -2872,8 +2863,7 @@ main (argc, argv)
            endian = BFD_ENDIAN_LITTLE;
          else
            {
-             fprintf (stderr, _("%s: unrecognized --endian type `%s'\n"),
-                     program_name, optarg);
+             non_fatal (_("unrecognized --endian type `%s'"), optarg);
              usage (stderr, 1);
            }
          break;