From John Reiser <jreiser@BitWagon.com>
authorAlan Modra <amodra@gmail.com>
Sat, 29 Sep 2001 12:57:54 +0000 (12:57 +0000)
committerAlan Modra <amodra@gmail.com>
Sat, 29 Sep 2001 12:57:54 +0000 (12:57 +0000)
* 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.

ld/ChangeLog
ld/ld.h
ld/ld.texinfo
ld/ldgram.y
ld/ldlang.c
ld/ldlex.l
ld/ldmain.c
ld/lexsup.c

index de5b83dedbdbb2751daf5957662718015fcb0765..62e2ba0e960a967895c0ccf9b99ca407ca639156 100644 (file)
@@ -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 fef40a5338e70b06685f3589fa50ce2774059b28..68dfbdc5842c068431d57522fd3b7c42d15c1155 100644 (file)
--- 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.  */
index 2d04a57e54fe4c4783f0e8ea2adf184b75c9b8ff..0b67ae10f7c391c3ff5d9748ad2c4268d9ee10ea 100644 (file)
@@ -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
index a823bab76863d01732a2197176bb114b9ee9be64..25d8d090b28c8f17e855e7844b2ff7ed7d905aee 100644 (file)
@@ -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 (); }
index 1b634684ee882a62b049421118fa1f3920270fe1..d463d7b7d4c6c8bd906010965e7c6df1288a43f0 100644 (file)
@@ -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;
index eebb950bb315909d6b30e6a99aaeafa2d287006c..b43cfa31874509fe48f4d446c0748993df3fcf34 100644 (file)
@@ -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);}
index e31f27694b6e9f9183b6ac5b4433e27180473b80..65db442638920bd66d6d634c2f94fe8539b12222 100644 (file)
@@ -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;
index d544df544330f5ec43fcc4b447191f9db974c968..70e9017f1bd7fcb717d4043e8729387d06006aef 100644 (file)
@@ -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;
This page took 0.043205 seconds and 4 git commands to generate.