aboutsummaryrefslogtreecommitdiff
path: root/ld/plugin.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-07-22 03:49:07 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-07-22 03:49:17 -0700
commit0e6a3f07f50723d1831291492b96fdf74bcbdc11 (patch)
treea4b39ecfd8c04d2836ef2e5620e5e2169d65572c /ld/plugin.c
parent1ad2776d3db6d82cb59cef1495642fc7fcd57ed5 (diff)
downloadgdb-0e6a3f07f50723d1831291492b96fdf74bcbdc11.zip
gdb-0e6a3f07f50723d1831291492b96fdf74bcbdc11.tar.gz
gdb-0e6a3f07f50723d1831291492b96fdf74bcbdc11.tar.bz2
ld: Properly override the IR definition
We change the previous definition in the IR object to undefweak only after all LTO symbols have been read. include/ PR ld/26262 PR ld/26267 * bfdlink.h (bfd_link_info): Add lto_all_symbols_read. ld/ PR ld/26262 PR ld/26267 * ldlang.c (lang_process): Set lto_all_symbols_read after all LTO IR symbols have been read. * plugin.c (plugin_notice): Override the IR definition only if all LTO IR symbols have been read or the new definition is non-weak and the the IR definition is weak * testsuite/ld-plugin/lto.exp: Run PR ld/26262 and ld/26267 tests. * testsuite/ld-plugin/pr26262a.c: New file. * testsuite/ld-plugin/pr26262b.c: Likewise. * testsuite/ld-plugin/pr26262c.c: Likewise. * testsuite/ld-plugin/pr26267.err: Likewise. * testsuite/ld-plugin/pr26267a.c: Likewise. * testsuite/ld-plugin/pr26267b.c: Likewise. * testsuite/ld-plugin/pr26267c.c: Likewise.
Diffstat (limited to 'ld/plugin.c')
-rw-r--r--ld/plugin.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/ld/plugin.c b/ld/plugin.c
index b455af6..d709ee1 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -1433,12 +1433,16 @@ plugin_notice (struct bfd_link_info *info,
new value from a real BFD. Weak symbols are not normally
overridden by a new weak definition, and strong symbols
will normally cause multiple definition errors. Avoid
- this by making the symbol appear to be undefined. */
- else if (((h->type == bfd_link_hash_defweak
- || h->type == bfd_link_hash_defined)
- && is_ir_dummy_bfd (sym_bfd = h->u.def.section->owner))
- || (h->type == bfd_link_hash_common
- && is_ir_dummy_bfd (sym_bfd = h->u.c.p->section->owner)))
+ this by making the symbol appear to be undefined.
+
+ NB: We change the previous definition in the IR object to
+ undefweak only after all LTO symbols have been read. */
+ else if (info->lto_all_symbols_read
+ && (((h->type == bfd_link_hash_defweak
+ || h->type == bfd_link_hash_defined)
+ && is_ir_dummy_bfd (sym_bfd = h->u.def.section->owner))
+ || (h->type == bfd_link_hash_common
+ && is_ir_dummy_bfd (sym_bfd = h->u.c.p->section->owner))))
{
h->type = bfd_link_hash_undefweak;
h->u.undef.abfd = sym_bfd;