* ld-elf/orphan-region.d: Use ld -N.
[binutils-gdb.git] / ld / lexsup.c
index d3d6e569837bd1ecd9057693a3ad7e068a41fe1b..b992fca37ab13cdb9ddf4be677304b5777035ad2 100644 (file)
@@ -90,6 +90,7 @@ enum option_values
   OPTION_NO_WHOLE_ARCHIVE,
   OPTION_OFORMAT,
   OPTION_RELAX,
+  OPTION_NO_RELAX,
   OPTION_RETAIN_SYMBOLS_FILE,
   OPTION_RPATH,
   OPTION_RPATH_LINK,
@@ -125,10 +126,10 @@ enum option_values
   OPTION_SPLIT_BY_RELOC,
   OPTION_SPLIT_BY_FILE ,
   OPTION_WHOLE_ARCHIVE,
-  OPTION_ADD_NEEDED,
-  OPTION_NO_ADD_NEEDED,
-  OPTION_AS_NEEDED,
-  OPTION_NO_AS_NEEDED,
+  OPTION_ADD_DT_NEEDED_FOR_DYNAMIC,
+  OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC,
+  OPTION_ADD_DT_NEEDED_FOR_REGULAR,
+  OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR,
   OPTION_WRAP,
   OPTION_FORCE_EXE_SUFFIX,
   OPTION_GC_SECTIONS,
@@ -333,19 +334,22 @@ static const struct ld_option ld_options[] =
      OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH},
     '\0', NULL, N_("Reject input files whose architecture is unknown"),
     TWO_DASHES },
-  { {"add-needed", no_argument, NULL, OPTION_ADD_NEEDED},
-    '\0', NULL, N_("Set DT_NEEDED tags for DT_NEEDED entries in\n"
-                  "                                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"
-                  "                                in following dynamic libs"),
-    TWO_DASHES },
-  { {"as-needed", no_argument, NULL, OPTION_AS_NEEDED},
+
+  /* The next two options are deprecated because of their similarity to
+     --as-needed and --no-as-needed.  They have been replaced by
+     --resolve-implicit-dynamic-symbols and
+     --no-resolve-implicit-dynamic-symbols.  */
+  { {"add-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_DYNAMIC},
+    '\0', NULL, NULL, NO_HELP },
+  { {"no-add-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC},
+    '\0', NULL, NULL, NO_HELP },
+
+  { {"as-needed", no_argument, NULL, OPTION_ADD_DT_NEEDED_FOR_REGULAR},
     '\0', NULL, N_("Only set DT_NEEDED for following dynamic libs if used"),
     TWO_DASHES },
-  { {"no-as-needed", no_argument, NULL, OPTION_NO_AS_NEEDED},
-    '\0', NULL, N_("Always set DT_NEEDED for following dynamic libs"),
+  { {"no-as-needed", no_argument, NULL, OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR},
+    '\0', NULL, N_("Always set DT_NEEDED for dynamic libraries mentioned on\n"
+                  "                                the command line"),
     TWO_DASHES },
   { {"assert", required_argument, NULL, OPTION_ASSERT},
     '\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH },
@@ -373,6 +377,15 @@ static const struct ld_option ld_options[] =
   { {"no-check-sections", no_argument, NULL, OPTION_NO_CHECK_SECTIONS},
     '\0', NULL, N_("Do not check section addresses for overlaps"),
     TWO_DASHES },
+  { {"copy-dt-needed-entries", no_argument, NULL,
+     OPTION_ADD_DT_NEEDED_FOR_DYNAMIC},
+    '\0', NULL, N_("Copy DT_NEEDED links mentioned inside DSOs that follow"),
+    TWO_DASHES },
+  { {"no-copy-dt-needed-entries", no_argument, NULL,
+     OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC},
+    '\0', NULL, N_("Do not copy DT_NEEDED links mentioned inside DSOs that follow"),
+    TWO_DASHES },
+
   { {"cref", no_argument, NULL, OPTION_CREF},
     '\0', NULL, N_("Output cross reference table"), TWO_DASHES },
   { {"defsym", required_argument, NULL, OPTION_DEFSYM},
@@ -467,7 +480,9 @@ static const struct ld_option ld_options[] =
     '\0', NULL, N_("Reduce memory overheads, possibly taking much longer"),
     TWO_DASHES },
   { {"relax", no_argument, NULL, OPTION_RELAX},
-    '\0', NULL, N_("Relax branches on certain targets"), TWO_DASHES },
+    '\0', NULL, N_("Reduce code size by using target specific optimizations"), TWO_DASHES },
+  { {"no-relax", no_argument, NULL, OPTION_NO_RELAX},
+    '\0', NULL, N_("Do not use relaxation techniques to reduce code size"), TWO_DASHES },
   { {"retain-symbols-file", required_argument, NULL,
      OPTION_RETAIN_SYMBOLS_FILE},
     '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES },
@@ -832,7 +847,6 @@ parse_args (unsigned argc, char **argv)
          break;
        case 'e':
          lang_add_entry (optarg, TRUE);
-         ldlang_add_undef (optarg);
          break;
        case 'f':
          if (command_line.auxiliary_filters == NULL)
@@ -1121,8 +1135,11 @@ parse_args (unsigned argc, char **argv)
              command_line.rpath_link = buf;
            }
          break;
+       case OPTION_NO_RELAX:
+         DISABLE_RELAXATION;
+         break;
        case OPTION_RELAX:
-         command_line.relax = TRUE;
+         ENABLE_RELAXATION;
          break;
        case OPTION_RETAIN_SYMBOLS_FILE:
          add_keepsyms_file (optarg);
@@ -1380,17 +1397,17 @@ parse_args (unsigned argc, char **argv)
        case OPTION_WHOLE_ARCHIVE:
          whole_archive = TRUE;
          break;
-       case OPTION_ADD_NEEDED:
-         add_needed = TRUE;
+       case OPTION_ADD_DT_NEEDED_FOR_DYNAMIC:
+         add_DT_NEEDED_for_dynamic = TRUE;
          break;
-       case OPTION_NO_ADD_NEEDED:
-         add_needed = FALSE;
+       case OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC:
+         add_DT_NEEDED_for_dynamic = FALSE;
          break;
-       case OPTION_AS_NEEDED:
-         as_needed = TRUE;
+       case OPTION_ADD_DT_NEEDED_FOR_REGULAR:
+         add_DT_NEEDED_for_regular = TRUE;
          break;
-       case OPTION_NO_AS_NEEDED:
-         as_needed = FALSE;
+       case OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR:
+         add_DT_NEEDED_for_regular = FALSE;
          break;
        case OPTION_WRAP:
          add_wrap (optarg);
@@ -1442,18 +1459,15 @@ parse_args (unsigned argc, char **argv)
          command_line.accept_unknown_input_arch = FALSE;
          break;
        case '(':
-         if (ingroup)
-           einfo (_("%P%F: may not nest groups (--help for usage)\n"));
-
          lang_enter_group ();
-         ingroup = 1;
+         ingroup++;
          break;
        case ')':
          if (! ingroup)
            einfo (_("%P%F: group ended before it began (--help for usage)\n"));
 
          lang_leave_group ();
-         ingroup = 0;
+         ingroup--;
          break;
 
        case OPTION_INIT:
@@ -1484,8 +1498,11 @@ parse_args (unsigned argc, char **argv)
        }
     }
 
-  if (ingroup)
-    lang_leave_group ();
+  while (ingroup)
+    {
+      lang_leave_group ();
+      ingroup--;
+    }
 
   if (default_dirlist != NULL)
     {