aboutsummaryrefslogtreecommitdiff
path: root/ld/plugin.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2016-06-20 09:53:50 +0930
committerAlan Modra <amodra@gmail.com>2016-06-20 11:26:13 +0930
commit0616a2803812f5c13f8936d281bd71c3d9c09655 (patch)
tree9e08397ff38e47df39dccd4dbc7ac0d418d02bbd /ld/plugin.c
parent6336b4b7370b8034091364f500184c0a8674a340 (diff)
downloadgdb-0616a2803812f5c13f8936d281bd71c3d9c09655.zip
gdb-0616a2803812f5c13f8936d281bd71c3d9c09655.tar.gz
gdb-0616a2803812f5c13f8936d281bd71c3d9c09655.tar.bz2
PR ld/20276: Set non_ir_ref on common symbol
Also, don't check alignment on symbol from plugin dummy input. bfd/ PR ld/20276 * elflink.c (elf_link_add_object_symbols): Don't check alignment on symbol from plugin dummy input. ld/ PR ld/20276 * plugin.c (plugin_notice): Set non_ir_ref on common symbols. * testsuite/ld-plugin/lto.exp (lto_link_tests): Add test for PR ld/20276. (lto_run_tests): Likewise. * testsuite/ld-plugin/pass.out: New file. * testsuite/ld-plugin/pr20276a.c: Likewise. * testsuite/ld-plugin/pr20276b.c: Likewise.
Diffstat (limited to 'ld/plugin.c')
-rw-r--r--ld/plugin.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/ld/plugin.c b/ld/plugin.c
index cb61318..4c161d1 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -1325,20 +1325,30 @@ plugin_notice (struct bfd_link_info *info,
h->non_ir_ref = TRUE;
}
- /* Otherwise, it must be a new def. Ensure any symbol defined
- in an IR dummy BFD takes on a 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)))
+ /* Otherwise, it must be a new def. */
+ else
{
- h->type = bfd_link_hash_undefweak;
- h->u.undef.abfd = sym_bfd;
+ /* A common symbol should be merged with other commons or
+ defs with the same name. In particular, a common ought
+ to be overridden by a def in a -flto object. In that
+ sense a common is also a ref. */
+ if (bfd_is_com_section (section))
+ h->non_ir_ref = TRUE;
+
+ /* Ensure any symbol defined in an IR dummy BFD takes on a
+ 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. */
+ 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)))
+ {
+ h->type = bfd_link_hash_undefweak;
+ h->u.undef.abfd = sym_bfd;
+ }
}
}