aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2001-09-29 12:57:54 +0000
committerAlan Modra <amodra@gmail.com>2001-09-29 12:57:54 +0000
commit4818e05fe52eb069d4ae6b306a31b5ecf0e1a6fd (patch)
tree20bd3d7ae9a352be8c4003ccf8f4b855c3d1891a /ld
parent862517b6506a76ce9dc0e06b8f1d98577371e3b4 (diff)
downloadgdb-4818e05fe52eb069d4ae6b306a31b5ecf0e1a6fd.zip
gdb-4818e05fe52eb069d4ae6b306a31b5ecf0e1a6fd.tar.gz
gdb-4818e05fe52eb069d4ae6b306a31b5ecf0e1a6fd.tar.bz2
From John Reiser <jreiser@BitWagon.com>
* ldlang.c (lang_common): Conditionally inhibit Common allocation. * lexsup.c: Add --no-define-common commandline option. * ldgram.y: Add INHIBIT_COMMON_ALLOCATION script command. * ldlex.l: Likewise. * ld.h: Add command_line.inhibit_common_definition. * ldmain.c (main): Initialize. * ld.texinfo: Document.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog10
-rw-r--r--ld/ld.h3
-rw-r--r--ld/ld.texinfo25
-rw-r--r--ld/ldgram.y3
-rw-r--r--ld/ldlang.c2
-rw-r--r--ld/ldlex.l1
-rw-r--r--ld/ldmain.c1
-rw-r--r--ld/lexsup.c6
8 files changed, 49 insertions, 2 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index de5b83d..62e2ba0 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,6 +1,12 @@
-2001-09-29 Alan Modra <amodra@bigpond.net.au>
+2001-09-29 John Reiser <jreiser@BitWagon.com>
- * ldlang.c (section_already_linked): Remove assignment to kept_section.
+ * ldlang.c (lang_common): Conditionally inhibit Common allocation.
+ * lexsup.c: Add --no-define-common commandline option.
+ * ldgram.y: Add INHIBIT_COMMON_ALLOCATION script command.
+ * ldlex.l: Likewise.
+ * ld.h: Add command_line.inhibit_common_definition.
+ * ldmain.c (main): Initialize.
+ * ld.texinfo: Document.
2001-09-26 Alan Modra <amodra@bigpond.net.au>
diff --git a/ld/ld.h b/ld/ld.h
index fef40a5..68dfbdc 100644
--- a/ld/ld.h
+++ b/ld/ld.h
@@ -102,6 +102,9 @@ typedef struct user_section_struct {
typedef struct {
/* 1 => assign space to common symbols even if `relocatable_output'. */
boolean force_common_definition;
+
+ /* 1 => do not assign addresses to common symbols. */
+ boolean inhibit_common_definition;
boolean relax;
/* Name of runtime interpreter to invoke. */
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index 2d04a57..0b67ae1 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -950,6 +950,24 @@ sorted by name. For each symbol, a list of file names is given. If the
symbol is defined, the first file listed is the location of the
definition. The remaining files contain references to the symbol.
+@cindex common allocation
+@kindex --no-define-common
+@item --no-define-common
+This option inhibits the assignment of addresses to common symbols.
+The script command @code{INHIBIT_COMMON_ALLOCATION} has the same effect.
+@xref{Miscellaneous Commands}.
+
+The @samp{--no-define-common} option allows decoupling
+the decision to assign addresses to Common symbols from the choice
+of the output file type; otherwise a non-Relocatable output type
+forces assigning addresses to Common symbols.
+Using @samp{--no-define-common} allows Common symbols that are referenced
+from a shared library to be assigned addresses only in the main program.
+This eliminates the unused duplicate space in the shared library,
+and also prevents any possible confusion over resolving to the wrong
+duplicate when there are many dynamic modules with specialized search
+paths for runtime symbol resolution.
+
@cindex symbols, from command line
@kindex --defsym @var{symbol}=@var{exp}
@item --defsym @var{symbol}=@var{expression}
@@ -2311,6 +2329,13 @@ This command has the same effect as the @samp{-d} command-line option:
to make @code{ld} assign space to common symbols even if a relocatable
output file is specified (@samp{-r}).
+@item INHIBIT_COMMON_ALLOCATION
+@kindex INHIBIT_COMMON_ALLOCATION
+@cindex common allocation in linker script
+This command has the same effect as the @samp{--no-define-common}
+command-line option: to make @code{ld} omit the assignment of addresses
+to common symbols even for a non-relocatable output file.
+
@item NOCROSSREFS(@var{section} @var{section} @dots{})
@kindex NOCROSSREFS(@var{sections})
@cindex cross references
diff --git a/ld/ldgram.y b/ld/ldgram.y
index a823bab..25d8d09 100644
--- a/ld/ldgram.y
+++ b/ld/ldgram.y
@@ -125,6 +125,7 @@ static int error_index;
%token SECTIONS PHDRS SORT
%token '{' '}'
%token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
+%token INHIBIT_COMMON_ALLOCATION
%token SIZEOF_HEADERS
%token INCLUDE
%token MEMORY DEFSYMEND
@@ -321,6 +322,8 @@ ifile_p1:
{ ldfile_set_output_arch($3); }
| FORCE_COMMON_ALLOCATION
{ command_line.force_common_definition = true ; }
+ | INHIBIT_COMMON_ALLOCATION
+ { command_line.inhibit_common_definition = true ; }
| INPUT '(' input_list ')'
| GROUP
{ lang_enter_group (); }
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 1b63468..d463d7b 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -3550,6 +3550,8 @@ lang_check ()
static void
lang_common ()
{
+ if (command_line.inhibit_common_definition)
+ return;
if (link_info.relocateable
&& ! command_line.force_common_definition)
return;
diff --git a/ld/ldlex.l b/ld/ldlex.l
index eebb950..b43cfa3 100644
--- a/ld/ldlex.l
+++ b/ld/ldlex.l
@@ -260,6 +260,7 @@ V_IDENTIFIER [*?.$_a-zA-Z]([*?.$_a-zA-Z0-9]|::)*
<BOTH,SCRIPT>"CREATE_OBJECT_SYMBOLS" { RTOKEN(CREATE_OBJECT_SYMBOLS);}
<BOTH,SCRIPT>"CONSTRUCTORS" { RTOKEN( CONSTRUCTORS);}
<BOTH,SCRIPT>"FORCE_COMMON_ALLOCATION" { RTOKEN(FORCE_COMMON_ALLOCATION);}
+<BOTH,SCRIPT>"INHIBIT_COMMON_ALLOCATION" { RTOKEN(INHIBIT_COMMON_ALLOCATION);}
<BOTH,SCRIPT>"SECTIONS" { RTOKEN(SECTIONS);}
<BOTH,SCRIPT>"FILL" { RTOKEN(FILL);}
<BOTH,SCRIPT>"STARTUP" { RTOKEN(STARTUP);}
diff --git a/ld/ldmain.c b/ld/ldmain.c
index e31f276..65db442 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -205,6 +205,7 @@ main (argc, argv)
config.split_by_reloc = (unsigned) -1;
config.split_by_file = (bfd_size_type) -1;
command_line.force_common_definition = false;
+ command_line.inhibit_common_definition = false;
command_line.interpreter = NULL;
command_line.rpath = NULL;
command_line.warn_mismatch = true;
diff --git a/ld/lexsup.c b/ld/lexsup.c
index d544df5..70e9017 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -132,6 +132,7 @@ int parsing_defsym = 0;
#define OPTION_ALLOW_SHLIB_UNDEFINED (OPTION_TARGET_HELP + 1)
#define OPTION_DISCARD_NONE (OPTION_ALLOW_SHLIB_UNDEFINED + 1)
#define OPTION_SPARE_DYNAMIC_TAGS (OPTION_DISCARD_NONE + 1)
+#define OPTION_NO_DEFINE_COMMON (OPTION_SPARE_DYNAMIC_TAGS + 1)
/* The long options. This structure is used for both the option
parsing and the help text. */
@@ -311,6 +312,8 @@ static const struct ld_option ld_options[] =
'\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH },
{ {"Map", required_argument, NULL, OPTION_MAP},
'\0', N_("FILE"), N_("Write a map file"), ONE_DASH },
+ { {"no-define-common", no_argument, NULL, OPTION_NO_DEFINE_COMMON},
+ '\0', NULL, N_("Do not define Common storage"), TWO_DASHES },
{ {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE },
'\0', NULL, N_("Do not demangle symbol names"), TWO_DASHES },
{ {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
@@ -747,6 +750,9 @@ parse_args (argc, argv)
config.magic_demand_paged = false;
config.dynamic_link = false;
break;
+ case OPTION_NO_DEFINE_COMMON:
+ command_line.inhibit_common_definition = true;
+ break;
case OPTION_NO_DEMANGLE:
demangling = false;
break;