aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog15
-rw-r--r--ld/NEWS8
-rw-r--r--ld/ld.h5
-rw-r--r--ld/ld.texinfo18
-rw-r--r--ld/ldmain.c4
-rw-r--r--ld/lexsup.c22
6 files changed, 67 insertions, 5 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 38bbbe7..46e4865 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,18 @@
+2004-05-21 Andy Chittenden <achittenden@bluearc.com>
+
+ * ld.h (ld_config_type): Add new field: hash_table_size.
+ * ldmain.c: Initialise the new field to zero. If it is non-zero
+ after parsing the linker's command line call
+ bfd_hash_set_default_size.
+ * lexsup.c (option_values): Add OPTION_HASH_SIZE.
+ (ld_options): Add hash-size.
+ (parse_args): Parse --hash-size option. Allow
+ --reduce-memory-overheads to set the default hash table size as
+ well.
+ * ld.texinfo: Document the new switch. Also mention that
+ --reduce-memory-overheads can affect the hash table size.
+ * NEWS: Mention the new feature.
+
2004-05-19 J"orn Rennecke <joern.rennecke@superh.com>
* NEWS: Mention new linker map file generation and the
diff --git a/ld/NEWS b/ld/NEWS
index a33c6dc..1d07084 100644
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -1,11 +1,19 @@
-*- text -*-
+* A new linker command line switch has been added which allows the hash table
+ size to be set to a suitable prime value near to its argument. This switch
+ is --hash-size=<NUMBER>. Also if the switch --reduce-memory-overheads is
+ used, and --hash-size has not been used, then the default value will be set
+ to 1021.
+
* Linker map files are now generated with an O(N) algorithm for finding symbols
that are defined in each section. This uses about 40% more memory for
symbols than the old O(N^2) algorithm. You can use the new
--reduce-memory-overheads option to select the old algorithm; this option
might also be used in the future to select similar tradeoffs.
+Changes in 2.15:
+
* New PE --large-address-aware option to indicate executables support virtual
addresses greater than 2 gigabytes.
diff --git a/ld/ld.h b/ld/ld.h
index 1061c35..2bcf7d2 100644
--- a/ld/ld.h
+++ b/ld/ld.h
@@ -1,5 +1,5 @@
/* ld.h -- general linker header file
- Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002
+ Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2004
Free Software Foundation, Inc.
This file is part of GLD, the Gnu Linker.
@@ -241,6 +241,9 @@ typedef struct {
/* If set, only search library directories explicitly selected
on the command line. */
bfd_boolean only_cmd_line_lib_dirs;
+
+ /* The size of the hash table to use. */
+ bfd_size_type hash_table_size;
} ld_config_type;
extern ld_config_type config;
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index b78d1b0..db87e3f 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -1734,13 +1734,27 @@ If you specify @option{--disable-new-dtags}, no new dynamic tags will be
created. By default, the new dynamic tags are not created. Note that
those options are only available for ELF systems.
+@kindex --hash-size=@var{number}
+Set the default size of the linker's hash tables to a prime number
+close to @var{number}. Increasing this value can reduce the length of
+time it takes the linker to perform its tasks, at the expense of
+increasing the linker's memory requirements. Similarly reducing this
+value can reduce the memory requirements at the expense of speed.
+
@kindex --reduce-memory-overheads
@item --reduce-memory-overheads
This option reduces memory requirements at ld runtime, at the expense of
linking speed. This was introduced to to select the old O(n^2) algorithm
for link map file generation, rather than the new O(n) algorithm which uses
-about 40% more memory for symbol storage. It may be also be used for
-similar such tradeoffs in the future.
+about 40% more memory for symbol storage.
+
+Another affect of the switch is to set the default hash table size to
+1021, which again saves memory at the cost of lengthening the linker's
+run time. This is not done however if the *option{--hash-size} switch
+has been used.
+
+The @option{--reduce-memory-overheads} switch may be also be used to
+enable other tradeoffs in future versions of the linker.
@end table
diff --git a/ld/ldmain.c b/ld/ldmain.c
index f3df44f..f1804c4 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -267,6 +267,7 @@ main (int argc, char **argv)
config.has_shared = FALSE;
config.split_by_reloc = (unsigned) -1;
config.split_by_file = (bfd_size_type) -1;
+ config.hash_table_size = 0;
command_line.force_common_definition = FALSE;
command_line.inhibit_common_definition = FALSE;
command_line.interpreter = NULL;
@@ -344,6 +345,9 @@ main (int argc, char **argv)
lang_has_input_file = FALSE;
parse_args (argc, argv);
+ if (config.hash_table_size != 0)
+ bfd_hash_set_default_size (config.hash_table_size);
+
ldemul_set_symbols ();
if (link_info.relocatable)
diff --git a/ld/lexsup.c b/ld/lexsup.c
index fcca4d3..5137341 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -118,6 +118,7 @@ enum option_values
OPTION_FORCE_EXE_SUFFIX,
OPTION_GC_SECTIONS,
OPTION_NO_GC_SECTIONS,
+ OPTION_HASH_SIZE,
OPTION_CHECK_SECTIONS,
OPTION_NO_CHECK_SECTIONS,
OPTION_NO_UNDEFINED,
@@ -328,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},
@@ -364,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,
@@ -447,8 +452,6 @@ static const struct ld_option ld_options[] =
'\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 },
- { {"reduce-memory-overheads", no_argument, NULL, OPTION_REDUCE_MEMORY_OVERHEADS},
- '\0', NULL, N_("reduce memory overheads, possibly taking much longer"), TWO_DASHES },
};
#define OPTION_COUNT ARRAY_SIZE (ld_options)
@@ -1224,9 +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;
}
}