ld: Change indirect symbol from IR to undefined

bfd/

	PR ld/28264
	* elflink.c (_bfd_elf_merge_symbol): Change indirect symbol from
	IR to undefined.

ld/

	PR ld/28264
	* testsuite/ld-plugin/lto.exp: Run PR ld/28264 test.
	* testsuite/ld-plugin/pr28264-1.d: New file.
	* testsuite/ld-plugin/pr28264-2.d: Likewise.
	* testsuite/ld-plugin/pr28264-3.d: Likewise.
	* testsuite/ld-plugin/pr28264-4.d: Likewise.
	* testsuite/ld-plugin/pr28264.c: Likewise.
	* testsuite/ld-plugin/pr28264.ver: Likewise.
This commit is contained in:
H.J. Lu
2021-08-26 07:43:23 -07:00
parent b05929a20e
commit 7de7786bb7
8 changed files with 63 additions and 6 deletions

View File

@ -1272,14 +1272,25 @@ _bfd_elf_merge_symbol (bfd *abfd,
olddyn = (oldsec->symbol->flags & BSF_DYNAMIC) != 0;
}
/* Handle a case where plugin_notice won't be called and thus won't
set the non_ir_ref flags on the first pass over symbols. */
if (oldbfd != NULL
&& (oldbfd->flags & BFD_PLUGIN) != (abfd->flags & BFD_PLUGIN)
&& newdyn != olddyn)
&& (oldbfd->flags & BFD_PLUGIN) != (abfd->flags & BFD_PLUGIN))
{
h->root.non_ir_ref_dynamic = true;
hi->root.non_ir_ref_dynamic = true;
if (newdyn != olddyn)
{
/* Handle a case where plugin_notice won't be called and thus
won't set the non_ir_ref flags on the first pass over
symbols. */
h->root.non_ir_ref_dynamic = true;
hi->root.non_ir_ref_dynamic = true;
}
if ((oldbfd->flags & BFD_PLUGIN) != 0
&& hi->root.type == bfd_link_hash_indirect)
{
/* Change indirect symbol from IR to undefined. */
hi->root.type = bfd_link_hash_undefined;
hi->root.u.undef.abfd = oldbfd;
}
}
/* NEWDEF and OLDDEF indicate whether the new or old symbol,