public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ld: orthogonal functionality?
@ 2001-09-07  8:56 John Reiser
  2001-09-10 10:43 ` Nick Clifton
  0 siblings, 1 reply; 11+ messages in thread
From: John Reiser @ 2001-09-07  8:56 UTC (permalink / raw)
  To: binutils

In ld for ELF, I'd like to control these features separately and
independently, both from the command line and from an input script:

0. output type ET_EXEC, ET_DYN, ET_REL
1. warn (alt: not) if undefined symbols are referenced
2. force non-zero exit status if undefined symbols are referenced
   (alt: undefineds have no effect on exit status)
3. inhibit output (alt: not) if undefined symbols are referenced
4. lazy relocation (delay as long as possible) vs. eager relocation
   (reduce strength [symbol==>section==>segment==><done>] as soon
   as possible)
5. allocate Common blocks (alt: not)

Current flags such as -dc, -r, -Bsymbolic, -shared, --no-undefined,
--noinhibit-exec provide only partial, non-orthogonal coverage
of the cases.  Lately I've run into several situations where I
could not figure out how to get what I want, even though the
underlying features are implemented for some other combination.

Please comment, suggest, cite known pitfalls, etc.  Thank you.

-- 
John Reiser, jreiser@BitWagon.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: ld: orthogonal functionality?
  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-25 11:55   ` optionally postpone assignment of Common John Reiser
  0 siblings, 2 replies; 11+ messages in thread
From: Nick Clifton @ 2001-09-10 10:43 UTC (permalink / raw)
  To: John Reiser; +Cc: binutils

Hi John,

> In ld for ELF, I'd like to control these features separately and
> independently, both from the command line and from an input script:
> 
> 0. output type ET_EXEC, ET_DYN, ET_REL
> 1. warn (alt: not) if undefined symbols are referenced
> 2. force non-zero exit status if undefined symbols are referenced
>    (alt: undefineds have no effect on exit status)
> 3. inhibit output (alt: not) if undefined symbols are referenced
> 4. lazy relocation (delay as long as possible) vs. eager relocation
>    (reduce strength [symbol==>section==>segment==><done>] as soon
>    as possible)
> 5. allocate Common blocks (alt: not)
> 
> Current flags such as -dc, -r, -Bsymbolic, -shared, --no-undefined,
> --noinhibit-exec provide only partial, non-orthogonal coverage
> of the cases.  Lately I've run into several situations where I
> could not figure out how to get what I want, even though the
> underlying features are implemented for some other combination.

Creating a complete and orthogonal command set is laudable goal, and
since you raise the issue I assume that you are considering doing the
work too.  One thing to remember however is that a lot of the
linker's command line switches are their to emulate the behaviour of
switches in other, non-GNU, linkers.  So, if possible, you should
preserve their current semantics.

Cheers
        Nick

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] Re: ld: orthogonal functionality?
  2001-09-10 10:43 ` Nick Clifton
@ 2001-09-19  9:07   ` John Reiser
  2001-09-19  9:13     ` H . J . Lu
  2001-09-25 11:55   ` optionally postpone assignment of Common John Reiser
  1 sibling, 1 reply; 11+ messages in thread
From: John Reiser @ 2001-09-19  9:07 UTC (permalink / raw)
  To: binutils

Here is an integration of -Bsymbolic and --allow-shlib-undefined
with diffs against the latest release binutils-2.11.2.
The i386 version has been tested, but not the others.
=====
2001-09-19  John Reiser  <jreiser@BitWagon.com>

	* elf32-i386.c (elf_i386_relocate_section): coordinate info->symbolic
	  and info->allow_shlib_undefined.
	* elf32-hppa.c: likewise
	* elf32-m68k.c: likewise
	* elf32-mips.c: likewise
	* elf32-ppc.c: likewise
	* elf32-sh.c: likewise
	* elf32-sparc.c: likewise

