Add --hash-size switch to the linker
[deliverable/binutils-gdb.git] / ld / lexsup.c
index e43e15ef4b60ed744fadbed3ffda8e311e5962f9..51373413f1049741ed62c5b68d25c836e9646d39 100644 (file)
@@ -1,6 +1,6 @@
 /* Parse options for the GNU linker.
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003
+   2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
 
    This file is part of GLD, the Gnu Linker.
@@ -112,10 +112,13 @@ enum option_values
   OPTION_SPLIT_BY_RELOC,
   OPTION_SPLIT_BY_FILE ,
   OPTION_WHOLE_ARCHIVE,
+  OPTION_AS_NEEDED,
+  OPTION_NO_AS_NEEDED,
   OPTION_WRAP,
   OPTION_FORCE_EXE_SUFFIX,
   OPTION_GC_SECTIONS,
   OPTION_NO_GC_SECTIONS,
+  OPTION_HASH_SIZE,
   OPTION_CHECK_SECTIONS,
   OPTION_NO_CHECK_SECTIONS,
   OPTION_NO_UNDEFINED,
@@ -140,7 +143,8 @@ enum option_values
   OPTION_PIE,
   OPTION_UNRESOLVED_SYMBOLS,
   OPTION_WARN_UNRESOLVED_SYMBOLS,
-  OPTION_ERROR_UNRESOLVED_SYMBOLS
+  OPTION_ERROR_UNRESOLVED_SYMBOLS,
+  OPTION_REDUCE_MEMORY_OVERHEADS
 };
 
 /* The long options.  This structure is used for both the option
@@ -325,6 +329,8 @@ static const struct ld_option ld_options[] =
   { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS},
       '\0', NULL, N_("Don't remove unused sections (default)"),
       TWO_DASHES },
+  { {"hash-size=<NUMBER>", required_argument, NULL, OPTION_HASH_SIZE},
+      '\0', NULL, N_("Set default hash table size close to <NUMBER>"), TWO_DASHES },
   { {"help", no_argument, NULL, OPTION_HELP},
       '\0', NULL, N_("Print option help"), TWO_DASHES },
   { {"init", required_argument, NULL, OPTION_INIT},
@@ -361,6 +367,8 @@ static const struct ld_option ld_options[] =
       '\0', N_("TARGET"), N_("Specify target of output file"), EXACTLY_TWO_DASHES },
   { {"qmagic", no_argument, NULL, OPTION_IGNORE},
       '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH },
+  { {"reduce-memory-overheads", no_argument, NULL, OPTION_REDUCE_MEMORY_OVERHEADS},
+      '\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 },
   { {"retain-symbols-file", required_argument, NULL,
@@ -438,8 +446,12 @@ static const struct ld_option ld_options[] =
      TWO_DASHES },
   { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
       '\0', NULL, N_("Include all objects from following archives"), 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 },
+  { {"no-as-needed", no_argument, NULL, OPTION_NO_AS_NEEDED},
+      '\0', NULL, N_("Always set DT_NEEDED for following dynamic libs"), TWO_DASHES },
   { {"wrap", required_argument, NULL, OPTION_WRAP},
-      '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES }
+      '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES },
 };
 
 #define OPTION_COUNT ARRAY_SIZE (ld_options)
@@ -634,27 +646,9 @@ parse_args (unsigned argc, char **argv)
          break;
        case OPTION_CALL_SHARED:
          config.dynamic_link = TRUE;
-         /* When linking against shared libraries, the default behaviour is
-            to report any unresolved references.  Although strictly speaking
-            it is not a failure to encounter unresolved symbols at link time
-            - the symbol *might* be available at load time - it is a strong
-            indication that the resulting executable will not work.  Plus it
-            is necessary for the correct execution of the autoconf package,
-            which needs to be able to detect functions that are not provided
-            by the host OS.  */
-         if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
-           link_info.unresolved_syms_in_objects = how_to_report_unresolved_symbols;
-         if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
-           link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols;
          break;
        case OPTION_NON_SHARED:
          config.dynamic_link = FALSE;
-         /* When linking against static libraries, the default
-            behaviour is to report any unresolved references.  */
-         if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
-           link_info.unresolved_syms_in_objects = how_to_report_unresolved_symbols;
-         if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
-           link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols;
          break;
        case OPTION_CREF:
          command_line.cref = TRUE;
@@ -1156,6 +1150,12 @@ parse_args (unsigned argc, char **argv)
        case OPTION_WHOLE_ARCHIVE:
          whole_archive = TRUE;
          break;
+       case OPTION_AS_NEEDED:
+         as_needed = TRUE;
+         break;
+       case OPTION_NO_AS_NEEDED:
+         as_needed = FALSE;
+         break;
        case OPTION_WRAP:
          add_wrap (optarg);
          break;
@@ -1227,6 +1227,24 @@ parse_args (unsigned argc, char **argv)
        case OPTION_FINI:
          link_info.fini_function = optarg;
          break;
+
+       case OPTION_REDUCE_MEMORY_OVERHEADS:
+         command_line.reduce_memory_overheads = TRUE;
+         if (config.hash_table_size == 0)
+           config.hash_table_size = 1021;
+         break;
+
+        case OPTION_HASH_SIZE:
+         {
+           bfd_size_type new_size;
+
+            new_size = strtoul (optarg, NULL, 0);
+            if (new_size)
+              config.hash_table_size = new_size;
+            else
+              einfo (_("%P%X: --hash-size needs a numeric argument\n"));
+          }
+          break;
        }
     }
 
This page took 0.02431 seconds and 4 git commands to generate.