/* as.c - GAS main program.
Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001
+ 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#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"
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;
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. */
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"));
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
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)
{"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. */
#endif
case OPTION_VERBOSE:
print_version_id ();
+ verbose = 1;
break;
}
/* Fall through. */
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);
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 2001 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"));
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;
*pargc = new_argc;
*pargv = new_argv;
+
+#ifdef md_after_parse_args
+ md_after_parse_args ();
+#endif
}
static long start_time;
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);
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;
and sections already created, in BFD_ASSEMBLER mode. */
md_begin ();
+#ifdef USING_CGEN
+ gas_cgen_begin ();
+#endif
#ifdef obj_begin
obj_begin ();
#endif