===== binutils-2.11.2/bfd
--- elf32-hppa.c.orig	Mon Jun 11 03:04:10 2001
+++ elf32-hppa.c	Wed Sep 19 08:40:19 2001
@@ -3662,7 +3662,7 @@
 		   && ELF_ST_VISIBILITY (h->elf.other) == STV_DEFAULT
 		   && h->elf.type != STT_PARISC_MILLI)
 	    {
-	      if (info->symbolic)
+	      if (info->symbolic && !info->allow_shlib_undefined)
 		if (!((*info->callbacks->undefined_symbol)
 		      (info, h->elf.root.root.string, input_bfd,
 		       input_section, rel->r_offset, false)))
--- elf32-i386.c.orig	Mon Jun 11 03:04:10 2001
+++ elf32-i386.c	Wed Sep 19 08:35:26 2001
@@ -1465,7 +1465,8 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic
+	  else if (info->shared
+                   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
--- elf32-m68k.c.orig	Wed Jun  6 20:08:24 2001
+++ elf32-m68k.c	Wed Sep 19 08:41:54 2001
@@ -1490,7 +1490,8 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic
+	  else if (info->shared
+		   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
--- elf32-mips.c.orig	Mon Jun 11 03:04:11 2001
+++ elf32-mips.c	Wed Sep 19 08:53:09 2001
@@ -6136,7 +6136,9 @@
 	   and check to see if they exist by looking at their
 	   addresses.  */
 	symbol = 0;
-      else if (info->shared && !info->symbolic && !info->no_undefined
+      else if (info->shared
+	       && (!info->symbolic || info->allow_shlib_undefined)
+	       && !info->no_undefined
 	       && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
 	symbol = 0;
       else if (strcmp (h->root.root.root.string, "_DYNAMIC_LINK") == 0 ||
--- elf32-ppc.c.orig	Wed Jun  6 20:08:25 2001
+++ elf32-ppc.c	Wed Sep 19 08:53:34 2001
@@ -3102,7 +3102,9 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic && !info->no_undefined
+	  else if (info->shared
+		   && (!info->symbolic || info->allow_shlib_undefined)
+		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
 	  else
--- elf32-sh.c.orig	Wed Jun  6 20:08:25 2001
+++ elf32-sh.c	Wed Sep 19 08:44:16 2001
@@ -3006,7 +3006,9 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic && !info->no_undefined)
+	  else if (info->shared
+	       && (!info->symbolic || info->allow_shlib_undefined)
+	       && !info->no_undefined )
 	    relocation = 0;
 	  else
 	    {
--- elf32-sparc.c.orig	Mon Jun 11 03:04:13 2001
+++ elf32-sparc.c	Wed Sep 19 08:44:52 2001
@@ -1241,7 +1241,8 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic
+	  else if (info->shared
+		   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
=====

-- 
John Reiser, jreiser@BitWagon.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Re: ld: orthogonal functionality?
  2001-09-19  9:07   ` [PATCH] " John Reiser
@ 2001-09-19  9:13     ` H . J . Lu
  2001-09-19 10:53       ` John Reiser
                         ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: H . J . Lu @ 2001-09-19  9:13 UTC (permalink / raw)
  To: John Reiser; +Cc: binutils

On Wed, Sep 19, 2001 at 09:09:03AM -0700, John Reiser wrote:
> Here is an integration of -Bsymbolic and --allow-shlib-undefined
> with diffs against the latest release binutils-2.11.2.
					^^^^^^^^^^^^^^^^
That may be too old. Please try CVS, snapshot, the Linux binutils, in
that order, if you want to submit patches to binutils.



H.J.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Re: ld: orthogonal functionality?
  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
  2 siblings, 0 replies; 11+ messages in thread
From: John Reiser @ 2001-09-19 10:53 UTC (permalink / raw)
  To: H . J . Lu; +Cc: binutils

"H . J . Lu" wrote:
> 
> On Wed, Sep 19, 2001 at 09:09:03AM -0700, John Reiser wrote:
> > Here is an integration of -Bsymbolic and --allow-shlib-undefined
> > with diffs against the latest release binutils-2.11.2.
>                                         ^^^^^^^^^^^^^^^^
> That may be too old. Please try CVS, snapshot, the Linux binutils, in
> that order, if you want to submit patches to binutils.

I will look into those alternatives.  But if patches against
the latest release are too old, then that is a sign of a broken
development process.  CVS with branches and release tags
provides explicit, direct support for patching the latest release,
and for merging changes from branch to mainline.  And working from
the latest release guarantees that separate threads of development
are identified and contained, and that interactions are restricted
to known merge points.

-- 
John Reiser, jreiser@BitWagon.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Re: ld: orthogonal functionality?
  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
  2 siblings, 0 replies; 11+ messages in thread
From: John Reiser @ 2001-09-19 12:14 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 667 bytes --]

OK, this time against today's CVS.  Non-i386 not tested.

=====
2001-09-19  John Reiser  <jreiser@BitWagon.com>
	* elf32-i386.c (elf_i386_relocate_section): coordinate info->symbolic
	  and info->allow_shlib_undefined.
	* elf32-cris.c: likewise
	* elf32-hppa.c: likewise
	* elf32-m68k.c: likewise
	* elf32-mips.c: likewise
	* elf32-ppc.c: likewise
	* elf32-s390.c: likewise
	* elf32-sh.c: likewise
	* elf32-sparc.c: likewise
	* elf64-alpha.c: likewise
	* elf64-hppa.c: likewise
	* elf64-ppc.c: likewise
	* elf64-s390.c: likewise
	* elf64-sparc.c: likewise
	* elf64-x86-64.c: likewise
	* elfxx-ia64.c: likewise

=====

-- 
John Reiser, jreiser@BitWagon.com
diffs.out


[-- Attachment #2: diffs.out --]
[-- Type: text/x-diff, Size: 11117 bytes --]

Index: elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.9
diff -u -r1.9 elf32-cris.c
--- elf32-cris.c	2001/09/18 09:57:23	1.9
+++ elf32-cris.c	2001/09/19 18:59:03
@@ -898,7 +898,7 @@
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
 	  else if (info->shared
-		   && !info->symbolic
+		   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
Index: elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.44
diff -u -r1.44 elf32-hppa.c
--- elf32-hppa.c	2001/09/18 09:57:23	1.44
+++ elf32-hppa.c	2001/09/19 18:59:07
@@ -3679,7 +3679,7 @@
 		   && ELF_ST_VISIBILITY (h->elf.other) == STV_DEFAULT
 		   && h->elf.type != STT_PARISC_MILLI)
 	    {
-	      if (info->symbolic)
+	      if (info->symbolic && !info->allow_shlib_undefined)
 		if (!((*info->callbacks->undefined_symbol)
 		      (info, h->elf.root.root.string, input_bfd,
 		       input_section, rel->r_offset, false)))
Index: elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.43
diff -u -r1.43 elf32-i386.c
--- elf32-i386.c	2001/09/18 09:57:23	1.43
+++ elf32-i386.c	2001/09/19 18:59:10
@@ -1549,7 +1549,8 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    ;
-	  else if (info->shared && !info->symbolic
+	  else if (info->shared
+		   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    ;
Index: elf32-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68k.c,v
retrieving revision 1.25
diff -u -r1.25 elf32-m68k.c
--- elf32-m68k.c	2001/09/18 09:57:23	1.25
+++ elf32-m68k.c	2001/09/19 18:59:12
@@ -1474,7 +1474,8 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic
+	  else if (info->shared
+		   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
Index: elf32-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mips.c,v
retrieving revision 1.112
diff -u -r1.112 elf32-mips.c
--- elf32-mips.c	2001/09/18 09:57:23	1.112
+++ elf32-mips.c	2001/09/19 18:59:22
@@ -6142,7 +6142,9 @@
 	   and check to see if they exist by looking at their
 	   addresses.  */
 	symbol = 0;
-      else if (info->shared && !info->symbolic && !info->no_undefined
+      else if (info->shared
+	       && (!info->symbolic || info->allow_shlib_undefined)
+	       && !info->no_undefined
 	       && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
 	symbol = 0;
       else if (strcmp (h->root.root.root.string, "_DYNAMIC_LINK") == 0 ||
Index: elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.28
diff -u -r1.28 elf32-ppc.c
--- elf32-ppc.c	2001/09/18 09:57:24	1.28
+++ elf32-ppc.c	2001/09/19 18:59:26
@@ -3106,7 +3106,9 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic && !info->no_undefined
+	  else if (info->shared
+		   && (!info->symbolic || info->allow_shlib_undefined)
+		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
 	  else
Index: elf32-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-s390.c,v
retrieving revision 1.5
diff -u -r1.5 elf32-s390.c
--- elf32-s390.c	2001/09/18 09:57:24	1.5
+++ elf32-s390.c	2001/09/19 18:59:29
@@ -1444,7 +1444,8 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic
+	  else if (info->shared
+		   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
Index: elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.32
diff -u -r1.32 elf32-sh.c
--- elf32-sh.c	2001/09/18 09:57:24	1.32
+++ elf32-sh.c	2001/09/19 18:59:34
@@ -3114,7 +3114,9 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic && !info->no_undefined)
+	  else if (info->shared
+	       && (!info->symbolic || info->allow_shlib_undefined)
+	       && !info->no_undefined)
 	    relocation = 0;
 	  else
 	    {
Index: elf32-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sparc.c,v
retrieving revision 1.25
diff -u -r1.25 elf32-sparc.c
--- elf32-sparc.c	2001/09/18 09:57:24	1.25
+++ elf32-sparc.c	2001/09/19 18:59:36
@@ -1237,7 +1237,8 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic
+	  else if (info->shared
+		   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
Index: elf64-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-alpha.c,v
retrieving revision 1.40
diff -u -r1.40 elf64-alpha.c
--- elf64-alpha.c	2001/09/18 09:57:24	1.40
+++ elf64-alpha.c	2001/09/19 18:59:40
@@ -3346,7 +3346,8 @@
 	    }
 	  else if (h->root.root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic
+	  else if (info->shared
+		   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
 	    relocation = 0;
Index: elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.15
diff -u -r1.15 elf64-hppa.c
--- elf64-hppa.c	2001/09/18 09:57:24	1.15
+++ elf64-hppa.c	2001/09/19 18:59:43
@@ -746,7 +746,8 @@
 	 have yet been processed.  Do something with what we know, as
 	 this may help reduce memory usage and processing time later.  */
       maybe_dynamic = false;
-      if (h && ((info->shared && ! info->symbolic)
+      if (h && ((info->shared
+		    && (!info->symbolic || info->allow_shlib_undefined) )
 		|| ! (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)
 		|| h->root.type == bfd_link_hash_defweak))
 	maybe_dynamic = true;
@@ -973,7 +974,7 @@
   if (h->root.root.string[0] == '$' && h->root.root.string[1] == '$')
     return false;
 
-  if ((info->shared && !info->symbolic)
+  if ((info->shared && (!info->symbolic || info->allow_shlib_undefined))
       || ((h->elf_link_hash_flags
 	   & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))
 	  == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)))
Index: elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.2
diff -u -r1.2 elf64-ppc.c
--- elf64-ppc.c	2001/09/18 09:57:24	1.2
+++ elf64-ppc.c	2001/09/19 18:59:47
@@ -2847,7 +2847,9 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic && !info->no_undefined)
+	  else if (info->shared
+	       && (!info->symbolic || info->allow_shlib_undefined)
+	       && !info->no_undefined)
 	    relocation = 0;
 	  else
 	    {
Index: elf64-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-s390.c,v
retrieving revision 1.5
diff -u -r1.5 elf64-s390.c
--- elf64-s390.c	2001/09/18 09:57:24	1.5
+++ elf64-s390.c	2001/09/19 18:59:50
@@ -1432,7 +1432,8 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic
+	  else if (info->shared
+		   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
Index: elf64-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sparc.c,v
retrieving revision 1.34
diff -u -r1.34 elf64-sparc.c
--- elf64-sparc.c	2001/09/18 09:57:24	1.34
+++ elf64-sparc.c	2001/09/19 18:59:53
@@ -2069,7 +2069,8 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic
+	  else if (info->shared
+		   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
Index: elf64-x86-64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
retrieving revision 1.24
diff -u -r1.24 elf64-x86-64.c
--- elf64-x86-64.c	2001/09/18 09:57:24	1.24
+++ elf64-x86-64.c	2001/09/19 18:59:55
@@ -1300,7 +1300,9 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared && !info->symbolic && !info->no_undefined
+	  else if (info->shared
+		   && (!info->symbolic || info->allow_shlib_undefined)
+		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
 	  else
Index: elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.22
diff -u -r1.22 elfxx-ia64.c
--- elfxx-ia64.c	2001/09/18 09:57:24	1.22
+++ elfxx-ia64.c	2001/09/19 19:00:00
@@ -1429,7 +1429,7 @@
       || h->root.type == bfd_link_hash_defweak)
     return true;
 
-  if ((info->shared && !info->symbolic)
+  if ((info->shared && (!info->symbolic || info->allow_shlib_undefined))
       || ((h->elf_link_hash_flags
 	   & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))
 	  == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)))
@@ -2020,7 +2020,8 @@
 	 have yet been processed.  Do something with what we know, as
 	 this may help reduce memory usage and processing time later.  */
       maybe_dynamic = false;
-      if (h && ((info->shared && ! info->symbolic)
+      if (h && ((info->shared
+		      && (!info->symbolic || info->allow_shlib_undefined))
 		|| ! (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)
 		|| h->root.type == bfd_link_hash_defweak
 		|| elfNN_ia64_aix_vec (abfd->xvec)))
@@ -3509,7 +3510,8 @@
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    undef_weak_ref = true;
-	  else if (info->shared && !info->symbolic
+	  else if (info->shared
+		   && (!info->symbolic || info->allow_shlib_undefined)
 		   && !info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    ;

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Where can I add "-lm" flag to compile tc-*.c
  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       ` jw c
  2 siblings, 0 replies; 11+ messages in thread
From: jw c @ 2001-09-24 23:38 UTC (permalink / raw)
  To: binutils

Hello, I modified one of tc-*.c just for personal
perpose.
The new code includes some math functions such as
pow(), log().
And also I added #include <math.h> line. 

But I can't find the proper place to add "-lm" flag.
I found as_new_LDFLAG in the gas build directory's
Makefile.
But I think I better change a file in the source
directory.

Which file should I change to compile tc-*.c file
correctly?

Thanks.

__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger. http://im.yahoo.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* optionally postpone assignment of Common
  2001-09-10 10:43 ` Nick Clifton
  2001-09-19  9:07   ` [PATCH] " John Reiser
@ 2001-09-25 11:55   ` John Reiser
  2001-09-25 19:13     ` Alan Modra
  1 sibling, 1 reply; 11+ messages in thread
From: John Reiser @ 2001-09-25 11:55 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: optionally postpone assignment of Common
  2001-09-25 11:55   ` optionally postpone assignment of Common John Reiser
@ 2001-09-25 19:13     ` Alan Modra
  2001-09-25 21:13       ` John Reiser
  0 siblings, 1 reply; 11+ messages in thread
From: Alan Modra @ 2001-09-25 19:13 UTC (permalink / raw)
  To: John Reiser; +Cc: binutils

On Tue, Sep 25, 2001 at 11:57:48AM -0700, John Reiser wrote:
> --- 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.
>  

Hi John,
  Would you please expand your documentation a little, specifying why
this option might be useful.

Alan

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: optionally postpone assignment of Common
  2001-09-25 19:13     ` Alan Modra
@ 2001-09-25 21:13       ` John Reiser
  2001-09-29  5:58         ` Alan Modra
  0 siblings, 1 reply; 11+ messages in thread
From: John Reiser @ 2001-09-25 21:13 UTC (permalink / raw)
  To: binutils; +Cc: Alan Modra

Hi Alan and binutils,

Using --no-define-common can save space, and can help prevent
selecting an impostor when many dynamic modules have special
search rules for symbol resolution.


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/26 03:59:04
@@ -950,6 +950,24 @@
 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}
@@ -2310,6 +2328,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})

-- 
John Reiser, jreiser@BitWagon.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: optionally postpone assignment of Common
  2001-09-25 21:13       ` John Reiser
@ 2001-09-29  5:58         ` Alan Modra
  0 siblings, 0 replies; 11+ messages in thread
From: Alan Modra @ 2001-09-29  5:58 UTC (permalink / raw)
  To: John Reiser; +Cc: binutils

On Tue, Sep 25, 2001 at 09:15:06PM -0700, John Reiser wrote:
> Hi Alan and binutils,
> 
> Using --no-define-common can save space, and can help prevent
> selecting an impostor when many dynamic modules have special
> search rules for symbol resolution.

I have committed your patch.

Alan

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2001-09-29  5:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` optionally postpone assignment of Common John Reiser
2001-09-25 19:13     ` Alan Modra
2001-09-25 21:13       ` John Reiser
2001-09-29  5:58         ` Alan Modra

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).