Fix typos in ChangeLogs and update copyright notices
[deliverable/binutils-gdb.git] / binutils / objdump.c
index 522f6ec217472e44a34887b359be0fd74fcd407f..27002ab80ff748a91c230fe55428ec7bb697de1b 100644 (file)
@@ -1,5 +1,6 @@
 /* objdump.c -- dump information about an object file.
-   Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+   2000, 2001
    Free Software Foundation, Inc.
 
 This file is part of GNU Binutils.
@@ -220,55 +221,58 @@ usage (stream, status)
      FILE *stream;
      int status;
 {
-  fprintf (stream, _("Usage: %s <switches> file(s)\n"), program_name);
-  fprintf (stream, _(" At least one of the following switches must be given:\n"));
+  fprintf (stream, _("Usage: %s OPTION... FILE...\n"), program_name);
+  fprintf (stream, _("Display information from object FILE.\n"));
+  fprintf (stream, _("\n At least one of the following switches must be given:\n"));
   fprintf (stream, _("\
-  -a  --archive-headers    Display archive header information\n\
-  -f  --file-headers       Display the contents of the overall file header\n\
-  -p  --private-headers    Display object format specific file header contents\n\
-  -h  --[section-]headers  Display the contents of the section headers\n\
-  -x  --all-headers        Display the contents of all headers\n\
-  -d  --disassemble        Display assembler contents of executable sections\n\
-  -D  --disassemble-all    Display assembler contents of all sections\n\
-  -S  --source             Intermix source code with disassembly\n\
-  -s  --full-contents      Display the full contents of all sections requested\n\
-  -g  --debugging          Display debug information in object file\n\
-  -G  --stabs              Display the STABS contents of an ELF format file\n\
-  -t  --syms               Display the contents of the symbol table(s)\n\
-  -T  --dynamic-syms       Display the contents of the dynamic symbol table\n\
-  -r  --reloc              Display the relocation entries in the file\n\
-  -R  --dynamic-reloc      Display the dynamic relocation entries in the file\n\
-  -V  --version            Display this program's version number\n\
-  -i  --info               List object formats and architectures supported\n\
-  -H  --help               Display this information\n\
+  -a, --archive-headers    Display archive header information\n\
+  -f, --file-headers       Display the contents of the overall file header\n\
+  -p, --private-headers    Display object format specific file header contents\n\
+  -h, --[section-]headers  Display the contents of the section headers\n\
+  -x, --all-headers        Display the contents of all headers\n\
+  -d, --disassemble        Display assembler contents of executable sections\n\
+  -D, --disassemble-all    Display assembler contents of all sections\n\
+  -S, --source             Intermix source code with disassembly\n\
+  -s, --full-contents      Display the full contents of all sections requested\n\
+  -g, --debugging          Display debug information in object file\n\
+  -G, --stabs              Display (in raw form) any STABS info in the file\n\
+  -t, --syms               Display the contents of the symbol table(s)\n\
+  -T, --dynamic-syms       Display the contents of the dynamic symbol table\n\
+  -r, --reloc              Display the relocation entries in the file\n\
+  -R, --dynamic-reloc      Display the dynamic relocation entries in the file\n\
+  -V, --version            Display this program's version number\n\
+  -i, --info               List object formats and architectures supported\n\
+  -H, --help               Display this information\n\
 "));
   if (status != 2)
     {
       fprintf (stream, _("\n The following switches are optional:\n"));
       fprintf (stream, _("\
-  -b  --target <bfdname>         Specify the target object format as <bfdname>\n\
-  -m  --architecture <machine>   Specify the target architecture as <machine>\n\
-  -j  --section <name>           Only display information for section <name>\n\
-  -M  --disassembler-options <o> Pass text <o> on to the disassembler\n\
+  -b, --target=BFDNAME           Specify the target object format as BFDNAME\n\
+  -m, --architecture=MACHINE     Specify the target architecture as MACHINE\n\
+  -j, --section=NAME             Only display information for section NAME\n\
+  -M, --disassembler-options=OPT Pass text OPT on to the disassembler\n\
   -EB --endian=big               Assume big endian format when disassembling\n\
   -EL --endian=little            Assume little endian format when disassembling\n\
       --file-start-context       Include context from start of file (with -S)\n\
-  -l  --line-numbers             Include line numbers and filenames in output\n\
-  -C  --demangle                 Decode mangled/processed symbol names\n\
-  -w  --wide                     Format output for more than 80 columns\n\
-  -z  --disassemble-zeroes       Do not skip blocks of zeroes when disassembling\n\
-      --start-address <addr>     Only process data whoes address is >= <addr>\n\
-      --stop-address <addr>      Only process data whoes address is <= <addr>\n\
+  -l, --line-numbers             Include line numbers and filenames in output\n\
+  -C, --demangle[=STYLE]         Decode mangled/processed symbol names\n\
+                                  The STYLE, if specified, can be `auto', 'gnu',\n\
+                                  'lucid', 'arm', 'hp', 'edg', or 'gnu-new-abi'\n\
+  -w, --wide                     Format output for more than 80 columns\n\
+  -z, --disassemble-zeroes       Do not skip blocks of zeroes when disassembling\n\
+      --start-address=ADDR       Only process data whoes address is >= ADDR\n\
+      --stop-address=ADDR        Only process data whoes address is <= ADDR\n\
       --prefix-addresses         Print complete address alongside disassembly\n\
       --[no-]show-raw-insn       Display hex alongside symbolic disassembly\n\
-      --adjust-vma <offset>      Add <offset> to all displayed section addresses\n\
+      --adjust-vma=OFFSET        Add OFFSET to all displayed section addresses\n\
 \n"));
       list_supported_targets (program_name, stream);
-      
+
       disassembler_usage (stream);
     }
   if (status == 0)
-    fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO);
+    fprintf (stream, _("Report bugs to %s.\n"), REPORT_BUGS_TO);
   exit (status);
 }
 
@@ -287,7 +291,7 @@ static struct option long_options[]=
   {"architecture", required_argument, NULL, 'm'},
   {"archive-headers", no_argument, NULL, 'a'},
   {"debugging", no_argument, NULL, 'g'},
-  {"demangle", no_argument, NULL, 'C'},
+  {"demangle", optional_argument, NULL, 'C'},
   {"disassemble", no_argument, NULL, 'd'},
   {"disassemble-all", no_argument, NULL, 'D'},
   {"disassembler-options", required_argument, NULL, 'M'},
@@ -1355,13 +1359,15 @@ disassemble_bytes (info, disassemble_fn, insns, data,
              info->bytes_per_line = 0;
              info->bytes_per_chunk = 0;
 
+#ifdef DISASSEMBLER_NEEDS_RELOCS
              /* FIXME: This is wrong.  It tests the number of octets
                  in the last instruction, not the current one.  */
              if (*relppp < relppend
                  && (**relppp)->address >= addr_offset
-                 && (**relppp)->address < addr_offset + octets / opb)
+                 && (**relppp)->address <= addr_offset + octets / opb)
                info->flags = INSN_HAS_RELOC;
              else
