public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* --as-needed change wrt undefined weak symbols
@ 2013-01-14  3:58 Alan Modra
  2013-01-14 15:31 ` H.J. Lu
  0 siblings, 1 reply; 17+ messages in thread
From: Alan Modra @ 2013-01-14  3:58 UTC (permalink / raw)
  To: binutils; +Cc: Pierre Ossman

Does anyone have objections or serious reservations on changing
--as-needed to require a strong reference?  I'm in favour of excluding
weak references as that more closely follows the rules for ld
extracting objects from archives.

Now that http://sourceware.org/ml/binutils/2013-01/msg00165.html and
http://sourceware.org/ml/binutils/2013-01/msg00186.html have gone in I
think the following is all we need.

bfd/
	PR ld/12549
	elflink.c (elf_link_add_object_symbols): Exclude weak refs when
	considering whether an --as-needed library is needed.
ld/
	* ld.texinfo (--as-needed): Update.
ld/testsuite/
	* ld-elf/pr14862.out: Expect no output.

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.463
diff -u -p -r1.463 elflink.c
--- bfd/elflink.c	13 Jan 2013 12:32:10 -0000	1.463
+++ bfd/elflink.c	14 Jan 2013 03:37:56 -0000
@@ -4480,8 +4480,8 @@ error_free_dyn:
 	  if (!add_needed
 	      && definition
 	      && ((dynsym
-		   && h->ref_regular)
-		  || (h->ref_dynamic
+		   && h->ref_regular_nonweak)
+		  || (h->ref_dynamic_nonweak
 		      && (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0
 		      && !on_needed_list (elf_dt_name (abfd), htab->needed))))
 	    {
Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.290
diff -u -p -r1.290 ld.texinfo
--- ld/ld.texinfo	7 Jan 2013 12:11:11 -0000	1.290
+++ ld/ld.texinfo	14 Jan 2013 03:37:57 -0000
@@ -1150,11 +1150,14 @@ on the command line after the @option{--
 the linker will add a DT_NEEDED tag for each dynamic library mentioned
 on the command line, regardless of whether the library is actually
 needed or not.  @option{--as-needed} causes a DT_NEEDED tag to only be
-emitted for a library that satisfies an undefined symbol reference
-from a regular object file or, if the library is not found in the
-DT_NEEDED lists of other libraries linked up to that point, an
-undefined symbol reference from another dynamic library.
-@option{--no-as-needed} restores the default behaviour.
+emitted for a library that @emph{at that point in the link} satisfies a
+non-weak undefined symbol reference from a regular object file or, if
+the library is not found in the DT_NEEDED lists of other libraries, a
+non-weak undefined symbol reference from another dynamic library.
+Object files or libraries appearing on the command line @emph{after}
+the library in question do not affect whether the library is seen as
+needed.  This is similar to the rules for extraction of object files
+from archives.  @option{--no-as-needed} restores the default behaviour.
 
 @kindex --add-needed
 @kindex --no-add-needed
Index: ld/testsuite/ld-elf/pr14862.out
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/pr14862.out,v
retrieving revision 1.1
diff -u -p -r1.1 pr14862.out
--- ld/testsuite/ld-elf/pr14862.out	20 Nov 2012 22:17:27 -0000	1.1
+++ ld/testsuite/ld-elf/pr14862.out	14 Jan 2013 03:37:57 -0000
@@ -1 +0,0 @@
-OK

-- 
Alan Modra
Australia Development Lab, IBM

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

end of thread, other threads:[~2013-04-05  1:07 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-14  3:58 --as-needed change wrt undefined weak symbols Alan Modra
2013-01-14 15:31 ` H.J. Lu
2013-01-15  2:23   ` Alan Modra
2013-01-15  3:30     ` H.J. Lu
2013-01-15  5:23       ` Alan Modra
2013-01-15 15:04         ` H.J. Lu
2013-03-18  2:41           ` Alan Modra
2013-03-18  7:55             ` [GOLD] " Alan Modra
2013-03-18  8:16               ` Alan Modra
     [not found]                 ` <CAKOQZ8xsNiO7f2mNVLqy0vs5ws_C3sDXXdM60j5uSmfzyQKYEQ@mail.gmail.com>
     [not found]                   ` <20130319023425.GG18331@bubble.grove.modra.org>
2013-03-19 21:37                     ` Ian Lance Taylor
2013-03-20  0:26                       ` Alan Modra
2013-03-18 13:43             ` Will Newton
     [not found]               ` <CANu=DmjqJHk2qhcxcGF=8TKVKJbv8TLSpy94MVK9+2yAdaR5Mg@mail.gmail.com>
     [not found]                 ` <20130319023947.GH18331@bubble.grove.modra.org>
2013-03-20  2:27                   ` Alan Modra
2013-04-04 17:16             ` H.J. Lu
2013-04-04 22:39               ` Alan Modra
2013-04-04 23:11                 ` H.J. Lu
2013-04-05  1:07                   ` 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).