bfd/ChangeLog:
[platform/upstream/binutils.git] / gas / as.c
index bcb827b..e494fa5 100644 (file)
--- a/gas/as.c
+++ b/gas/as.c
@@ -1,6 +1,6 @@
 /* as.c - GAS main program.
    Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 #ifdef HAVE_ITBL_CPU
 #include "itbl-ops.h"
 #else
-#define itbl_parse(itbl_file) 1
 #define itbl_init()
 #endif
 
 #ifdef HAVE_SBRK
 #ifdef NEED_DECLARATION_SBRK
-extern PTR sbrk ();
+extern void *sbrk ();
 #endif
 #endif
 
@@ -60,13 +59,6 @@ extern PTR sbrk ();
 extern void gas_cgen_begin (void);
 #endif
 
-/* Keep a record of the itbl files we read in.  */
-struct itbl_file_list
-{
-  struct itbl_file_list *next;
-  char *name;
-};
-
 /* We build a list of defsyms as we read the options, and then define
    them after we have initialized everything.  */
 struct defsym_list
@@ -106,6 +98,9 @@ int debug_memory = 0;
 /* Enable verbose mode.  */
 int verbose = 0;
 
+/* Keep the output file.  */
+int keep_it = 0;
+
 segT reg_section;
 segT expr_section;
 segT text_section;
@@ -117,7 +112,15 @@ static char *listing_filename = NULL;
 
 static struct defsym_list *defsyms;
 
+#ifdef HAVE_ITBL_CPU
+/* Keep a record of the itbl files we read in.  */
+struct itbl_file_list
+{
+  struct itbl_file_list *next;
+  char *name;
+};
 static struct itbl_file_list *itbl_files;
+#endif
 
 static long start_time;
 
@@ -232,6 +235,7 @@ Options:\n\
                          Sub-options [default hls]:\n\
                          c      omit false conditionals\n\
                          d      omit debugging directives\n\
+                         g      include general info\n\
                          h      include high-level source\n\
                          l      include assembly\n\
                          m      include macro expansions\n\
