From 8b6ed5b4da2a02a7cefa7db05e99cce952cbcd54 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 9 Jul 2011 06:20:50 +0000 Subject: PR ld/12942 bfd/ * elflink.c (elf_link_add_object_symbols): Use elf_discarded_section rather than kept_section to determine whether a symbol is from a discarded section. * cofflink.c (coff_link_add_symbols): Make symbols from discarded sections appear undefined. * elf-bfd.h (_bfd_elf_section_already_linked): Replace "asection *" with "struct already_linked *". * libbfd-in.h (_bfd_nolink_section_already_linked): Likewise. (_bfd_generic_section_already_linked): Likewise. (bfd_section_already_linked_table_insert): Likewise. (struct already_linked): New. (struct bfd_section_already_linked): Use it. * elflink.c (_bfd_elf_section_already_linked): Replace. "asection *" with "struct already_linked *". Replace the plugin dummy with the LTO output. * linker.c (_bfd_generic_section_already_linked): Likewise. * targets.c (struct already_linked): Add forward declaration. (bfd_target): Replace "struct bfd_section *" with "struct already_linked *" in _section_already_linked. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. include/ * bfdlink.h (bfd_link_info): Add loading_lto_outputs. ld/ * ldlang.c (section_already_linked): Pass "struct already_linked *" to bfd_section_already_linked. (lang_process): Set link_info.loading_lto_outputs before loading LTO outputs. * plugin.c: Include "libbfd.h". (add_symbols): Call bfd_section_already_linked with comdat_key. --- ld/plugin.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'ld/plugin.c') diff --git a/ld/plugin.c b/ld/plugin.c index 60eb1028a8..0a0ee0c0d3 100644 --- a/ld/plugin.c +++ b/ld/plugin.c @@ -32,6 +32,7 @@ #include "plugin.h" #include "plugin-api.h" #include "elf-bfd.h" +#include "libbfd.h" #if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) #include #endif @@ -385,7 +386,16 @@ add_symbols (void *handle, int nsyms, const struct ld_plugin_symbol *syms) for (n = 0; n < nsyms; n++) { enum ld_plugin_status rv; - asymbol *bfdsym = bfd_make_empty_symbol (abfd); + asymbol *bfdsym; + + if (syms[n].comdat_key) + { + struct already_linked linked; + linked.comdat_key = xstrdup (syms[n].comdat_key); + linked.u.abfd = abfd; + bfd_section_already_linked (abfd, &linked, &link_info); + } + bfdsym = bfd_make_empty_symbol (abfd); symptrs[n] = bfdsym; rv = asymbol_from_plugin_symbol (abfd, bfdsym, syms + n); if (rv != LDPS_OK) -- cgit v1.2.1