/* as.c - GAS main program.
- Copyright (C) 1987-2016 Free Software Foundation, Inc.
+ Copyright (C) 1987-2019 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#define COMMON
+/* Disable code to set FAKE_LABEL_NAME in obj-multi.h, to avoid circular
+ reference. */
+#define INITIALIZING_EMULS
+
#include "as.h"
#include "subsegs.h"
#include "output-file.h"
#include "dwarf2dbg.h"
#include "dw2gencfi.h"
#include "bfdver.h"
+#include "write.h"
#ifdef HAVE_ITBL_CPU
#include "itbl-ops.h"
#define itbl_init()
#endif
-#ifdef HAVE_SBRK
-#ifdef NEED_DECLARATION_SBRK
-extern void *sbrk ();
-#endif
-#endif
-
#ifdef USING_CGEN
/* Perform any cgen specific initialisation for gas. */
extern void gas_cgen_begin (void);
#if defined OBJ_ELF || defined OBJ_MAYBE_ELF
int flag_use_elf_stt_common = DEFAULT_GENERATE_ELF_STT_COMMON;
+bfd_boolean flag_generate_build_notes = DEFAULT_GENERATE_BUILD_NOTES;
#endif
/* Keep the output file. */
#endif
static long start_time;
-#ifdef HAVE_SBRK
-char *start_sbrk;
-#endif
static int flag_macro_alternate;
if (this_emulation->fake_label_name == 0)
{
if (this_emulation->leading_underscore)
- this_emulation->fake_label_name = "L0\001";
+ this_emulation->fake_label_name = FAKE_LABEL_NAME;
else
/* What other parameters should we test? */
- this_emulation->fake_label_name = ".L0\001";
+ this_emulation->fake_label_name = "." FAKE_LABEL_NAME;
}
}
#endif
--size-check=[error|warning]\n\
ELF .size directive check (default --size-check=error)\n"));
fprintf (stream, _("\
- --elf-stt-common=[no|yes]\n\
+ --elf-stt-common=[no|yes] "));
+ if (DEFAULT_GENERATE_ELF_STT_COMMON)
+ fprintf (stream, _("(default: yes)\n"));
+ else
+ fprintf (stream, _("(default: no)\n"));
+ fprintf (stream, _("\
generate ELF common symbols with STT_COMMON type\n"));
fprintf (stream, _("\
--sectname-subst enable section name substitution sequences\n"));
+
+ fprintf (stream, _("\
+ --generate-missing-build-notes=[no|yes] "));
+#if DEFAULT_GENERATE_BUILD_NOTES
+ fprintf (stream, _("(default: yes)\n"));
+#else
+ fprintf (stream, _("(default: no)\n"));
#endif
fprintf (stream, _("\
+ generate GNU Build notes if none are present in the input\n"));
+#endif /* OBJ_ELF */
+
+ fprintf (stream, _("\
-f skip whitespace and comment preprocessing\n"));
fprintf (stream, _("\
-g --gen-debug generate debugging information\n"));
OPTION_NOEXECSTACK,
OPTION_SIZE_CHECK,
OPTION_ELF_STT_COMMON,
+ OPTION_ELF_BUILD_NOTES,
OPTION_SECTNAME_SUBST,
OPTION_ALTERNATE,
OPTION_AL,
,{"size-check", required_argument, NULL, OPTION_SIZE_CHECK}
,{"elf-stt-common", required_argument, NULL, OPTION_ELF_STT_COMMON}
,{"sectname-subst", no_argument, NULL, OPTION_SECTNAME_SUBST}
+ ,{"generate-missing-build-notes", required_argument, NULL, OPTION_ELF_BUILD_NOTES}
#endif
,{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
,{"gdwarf-2", no_argument, NULL, OPTION_GDWARF2}
case OPTION_VERSION:
/* This output is intended to follow the GNU standards document. */
printf (_("GNU assembler %s\n"), BFD_VERSION_STRING);
- printf (_("Copyright (C) 2016 Free Software Foundation, Inc.\n"));
+ printf (_("Copyright (C) 2019 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\
case OPTION_SECTNAME_SUBST:
flag_sectname_subst = 1;
break;
-#endif
+
+ case OPTION_ELF_BUILD_NOTES:
+ if (strcasecmp (optarg, "no") == 0)
+ flag_generate_build_notes = FALSE;
+ else if (strcasecmp (optarg, "yes") == 0)
+ flag_generate_build_notes = TRUE;
+ else
+ as_fatal (_("Invalid --generate-missing-build-notes option: `%s'"),
+ optarg);
+ break;
+
+#endif /* OBJ_ELF */
+
case 'Z':
flag_always_generate_output = 1;
break;
static void
dump_statistics (void)
{
-#ifdef HAVE_SBRK
- char *lim = (char *) sbrk (0);
-#endif
long run_time = get_run_time () - start_time;
fprintf (stderr, _("%s: total time in assembly: %ld.%06ld\n"),
myname, run_time / 1000000, run_time % 1000000);
-#ifdef HAVE_SBRK
- fprintf (stderr, _("%s: data size %ld\n"),
- myname, (long) (lim - start_sbrk));
-#endif
subsegs_print_statistics (stderr);
write_print_statistics (stderr);
static size_t
macro_expr (const char *emsg, size_t idx, sb *in, offsetT *val)
{
- char *hold;
expressionS ex;
sb_terminate (in);
- hold = input_line_pointer;
- input_line_pointer = in->ptr + idx;
+ temp_ilp (in->ptr + idx);
expression_and_evaluate (&ex);
idx = input_line_pointer - in->ptr;
- input_line_pointer = hold;
+ restore_ilp ();
if (ex.X_op != O_constant)
as_bad ("%s", emsg);
main (int argc, char ** argv)
{
char ** argv_orig = argv;
+ struct stat sob;
int macro_strip_at;
start_time = get_run_time ();
-#ifdef HAVE_SBRK
- start_sbrk = (char *) sbrk (0);
-#endif
+ signal_init ();
#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
setlocale (LC_MESSAGES, "");
out_file_name = OBJ_DEFAULT_OUTPUT_FILE_NAME;
hex_init ();
- bfd_init ();
+ if (bfd_init () != BFD_INIT_MAGIC)
+ as_fatal (_("libbfd ABI mismatch"));
bfd_set_error_program_name (myname);
#ifdef USE_EMULATIONS
/* Call parse_args before any of the init/begin functions
so that switches like --hash-size can be honored. */
parse_args (&argc, &argv);
+
+ if (argc > 1 && stat (out_file_name, &sob) == 0)
+ {
+ int i;
+
+ for (i = 1; i < argc; ++i)
+ {
+ struct stat sib;
+
+ /* Check that the input file and output file are different. */
+ if (stat (argv[i], &sib) == 0
+ && sib.st_ino == sob.st_ino
+ /* POSIX emulating systems may support stat() but if the
+ underlying file system does not support a file serial number
+ of some kind then they will return 0 for the inode. So
+ two files with an inode of 0 may not actually be the same.
+ On real POSIX systems no ordinary file will ever have an
+ inode of 0. */
+ && sib.st_ino != 0
+ /* Different files may have the same inode number if they
+ reside on different devices, so check the st_dev field as
+ well. */
+ && sib.st_dev == sob.st_dev)
+ {
+ const char *saved_out_file_name = out_file_name;
+
+ /* Don't let as_fatal remove the output file! */
+ out_file_name = NULL;
+ as_fatal (_("The input '%s' and output '%s' files are the same"),
+ argv[i], saved_out_file_name);
+ }
+ }
+ }
+
symbol_begin ();
frag_init ();
subsegs_begin ();
n_warns = had_warnings ();
n_errs = had_errors ();
- if (n_warns == 1)
- sprintf (warn_msg, _("%d warning"), n_warns);
- else
- sprintf (warn_msg, _("%d warnings"), n_warns);
- if (n_errs == 1)
- sprintf (err_msg, _("%d error"), n_errs);
- else
- sprintf (err_msg, _("%d errors"), n_errs);
-
+ sprintf (warn_msg,
+ ngettext ("%d warning", "%d warnings", n_warns), n_warns);
+ sprintf (err_msg,
+ ngettext ("%d error", "%d errors", n_errs), n_errs);
if (flag_fatal_warnings && n_warns != 0)
{
if (n_errs == 0)