From 8fbb09e83e588193462a3c488466cb4d1a80ba98 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 6 Dec 2012 00:25:19 +0000 Subject: 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. --- ld/emultempl/elf32.em | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'ld/emultempl') diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 6c84b82..d30a0ad 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. */ -- cgit v1.1