PR ld/10569
[deliverable/binutils-gdb.git] / ld / lexsup.c
index 287a46398b8b836c64a31afb11548f1f9507008b..a9a26890dfa8564d88f808fdc506b0d98f426b9f 100644 (file)
@@ -3,27 +3,26 @@
    2001, 2002, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
 
-   This file is part of GLD, the Gnu Linker.
+   This file is part of the GNU Binutils.
 
-   GLD is free software; you can redistribute it and/or modify
+   This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
-   GLD is distributed in the hope that it will be useful,
+   This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with GLD; see the file COPYING.  If not, write to the Free
-   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
-   02110-1301, USA.  */
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
-#include "config.h"
+#include "sysdep.h"
 #include "bfd.h"
 #include "bfdver.h"
-#include "sysdep.h"
 #include "libiberty.h"
 #include <stdio.h>
 #include <string.h>
@@ -78,12 +77,14 @@ enum option_values
   OPTION_EL,
   OPTION_EMBEDDED_RELOCS,
   OPTION_EXPORT_DYNAMIC,
+  OPTION_NO_EXPORT_DYNAMIC,
   OPTION_HELP,
   OPTION_IGNORE,
   OPTION_MAP,
   OPTION_NO_DEMANGLE,
   OPTION_NO_KEEP_MEMORY,
   OPTION_NO_WARN_MISMATCH,
+  OPTION_NO_WARN_SEARCH_MISMATCH,
   OPTION_NOINHIBIT_EXEC,
   OPTION_NON_SHARED,
   OPTION_NO_WHOLE_ARCHIVE,
@@ -103,6 +104,7 @@ enum option_values
   OPTION_TBSS,
   OPTION_TDATA,
   OPTION_TTEXT,
+  OPTION_TTEXT_SEGMENT,
   OPTION_TRADITIONAL_FORMAT,
   OPTION_UR,
   OPTION_VERBOSE,
@@ -116,6 +118,7 @@ enum option_values
   OPTION_WARN_COMMON,
   OPTION_WARN_CONSTRUCTORS,
   OPTION_WARN_FATAL,
+  OPTION_NO_WARN_FATAL,
   OPTION_WARN_MULTIPLE_GP,
   OPTION_WARN_ONCE,
   OPTION_WARN_SECTION_ALIGN,
@@ -161,6 +164,7 @@ enum option_values
   OPTION_WARN_UNRESOLVED_SYMBOLS,
   OPTION_ERROR_UNRESOLVED_SYMBOLS,
   OPTION_WARN_SHARED_TEXTREL,
+  OPTION_WARN_ALTERNATE_EM,
   OPTION_REDUCE_MEMORY_OVERHEADS,
   OPTION_DEFAULT_SCRIPT
 };
@@ -219,6 +223,8 @@ static const struct ld_option ld_options[] =
     'e', N_("ADDRESS"), N_("Set start address"), TWO_DASHES },
   { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
     'E', NULL, N_("Export all dynamic symbols"), TWO_DASHES },
+  { {"no-export-dynamic", no_argument, NULL, OPTION_NO_EXPORT_DYNAMIC},
+    '\0', NULL, N_("Undo the effect of --export-dynamic"), TWO_DASHES },
   { {"EB", no_argument, NULL, OPTION_EB},
     '\0', NULL, N_("Link big-endian objects"), ONE_DASH },
   { {"EL", no_argument, NULL, OPTION_EL},
@@ -327,10 +333,12 @@ static const struct ld_option ld_options[] =
     TWO_DASHES },
   { {"add-needed", no_argument, NULL, OPTION_ADD_NEEDED},
     '\0', NULL, N_("Set DT_NEEDED tags for DT_NEEDED entries in\n"
-                  "\t\t\t\tfollowing dynamic libs"), TWO_DASHES },
+                  "                                following dynamic libs"),
+    TWO_DASHES },
   { {"no-add-needed", no_argument, NULL, OPTION_NO_ADD_NEEDED},
     '\0', NULL, N_("Do not set DT_NEEDED tags for DT_NEEDED entries\n"
-                  "\t\t\t\tin following dynamic libs"), TWO_DASHES },
+                  "                                in following dynamic libs"),
+    TWO_DASHES },
   { {"as-needed", no_argument, NULL, OPTION_AS_NEEDED},
     '\0', NULL, N_("Only set DT_NEEDED for following dynamic libs if used"),
     TWO_DASHES },
