Fix handling symbol versioning with LTO plugins.

Resolves: #2148469
This commit is contained in:
Nick Clifton 2022-11-30 08:43:44 +00:00
parent cbd5319db8
commit 8795aabf39
2 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,47 @@
diff -rup binutils.orig/bfd/elflink.c binutils-2.35.2/bfd/elflink.c
--- binutils.orig/bfd/elflink.c 2022-11-28 16:10:23.919422266 +0000
+++ binutils-2.35.2/bfd/elflink.c 2022-11-28 16:14:24.308499080 +0000
@@ -1260,14 +1260,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,
diff -rup binutils.orig/bfd/linker.c binutils-2.35.2/bfd/linker.c
--- binutils.orig/bfd/linker.c 2022-11-28 16:10:23.822422639 +0000
+++ binutils-2.35.2/bfd/linker.c 2022-11-28 16:13:28.709712603 +0000
@@ -1672,7 +1672,7 @@ _bfd_generic_link_add_one_symbol (struct
case MIND:
/* Multiple indirect symbols. This is OK if they both point
to the same symbol. */
- if (strcmp (h->u.i.link->root.string, string) == 0)
+ if (string != NULL && strcmp (h->u.i.link->root.string, string) == 0)
break;
/* Fall through. */
case MDEF:

View File

@ -39,7 +39,7 @@
Summary: A GNU collection of binary utilities
Name: binutils%{?name_cross}%{?_with_debug:-debug}
Version: 2.35.2
Release: 25%{?dist}
Release: 26%{?dist}
License: GPLv3+
URL: https://sourceware.org/binutils
@ -432,6 +432,10 @@ Patch57: binutils-undefined-ref-to-sym.patch
# Lifetime: Fixed in 2.40
Patch58: binutils-CIE-generation.patch
# Purpose: Fix a problem with symbol versioning with the LTO plugin.
# Lifetime: Fixed in 2.38
Patch59: binutils-ld-ir-plugin.patch
#----------------------------------------------------------------------------
Provides: bundled(libiberty)
@ -1025,6 +1029,9 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Mon Nov 28 2022 Nick Clifton <nickc@redhat.com> - 2.35.2-26
- Fix handling symbol versioning with LTO plugins. (#2148469)
* Thu Sep 08 2022 Nick Clifton <nickc@redhat.com> - 2.35.2-25
- Fix the generation of unnecesaary CIE stack unwinding frames. (#2121123)