/* as.c - GAS main program.
- Copyright (C) 1987-2015 Free Software Foundation, Inc.
+ Copyright (C) 1987-2018 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);
/* Enable verbose mode. */
int verbose = 0;
+#if defined OBJ_ELF || defined OBJ_MAYBE_ELF
+int flag_use_elf_stt_common = DEFAULT_GENERATE_ELF_STT_COMMON;
+#endif
+
/* Keep the output file. */
static int keep_it = 0;
#endif
static long start_time;
-#ifdef HAVE_SBRK
-char *start_sbrk;
-#endif
static int flag_macro_alternate;
select_emulation_mode (int argc, char **argv)
{
int i;
- char *p, *em = 0;
+ char *p;
+ const char *em = NULL;
for (i = 1; i < argc; i++)
if (!strncmp ("--em", argv[i], 4))
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
#ifdef USE_EMULATIONS
{
int i;
- char *def_em;
+ const char *def_em;
fprintf (stream, "\
--em=[");
--size-check=[error|warning]\n\
ELF .size directive check (default --size-check=error)\n"));
fprintf (stream, _("\
+ --elf-stt-common=[no|yes]\n\
+ generate ELF common symbols with STT_COMMON type\n"));
+ fprintf (stream, _("\
--sectname-subst enable section name substitution sequences\n"));
#endif
fprintf (stream, _("\
fprintf (stream, _("\
-nocpp ignored\n"));
fprintf (stream, _("\
+ -no-pad-sections do not pad the end of sections to alignment boundaries\n"));
+ fprintf (stream, _("\
-o OBJFILE name the object-file output OBJFILE (default a.out)\n"));
fprintf (stream, _("\
-R fold data section into text section\n"));
OPTION_EXECSTACK,
OPTION_NOEXECSTACK,
OPTION_SIZE_CHECK,
+ OPTION_ELF_STT_COMMON,
OPTION_SECTNAME_SUBST,
OPTION_ALTERNATE,
OPTION_AL,
OPTION_REDUCE_MEMORY_OVERHEADS,
OPTION_WARN_FATAL,
OPTION_COMPRESS_DEBUG,
- OPTION_NOCOMPRESS_DEBUG
+ OPTION_NOCOMPRESS_DEBUG,
+ OPTION_NO_PAD_SECTIONS /* = STD_BASE + 40 */
/* When you add options here, check that they do
not collide with OPTION_MD_BASE. See as.h. */
};
,{"execstack", no_argument, NULL, OPTION_EXECSTACK}
,{"noexecstack", no_argument, NULL, OPTION_NOEXECSTACK}
,{"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}
#endif
,{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
,{"MD", required_argument, NULL, OPTION_DEPFILE}
,{"mri", no_argument, NULL, 'M'}
,{"nocpp", no_argument, NULL, OPTION_NOCPP}
+ ,{"no-pad-sections", no_argument, NULL, OPTION_NO_PAD_SECTIONS}
,{"no-warn", no_argument, NULL, 'W'}
,{"reduce-memory-overheads", no_argument, NULL, OPTION_REDUCE_MEMORY_OVERHEADS}
,{"statistics", no_argument, NULL, OPTION_STATISTICS}
old_argv = *pargv;
/* Initialize a new argv that contains no options. */
- new_argv = (char **) xmalloc (sizeof (char *) * (old_argc + 1));
+ new_argv = XNEWVEC (char *, old_argc + 1);
new_argv[0] = old_argv[0];
new_argc = 1;
new_argv[new_argc] = NULL;
case 1: /* File name. */
if (!strcmp (optarg, "-"))
- optarg = "";
+ optarg = (char *) "";
new_argv[new_argc++] = optarg;
new_argv[new_argc] = NULL;
break;
case OPTION_NOCPP:
break;
+ case OPTION_NO_PAD_SECTIONS:
+ do_not_pad_sections_to_alignment = 1;
+ break;
+
case OPTION_STATISTICS:
flag_print_statistics = 1;
break;
case OPTION_VERSION:
/* This output is intended to follow the GNU standards document. */
printf (_("GNU assembler %s\n"), BFD_VERSION_STRING);
- printf (_("Copyright (C) 2015 Free Software Foundation, Inc.\n"));
+ printf (_("Copyright (C) 2018 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\
This program has absolutely no warranty.\n"));
+#ifdef TARGET_WITH_CPU
+ printf (_("This assembler was configured for a target of `%s' "
+ "and default,\ncpu type `%s'.\n"),
+ TARGET_ALIAS, TARGET_WITH_CPU);
+#else
printf (_("This assembler was configured for a target of `%s'.\n"),
TARGET_ALIAS);
+#endif
exit (EXIT_SUCCESS);
case OPTION_EMULATION:
as_fatal (_("bad defsym; format is --defsym name=value"));
*s++ = '\0';
i = bfd_scan_vma (s, (const char **) NULL, 0);
- n = (struct defsym_list *) xmalloc (sizeof *n);
+ n = XNEW (struct defsym_list);
n->next = defsyms;
n->name = optarg;
n->value = i;
break;
}
- n = xmalloc (sizeof * n);
+ n = XNEW (struct itbl_file_list);
n->next = itbl_files;
n->name = optarg;
itbl_files = n;
case OPTION_SIZE_CHECK:
if (strcasecmp (optarg, "error") == 0)
- flag_size_check = size_check_error;
+ flag_allow_nonconst_size = FALSE;
else if (strcasecmp (optarg, "warning") == 0)
- flag_size_check = size_check_warning;
+ flag_allow_nonconst_size = TRUE;
else
as_fatal (_("Invalid --size-check= option: `%s'"), optarg);
break;
+ case OPTION_ELF_STT_COMMON:
+ if (strcasecmp (optarg, "no") == 0)
+ flag_use_elf_stt_common = 0;
+ else if (strcasecmp (optarg, "yes") == 0)
+ flag_use_elf_stt_common = 1;
+ else
+ as_fatal (_("Invalid --elf-stt-common= option: `%s'"),
+ optarg);
+ break;
+
case OPTION_SECTNAME_SUBST:
flag_sectname_subst = 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);
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, "");
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)