]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gas/as.c
x86: Suggest -fPIE when not building shared object
[thirdparty/binutils-gdb.git] / gas / as.c
index 6e8ec5678556e8b41f52d9f80a7398fa7d2ca80c..c7bdf0cd8896c721f22439c46f0e0adfd2b9c5ff 100644 (file)
--- a/gas/as.c
+++ b/gas/as.c
@@ -1,5 +1,5 @@
 /* as.c - GAS main program.
-   Copyright (C) 1987-2018 Free Software Foundation, Inc.
+   Copyright (C) 1987-2019 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -97,6 +97,7 @@ int verbose = 0;
 
 #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.  */
@@ -300,11 +301,27 @@ Options:\n\
   --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, _("\
@@ -470,6 +487,7 @@ parse_args (int * pargc, char *** pargv)
       OPTION_NOEXECSTACK,
       OPTION_SIZE_CHECK,
       OPTION_ELF_STT_COMMON,
+      OPTION_ELF_BUILD_NOTES,
       OPTION_SECTNAME_SUBST,
       OPTION_ALTERNATE,
       OPTION_AL,
@@ -508,6 +526,7 @@ parse_args (int * pargc, char *** pargv)
     ,{"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}
@@ -656,7 +675,7 @@ parse_args (int * pargc, char *** pargv)
        case OPTION_VERSION:
          /* This output is intended to follow the GNU standards document.  */
          printf (_("GNU assembler %s\n"), BFD_VERSION_STRING);
-         printf (_("Copyright (C) 2018 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\
@@ -900,7 +919,19 @@ This program has absolutely no warranty.\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;
@@ -1071,16 +1102,14 @@ close_output_file (void)
 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);
@@ -1208,7 +1237,8 @@ main (int argc, char ** argv)
   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
@@ -1228,14 +1258,27 @@ main (int argc, char ** argv)
        {
          struct stat sib;
 
-         if (stat (argv[i], &sib) == 0)
+         /* 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)
            {
-             if (sib.st_ino == sob.st_ino)
-               {
-                 /* Don't let as_fatal remove the output file!  */
-                 out_file_name = NULL;
-                 as_fatal (_("The input and output files must be distinct"));
-               }
+             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);
            }
        }
     }