From 13e570f80cbfb299a8858ce6830e91a6cb40ab7b Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 5 Aug 2014 10:46:57 +0930 Subject: Fix LTO vs. COFF archives Avoid scan of symbols on objects in coff archives since we don't need to do anything special with common symbols. The scan is quite useless, and breaks LTO due to slim LTO objects not having symbols available until after the plugin has claimed them. Instead we can add objects based on their archive symbol map. Also, rip out the archive symbol hash table used by the generic linker. Using a hash breaks one feature of unix archive linking; The first object file in an archive defining any given symbol should be the object extracted to satisfy that symbol. What's more a hash isn't much faster except in pathological cases where object file ordering causes many scans of the archive. See the comment which I'm removing from elf_link_add_archive_symbols. Finally, tidy elflink.c archive handling a little. PR 13557 * linker.c (struct archive_list, struct archive_hash_entry, struct archive_hash_table, archive_hash_newfunc, archive_hash_table_init, archive_hash_lookup, archive_hash_allocate, archive_hash_table_free): Delete. (_bfd_generic_link_add_archive_symbols): Add h and name params to checkfn. Rewrite using a straight-forward scan over archive map. (generic_link_check_archive_element_no_collect, generic_link_check_archive_element_collect, generic_link_check_archive_element): Add h and name params. * aoutx.h (aout_link_check_archive_element): Likewise. * pdp11.c (aout_link_check_archive_element): Likewise. * xcofflink.c (xcoff_link_check_archive_element): Likewise. * cofflink.c (coff_link_check_archive_element): Likewise. Don't scan symbols, simply add archive element whenever h is undefined. (coff_link_check_ar_symbols): Delete. * ecoff.c (read_ext_syms_and_strs): Delete. (reread_ext_syms_and_strs): Delete. (ecoff_link_check_archive_element): Add h and name param. Don't scan symbols, simply add based on h. Use ecoff_link_add_object_symbols. * elflink.c (elf_link_is_defined_archive_symbol): Don't test archive_pass. (elf_link_add_archive_symbols): Delete "defined" array, merge functionality into "included". Make "included" a char array. Don't set or test archive_pass. * libbfd-in.h (_bfd_generic_link_add_archive_symbols): Update. * libbfd.h: Regenerate. --- bfd/xcofflink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bfd/xcofflink.c') diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index 67e1c52..1ca9c2e 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -2384,6 +2384,8 @@ xcoff_link_check_ar_symbols (bfd *abfd, static bfd_boolean xcoff_link_check_archive_element (bfd *abfd, struct bfd_link_info *info, + struct bfd_link_hash_entry *h ATTRIBUTE_UNUSED, + const char *name ATTRIBUTE_UNUSED, bfd_boolean *pneeded) { bfd_boolean keep_syms_p; @@ -2463,7 +2465,7 @@ _bfd_xcoff_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info) bfd_boolean needed; if (! xcoff_link_check_archive_element (member, info, - &needed)) + NULL, NULL, &needed)) return FALSE; if (needed) member->archive_pass = -1; -- cgit v1.1