import binutils-2.30-108.el8

This commit is contained in:
CentOS Sources 2021-07-08 18:19:31 +00:00 committed by Stepan Oksanichenko
parent 6f5ec9e4fe
commit ca6ad7b567
3 changed files with 681 additions and 1 deletions

View File

@ -0,0 +1,306 @@
diff -rup binutils.orig/bfd/cofflink.c binutils-2.30/bfd/cofflink.c
--- binutils.orig/bfd/cofflink.c 2021-06-15 15:38:31.578170486 +0100
+++ binutils-2.30/bfd/cofflink.c 2021-06-15 15:59:12.394611963 +0100
@@ -3084,8 +3084,8 @@ _bfd_coff_generic_relocate_section (bfd
then zero this reloc field. */
if (sec != NULL && discarded_section (sec))
{
- _bfd_clear_contents (howto, input_bfd, input_section,
- contents + (rel->r_vaddr - input_section->vma));
+ (void) _bfd_clear_contents (howto, input_bfd, input_section,
+ contents, (rel->r_vaddr - input_section->vma));
continue;
}
diff -rup binutils.orig/bfd/dwarf2.c binutils-2.30/bfd/dwarf2.c
--- binutils.orig/bfd/dwarf2.c 2021-06-15 15:38:31.597170370 +0100
+++ binutils-2.30/bfd/dwarf2.c 2021-06-15 15:42:19.979779516 +0100
@@ -2865,7 +2865,9 @@ find_abstract_instance_name (struct comp
info_ptr = unit->stash->info_ptr_memory;
info_ptr_end = unit->stash->info_ptr_end;
total = info_ptr_end - info_ptr;
- if (!die_ref || die_ref >= total)
+ if (!die_ref)
+ return TRUE;
+ if (die_ref >= total)
{
_bfd_error_handler
(_("Dwarf Error: Invalid abstract instance DIE ref."));
diff -rup binutils.orig/bfd/elf-bfd.h binutils-2.30/bfd/elf-bfd.h
--- binutils.orig/bfd/elf-bfd.h 2021-06-15 15:38:31.595170382 +0100
+++ binutils-2.30/bfd/elf-bfd.h 2021-06-15 15:58:55.365715715 +0100
@@ -2829,8 +2829,8 @@ extern asection _bfd_elf_large_com_secti
howto, index, contents) \
{ \
int i_; \
- _bfd_clear_contents (howto, input_bfd, input_section, \
- contents + rel[index].r_offset); \
+ (void) _bfd_clear_contents (howto, input_bfd, input_section, \
+ contents, rel[index].r_offset); \
\
if (bfd_link_relocatable (info) \
&& (input_section->flags & SEC_DEBUGGING)) \
diff -rup binutils.orig/bfd/elf32-arc.c binutils-2.30/bfd/elf32-arc.c
--- binutils.orig/bfd/elf32-arc.c 2021-06-15 15:38:31.579170480 +0100
+++ binutils-2.30/bfd/elf32-arc.c 2021-06-15 15:58:28.869877138 +0100
@@ -1532,8 +1532,8 @@ elf_arc_relocate_section (bfd * outp
/* Clean relocs for symbols in discarded sections. */
if (sec != NULL && discarded_section (sec))
{
- _bfd_clear_contents (howto, input_bfd, input_section,
- contents + rel->r_offset);
+ (void) _bfd_clear_contents (howto, input_bfd, input_section,
+ contents, rel->r_offset);
rel->r_offset = rel->r_offset;
rel->r_info = 0;
rel->r_addend = 0;
diff -rup binutils.orig/bfd/elf32-i386.c binutils-2.30/bfd/elf32-i386.c
--- binutils.orig/bfd/elf32-i386.c 2021-06-15 15:38:31.578170486 +0100
+++ binutils-2.30/bfd/elf32-i386.c 2021-06-15 15:58:12.694975692 +0100
@@ -2165,8 +2165,8 @@ elf_i386_relocate_section (bfd *output_b
if (sec != NULL && discarded_section (sec))
{
- _bfd_clear_contents (howto, input_bfd, input_section,
- contents + rel->r_offset);
+ (void) _bfd_clear_contents (howto, input_bfd, input_section,
+ contents, rel->r_offset);
wrel->r_offset = rel->r_offset;
wrel->r_info = 0;
wrel->r_addend = 0;
diff -rup binutils.orig/bfd/elf32-metag.c binutils-2.30/bfd/elf32-metag.c
--- binutils.orig/bfd/elf32-metag.c 2021-06-15 15:38:31.593170394 +0100
+++ binutils-2.30/bfd/elf32-metag.c 2021-06-15 15:57:48.039125909 +0100
@@ -1392,8 +1392,8 @@ metag_final_link_relocate (reloc_howto_t
#define METAG_RELOC_AGAINST_DISCARDED_SECTION(info, input_bfd, input_section, \
rel, relend, howto, contents) \
{ \
- _bfd_clear_contents (howto, input_bfd, input_section, \
- contents + rel->r_offset); \
+ (void) _bfd_clear_contents (howto, input_bfd, input_section, \
+ contents, rel->r_offset); \
\
if (bfd_link_relocatable (info) \
&& (input_section->flags & SEC_DEBUGGING)) \
diff -rup binutils.orig/bfd/elf32-nds32.c binutils-2.30/bfd/elf32-nds32.c
--- binutils.orig/bfd/elf32-nds32.c 2021-06-15 15:38:31.589170419 +0100
+++ binutils-2.30/bfd/elf32-nds32.c 2021-06-15 15:56:30.184600239 +0100
@@ -12771,18 +12771,17 @@ nds32_elf_get_relocated_section_contents
symbol = *(*parent)->sym_ptr_ptr;
if (symbol->section && discarded_section (symbol->section))
{
- bfd_byte *p;
+ bfd_vma off;
static reloc_howto_type none_howto
= HOWTO (0, 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL,
"unused", FALSE, 0, 0, FALSE);
- p = data + (*parent)->address * bfd_octets_per_byte (input_bfd);
- _bfd_clear_contents ((*parent)->howto, input_bfd, input_section,
- p);
- (*parent)->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ off = (*parent)->address * bfd_octets_per_byte (input_bfd);
+ r = _bfd_clear_contents ((*parent)->howto, input_bfd,
+ input_section, data, off);
+ (*parent)->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
(*parent)->addend = 0;
(*parent)->howto = &none_howto;
- r = bfd_reloc_ok;
}
else
r = bfd_perform_relocation (input_bfd, *parent, data,
diff -rup binutils.orig/bfd/elf32-ppc.c binutils-2.30/bfd/elf32-ppc.c
--- binutils.orig/bfd/elf32-ppc.c 2021-06-15 15:38:31.597170370 +0100
+++ binutils-2.30/bfd/elf32-ppc.c 2021-06-15 15:56:39.367544293 +0100
@@ -7778,8 +7778,8 @@ ppc_elf_relocate_section (bfd *output_bf
if (r_type < R_PPC_max)
howto = ppc_elf_howto_table[r_type];
- _bfd_clear_contents (howto, input_bfd, input_section,
- contents + rel->r_offset);
+ (void) _bfd_clear_contents (howto, input_bfd, input_section,
+ contents, rel->r_offset);
wrel->r_offset = rel->r_offset;
wrel->r_info = 0;
wrel->r_addend = 0;
diff -rup binutils.orig/bfd/elf32-visium.c binutils-2.30/bfd/elf32-visium.c
--- binutils.orig/bfd/elf32-visium.c 2021-06-15 15:38:31.580170473 +0100
+++ binutils-2.30/bfd/elf32-visium.c 2021-06-15 15:57:29.271240254 +0100
@@ -616,8 +616,8 @@ visium_elf_relocate_section (bfd *output
/* For relocs against symbols from removed linkonce sections,
or sections discarded by a linker script, we just want the
section contents zeroed. Avoid any special processing. */
- _bfd_clear_contents (howto, input_bfd, input_section,
- contents + rel->r_offset);
+ (void) _bfd_clear_contents (howto, input_bfd, input_section,
+ contents, rel->r_offset);
rel->r_info = 0;
rel->r_addend = 0;
diff -rup binutils.orig/bfd/elf64-ppc.c binutils-2.30/bfd/elf64-ppc.c
--- binutils.orig/bfd/elf64-ppc.c 2021-06-15 15:38:31.578170486 +0100
+++ binutils-2.30/bfd/elf64-ppc.c 2021-06-15 15:57:01.529409265 +0100
@@ -13526,9 +13526,9 @@ ppc64_elf_relocate_section (bfd *output_
if (sec != NULL && discarded_section (sec))
{
- _bfd_clear_contents (ppc64_elf_howto_table[r_type],
- input_bfd, input_section,
- contents + rel->r_offset);
+ (void) _bfd_clear_contents (ppc64_elf_howto_table[r_type],
+ input_bfd, input_section,
+ contents, rel->r_offset);
wrel->r_offset = rel->r_offset;
wrel->r_info = 0;
wrel->r_addend = 0;
diff -rup binutils.orig/bfd/elf64-x86-64.c binutils-2.30/bfd/elf64-x86-64.c
--- binutils.orig/bfd/elf64-x86-64.c 2021-06-15 15:38:31.585170443 +0100
+++ binutils-2.30/bfd/elf64-x86-64.c 2021-06-15 15:57:09.831358693 +0100
@@ -2457,8 +2457,8 @@ elf_x86_64_relocate_section (bfd *output
if (sec != NULL && discarded_section (sec))
{
- _bfd_clear_contents (howto, input_bfd, input_section,
- contents + rel->r_offset);
+ (void) _bfd_clear_contents (howto, input_bfd, input_section,
+ contents, rel->r_offset);
wrel->r_offset = rel->r_offset;
wrel->r_info = 0;
wrel->r_addend = 0;
diff -rup binutils.orig/bfd/libbfd-in.h binutils-2.30/bfd/libbfd-in.h
--- binutils.orig/bfd/libbfd-in.h 2021-06-15 15:38:31.593170394 +0100
+++ binutils-2.30/bfd/libbfd-in.h 2021-06-15 15:54:10.856449129 +0100
@@ -674,8 +674,9 @@ extern bfd_reloc_status_type _bfd_reloca
(reloc_howto_type *, bfd *, bfd_vma, bfd_byte *);
/* Clear a given location using a given howto. */
-extern void _bfd_clear_contents (reloc_howto_type *howto, bfd *input_bfd,
- asection *input_section, bfd_byte *location);
+extern bfd_reloc_status_type _bfd_clear_contents
+ (reloc_howto_type *howto, bfd *input_bfd,
+ asection *input_section, bfd_byte *, bfd_vma);
/* Link stabs in sections in the first pass. */
diff -rup binutils.orig/bfd/libbfd.h binutils-2.30/bfd/libbfd.h
--- binutils.orig/bfd/libbfd.h 2021-06-15 15:38:31.581170467 +0100
+++ binutils-2.30/bfd/libbfd.h 2021-06-15 15:53:55.863540475 +0100
@@ -679,8 +679,9 @@ extern bfd_reloc_status_type _bfd_reloca
(reloc_howto_type *, bfd *, bfd_vma, bfd_byte *);
/* Clear a given location using a given howto. */
-extern void _bfd_clear_contents (reloc_howto_type *howto, bfd *input_bfd,
- asection *input_section, bfd_byte *location);
+extern bfd_reloc_status_type _bfd_clear_contents
+ (reloc_howto_type *howto, bfd *input_bfd,
+ asection *input_section, bfd_byte *, bfd_vma);
/* Link stabs in sections in the first pass. */
diff -rup binutils.orig/bfd/reloc.c binutils-2.30/bfd/reloc.c
--- binutils.orig/bfd/reloc.c 2021-06-15 15:38:31.593170394 +0100
+++ binutils-2.30/bfd/reloc.c 2021-06-15 15:51:59.449249747 +0100
@@ -1604,23 +1604,29 @@ _bfd_relocate_contents (reloc_howto_type
relocations against discarded symbols, to make ignorable debug or unwind
information more obvious. */
-void
+bfd_reloc_status_type
_bfd_clear_contents (reloc_howto_type *howto,
bfd *input_bfd,
asection *input_section,
- bfd_byte *location)
+ bfd_byte *buf,
+ bfd_vma off)
{
int size;
bfd_vma x = 0;
+ bfd_byte *location;
+
+ if (!bfd_reloc_offset_in_range (howto, input_bfd, input_section, off))
+ return bfd_reloc_outofrange;
/* Get the value we are going to relocate. */
- size = bfd_get_reloc_size (howto);
+ location = buf + off;
+ size = bfd_get_reloc_size (howto);
switch (size)
{
default:
- abort ();
+ return bfd_reloc_notsupported;
case 0:
- return;
+ return bfd_reloc_ok;
case 1:
x = bfd_get_8 (input_bfd, location);
break;
@@ -1634,7 +1640,7 @@ _bfd_clear_contents (reloc_howto_type *h
#ifdef BFD64
x = bfd_get_64 (input_bfd, location);
#else
- abort ();
+ return bfd_reloc_notsupported;
#endif
break;
}
@@ -1654,7 +1660,7 @@ _bfd_clear_contents (reloc_howto_type *h
{
default:
case 0:
- abort ();
+ return bfd_reloc_notsupported;
case 1:
bfd_put_8 (input_bfd, x, location);
break;
@@ -1668,10 +1674,12 @@ _bfd_clear_contents (reloc_howto_type *h
#ifdef BFD64
bfd_put_64 (input_bfd, x, location);
#else
- abort ();
+ return bfd_reloc_notsupported;
#endif
break;
}
+
+ return bfd_reloc_ok;
}
/*
@@ -8209,20 +8217,30 @@ bfd_generic_get_relocated_section_conten
goto error_return;
}
- if (symbol->section && discarded_section (symbol->section))
+ /* Zap reloc field when the symbol is from a discarded
+ section, ignoring any addend. Do the same when called
+ from bfd_simple_get_relocated_section_contents for
+ undefined symbols in debug sections. This is to keep
+ debug info reasonably sane, in particular so that
+ DW_FORM_ref_addr to another file's .debug_info isn't
+ confused with an offset into the current file's
+ .debug_info. */
+ if ((symbol->section != NULL && discarded_section (symbol->section))
+ || (symbol->section == bfd_und_section_ptr
+ && (input_section->flags & SEC_DEBUGGING) != 0
+ && link_info->input_bfds == link_info->output_bfd))
{
- bfd_byte *p;
+ bfd_vma off;
static reloc_howto_type none_howto
= HOWTO (0, 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL,
"unused", FALSE, 0, 0, FALSE);
- p = data + (*parent)->address * bfd_octets_per_byte (input_bfd);
- _bfd_clear_contents ((*parent)->howto, input_bfd, input_section,
- p);
+ off = (*parent)->address * bfd_octets_per_byte (input_bfd);
+ r = _bfd_clear_contents ((*parent)->howto, input_bfd,
+ input_section, data, off);
(*parent)->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
(*parent)->addend = 0;
(*parent)->howto = &none_howto;
- r = bfd_reloc_ok;
}
else
r = bfd_perform_relocation (input_bfd,

View File

@ -0,0 +1,355 @@
diff --git a/gold/i386.cc b/gold/i386.cc
index bf209fe9a86..31161ff091c 100644
--- a/gold/i386.cc
+++ b/gold/i386.cc
@@ -360,7 +360,11 @@ class Target_i386 : public Sized_target<32, false>
got_(NULL), plt_(NULL), got_plt_(NULL), got_irelative_(NULL),
got_tlsdesc_(NULL), global_offset_table_(NULL), rel_dyn_(NULL),
rel_irelative_(NULL), copy_relocs_(elfcpp::R_386_COPY),
- got_mod_index_offset_(-1U), tls_base_symbol_defined_(false)
+ got_mod_index_offset_(-1U), tls_base_symbol_defined_(false),
+ isa_1_used_(0), isa_1_needed_(0),
+ feature_1_(0), feature_2_used_(0), feature_2_needed_(0),
+ object_isa_1_used_(0), object_feature_1_(0),
+ object_feature_2_used_(0), seen_first_object_(false)
{ }
// Process the relocations to determine unreferenced sections for
@@ -859,6 +863,21 @@ class Target_i386 : public Sized_target<32, false>
this->rel_dyn_section(layout));
}
+ // Record a target-specific program property in the .note.gnu.property
+ // section.
+ void
+ record_gnu_property(unsigned int, unsigned int, size_t,
+ const unsigned char*, const Object*);
+
+ // Merge the target-specific program properties from the current object.
+ void
+ merge_gnu_properties(const Object*);
+
+ // Finalize the target-specific program properties and add them back to
+ // the layout.
+ void
+ do_finalize_gnu_properties(Layout*) const;
+
// Information about this specific target which we pass to the
// general Target structure.
static const Target::Target_info i386_info;
@@ -898,6 +917,26 @@ class Target_i386 : public Sized_target<32, false>
unsigned int got_mod_index_offset_;
// True if the _TLS_MODULE_BASE_ symbol has been defined.
bool tls_base_symbol_defined_;
+
+ // Target-specific program properties, from .note.gnu.property section.
+ // Each bit represents a specific feature.
+ uint32_t isa_1_used_;
+ uint32_t isa_1_needed_;
+ uint32_t feature_1_;
+ uint32_t feature_2_used_;
+ uint32_t feature_2_needed_;
+ // Target-specific properties from the current object.
+ // These bits get ORed into ISA_1_USED_ after all properties for the object
+ // have been processed. But if either is all zeroes (as when the property
+ // is absent from an object), the result should be all zeroes.
+ // (See PR ld/23486.)
+ uint32_t object_isa_1_used_;
+ // These bits get ANDed into FEATURE_1_ after all properties for the object
+ // have been processed.
+ uint32_t object_feature_1_;
+ uint32_t object_feature_2_used_;
+ // Whether we have seen our first object, for use in initializing FEATURE_1_.
+ bool seen_first_object_;
};
const Target::Target_info Target_i386::i386_info =
@@ -1042,6 +1081,126 @@ Target_i386::rel_irelative_section(Layout* layout)
return this->rel_irelative_;
}
+// Record a target-specific program property from the .note.gnu.property
+// section.
+void
+Target_i386::record_gnu_property(
+ unsigned int, unsigned int pr_type,
+ size_t pr_datasz, const unsigned char* pr_data,
+ const Object* object)
+{
+ uint32_t val = 0;
+
+ switch (pr_type)
+ {
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_USED:
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED:
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED:
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED:
+ case elfcpp::GNU_PROPERTY_X86_ISA_1_USED:
+ case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED:
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND:
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
+ if (pr_datasz != 4)
+ {
+ gold_warning(_("%s: corrupt .note.gnu.property section "
+ "(pr_datasz for property %d is not 4)"),
+ object->name().c_str(), pr_type);
+ return;
+ }
+ val = elfcpp::Swap<32, false>::readval(pr_data);
+ break;
+ default:
+ gold_warning(_("%s: unknown program property type 0x%x "
+ "in .note.gnu.property section"),
+ object->name().c_str(), pr_type);
+ break;
+ }
+
+ switch (pr_type)
+ {
+ case elfcpp::GNU_PROPERTY_X86_ISA_1_USED:
+ this->object_isa_1_used_ |= val;
+ break;
+ case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED:
+ this->isa_1_needed_ |= val;
+ break;
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND:
+ // If we see multiple feature props in one object, OR them together.
+ this->object_feature_1_ |= val;
+ break;
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
+ this->object_feature_2_used_ |= val;
+ break;
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
+ this->feature_2_needed_ |= val;
+ break;
+ }
+}
+
+// Merge the target-specific program properties from the current object.
+void
+Target_i386::merge_gnu_properties(const Object*)
+{
+ if (this->seen_first_object_)
+ {
+ // If any object is missing the ISA_1_USED property, we must omit
+ // it from the output file.
+ if (this->object_isa_1_used_ == 0)
+ this->isa_1_used_ = 0;
+ else if (this->isa_1_used_ != 0)
+ this->isa_1_used_ |= this->object_isa_1_used_;
+ this->feature_1_ &= this->object_feature_1_;
+ // If any object is missing the FEATURE_2_USED property, we must
+ // omit it from the output file.
+ if (this->object_feature_2_used_ == 0)
+ this->feature_2_used_ = 0;
+ else if (this->feature_2_used_ != 0)
+ this->feature_2_used_ |= this->object_feature_2_used_;
+ }
+ else
+ {
+ this->isa_1_used_ = this->object_isa_1_used_;
+ this->feature_1_ = this->object_feature_1_;
+ this->feature_2_used_ = this->object_feature_2_used_;
+ this->seen_first_object_ = true;
+ }
+ this->object_isa_1_used_ = 0;
+ this->object_feature_1_ = 0;
+ this->object_feature_2_used_ = 0;
+}
+
+static inline void
+add_property(Layout* layout, unsigned int pr_type, uint32_t val)
+{
+ unsigned char buf[4];
+ elfcpp::Swap<32, false>::writeval(buf, val);
+ layout->add_gnu_property(elfcpp::NT_GNU_PROPERTY_TYPE_0, pr_type, 4, buf);
+}
+
+// Finalize the target-specific program properties and add them back to
+// the layout.
+void
+Target_i386::do_finalize_gnu_properties(Layout* layout) const
+{
+ if (this->isa_1_used_ != 0)
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_ISA_1_USED,
+ this->isa_1_used_);
+ if (this->isa_1_needed_ != 0)
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED,
+ this->isa_1_needed_);
+ if (this->feature_1_ != 0)
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND,
+ this->feature_1_);
+ if (this->feature_2_used_ != 0)
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED,
+ this->feature_2_used_);
+ if (this->feature_2_needed_ != 0)
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED,
+ this->feature_2_needed_);
+}
+
// Write the first three reserved words of the .got.plt section.
// The remainder of the section is written while writing the PLT
// in Output_data_plt_i386::do_write.
--- binutils.orig/elfcpp/elfcpp.h 2021-06-23 12:31:04.550738064 +0100
+++ binutils-2.30/elfcpp/elfcpp.h 2021-06-23 12:33:18.068875079 +0100
@@ -1008,9 +1008,21 @@ enum
GNU_PROPERTY_STACK_SIZE = 1,
GNU_PROPERTY_NO_COPY_ON_PROTECTED = 2,
GNU_PROPERTY_LOPROC = 0xc0000000,
- GNU_PROPERTY_X86_ISA_1_USED = 0xc0000000,
- GNU_PROPERTY_X86_ISA_1_NEEDED = 0xc0000001,
- GNU_PROPERTY_X86_FEATURE_1_AND = 0xc0000002,
+ GNU_PROPERTY_X86_COMPAT_ISA_1_USED = 0xc0000000,
+ GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED = 0xc0000001,
+ GNU_PROPERTY_X86_UINT32_AND_LO = 0xc0000002,
+ GNU_PROPERTY_X86_UINT32_AND_HI = 0xc0007fff,
+ GNU_PROPERTY_X86_UINT32_OR_LO = 0xc0008000,
+ GNU_PROPERTY_X86_UINT32_OR_HI = 0xc000ffff,
+ GNU_PROPERTY_X86_UINT32_OR_AND_LO = 0xc0010000,
+ GNU_PROPERTY_X86_UINT32_OR_AND_HI = 0xc0017fff,
+ GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED = GNU_PROPERTY_X86_UINT32_OR_LO + 0,
+ GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED = GNU_PROPERTY_X86_UINT32_OR_AND_LO + 0,
+ GNU_PROPERTY_X86_FEATURE_1_AND = GNU_PROPERTY_X86_UINT32_AND_LO + 0,
+ GNU_PROPERTY_X86_ISA_1_NEEDED = GNU_PROPERTY_X86_UINT32_OR_LO + 2,
+ GNU_PROPERTY_X86_FEATURE_2_NEEDED = GNU_PROPERTY_X86_UINT32_OR_LO + 1,
+ GNU_PROPERTY_X86_ISA_1_USED = GNU_PROPERTY_X86_UINT32_OR_AND_LO + 2,
+ GNU_PROPERTY_X86_FEATURE_2_USED = GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1,
GNU_PROPERTY_HIPROC = 0xdfffffff,
GNU_PROPERTY_LOUSER = 0xe0000000,
GNU_PROPERTY_HIUSER = 0xffffffff
--- binutils.orig/gold/i386.cc 2021-07-07 14:15:34.369441519 +0100
+++ binutils-2.30/gold/i386.cc 2021-07-07 14:36:11.932838272 +0100
@@ -362,9 +362,8 @@ class Target_i386 : public Sized_target<
rel_irelative_(NULL), copy_relocs_(elfcpp::R_386_COPY),
got_mod_index_offset_(-1U), tls_base_symbol_defined_(false),
isa_1_used_(0), isa_1_needed_(0),
- feature_1_(0), feature_2_used_(0), feature_2_needed_(0),
- object_isa_1_used_(0), object_feature_1_(0),
- object_feature_2_used_(0), seen_first_object_(false)
+ feature_1_(0), object_feature_1_(0),
+ seen_first_object_(false)
{ }
// Process the relocations to determine unreferenced sections for
@@ -866,7 +865,7 @@ class Target_i386 : public Sized_target<
// Record a target-specific program property in the .note.gnu.property
// section.
void
- record_gnu_property(unsigned int, unsigned int, size_t,
+ record_gnu_property(int, int, size_t,
const unsigned char*, const Object*);
// Merge the target-specific program properties from the current object.
@@ -923,18 +922,10 @@ class Target_i386 : public Sized_target<
uint32_t isa_1_used_;
uint32_t isa_1_needed_;
uint32_t feature_1_;
- uint32_t feature_2_used_;
- uint32_t feature_2_needed_;
// Target-specific properties from the current object.
- // These bits get ORed into ISA_1_USED_ after all properties for the object
- // have been processed. But if either is all zeroes (as when the property
- // is absent from an object), the result should be all zeroes.
- // (See PR ld/23486.)
- uint32_t object_isa_1_used_;
// These bits get ANDed into FEATURE_1_ after all properties for the object
// have been processed.
uint32_t object_feature_1_;
- uint32_t object_feature_2_used_;
// Whether we have seen our first object, for use in initializing FEATURE_1_.
bool seen_first_object_;
};
@@ -1084,7 +1075,7 @@ Target_i386::rel_irelative_section(Layou
// section.
void
Target_i386::record_gnu_property(
- unsigned int, unsigned int pr_type,
+ int, int pr_type,
size_t pr_datasz, const unsigned char* pr_data,
const Object* object)
{
@@ -1092,15 +1083,9 @@ Target_i386::record_gnu_property(
switch (pr_type)
{
- case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_USED:
- case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED:
- case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED:
- case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED:
case elfcpp::GNU_PROPERTY_X86_ISA_1_USED:
case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED:
case elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND:
- case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
- case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
if (pr_datasz != 4)
{
gold_warning(_("%s: corrupt .note.gnu.property section "
@@ -1120,7 +1105,7 @@ Target_i386::record_gnu_property(
switch (pr_type)
{
case elfcpp::GNU_PROPERTY_X86_ISA_1_USED:
- this->object_isa_1_used_ |= val;
+ this->isa_1_used_ |= val;
break;
case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED:
this->isa_1_needed_ |= val;
@@ -1129,12 +1114,6 @@ Target_i386::record_gnu_property(
// If we see multiple feature props in one object, OR them together.
this->object_feature_1_ |= val;
break;
- case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
- this->object_feature_2_used_ |= val;
- break;
- case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
- this->feature_2_needed_ |= val;
- break;
}
}
@@ -1143,31 +1122,13 @@ void
Target_i386::merge_gnu_properties(const Object*)
{
if (this->seen_first_object_)
- {
- // If any object is missing the ISA_1_USED property, we must omit
- // it from the output file.
- if (this->object_isa_1_used_ == 0)
- this->isa_1_used_ = 0;
- else if (this->isa_1_used_ != 0)
- this->isa_1_used_ |= this->object_isa_1_used_;
- this->feature_1_ &= this->object_feature_1_;
- // If any object is missing the FEATURE_2_USED property, we must
- // omit it from the output file.
- if (this->object_feature_2_used_ == 0)
- this->feature_2_used_ = 0;
- else if (this->feature_2_used_ != 0)
- this->feature_2_used_ |= this->object_feature_2_used_;
- }
+ this->feature_1_ &= this->object_feature_1_;
else
{
- this->isa_1_used_ = this->object_isa_1_used_;
this->feature_1_ = this->object_feature_1_;
- this->feature_2_used_ = this->object_feature_2_used_;
this->seen_first_object_ = true;
}
- this->object_isa_1_used_ = 0;
this->object_feature_1_ = 0;
- this->object_feature_2_used_ = 0;
}
static inline void
@@ -1192,12 +1153,6 @@ Target_i386::do_finalize_gnu_properties(
if (this->feature_1_ != 0)
add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND,
this->feature_1_);
- if (this->feature_2_used_ != 0)
- add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED,
- this->feature_2_used_);
- if (this->feature_2_needed_ != 0)
- add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED,
- this->feature_2_needed_);
}
// Write the first three reserved words of the .got.plt section.

View File

@ -43,7 +43,7 @@
Summary: A GNU collection of binary utilities
Name: binutils%{?name_cross}%{?_with_debug:-debug}
Version: 2.30
Release: 104%{?dist}
Release: 108%{?dist}
License: GPLv3+
URL: https://sourceware.org/binutils
@ -583,6 +583,14 @@ Patch89: binutils-CVE-2020-35448.patch
# Lifetime: Fixed in 2.36
Patch90: binutils-CVE-2021-20284.patch
# Purpose: Fixed the handling of relocations against discarded sections.
# Lifetime: Fixed in 2.34
Patch91: binutils-clearing-discarded-relocs.patch
# Purpose: Fix the GOLD linker's generation of .note.gnu.property sections for x86.
# Lifetime: Fixed in 2.37 (maybe)
Patch92: binutils-gold-i386-gnu-property-notes.patch
#----------------------------------------------------------------------------
Provides: bundled(libiberty)
@ -810,6 +818,8 @@ using libelf instead of BFD.
%patch88 -p1
%patch89 -p1
%patch90 -p1
%patch91 -p1
%patch92 -p1
# We cannot run autotools as there is an exact requirement of autoconf-2.59.
# FIXME - this is no longer true. Maybe try reinstating autotool use ?
@ -1259,6 +1269,15 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Wed Jul 07 2021 Nick Clifton <nickc@redhat.com> - 2.30-108
- Fix thinko in previous delta. (#1970961)
* Wed Jun 23 2021 Nick Clifton <nickc@redhat.com> - 2.30-107
- Fix the GOLD linker's generation of .note.gnu.property sections for x86. (#1970961)
* Tue Jun 15 2021 Nick Clifton <nickc@redhat.com> - 2.30-105
- Fix the handling of relocations against discarded sections. (#1969775)
* Wed May 19 2021 Nick Clifton <nickc@redhat.com> - 2.30-104
- Fix heap-based buffer overflow in _bfd_elf_slurp_secondary_reloc_section. (#1961526)