From 7e9f086769d3ad7ed3ee0562888fbb72747a02b1 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 25 Jan 2005 01:40:04 +0000 Subject: bfd/ * elflink.c (elf_link_add_object_symbols): Don't create link dynamic sections immediately when linking shared libs. Instead, wait until we know a lib is needed. (_bfd_elf_link_create_dynstrtab): Extract from.. (_bfd_elf_link_create_dynamic_sections_): ..here. (elf_add_dt_needed_tag): Call _bfd_elf_link_create_dynstrtab and _bfd_elf_link_create_dynamic_sections. Add abfd param. Allow for non-existent .dynamic. (elf_link_output_extsym): Don't complain about undefined symbols in as-needed dynamic libs that aren't actually linked. ld/ * emultempl/elf32.em (gld${EMULATION_NAME}_try_needed): Formatting. (gld${EMULATION_NAME}_after_open): Ignore needed libs if they were only needed by an as-needed lib that didn't get linked. --- ld/emultempl/elf32.em | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'ld/emultempl') diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index c6bc7c2..fd35938 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -13,7 +13,7 @@ cat >e${EMULATION_NAME}.c < ELF support by Ian Lance Taylor @@ -398,9 +398,8 @@ cat >>e${EMULATION_NAME}.c <by - && (bfd_elf_get_dyn_lib_class (needed->by) - & DYN_NO_ADD_NEEDED) != 0) + if (needed->by != NULL + && (bfd_elf_get_dyn_lib_class (needed->by) & DYN_NO_ADD_NEEDED) != 0) class |= DYN_NO_NEEDED | DYN_NO_ADD_NEEDED; bfd_elf_set_dyn_lib_class (abfd, class); @@ -785,9 +784,17 @@ gld${EMULATION_NAME}_after_open (void) struct dt_needed n, nn; 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. */ + if (l->by != NULL + && (bfd_elf_get_dyn_lib_class (l->by) & DYN_AS_NEEDED) != 0) + continue; + /* If we've already seen this file, skip it. */ for (ll = needed; ll != l; ll = ll->next) - if (strcmp (ll->name, l->name) == 0) + if ((ll->by == NULL + || (bfd_elf_get_dyn_lib_class (ll->by) & DYN_AS_NEEDED) == 0) + && strcmp (ll->name, l->name) == 0) break; if (ll != l) continue; -- cgit v1.1