From: John Reiser <jreiser@BitWagon.com>
To: binutils@sourceware.cygnus.com
Subject: optionally postpone assignment of Common
Date: Tue, 25 Sep 2001 11:55:00 -0000 [thread overview]
Message-ID: <3BB0D3AC.16552408@BitWagon.com> (raw)
In-Reply-To: <m3iterhri6.fsf@north-pole.nickc.cambridge.redhat.com>
This patch against today's CVS add a new commandline option
--no-define-common and corresponding script command
INHIBIT_COMMON_ALLOCATION, which postpone the assignment of
addresses for Common symbols. Tested on i386.
If a Common block is left "dangling" (no allocation in some
other module before runtime) then some existing rtld
(such as Linux /lib/ld-2.1.3.so) allocate it in .text,
but that is a problem that is outside of binutils.
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/ld/ChangeLog,v
retrieving revision 1.490
diff -u -r1.490 ChangeLog
--- ChangeLog 2001/09/24 21:16:47 1.490
+++ ChangeLog 2001/09/25 18:38:07
@@ -1,3 +1,13 @@
+2001-09-25 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.
+
2001-09-24 Charles Wilson <cwilson@ece.gatech.edu>
* pe-dll.c: Remove obsoleted declaration of
Index: ld.h
===================================================================
RCS file: /cvs/src/src/ld/ld.h,v
retrieving revision 1.14
diff -u -r1.14 ld.h
--- ld.h 2001/08/12 07:59:28 1.14
+++ ld.h 2001/09/25 18:30:49
@@ -102,6 +102,9 @@
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: ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.51
diff -u -r1.51 ld.texinfo
--- ld.texinfo 2001/09/24 18:35:08 1.51
+++ ld.texinfo 2001/09/25 18:30:56
@@ -950,6 +950,13 @@
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}.
+
@cindex symbols, from command line
@kindex --defsym @var{symbol}=@var{exp}
@item --defsym @var{symbol}=@var{expression}
@@ -2310,6 +2317,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})
Index: ldgram.y
===================================================================
RCS file: /cvs/src/src/ld/ldgram.y,v
retrieving revision 1.13
diff -u -r1.13 ldgram.y
--- ldgram.y 2001/08/15 17:10:18 1.13
+++ ldgram.y 2001/09/25 18:30:57
@@ -125,6 +125,7 @@
%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 @@
{ 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: ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.62
diff -u -r1.62 ldlang.c
--- ldlang.c 2001/09/19 05:33:33 1.62
+++ ldlang.c 2001/09/25 18:31:01
@@ -3553,6 +3553,8 @@
static void
lang_common ()
{
+ if (command_line.inhibit_common_definition)
+ return;
if (link_info.relocateable
&& ! command_line.force_common_definition)
return;
Index: ldlex.l
===================================================================
RCS file: /cvs/src/src/ld/ldlex.l,v
retrieving revision 1.6
diff -u -r1.6 ldlex.l
--- ldlex.l 2001/09/19 05:33:33 1.6
+++ ldlex.l 2001/09/25 18:31:02
@@ -260,6 +260,7 @@
<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: ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.34
diff -u -r1.34 ldmain.c
--- ldmain.c 2001/09/19 05:33:33 1.34
+++ ldmain.c 2001/09/25 18:31:03
@@ -205,6 +205,7 @@
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: lexsup.c
===================================================================
RCS file: /cvs/src/src/ld/lexsup.c,v
retrieving revision 1.40
diff -u -r1.40 lexsup.c
--- lexsup.c 2001/09/19 05:33:33 1.40
+++ lexsup.c 2001/09/25 18:31:05
@@ -132,6 +132,7 @@
#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 @@
'\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},
@@ -746,6 +749,9 @@
case 'n':
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;
--
John Reiser, jreiser@BitWagon.com
next prev parent reply other threads:[~2001-09-25 11:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-09-07 8:56 ld: orthogonal functionality? John Reiser
2001-09-10 10:43 ` Nick Clifton
2001-09-19 9:07 ` [PATCH] " John Reiser
2001-09-19 9:13 ` H . J . Lu
2001-09-19 10:53 ` John Reiser
2001-09-19 12:14 ` John Reiser
2001-09-24 23:38 ` Where can I add "-lm" flag to compile tc-*.c jw c
2001-09-25 11:55 ` John Reiser [this message]
2001-09-25 19:13 ` optionally postpone assignment of Common Alan Modra
2001-09-25 21:13 ` John Reiser
2001-09-29 5:58 ` Alan Modra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3BB0D3AC.16552408@BitWagon.com \
--to=jreiser@bitwagon.com \
--cc=binutils@sourceware.cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).