2014-08-18 Alan Modra <amodra@gmail.com>
+ PR 17287
+ * elflink.c (on_needed_list): Only consider libraries that have
+ been loaded.
+
+2014-08-18 Alan Modra <amodra@gmail.com>
+
* elflink.c (bfd_elf_discard_info): Return int error status.
* stabs.c (_bfd_discard_section_stabs): Comment typo fix.
* bfd-in.h (bfd_elf_discard_info): Updata prototype.
on_needed_list (const char *soname, struct bfd_link_needed_list *needed)
{
for (; needed != NULL; needed = needed->next)
- if (strcmp (soname, needed->name) == 0)
+ if ((elf_dyn_lib_class (needed->by) & DYN_AS_NEEDED) == 0
+ && strcmp (soname, needed->name) == 0)
return TRUE;
return FALSE;
2014-08-18 Alan Modra <amodra@gmail.com>
+ * ld.texinfo (--as-needed): Clarify that references from libraries
+ must be from needed libraries.
+
+2014-08-18 Alan Modra <amodra@gmail.com>
+
* emultempl/aarch64elf.em (gld${EMULATION_NAME}_after_allocation):
Handle error status from bfd_elf_discard_info.
* emultempl/armelf.em: Likewise.
needed or not. @option{--as-needed} causes a DT_NEEDED tag to only be
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.
+the library is not found in the DT_NEEDED lists of other needed libraries, a
+non-weak undefined symbol reference from another needed 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
+2014-08-18 Alan Modra <amodra@gmail.com>
+
+ * ld-plugin/needed3.c: New file.
+ * ld-elf/shared.exp: Add needed3 test.
+
2014-08-12 Alan Modra <amodra@gmail.com>
* lib/ld-lib.exp (check_plugin_api_available): Match "-plugin PLUGIN".
--- /dev/null
+extern void foo (void);
+
+int
+main ()
+{
+ foo ();
+ return 0;
+}
{"Build needed2"
"tmpdir/libneeded2c.o -Wl,--as-needed tmpdir/libneeded2a.so tmpdir/libneeded2b.so" ""
{dummy.c} {} "needed2"}
+ {"Build libneeded3a.so"
+ "-shared -Wl,--no-add-needed" "-fPIC"
+ {needed1a.c} {} "libneeded3a.so"}
+ {"Build libneeded3b.so"
+ "-shared -Wl,--no-as-needed,--add-needed -Ltmpdir -lneeded1b" "-fPIC"
+ {dummy.c} {} "libneeded3b.so"}
+ {"Build needed3.o"
+ "-r -nostdlib" ""
+ {needed3.c} {} "libneeded3.so"}
+ {"Build needed3"
+ "tmpdir/needed3.o -Wl,--as-needed -Ltmpdir -lneeded3a -lneeded3b -lneeded1b" ""
+ {dummy.c} {} "needed3"}
{"Build libpr2404a.so"
"-shared" "-fPIC"
{pr2404a.c} {} "libpr2404a.so"}