@@ -375,6 +383,9 @@ static const struct ld_option ld_options[] =
   { {"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL},
     '\0', NULL, N_("Treat warnings as errors"),
     TWO_DASHES },
+  { {"no-fatal-warnings", no_argument, NULL, OPTION_NO_WARN_FATAL},
+    '\0', NULL, N_("Do not treat warnings as errors (default)"),
+    TWO_DASHES },
   { {"fini", required_argument, NULL, OPTION_FINI},
     '\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH },
   { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX},
@@ -429,6 +440,10 @@ static const struct ld_option ld_options[] =
     TWO_DASHES },
   { {"no-warn-mismatch", no_argument, NULL, OPTION_NO_WARN_MISMATCH},
     '\0', NULL, N_("Don't warn about mismatched input files"), TWO_DASHES},
+  { {"no-warn-search-mismatch", no_argument, NULL,
+     OPTION_NO_WARN_SEARCH_MISMATCH},
+    '\0', NULL, N_("Don't warn on finding an incompatible library"),
+    TWO_DASHES},
   { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
     '\0', NULL, N_("Turn off --whole-archive"), TWO_DASHES },
   { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
@@ -438,7 +453,8 @@ static const struct ld_option ld_options[] =
     '\0', NULL, NULL, NO_HELP },
   { {"nostdlib", no_argument, NULL, OPTION_NOSTDLIB},
     '\0', NULL, N_("Only use library directories specified on\n"
-                  "\t\t\t\tthe command line"), ONE_DASH },
+                  "                                the command line"),
+    ONE_DASH },
   { {"oformat", required_argument, NULL, OPTION_OFORMAT},
     '\0', N_("TARGET"), N_("Specify target of output file"),
     EXACTLY_TWO_DASHES },
@@ -466,8 +482,10 @@ static const struct ld_option ld_options[] =
     '\0', NULL, N_("Create a position independent executable"), ONE_DASH },
   { {"pic-executable", no_argument, NULL, OPTION_PIE},
     '\0', NULL, NULL, TWO_DASHES },
-  { {"sort-common", no_argument, NULL, OPTION_SORT_COMMON},
-    '\0', NULL, N_("Sort common symbols by size"), TWO_DASHES },
+  { {"sort-common", optional_argument, NULL, OPTION_SORT_COMMON},
+    '\0', N_("[=ascending|descending]"), 
+    N_("Sort common symbols by alignment [in specified order]"), 
+    TWO_DASHES },
   { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
     '\0', NULL, NULL, NO_HELP },
   { {"sort-section", required_argument, NULL, OPTION_SORT_SECTION},
@@ -499,11 +517,14 @@ static const struct ld_option ld_options[] =
     '\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH },
   { {"Ttext", required_argument, NULL, OPTION_TTEXT},
     '\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH },
+  { {"Ttext-segment", required_argument, NULL, OPTION_TTEXT_SEGMENT},
+    '\0', N_("ADDRESS"), N_("Set address of text segment"), ONE_DASH },
   { {"unresolved-symbols=<method>", required_argument, NULL,
      OPTION_UNRESOLVED_SYMBOLS},
     '\0', NULL, N_("How to handle unresolved symbols.  <method> is:\n"
-                  "\t\t\t\tignore-all, report-all, ignore-in-object-files,\n"
-                  "\t\t\t\tignore-in-shared-libs"), TWO_DASHES },
+                  "                                ignore-all, report-all, ignore-in-object-files,\n"
+                  "                                ignore-in-shared-libs"),
+    TWO_DASHES },
   { {"verbose", no_argument, NULL, OPTION_VERBOSE},
     '\0', NULL, N_("Output lots of information during link"), TWO_DASHES },
   { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux.  */
@@ -513,7 +534,8 @@ static const struct ld_option ld_options[] =
   { {"version-exports-section", required_argument, NULL,
      OPTION_VERSION_EXPORTS_SECTION },
     '\0', N_("SYMBOL"), N_("Take export symbols list from .exports, using\n"
-                          "\t\t\t\tSYMBOL as the version."), TWO_DASHES },
+                          "                                SYMBOL as the version."),
+    TWO_DASHES },
   { {"dynamic-list-data", no_argument, NULL, OPTION_DYNAMIC_LIST_DATA},
     '\0', NULL, N_("Add data symbols to dynamic list"), TWO_DASHES },
   { {"dynamic-list-cpp-new", no_argument, NULL, OPTION_DYNAMIC_LIST_CPP_NEW},
@@ -537,6 +559,9 @@ static const struct ld_option ld_options[] =
   { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_SHARED_TEXTREL},
     '\0', NULL, N_("Warn if shared object has DT_TEXTREL"),
     TWO_DASHES },
