summaryrefslogtreecommitdiff
path: root/ld/plugin.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2011-08-17 00:39:37 +0000
committerAlan Modra <amodra@bigpond.net.au>2011-08-17 00:39:37 +0000
commita51e98a30b095594dc3fa7657fefa8d93a4c3c8f (patch)
treedd79575c2c7880280dcdfaba5d0dfee0986e653c /ld/plugin.c
parent91e06b03cf3e5018f004de9be4ffe502d5135b63 (diff)
downloadbinutils-redhat-a51e98a30b095594dc3fa7657fefa8d93a4c3c8f.tar.gz
PR ld/12762
bfd/ * bfd-in.h (struct bfd_section_already_linked): Forward declare. (_bfd_handle_already_linked): Declare. * coff-alpha.c (_bfd_ecoff_section_already_linked): Define as _bfd_coff_section_already_linked. * coff-mips.c (_bfd_ecoff_section_already_linked): Likewise. * coffcode.h (coff_section_already_linked): Likewise. * cofflink.c (coff_link_add_symbols): Revert 2011-07-09 changes. * elf-bfd.h: Likewise. * libbfd-in.h: Likewise. * targets.c: Likewise. * linker.c (bfd_section_already_linked): Likewise. (bfd_section_already_linked_table_lookup): Likewise. (bfd_section_already_linked_table_insert): Likewise. (_bfd_generic_section_already_linked): Likewise. Call _bfd_handle_already_linked. (_bfd_handle_already_linked): New function, split out from.. * elflink.c (_bfd_elf_section_already_linked): ..here. Revert 2011-07-09 changes. Avoid unnecessary strcmp when matching already_linked_list entries. Match plugin linkonce section. (section_signature): Delete. * coffgen.c (_bfd_coff_section_already_linked): New function. * libcoff-in.h (_bfd_coff_section_already_linked): Declare. * libbfd.h: Regenerate. * libcoff.h: Regenerate. * bfd-in2.h: Regenerate. ld/ * ldlang.c (section_already_linked): Revert 2011-07-09 changes. * plugin.c: Likewise. (asymbol_from_plugin_symbol): Create linkonce section for syms with comdat_key.
Diffstat (limited to 'ld/plugin.c')
-rw-r--r--ld/plugin.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/ld/plugin.c b/ld/plugin.c
index 9baeb468a9..0be7fa3a6b 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -32,7 +32,6 @@
#include "plugin.h"
#include "plugin-api.h"
#include "elf-bfd.h"
-#include "libbfd.h"
#if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)
#include <windows.h>
#endif
@@ -240,7 +239,7 @@ plugin_get_ir_dummy_bfd (const char *name, bfd *srctemplate)
{
flagword flags;
- /* Create sections to own the symbols. */
+ /* Create section to own the symbols. */
flags = (SEC_CODE | SEC_HAS_CONTENTS | SEC_READONLY
| SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_EXCLUDE);
if (bfd_make_section_anyway_with_flags (abfd, ".text", flags))
@@ -285,7 +284,27 @@ asymbol_from_plugin_symbol (bfd *abfd, asymbol *asym,
/* FALLTHRU */
case LDPK_DEF:
flags |= BSF_GLOBAL;
- section = bfd_get_section_by_name (abfd, ".text");
+ if (ldsym->comdat_key)
+ {
+ char *name = concat (".gnu.linkonce.t.", ldsym->comdat_key,
+ (const char *) NULL);
+ section = bfd_get_section_by_name (abfd, name);
+ if (section != NULL)
+ free (name);
+ else
+ {
+ flagword sflags;
+
+ sflags = (SEC_CODE | SEC_HAS_CONTENTS | SEC_READONLY
+ | SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_EXCLUDE
+ | SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD);
+ section = bfd_make_section_anyway_with_flags (abfd, name, sflags);
+ if (section == NULL)
+ return LDPS_ERR;
+ }
+ }
+ else
+ section = bfd_get_section_by_name (abfd, ".text");
break;
case LDPK_WEAKUNDEF:
@@ -389,13 +408,6 @@ add_symbols (void *handle, int nsyms, const struct ld_plugin_symbol *syms)
enum ld_plugin_status rv;
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);