@@ -244,6 +248,8 @@ Options:\n\
   fprintf (stream, _("\
   -D                      produce assembler debugging messages\n"));
   fprintf (stream, _("\
+  --debug-prefix-map OLD=NEW  Map OLD to NEW in debug information\n"));
+  fprintf (stream, _("\
   --defsym SYM=VAL        define symbol SYM to given value\n"));
 #ifdef USE_EMULATIONS
   {
@@ -321,9 +327,11 @@ Options:\n\
   --warn                  don't suppress warnings\n"));
   fprintf (stream, _("\
   --fatal-warnings        treat warnings as errors\n"));
+#ifdef HAVE_ITBL_CPU
   fprintf (stream, _("\
   --itbl INSTTBL          extend instruction set to include instructions\n\
                           matching the specifications defined in file INSTTBL\n"));
+#endif
   fprintf (stream, _("\
   -w                      ignored\n"));
   fprintf (stream, _("\
@@ -390,8 +398,10 @@ parse_args (int * pargc, char *** pargv)
     'v',
 #endif
     'w', 'X',
+#ifdef HAVE_ITBL_CPU
     /* New option for extending instruction set (see also --itbl below).  */
     't', ':',
+#endif
     '\0'
   };
   struct option *longopts;
@@ -407,8 +417,8 @@ parse_args (int * pargc, char *** pargv)
       OPTION_DUMPCONFIG,
       OPTION_VERBOSE,
       OPTION_EMULATION,
+      OPTION_DEBUG_PREFIX_MAP,
       OPTION_DEFSYM,
-      OPTION_INSTTBL,
       OPTION_LISTING_LHS_WIDTH,
       OPTION_LISTING_LHS_WIDTH2,
       OPTION_LISTING_RHS_WIDTH,
@@ -427,7 +437,9 @@ parse_args (int * pargc, char *** pargv)
       OPTION_AL,
       OPTION_HASH_TABLE_SIZE,
       OPTION_REDUCE_MEMORY_OVERHEADS,
-      OPTION_WARN_FATAL
+      OPTION_WARN_FATAL,
+      OPTION_COMPRESS_DEBUG,
+      OPTION_NOCOMPRESS_DEBUG
     /* When you add options here, check that they do
        not collide with OPTION_MD_BASE.  See as.h.  */
     };
@@ -445,6 +457,9 @@ parse_args (int * pargc, char *** pargv)
     ,{"a", optional_argument, NULL, 'a'}
     /* Handle -al=<FILE>.  */
     ,{"al", optional_argument, NULL, OPTION_AL}
+    ,{"compress-debug-sections", no_argument, NULL, OPTION_COMPRESS_DEBUG}
+    ,{"nocompress-debug-sections", no_argument, NULL, OPTION_NOCOMPRESS_DEBUG}
+    ,{"debug-prefix-map", required_argument, NULL, OPTION_DEBUG_PREFIX_MAP}
     ,{"defsym", required_argument, NULL, OPTION_DEFSYM}
     ,{"dump-config", no_argument, NULL, OPTION_DUMPCONFIG}
     ,{"emulation", required_argument, NULL, OPTION_EMULATION}
@@ -462,13 +477,15 @@ parse_args (int * pargc, char *** pargv)
     ,{"gstabs+", no_argument, NULL, OPTION_GSTABS_PLUS}
     ,{"hash-size", required_argument, NULL, OPTION_HASH_TABLE_SIZE}
     ,{"help", no_argument, NULL, OPTION_HELP}
+#ifdef HAVE_ITBL_CPU
     /* New option for extending instruction set (see also -t above).
        The "-t file" or "--itbl file" option extends the basic set of
        valid instructions by reading "file", a text file containing a
        list of instruction formats.  The additional opcodes and their
        formats are added to the built-in set of instructions, and
        mnemonics for new registers may also be defined.  */
-    ,{"itbl", required_argument, NULL, OPTION_INSTTBL}
+    ,{"itbl", required_argument, NULL, 't'}
+#endif
     /* getopt allows abbreviations, so we do this to stop it from
        treating -k as an abbreviation for --keep-locals.  Some
        ports use -k to enable PIC assembly.  */
@@ -496,7 +513,8 @@ parse_args (int * pargc, char *** pargv)
      dependent list.  Include space for an extra NULL option and
      always NULL terminate.  */
   shortopts = concat (std_shortopts, md_shortopts, (char *) NULL);
-  longopts = xmalloc (sizeof (std_longopts) + md_longopts_size + sizeof (struct option));
+  longopts = (struct option *) xmalloc (sizeof (std_longopts)
+                                        + md_longopts_size + sizeof (struct option));
   memcpy (longopts, std_longopts, sizeof (std_longopts));
   memcpy (((char *) longopts) + sizeof (std_longopts), md_longopts, md_longopts_size);
   memset (((char *) longopts) + sizeof (std_longopts) + md_longopts_size,
@@ -507,7 +525,7 @@ parse_args (int * pargc, char *** pargv)
   old_argv = *pargv;
 
   /* Initialize a new argv that contains no options.  */
-  new_argv = xmalloc (sizeof (char *) * (old_argc + 1));
+  new_argv = (char **) xmalloc (sizeof (char *) * (old_argc + 1));
   new_argv[0] = old_argv[0];
   new_argc = 1;
   new_argv[new_argc] = NULL;
@@ -590,7 +608,7 @@ parse_args (int * pargc, char *** pargv)
        case OPTION_VERSION:
          /* This output is intended to follow the GNU standards document.  */
          printf (_("GNU assembler %s\n"), BFD_VERSION_STRING);
-         printf (_("Copyright 2007 Free Software Foundation, Inc.\n"));
+         printf (_("Copyright 2010 Free Software Foundation, Inc.\n"));
          printf (_("\
 This program is free software; you may redistribute it under the terms of\n\
 the GNU General Public License version 3 or later.\n\
@@ -620,6 +638,18 @@ This program has absolutely no warranty.\n"));
 #endif
          exit (EXIT_SUCCESS);
 
+       case OPTION_COMPRESS_DEBUG:
+         flag_compress_debug = 1;
+         break;
+
+       case OPTION_NOCOMPRESS_DEBUG:
+         flag_compress_debug = 0;
+         break;
+
+       case OPTION_DEBUG_PREFIX_MAP:
+         add_debug_prefix_map (optarg);
+         break;
+
        case OPTION_DEFSYM:
          {
            char *s;
@@ -632,7 +662,7 @@ This program has absolutely no warranty.\n"));
              as_fatal (_("bad defsym; format is --defsym name=value"));
            *s++ = '\0';
            i = bfd_scan_vma (s, (const char **) NULL, 0);
-           n = xmalloc (sizeof *n);
+           n = (struct defsym_list *) xmalloc (sizeof *n);
            n->next = defsyms;
            n->name = optarg;
            n->value = i;
@@ -640,7 +670,7 @@ This program has absolutely no warranty.\n"));
          }
          break;
 
-       case OPTION_INSTTBL:
+#ifdef HAVE_ITBL_CPU
        case 't':
          {
            /* optarg is the name of the file containing the instruction
@@ -668,6 +698,7 @@ This program has absolutely no warranty.\n"));
                        itbl_files->name);
          }
          break;
+#endif
 
        case OPTION_DEPFILE:
          start_dependencies (optarg);
@@ -811,6 +842,9 @@ This program has absolutely no warranty.\n"));
                    case 'd':
                      listing |= LISTING_NODEBUG;
                      break;
+                   case 'g':
+                     listing |= LISTING_GENERAL;
+                     break;
                    case 'h':
                      listing |= LISTING_HLL;
                      break;
@@ -930,13 +964,13 @@ dump_statistics (void)
 #endif
 }
 
-#ifndef OBJ_VMS
 static void
 close_output_file (void)
 {
   output_file_close (out_file_name);
+  if (!keep_it)
+    unlink_if_ordinary (out_file_name);
 }
-#endif
 
 /* The interface between the macro code and gas expression handling.  */
 
@@ -1038,7 +1072,6 @@ create_obj_attrs_section (void)
 {
   segT s;
   char *p;
-  addressT addr;
   offsetT size;
   const char *name;
 
@@ -1052,7 +1085,7 @@ create_obj_attrs_section (void)
       elf_section_type (s)
        = get_elf_backend_data (stdoutput)->obj_attrs_section_type;
       bfd_set_section_flags (stdoutput, s, SEC_READONLY | SEC_DATA);
-      addr = frag_now_fix ();
+      frag_now_fix ();
       p = frag_more (size);
       bfd_elf_set_obj_attr_contents (stdoutput, (bfd_byte *)p, size);
     }
@@ -1063,8 +1096,9 @@ create_obj_attrs_section (void)
 int
 main (int argc, char ** argv)
 {
+  char ** argv_orig = argv;
+
   int macro_strip_at;
-  int keep_it;
 
   start_time = get_run_time ();
 
@@ -1116,10 +1150,8 @@ main (int argc, char ** argv)
   input_scrub_begin ();
   expr_begin ();
 
-#ifndef OBJ_VMS /* Does its own file handling.  */
   /* It has to be called after dump_statistics ().  */
   xatexit (close_output_file);
-#endif
 
   if (flag_print_statistics)
     xatexit (dump_statistics);
@@ -1134,7 +1166,7 @@ main (int argc, char ** argv)
   PROGRESS (1);
 
   output_file_create (out_file_name);
-  assert (stdoutput != 0);
+  gas_assert (stdoutput != 0);
 
 #ifdef tc_init_after_args
   tc_init_after_args ();
@@ -1142,6 +1174,8 @@ main (int argc, char ** argv)
 
   itbl_init ();
 
+  dwarf2_init ();
+
   /* Now that we have fully initialized, and have created the output
      file, define any symbols requested by --defsym command line
      arguments.  */
@@ -1215,8 +1249,10 @@ main (int argc, char ** argv)
   if (keep_it)
     write_object_file ();
 
+  fflush (stderr);
+
 #ifndef NO_LISTING
-  listing_print (listing_filename);
+  listing_print (listing_filename, argv_orig);
 #endif
 
   if (flag_fatal_warnings && had_warnings () > 0 && had_errors () == 0)
@@ -1225,9 +1261,6 @@ main (int argc, char ** argv)
   if (had_errors () > 0 && ! flag_always_generate_output)
     keep_it = 0;
 
-  if (!keep_it)
-    unlink_if_ordinary (out_file_name);
-
   input_scrub_end ();
 
   END_PROGRESS (myname);