summaryrefslogtreecommitdiff
path: root/ld/emultempl
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2012-12-06 00:25:18 +0000
committerH.J. Lu <hjl.tools@gmail.com>2012-12-06 00:25:18 +0000
commit0ac1c7c4d952a1af66bb183c6c5e00465bb5ee7c (patch)
tree7845c302c472cc916e7fff1f6b12278e207041a1 /ld/emultempl
parent2192d5b068301d8da897f1056b57b630efede44a (diff)
downloadbinutils-redhat-0ac1c7c4d952a1af66bb183c6c5e00465bb5ee7c.tar.gz
Extend --copy-dt-needed-entries to creating DSO
ld/ PR ld/14915 * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Also check DT_NEEDED entries when creating shared object with --copy-dt-needed-entries. ld/testsuite/ PR ld/14915 * ld-elf/shared.exp (build_tests): Test --add-needed, --copy-dt-needed-entries, --no-add-needed and --no-copy-dt-needed-entries with -shared. Add tests for --no-add-needed and --no-copy-dt-needed-entries with -shared.
Diffstat (limited to 'ld/emultempl')
-rw-r--r--ld/emultempl/elf32.em10
1 files changed, 6 insertions, 4 deletions
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 6c84b82d4e..d30a0ad404 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1181,8 +1181,6 @@ gld${EMULATION_NAME}_after_open (void)
special action by the person doing the link. Note that the
needed list can actually grow while we are stepping through this
loop. */
- if (!link_info.executable)
- return;
needed = bfd_elf_get_needed_list (link_info.output_bfd, &link_info);
for (l = needed; l != NULL; l = l->next)
{
@@ -1191,9 +1189,13 @@ gld${EMULATION_NAME}_after_open (void)
int force;
/* If the lib that needs this one was --as-needed and wasn't
- found to be needed, then this lib isn't needed either. */
+ found to be needed, then this lib isn't needed either. Skip
+ the lib when creating a shared object unless we are copying
+ DT_NEEDED entres. */
if (l->by != NULL
- && (bfd_elf_get_dyn_lib_class (l->by) & DYN_AS_NEEDED) != 0)
+ && ((bfd_elf_get_dyn_lib_class (l->by) & DYN_AS_NEEDED) != 0
+ || (!link_info.executable
+ && bfd_elf_get_dyn_lib_class (l->by) & DYN_NO_ADD_NEEDED) != 0))
continue;
/* If we've already seen this file, skip it. */