From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Cc: Pierre Ossman <ossman@cendio.se>
Subject: --as-needed change wrt undefined weak symbols
Date: Mon, 14 Jan 2013 03:58:00 -0000 [thread overview]
Message-ID: <20130114035805.GF3244@bubble.grove.modra.org> (raw)
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
next reply other threads:[~2013-01-14 3:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-14 3:58 Alan Modra [this message]
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
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=20130114035805.GF3244@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=ossman@cendio.se \
/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).