binutils/SOURCES/binutils-plugin-as-needed-correct.patch
2022-03-30 15:40:33 +00:00

43 lines
1.6 KiB
Diff

--- binutils.orig/bfd/elf-bfd.h 2021-09-20 16:06:58.320914954 +0100
+++ binutils-2.30/bfd/elf-bfd.h 2021-09-20 16:26:11.307770371 +0100
@@ -180,6 +180,8 @@ struct elf_link_hash_entry
/* Symbol has a non-weak reference from a non-shared object (other than
the object in which it is defined). */
unsigned int ref_regular_nonweak : 1;
+ /* Symbol has a non-weak reference from a LTO IR object file. */
+ unsigned int ref_ir_nonweak : 1;
/* Dynamic symbol has been adjustd. */
unsigned int dynamic_adjusted : 1;
/* Symbol needs a copy reloc. */
--- binutils.orig/bfd/elflink.c 2021-09-29 14:36:01.294185139 +0100
+++ binutils-2.30/bfd/elflink.c 2021-09-29 14:39:08.113874485 +0100
@@ -4663,7 +4663,12 @@ error_free_dyn:
/* Plugin symbols aren't normal. Don't set def/ref flags. */
if ((abfd->flags & BFD_PLUGIN) != 0)
- ;
+ {
+ /* Except for this flag to track nonweak references. */
+ if (!definition
+ && bind != STB_WEAK)
+ h->ref_ir_nonweak = 1;
+ }
else if (!dynamic)
{
if (! definition)
@@ -4906,11 +4911,13 @@ error_free_dyn:
if (!add_needed
&& matched
&& definition
+ && h->root.type != bfd_link_hash_indirect
&& ((dynsym
&& h->ref_regular_nonweak)
|| (old_bfd != NULL
&& (old_bfd->flags & BFD_PLUGIN) != 0
- && bind != STB_WEAK)
+ && h->ref_ir_nonweak
+ && !info->lto_all_symbols_read)
|| (h->ref_dynamic_nonweak
&& (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0
&& !on_needed_list (elf_dt_name (abfd),