This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

--as-needed change wrt undefined weak symbols


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]