aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2009-01-31 11:44:38 +0000
committerAlan Modra <amodra@gmail.com>2009-01-31 11:44:38 +0000
commit010e5ae26efd7221bd797a2b6726eb671cb2528e (patch)
tree4f67226b3c29c107120006a9eb8678a9eaa6d568 /bfd
parent5d27446dac0017fcbea7ad53ba0aa713575d0354 (diff)
downloadgdb-010e5ae26efd7221bd797a2b6726eb671cb2528e.zip
gdb-010e5ae26efd7221bd797a2b6726eb671cb2528e.tar.gz
gdb-010e5ae26efd7221bd797a2b6726eb671cb2528e.tar.bz2
binutils/
* NEWS: Mention --as-needed change. ld/ * ld.texinfo (--as-needed): Update. bfd/ * elflink.c (on_needed_list): New function. (elf_link_add_object_symbols): Link in --as-needed libs if they satisfy undefined symbols in other libs.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c17
2 files changed, 21 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index d47fbe2..ba07018 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2009-01-31 Alan Modra <amodra@bigpond.net.au>
+
+ * elflink.c (on_needed_list): New function.
+ (elf_link_add_object_symbols): Link in --as-needed libs if they
+ satisfy undefined symbols in other libs.
+
2009-01-30 Julian Brown <julian@codesourcery.com>
* elf32-arm.c (bfd_elf32_arm_vfp11_erratum_scan): Skip BFDs with
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 927f1c4..8685a2f 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -3199,6 +3199,16 @@ elf_add_dt_needed_tag (bfd *abfd,
return 0;
}
+static bfd_boolean
+on_needed_list (const char *soname, struct bfd_link_needed_list *needed)
+{
+ for (; needed != NULL; needed = needed->next)
+ if (strcmp (soname, needed->name) == 0)
+ return TRUE;
+
+ return FALSE;
+}
+
/* Sort symbol by value and section. */
static int
elf_sort_symbol (const void *arg1, const void *arg2)
@@ -4434,8 +4444,11 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
if (!add_needed
&& definition
- && dynsym
- && h->ref_regular)
+ && ((dynsym
+ && h->ref_regular)
+ || (h->ref_dynamic
+ && (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0
+ && !on_needed_list (elf_dt_name (abfd), htab->needed))))
{
int ret;
const char *soname = elf_dt_name (abfd);