+#endif
                info->flags = 0;
 
              octets = (*disassemble_fn) (section->vma + addr_offset, info);
@@ -1501,12 +1507,20 @@ disassemble_bytes (info, disassemble_fn, insns, data,
            need_nl = true;
        }
 
-      if (dump_reloc_info
-         && (section->flags & SEC_RELOC) != 0)
+      if ((section->flags & SEC_RELOC) != 0
+#ifndef DISASSEMBLER_NEEDS_RELOCS        
+         && dump_reloc_info
+#endif
+         )
        {
          while ((*relppp) < relppend
                 && ((**relppp)->address >= (bfd_vma) addr_offset
                     && (**relppp)->address < (bfd_vma) addr_offset + octets / opb))
+#ifdef DISASSEMBLER_NEEDS_RELOCS
+           if (! dump_reloc_info)
+             ++(*relppp);
+           else
+#endif
            {
              arelent *q;
 
@@ -1662,8 +1676,11 @@ disassemble_data (abfd)
       if (only != (char *) NULL && strcmp (only, section->name) != 0)
        continue;
 
-      if (dump_reloc_info
-         && (section->flags & SEC_RELOC) != 0)
+      if ((section->flags & SEC_RELOC) != 0
+#ifndef DISASSEMBLER_NEEDS_RELOCS        
+         && dump_reloc_info
+#endif
+         ) 
        {
          long relsize;
 
@@ -2608,7 +2625,7 @@ dump_reloc_set (abfd, sec, relpp, relcount)
 }
 \f
 /* The length of the longest architecture name + 1.  */
-#define LONGEST_ARCH sizeof("rs6000:6000")
+#define LONGEST_ARCH sizeof("powerpc:common")
 
 static const char *
 endian_string (endian)
@@ -2628,14 +2645,14 @@ endian_string (endian)
 static void
 display_target_list ()
 {
-  extern bfd_target *bfd_target_vector[];
+  extern const bfd_target *const *bfd_target_vector;
   char *dummy_name;
   int t;
 
   dummy_name = make_temp_file (NULL);
   for (t = 0; bfd_target_vector[t]; t++)
     {
-      bfd_target *p = bfd_target_vector[t];
+      const bfd_target *p = bfd_target_vector[t];
       bfd *abfd = bfd_openw (dummy_name, p->name);
       int a;
 
@@ -2653,7 +2670,7 @@ display_target_list ()
        {
          if (bfd_get_error () != bfd_error_invalid_operation)
            nonfatal (p->name);
-         bfd_close (abfd);
+         bfd_close_all_done (abfd);
          continue;
        }
 
@@ -2661,7 +2678,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 (abfd);
+      bfd_close_all_done (abfd);
     }
   unlink (dummy_name);
   free (dummy_name);
@@ -2676,7 +2693,7 @@ display_info_table (first, last)
      int first;
      int last;
 {
-  extern bfd_target *bfd_target_vector[];
+  extern const bfd_target *const *bfd_target_vector;
   int t, a;
   char *dummy_name;
 
@@ -2694,7 +2711,7 @@ display_info_table (first, last)
                bfd_printable_arch_mach (a, 0));
        for (t = first; t < last && bfd_target_vector[t]; t++)
          {
-           bfd_target *p = bfd_target_vector[t];
+           const bfd_target *p = bfd_target_vector[t];
            boolean ok = true;
            bfd *abfd = bfd_openw (dummy_name, p->name);
 
@@ -2730,7 +2747,7 @@ display_info_table (first, last)
                putchar (' ');
              }
            if (abfd != NULL)
-             bfd_close (abfd);
+             bfd_close_all_done (abfd);
          }
        putchar ('\n');
       }
@@ -2745,7 +2762,7 @@ static void
 display_target_tables ()
 {
   int t, columns;
-  extern bfd_target *bfd_target_vector[];
+  extern const bfd_target *const *bfd_target_vector;
   char *colum;
 
   columns = 0;
@@ -2832,6 +2849,17 @@ main (argc, argv)
          break;
        case 'C':
          do_demangle = true;
+         if (optarg != NULL)
+           {
+             enum demangling_styles style;
+             
+             style = cplus_demangle_name_to_style (optarg);
+             if (style == unknown_demangling) 
+               fatal (_("unknown demangling style `%s'"),
+                      optarg);
+             
+             cplus_demangle_set_style (style);
+           }
          break;
        case 'w':
          wide_output = true;
This page took 0.034652 seconds and 4 git commands to generate.