* config/tc-xtensa.c (insn_labels, free_insn_labels, saved_insn_labels,
[deliverable/binutils-gdb.git] / gas / as.c
index 2f78cad486addaa08695eb4ab35d1b7d68f8c1ff..5ff140386af888ff851051ebf3fe65711f33cfa7 100644 (file)
--- a/gas/as.c
+++ b/gas/as.c
@@ -1,5 +1,6 @@
 /* as.c - GAS main program.
-   Copyright (C) 1987, 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
+   Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+   1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 #include "output-file.h"
 #include "sb.h"
 #include "macro.h"
+#include "dwarf2dbg.h"
+#include "dw2gencfi.h"
+
+#ifdef BFD_ASSEMBLER
+#include "bfdver.h"
+#endif
 
 #ifdef HAVE_ITBL_CPU
 #include "itbl-ops.h"
@@ -59,6 +66,10 @@ static void parse_args PARAMS ((int *, char ***));
 static void dump_statistics PARAMS ((void));
 static void perform_an_assembly_pass PARAMS ((int argc, char **argv));
 static int macro_expr PARAMS ((const char *, int, sb *, int *));
+#ifdef USING_CGEN
+/* Perform any cgen specific initialisation for gas.  */
+extern void gas_cgen_begin PARAMS ((void));
+#endif
 
 /* True if a listing is wanted.  */
 int listing;
@@ -68,7 +79,7 @@ static char *listing_filename = NULL;
 
 /* Type of debugging to generate.  */
 
-enum debug_info_type debug_type = DEBUG_NONE;
+enum debug_info_type debug_type = DEBUG_UNSPECIFIED;
 
 /* Maximum level of macro nesting.  */
 int max_macro_nest = 100;
@@ -88,11 +99,13 @@ int chunksize = 0;
    Then the chunk sizes for gas and bfd will be reduced.  */
 int debug_memory = 0;
 
+/* Enable verbose mode.  */
+int verbose = 0;
+
 /* We build a list of defsyms as we read the options, and then define
    them after we have initialized everything.  */
 
-struct defsym_list
-{
+struct defsym_list {
   struct defsym_list *next;
   char *name;
   valueT value;
@@ -102,8 +115,7 @@ static struct defsym_list *defsyms;
 
 /* Keep a record of the itbl files we read in.  */
 
-struct itbl_file_list
-{
+struct itbl_file_list {
   struct itbl_file_list *next;
   char *name;
 };
@@ -208,7 +220,7 @@ print_version_id ()
 
 #ifdef BFD_ASSEMBLER
   fprintf (stderr, _("GNU assembler version %s (%s) using BFD version %s"),
-          VERSION, TARGET_ALIAS, BFD_VERSION);
+          VERSION, TARGET_ALIAS, BFD_VERSION_STRING);
 #else
   fprintf (stderr, _("GNU assembler version %s (%s)"), VERSION, TARGET_ALIAS);
 #endif
@@ -232,7 +244,6 @@ Options:\n\
                          m      include macro expansions\n\
                          n      omit forms processing\n\
                          s      include symbols\n\
-                         L      include line debug statistics (if applicable)\n\
                          =FILE  list to FILE (must be last sub-option)\n"));
 
   fprintf (stream, _("\
@@ -256,6 +267,12 @@ Options:\n\
     fprintf (stream, _("\
                           emulate output (default %s)\n"), def_em);
   }
+#endif
+#if defined BFD_ASSEMBLER && (defined OBJ_ELF || defined OBJ_MAYBE_ELF)
+  fprintf (stream, _("\
+  --execstack             require executable stack for this object\n"));
+  fprintf (stream, _("\
+  --noexecstack           don't require executable stack for this object\n"));
 #endif
   fprintf (stream, _("\
   -f                      skip whitespace and comment preprocessing\n"));
@@ -266,6 +283,8 @@ Options:\n\
   fprintf (stream, _("\
   --help                  show this message and exit\n"));
   fprintf (stream, _("\
+  --target-help           show target specific options\n"));
+  fprintf (stream, _("\
   -I DIR                  add DIR to search list for .include directives\n"));
   fprintf (stream, _("\
   -J                      don't warn about signed overflow\n"));
@@ -349,31 +368,34 @@ parse_args (pargc, pargv)
      as if it were the argument of an option with character code 1.  */
 
   char *shortopts;
-  extern CONST char *md_shortopts;
-  static const char std_shortopts[] =
-    {
-      '-', 'J',
+  extern const char *md_shortopts;
+  static const char std_shortopts[] = {
+    '-', 'J',
 #ifndef WORKING_DOT_WORD
-      /* -K is not meaningful if .word is not being hacked.  */
-      'K',
+    /* -K is not meaningful if .word is not being hacked.  */
+    'K',
 #endif
-      'L', 'M', 'R', 'W', 'Z', 'f', 'a', ':', ':', 'D', 'I', ':', 'o', ':',
+    'L', 'M', 'R', 'W', 'Z', 'f', 'a', ':', ':', 'D', 'I', ':', 'o', ':',
 #ifndef VMS
-      /* -v takes an argument on VMS, so we don't make it a generic
-         option.  */
-      'v',
+    /* -v takes an argument on VMS, so we don't make it a generic
+       option.  */
+    'v',
 #endif
-      'w', 'X',
-      /* New option for extending instruction set (see also --itbl below)  */
-      't', ':',
-      '\0'
-    };
+    'w', 'X',
+    /* New option for extending instruction set (see also --itbl below)  */
+    't', ':',
+    '\0'
+  };
   struct option *longopts;
   extern struct option md_longopts[];
   extern size_t md_longopts_size;
   static const struct option std_longopts[] = {
 #define OPTION_HELP (OPTION_STD_BASE)
     {"help", no_argument, NULL, OPTION_HELP},
+    /* 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.  */
+    {"keep-locals", no_argument, NULL, 'L'},
     {"keep-locals", no_argument, NULL, 'L'},
     {"mri", no_argument, NULL, 'M'},
 #define OPTION_NOCPP (OPTION_STD_BASE + 1)
@@ -401,7 +423,7 @@ parse_args (pargc, pargv)
 #define OPTION_LISTING_LHS_WIDTH (OPTION_STD_BASE + 9)
     {"listing-lhs-width", required_argument, NULL, OPTION_LISTING_LHS_WIDTH},
 #define OPTION_LISTING_LHS_WIDTH2 (OPTION_STD_BASE + 10)
-    {"listing-lhs-width", required_argument, NULL, OPTION_LISTING_LHS_WIDTH2},
+    {"listing-lhs-width2", required_argument, NULL, OPTION_LISTING_LHS_WIDTH2},
 #define OPTION_LISTING_RHS_WIDTH (OPTION_STD_BASE + 11)
     {"listing-rhs-width", required_argument, NULL, OPTION_LISTING_RHS_WIDTH},
 #define OPTION_LISTING_CONT_LINES (OPTION_STD_BASE + 12)
@@ -419,8 +441,18 @@ parse_args (pargc, pargv)
     {"no-warn", no_argument, NULL, 'W'},
 #define OPTION_WARN (OPTION_STD_BASE + 18)
     {"warn", no_argument, NULL, OPTION_WARN},
-#define OPTION_WARN_FATAL (OPTION_STD_BASE + 19)
+#define OPTION_TARGET_HELP (OPTION_STD_BASE + 19)
+    {"target-help", no_argument, NULL, OPTION_TARGET_HELP},
+#if defined BFD_ASSEMBLER && (defined OBJ_ELF || defined OBJ_MAYBE_ELF)
+#define OPTION_EXECSTACK (OPTION_STD_BASE + 20)
+    {"execstack", no_argument, NULL, OPTION_EXECSTACK},
+#define OPTION_NOEXECSTACK (OPTION_STD_BASE + 21)
+    {"noexecstack", no_argument, NULL, OPTION_NOEXECSTACK},
+#endif
+#define OPTION_WARN_FATAL (OPTION_STD_BASE + 22)
     {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
+    /* When you add options here, check that they do not collide with
+       OPTION_MD_BASE.  See as.h.  */
   };
 
   /* Construct the option lists from the standard list and the target
@@ -474,13 +506,14 @@ parse_args (pargc, pargv)
                 VMS code in md_parse_option can return 0 in that case,
                 but it has no way of pushing the filename argument back.  */
              if (optarg && *optarg)
-               new_argv[new_argc++] = optarg,  new_argv[new_argc] = NULL;
+               new_argv[new_argc++] = optarg, new_argv[new_argc] = NULL;
              else
 #else
              case 'v':
 #endif
              case OPTION_VERBOSE:
                print_version_id ();
+               verbose = 1;
              break;
            }
          /* Fall through.  */
@@ -495,6 +528,10 @@ parse_args (pargc, pargv)
          new_argv[new_argc] = NULL;
          break;
 
+       case OPTION_TARGET_HELP:
+         md_show_usage (stdout);
+         exit (EXIT_SUCCESS);
+
        case OPTION_HELP:
          show_usage (stdout);
          exit (EXIT_SUCCESS);
@@ -516,8 +553,12 @@ parse_args (pargc, pargv)
 
        case OPTION_VERSION:
          /* This output is intended to follow the GNU standards document.  */
+#ifdef BFD_ASSEMBLER
+         printf (_("GNU assembler %s\n"), BFD_VERSION_STRING);
+#else
          printf (_("GNU assembler %s\n"), VERSION);
-         printf (_("Copyright 2000 Free Software Foundation, Inc.\n"));
+#endif
+         printf (_("Copyright 2002 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.  This program has absolutely no warranty.\n"));
@@ -579,7 +620,7 @@ the GNU General Public License.  This program has absolutely no warranty.\n"));
 
            if (optarg == NULL)
              {
-               as_warn (_("No file name following -t option\n"));
+               as_warn (_("no file name following -t option"));
                break;
              }
 
@@ -594,11 +635,8 @@ the GNU General Public License.  This program has absolutely no warranty.\n"));
               internal table.  */
            itbl_files->name = xstrdup (optarg);
            if (itbl_parse (itbl_files->name) != 0)
-             {
-               fprintf (stderr, _("Failed to read instruction table %s\n"),
-                        itbl_files->name);
-               exit (EXIT_SUCCESS);
-             }
+             as_fatal (_("failed to read instruction table %s\n"),
+                       itbl_files->name);
          }
          break;
 
@@ -672,6 +710,18 @@ the GNU General Public License.  This program has absolutely no warranty.\n"));
          flag_fatal_warnings = 1;
          break;
 
+#if defined BFD_ASSEMBLER && (defined OBJ_ELF || defined OBJ_MAYBE_ELF)
+       case OPTION_EXECSTACK:
+         flag_execstack = 1;
+         flag_noexecstack = 0;
+         break;
+
+       case OPTION_NOEXECSTACK:
+         flag_noexecstack = 1;
+         flag_execstack = 0;
+         break;
+#endif
+
        case 'Z':
          flag_always_generate_output = 1;
          break;
@@ -757,10 +807,16 @@ the GNU General Public License.  This program has absolutely no warranty.\n"));
 
   *pargc = new_argc;
   *pargv = new_argv;
+
+#ifdef md_after_parse_args
+  md_after_parse_args ();
+#endif
 }
 
 static long start_time;
 
+int main PARAMS ((int, char **));
+
 int
 main (argc, argv)
      int argc;
@@ -774,18 +830,15 @@ main (argc, argv)
 
 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
   setlocale (LC_MESSAGES, "");
+#endif
+#if defined (HAVE_SETLOCALE)
+  setlocale (LC_CTYPE, "");
 #endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
   if (debug_memory)
-    {
-#ifdef BFD_ASSEMBLER
-      extern long _bfd_chunksize;
-      _bfd_chunksize = 64;
-#endif
-      chunksize = 64;
-    }
+    chunksize = 64;
 
 #ifdef HOST_SPECIAL_INIT
   HOST_SPECIAL_INIT (argc, argv);
@@ -878,6 +931,27 @@ main (argc, argv)
   md_end ();
 #endif
 
+#if defined BFD_ASSEMBLER && (defined OBJ_ELF || defined OBJ_MAYBE_ELF)
+  if ((flag_execstack || flag_noexecstack)
+      && OUTPUT_FLAVOR == bfd_target_elf_flavour)
+    {
+      segT gnustack;
+
+      gnustack = subseg_new (".note.GNU-stack", 0);
+      bfd_set_section_flags (stdoutput, gnustack,
+                            SEC_READONLY | (flag_execstack ? SEC_CODE : 0));
+                                                                             
+    }
+#endif
+
+  /* If we've been collecting dwarf2 .debug_line info, either for
+     assembly debugging or on behalf of the compiler, emit it now.  */
+  dwarf2_finish ();
+
+  /* If we constructed dwarf2 .eh_frame info, either via .cfi 
+     directives from the user or by the backend, emit it now.  */
+  cfi_finish ();
+
   if (seen_at_least_1_file ()
       && (flag_always_generate_output || had_errors () == 0))
     keep_it = 1;
@@ -1040,6 +1114,9 @@ perform_an_assembly_pass (argc, argv)
      and sections already created, in BFD_ASSEMBLER mode.  */
   md_begin ();
 
+#ifdef USING_CGEN
+  gas_cgen_begin ();
+#endif
 #ifdef obj_begin
   obj_begin ();
 #endif
This page took 0.027851 seconds and 4 git commands to generate.