This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR ld/12277: Linker error: "final link failed: Nonrepresentable section on output"
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Tue, 1 Feb 2011 12:38:40 -0800
- Subject: PATCH: PR ld/12277: Linker error: "final link failed: Nonrepresentable section on output"
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
This patch avoids reporting undefined symbols referenced from plugin
dummy. Any objections?
Thanks.
H.J.
---
--
bfd/
2011-02-01 H.J. Lu <hongjiu.lu@intel.com>
PR ld/12277
* bfd.c (BFD_PLUGIN_DUMMY): New.
(BFD_FLAGS_SAVED): Add BFD_PLUGIN_DUMMY.
(BFD_FLAGS_FOR_BFD_USE_MASK): Likewise.
* bfd-in2.h: Regenerated.
* elflink.c (elf_link_output_extsym): Don't report undefined
symbols referenced from plugin dummy.
ld/
2011-02-01 H.J. Lu <hongjiu.lu@intel.com>
PR ld/12277
* ldfile.c (ldfile_try_open_bfd): Set BFD_PLUGIN_DUMMY on dummy
IR input.
* ldmain.c (add_archive_element): Likewise.
* plugin.c (IRONLY_SUFFIX): Removed.
(IRONLY_SUFFIX_LEN): Likewise.
(plugin_get_ir_dummy_bfd): Updated. Set BFD_PLUGIN_DUMMY on
dummy IR input.
(is_ir_dummy_bfd): Check BFD_PLUGIN_DUMMY.
(get_symbols): Re-indent.
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 84fc75d..e360c06 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -5096,14 +5096,18 @@ struct bfd
/* Decompress sections in this BFD. */
#define BFD_DECOMPRESS 0x10000
+ /* This BFD is a dummy bfd used by the linker plugin. */
+#define BFD_PLUGIN_DUMMY 0x20000
+
/* Flags bits to be saved in bfd_preserve_save. */
#define BFD_FLAGS_SAVED \
- (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS)
+ (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_PLUGIN_DUMMY)
/* Flags bits which are for BFD use only. */
#define BFD_FLAGS_FOR_BFD_USE_MASK \
(BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_LINKER_CREATED \
- | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT)
+ | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT \
+ | BFD_PLUGIN_DUMMY)
/* Currently my_archive is tested before adding origin to
anything. I believe that this can become always an add of
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 77582ec..c1bc6cc 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -157,14 +157,18 @@ CODE_FRAGMENT
. {* Decompress sections in this BFD. *}
.#define BFD_DECOMPRESS 0x10000
.
+. {* This BFD is a dummy bfd used by the linker plugin. *}
+.#define BFD_PLUGIN_DUMMY 0x20000
+.
. {* Flags bits to be saved in bfd_preserve_save. *}
.#define BFD_FLAGS_SAVED \
-. (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS)
+. (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_PLUGIN_DUMMY)
.
. {* Flags bits which are for BFD use only. *}
.#define BFD_FLAGS_FOR_BFD_USE_MASK \
. (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_LINKER_CREATED \
-. | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT)
+. | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT \
+. | BFD_PLUGIN_DUMMY)
.
. {* Currently my_archive is tested before adding origin to
. anything. I believe that this can become always an add of
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 79256bf..9d86019 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -8872,7 +8872,8 @@ elf_link_output_extsym (struct elf_link_hash_entry *h, void *data)
&& ELF_ST_VISIBILITY (sym.st_other) != STV_DEFAULT
&& ELF_ST_BIND (sym.st_info) != STB_WEAK
&& h->root.type == bfd_link_hash_undefined
- && !h->def_regular)
+ && !h->def_regular
+ && (h->root.u.undef.abfd->flags & BFD_PLUGIN_DUMMY) == 0)
{
const char *msg;
diff --git a/ld/ldfile.c b/ld/ldfile.c
index a9a6954..29e2a9c 100644
--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -340,6 +340,7 @@ success:
entry->the_bfd = file.handle;
entry->claimed = TRUE;
bfd_make_readable (entry->the_bfd);
+ entry->the_bfd->flags |= BFD_PLUGIN_DUMMY;
}
else
{
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 19c42d9..c1ff7ca 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -835,6 +835,7 @@ add_archive_element (struct bfd_link_info *info,
input->the_bfd = file.handle;
input->claimed = TRUE;
bfd_make_readable (input->the_bfd);
+ input->the_bfd->flags |= BFD_PLUGIN_DUMMY;
*subsbfd = input->the_bfd;
}
else
diff --git a/ld/plugin.c b/ld/plugin.c
index b285787..87bcce6 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -36,15 +36,6 @@
#include <Windows.h>
#endif
-/* The suffix to append to the name of the real (claimed) object file
- when generating a dummy BFD to hold the IR symbols sent from the
- plugin. */
-#define IRONLY_SUFFIX ".ironly\004"
-
-/* This is sizeof an array of chars, not sizeof a const char *. We
- also have to avoid inadvertently counting the trailing NUL. */
-#define IRONLY_SUFFIX_LEN (sizeof (IRONLY_SUFFIX) - 1)
-
/* Stores a single argument passed to a plugin. */
typedef struct plugin_arg
{
@@ -233,12 +224,12 @@ plugin_get_ir_dummy_bfd (const char *name, bfd *srctemplate)
bfd *abfd;
bfd_use_reserved_id = 1;
- abfd = bfd_create (concat (name, IRONLY_SUFFIX, (const char *)NULL),
- srctemplate);
+ abfd = bfd_create (name, srctemplate);
bfd_set_arch_info (abfd, bfd_get_arch_info (srctemplate));
bfd_make_writable (abfd);
bfd_copy_private_bfd_data (srctemplate, abfd);
bfd_set_gp_size (abfd, bfd_get_gp_size (abfd));
+ abfd->flags |= BFD_PLUGIN_DUMMY;
/* Create a minimal set of sections to own the symbols. */
sec = bfd_make_section_old_way (abfd, ".text");
bfd_set_section_flags (abfd, sec,
@@ -253,14 +244,9 @@ plugin_get_ir_dummy_bfd (const char *name, bfd *srctemplate)
static bfd_boolean
is_ir_dummy_bfd (const bfd *abfd)
{
- size_t namlen;
-
if (abfd == NULL)
return FALSE;
- namlen = strlen (abfd->filename);
- if (namlen < IRONLY_SUFFIX_LEN)
- return FALSE;
- return !strcmp (abfd->filename + namlen - IRONLY_SUFFIX_LEN, IRONLY_SUFFIX);
+ return (abfd->flags & BFD_PLUGIN_DUMMY) != 0;
}
/* Helpers to convert between BFD and GOLD symbol formats. */
@@ -535,9 +521,9 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms)
}
/* Was originally def, weakdef, or common, but has been pre-empted. */
- syms[n].resolution = is_ir_dummy_bfd (owner_sec->owner)
- ? LDPR_PREEMPTED_IR
- : LDPR_PREEMPTED_REG;
+ syms[n].resolution = (is_ir_dummy_bfd (owner_sec->owner)
+ ? LDPR_PREEMPTED_IR
+ : LDPR_PREEMPTED_REG);
}
return LDPS_OK;
}