+  { {"warn-alternate-em", no_argument, NULL, OPTION_WARN_ALTERNATE_EM},
+    '\0', NULL, N_("Warn if an object has alternate ELF machine code"),
+    TWO_DASHES },
   { {"warn-unresolved-symbols", no_argument, NULL,
      OPTION_WARN_UNRESOLVED_SYMBOLS},
     '\0', NULL, N_("Report unresolved symbols as warnings"), TWO_DASHES },
@@ -798,8 +823,12 @@ parse_args (unsigned argc, char **argv)
        case 'E': /* HP/UX compatibility.  */
          link_info.export_dynamic = TRUE;
          break;
+       case OPTION_NO_EXPORT_DYNAMIC:
+         link_info.export_dynamic = FALSE;
+         break;
        case 'e':
          lang_add_entry (optarg, TRUE);
+         ldlang_add_undef (optarg);
          break;
        case 'f':
          if (command_line.auxiliary_filters == NULL)
@@ -964,6 +993,9 @@ parse_args (unsigned argc, char **argv)
        case OPTION_NO_WARN_MISMATCH:
          command_line.warn_mismatch = FALSE;
          break;
+       case OPTION_NO_WARN_SEARCH_MISMATCH:
+         command_line.warn_search_mismatch = FALSE;
+         break;
        case OPTION_NOINHIBIT_EXEC:
          force_make_executable = TRUE;
          break;
@@ -1130,7 +1162,14 @@ parse_args (unsigned argc, char **argv)
          command_line.soname = optarg;
          break;
        case OPTION_SORT_COMMON:
-         config.sort_common = TRUE;
+         if (optarg == NULL
+             || strcmp (optarg, N_("descending")) == 0)
+            config.sort_common = sort_descending;
+          else if (strcmp (optarg, N_("ascending")) == 0)
+           config.sort_common = sort_ascending;
+         else
+           einfo (_("%P%F: invalid common section sorting option: %s\n"),
+                  optarg);
          break;
        case OPTION_SORT_SECTION:
          if (strcmp (optarg, N_("name")) == 0)
@@ -1154,9 +1193,11 @@ parse_args (unsigned argc, char **argv)
          trace_files = TRUE;
          break;
        case 'T':
+         previous_script_handle = saved_script_handle;
          ldfile_open_command_file (optarg);
          parser_input = input_script;
          yyparse ();
+         previous_script_handle = NULL;
          break;
        case OPTION_DEFAULT_SCRIPT:
          command_line.default_script = optarg;
@@ -1204,6 +1245,9 @@ parse_args (unsigned argc, char **argv)
        case OPTION_TTEXT:
          set_segment_start (".text", optarg);
          break;
+       case OPTION_TTEXT_SEGMENT:
+         set_segment_start (".text-segment", optarg);
+         break;
        case OPTION_TRADITIONAL_FORMAT:
          link_info.traditional_format = TRUE;
          break;
@@ -1310,6 +1354,9 @@ parse_args (unsigned argc, char **argv)
        case OPTION_WARN_FATAL:
          config.fatal_warnings = TRUE;
          break;
+       case OPTION_NO_WARN_FATAL:
+         config.fatal_warnings = FALSE;
+         break;
        case OPTION_WARN_MULTIPLE_GP:
          config.warn_multiple_gp = TRUE;
          break;
@@ -1322,6 +1369,9 @@ parse_args (unsigned argc, char **argv)
        case OPTION_WARN_SHARED_TEXTREL:
          link_info.warn_shared_textrel = TRUE;
          break;
+       case OPTION_WARN_ALTERNATE_EM:
+         link_info.warn_alternate_em = TRUE;
+         break;
        case OPTION_WHOLE_ARCHIVE:
          whole_archive = TRUE;
          break;
@@ -1375,10 +1425,10 @@ parse_args (unsigned argc, char **argv)
            config.split_by_file = 1;
          break;
        case OPTION_CHECK_SECTIONS:
-         command_line.check_section_addresses = TRUE;
+         command_line.check_section_addresses = 1;
          break;
        case OPTION_NO_CHECK_SECTIONS:
-         command_line.check_section_addresses = FALSE;
+         command_line.check_section_addresses = 0;
          break;
        case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH:
          command_line.accept_unknown_input_arch = TRUE;
This page took 0.026844 seconds and 4 git commands to generate.