* config/tc-xtensa.c (insn_labels, free_insn_labels, saved_insn_labels,
[deliverable/binutils-gdb.git] / gas / as.c
index 4878fcf6f794e804e7fb2c9738b72925335f383e..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;
@@ -88,6 +99,9 @@ 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.  */
 
@@ -206,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
@@ -230,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, _("\
@@ -254,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"));
@@ -349,7 +368,7 @@ parse_args (pargc, pargv)
      as if it were the argument of an option with character code 1.  */
 
   char *shortopts;
-  extern CONST char *md_shortopts;
+  extern const char *md_shortopts;
   static const char std_shortopts[] = {
     '-', 'J',
 #ifndef WORKING_DOT_WORD
@@ -373,6 +392,10 @@ parse_args (pargc, pargv)
   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)
@@ -400,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)
@@ -420,7 +443,13 @@ parse_args (pargc, pargv)
     {"warn", no_argument, NULL, OPTION_WARN},
 #define OPTION_TARGET_HELP (OPTION_STD_BASE + 19)
     {"target-help", no_argument, NULL, OPTION_TARGET_HELP},
-#define OPTION_WARN_FATAL (OPTION_STD_BASE + 20)
+#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.  */
@@ -484,6 +513,7 @@ parse_args (pargc, pargv)
 #endif
              case OPTION_VERBOSE:
                print_version_id ();
+               verbose = 1;
              break;
            }
          /* Fall through.  */
@@ -499,8 +529,8 @@ parse_args (pargc, pargv)
          break;
 
        case OPTION_TARGET_HELP:
-          md_show_usage (stdout);
-          exit (EXIT_SUCCESS);
+         md_show_usage (stdout);
+         exit (EXIT_SUCCESS);
 
        case OPTION_HELP:
          show_usage (stdout);
@@ -523,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"));
@@ -586,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;
              }
 
@@ -601,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;
 
@@ -679,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;
@@ -764,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;
@@ -781,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);
@@ -885,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;
@@ -1047,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.026496 seconds and 4 git commands to generate.