From c6c79eaa2c2530ae28f6041b3bcf5deb277d763b Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 24 Jun 2019 15:11:32 +0100 Subject: [PATCH 01/16] Stop gold from aborting when it encounters input sections with the same name and different flags. Relates: #1722715 --- binutils-gold-mismatched-section-flags.patch | 36 ++++++++++++++++++++ binutils.spec | 11 +++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 binutils-gold-mismatched-section-flags.patch diff --git a/binutils-gold-mismatched-section-flags.patch b/binutils-gold-mismatched-section-flags.patch new file mode 100644 index 0000000..4125801 --- /dev/null +++ b/binutils-gold-mismatched-section-flags.patch @@ -0,0 +1,36 @@ +diff -rup binutils.orig/gold/layout.cc binutils-2.32/gold/layout.cc +--- binutils.orig/gold/layout.cc 2019-06-24 14:37:36.013086899 +0100 ++++ binutils-2.32/gold/layout.cc 2019-06-24 14:41:40.054517479 +0100 +@@ -868,6 +868,7 @@ Layout::get_output_section(const char* n + && (same_name->flags() & elfcpp::SHF_TLS) == 0) + os = same_name; + } ++#if 0 /* BZ 1722715, PR 17556. */ + else if ((flags & elfcpp::SHF_TLS) == 0) + { + elfcpp::Elf_Xword zero_flags = 0; +@@ -878,6 +879,7 @@ Layout::get_output_section(const char* n + if (p != this->section_name_map_.end()) + os = p->second; + } ++#endif + } + + if (os == NULL) +diff -rup binutils.orig/gold/object.cc binutils-2.32/gold/object.cc +--- binutils.orig/gold/object.cc 2019-06-24 14:37:36.012086906 +0100 ++++ binutils-2.32/gold/object.cc 2019-06-24 14:39:59.287165501 +0100 +@@ -1644,6 +1644,13 @@ Sized_relobj_file::do_ + omit[i] = true; + } + ++ // Skip empty sections without flags. ++ if (!(shdr.get_sh_flags() & ~elfcpp::SHF_GROUP) ++ && !shdr.get_sh_size()) ++ { ++ omit[i] = true; ++ } ++ + bool discard = omit[i]; + if (!discard) + { diff --git a/binutils.spec b/binutils.spec index 2e1c504..5ebda79 100644 --- a/binutils.spec +++ b/binutils.spec @@ -85,7 +85,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.32 -Release: 14%{?dist} +Release: 15%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -211,6 +211,11 @@ Patch19: binutils-CVE-2019-9071.patch # Lifetime: Fixed in 2.33 Patch20: binutils-aarch64-gold-PLT-for-MOVW_ABS.patch +# Purpose: Stop gold from aborting when input sections with the same name +# have different flags. +# Lifetime: 2.33 (probably) +Patch21: binutils-gold-mismatched-section-flags.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -357,6 +362,7 @@ Conflicts: gcc-c++ < 4.0.0 %patch18 -p1 %patch19 -p1 %patch20 -p1 +%patch21 -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 ? @@ -753,6 +759,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Mon Jun 24 2019 Nick Clifton - 2.32-15 +- Stop gold from aborting when it encounters input sections with the same name and different flags. (#1722715) + * Tue May 21 2019 Nick Clifton - 2.32-14 - Import fix for PR 23870 in order to help building Go binaries. From 6f32c52f0335027cd1146c36940a3d3c079c0a54 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 1 Jul 2019 17:10:01 +0100 Subject: [PATCH 02/16] Stop gas from triggering a seg-fault when creating relocs for build notes. (PR 24748) --- binutils-gas-build-note-relocs.patch | 55 ++++++++++++++++++++++++++++ binutils.spec | 26 +++++++++---- 2 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 binutils-gas-build-note-relocs.patch diff --git a/binutils-gas-build-note-relocs.patch b/binutils-gas-build-note-relocs.patch new file mode 100644 index 0000000..52a4c0b --- /dev/null +++ b/binutils-gas-build-note-relocs.patch @@ -0,0 +1,55 @@ +--- binutils.orig/gas/write.c 2019-07-01 16:23:28.133707500 +0100 ++++ binutils-2.32/gas/write.c 2019-07-01 16:24:50.699130611 +0100 +@@ -1891,7 +1891,8 @@ create_obj_attrs_section (void) + static void + create_note_reloc (segT sec, + symbolS * sym, +- bfd_size_type offset, ++ bfd_size_type note_offset, ++ bfd_size_type desc2_offset, + int reloc_type, + bfd_vma addend, + char * note) +@@ -1901,10 +1902,10 @@ create_note_reloc (segT sec, + reloc = XNEW (struct reloc_list); + + /* We create a .b type reloc as resolve_reloc_expr_symbols() has already been called. */ +- reloc->u.b.sec = sec; +- reloc->u.b.s = symbol_get_bfdsym (sym); ++ reloc->u.b.sec = sec; ++ reloc->u.b.s = symbol_get_bfdsym (sym); + reloc->u.b.r.sym_ptr_ptr = & reloc->u.b.s; +- reloc->u.b.r.address = offset; ++ reloc->u.b.r.address = note_offset + desc2_offset; + reloc->u.b.r.addend = addend; + reloc->u.b.r.howto = bfd_reloc_type_lookup (stdoutput, reloc_type); + +@@ -1929,12 +1930,12 @@ create_note_reloc (segT sec, + if (target_big_endian) + { + if (bfd_arch_bits_per_address (stdoutput) <= 32) +- note[offset + 3] = addend; ++ note[desc2_offset + 3] = addend; + else +- note[offset + 7] = addend; ++ note[desc2_offset + 7] = addend; + } + else +- note[offset] = addend; ++ note[desc2_offset] = addend; + } + } + +@@ -2037,10 +2038,10 @@ maybe_generate_build_notes (void) + memcpy (note + 12, "GA$3a1", 8); + + /* Create a relocation to install the start address of the note... */ +- create_note_reloc (sec, sym, total_size + 20, desc_reloc, 0, note); ++ create_note_reloc (sec, sym, total_size, 20, desc_reloc, 0, note); + + /* ...and another one to install the end address. */ +- create_note_reloc (sec, sym, total_size + desc2_offset, desc_reloc, ++ create_note_reloc (sec, sym, total_size, desc2_offset, desc_reloc, + bfd_get_section_size (bsym->section), + note); + diff --git a/binutils.spec b/binutils.spec index 5ebda79..cdead03 100644 --- a/binutils.spec +++ b/binutils.spec @@ -1,3 +1,13 @@ + +Summary: A GNU collection of binary utilities +Name: %{?cross}binutils%{?_with_debug:-debug} +Version: 2.32 +Release: 16%{?dist} +License: GPLv3+ +URL: https://sourceware.org/binutils + +#---------------------------------------------------------------------------- + # Binutils SPEC file. Can be invoked with the following parameters: # --define "binutils_target arm-linux-gnu" to create arm-linux-gnu-binutils. @@ -82,13 +92,6 @@ #---------------------------------------------------------------------------- -Summary: A GNU collection of binary utilities -Name: %{?cross}binutils%{?_with_debug:-debug} -Version: 2.32 -Release: 15%{?dist} -License: GPLv3+ -URL: https://sourceware.org/binutils - # Note - the Linux Kernel binutils releases are too unstable and contain # too many controversial patches so we stick with the official FSF version # instead. @@ -216,6 +219,11 @@ Patch20: binutils-aarch64-gold-PLT-for-MOVW_ABS.patch # Lifetime: 2.33 (probably) Patch21: binutils-gold-mismatched-section-flags.patch +# Purpose: Corrcect a memory corruption when generating relocs for build +# notes in the assembler. +# Lifetime: 2.33 +Patch22: binutils-gas-build-note-relocs.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -363,6 +371,7 @@ Conflicts: gcc-c++ < 4.0.0 %patch19 -p1 %patch20 -p1 %patch21 -p1 +%patch22 -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 ? @@ -759,6 +768,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Mon Jul 01 2019 Nick Clifton - 2.32-16 +- Stop gas from triggering a seg-fault when creating relocs for build notes. (PR 24748) + * Mon Jun 24 2019 Nick Clifton - 2.32-15 - Stop gold from aborting when it encounters input sections with the same name and different flags. (#1722715) From cbe88f3d8f9457a28c96ff53cb89029fd820361c Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 2 Jul 2019 16:50:58 +0100 Subject: [PATCH 03/16] Stop the BFD library from complaining about sections found inside debuginfo files. (PR 24717) --- ...ls-do-not-warn-about-debuginfo-files.patch | 68 +++++++++++++++++++ binutils.spec | 16 ++++- 2 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 binutils-do-not-warn-about-debuginfo-files.patch diff --git a/binutils-do-not-warn-about-debuginfo-files.patch b/binutils-do-not-warn-about-debuginfo-files.patch new file mode 100644 index 0000000..bfe8135 --- /dev/null +++ b/binutils-do-not-warn-about-debuginfo-files.patch @@ -0,0 +1,68 @@ +diff -rup binutils.orig/bfd/elf-bfd.h binutils-2.32/bfd/elf-bfd.h +--- binutils.orig/bfd/elf-bfd.h 2019-07-02 16:03:41.758007318 +0100 ++++ binutils-2.32/bfd/elf-bfd.h 2019-07-02 16:04:02.025862020 +0100 +@@ -2749,6 +2749,8 @@ extern bfd_vma elf64_r_sym (bfd_vma); + extern bfd_vma elf32_r_info (bfd_vma, bfd_vma); + extern bfd_vma elf32_r_sym (bfd_vma); + ++extern bfd_boolean is_debuginfo_file (bfd *); ++ + /* Large common section. */ + extern asection _bfd_elf_large_com_section; + +Only in binutils-2.32/bfd: elf-bfd.h.orig +diff -rup binutils.orig/bfd/elf.c binutils-2.32/bfd/elf.c +--- binutils.orig/bfd/elf.c 2019-07-02 16:03:42.101004858 +0100 ++++ binutils-2.32/bfd/elf.c 2019-07-02 16:04:23.909705141 +0100 +@@ -5807,6 +5807,35 @@ assign_file_positions_for_load_sections + return TRUE; + } + ++/* Determine if a bfd is a debuginfo file. Unfortunately there ++ is no defined method for detecting such files, so we have to ++ use heuristics instead. */ ++ ++bfd_boolean ++is_debuginfo_file (bfd *abfd) ++{ ++ if (abfd == NULL || bfd_get_flavour (abfd) != bfd_target_elf_flavour) ++ return FALSE; ++ ++ Elf_Internal_Shdr **start_headers = elf_elfsections (abfd); ++ Elf_Internal_Shdr **end_headers = start_headers + elf_numsections (abfd); ++ Elf_Internal_Shdr **headerp; ++ ++ for (headerp = start_headers; headerp < end_headers; headerp ++) ++ { ++ Elf_Internal_Shdr *header = * headerp; ++ ++ /* Debuginfo files do not have any allocated SHT_PROGBITS sections. ++ The only allocated sections are SHT_NOBITS or SHT_NOTES. */ ++ if ((header->sh_flags & SHF_ALLOC) == SHF_ALLOC ++ && header->sh_type != SHT_NOBITS ++ && header->sh_type != SHT_NOTE) ++ return FALSE; ++ } ++ ++ return TRUE; ++} ++ + /* Assign file positions for the other sections. */ + + static bfd_boolean +@@ -5840,7 +5869,13 @@ assign_file_positions_for_non_load_secti + BFD_ASSERT (hdr->sh_offset == hdr->bfd_section->filepos); + else if ((hdr->sh_flags & SHF_ALLOC) != 0) + { +- if (hdr->sh_size != 0) ++ if (hdr->sh_size != 0 ++ /* PR 24717 - debuginfo files are known to be not strictly ++ compliant with the ELF standard. In particular they often ++ have .note.gnu.property sections that are outside of any ++ loadable segment. This is not a problem for such files, ++ so do not warn about them. */ ++ && ! is_debuginfo_file (abfd)) + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB: warning: allocated section `%s' not in segment"), +Only in binutils-2.32/bfd: elf.c.orig diff --git a/binutils.spec b/binutils.spec index cdead03..c2bc8a5 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.32 -Release: 16%{?dist} +Release: 17%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -216,14 +216,20 @@ Patch20: binutils-aarch64-gold-PLT-for-MOVW_ABS.patch # Purpose: Stop gold from aborting when input sections with the same name # have different flags. -# Lifetime: 2.33 (probably) +# Lifetime: Fixed in 2.33 (probably) Patch21: binutils-gold-mismatched-section-flags.patch # Purpose: Corrcect a memory corruption when generating relocs for build # notes in the assembler. -# Lifetime: 2.33 +# Lifetime: Fixed in 2.33 Patch22: binutils-gas-build-note-relocs.patch +# Purpose: Stop the BFD library from issueing warning messages about allocated +# sections being found outside of loadable segments, if they are +# found inside debuginfo files. +# Lifetime: Fixed in 2.33 +Patch23: binutils-do-not-warn-about-debuginfo-files.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -372,6 +378,7 @@ Conflicts: gcc-c++ < 4.0.0 %patch20 -p1 %patch21 -p1 %patch22 -p1 +%patch23 -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 ? @@ -768,6 +775,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Tue Jul 02 2019 Nick Clifton - 2.32-17 +- Stop the BFD library from complaining about sections found inside debuginfo files. (PR 24717) + * Mon Jul 01 2019 Nick Clifton - 2.32-16 - Stop gas from triggering a seg-fault when creating relocs for build notes. (PR 24748) From bc6d877ace8e7bcd308a6cd267c15a7285683620 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 22 Jul 2019 14:19:11 +0100 Subject: [PATCH 04/16] Stops the linker from merging section groups with different SHF_EXCLUDE flags. Resolves: #1730906 --- ...ot-merge-differing-SHF_EXCLUDE-groups.patch | 18 ++++++++++++++++++ binutils.spec | 10 +++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch diff --git a/binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch b/binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch new file mode 100644 index 0000000..e0653f9 --- /dev/null +++ b/binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch @@ -0,0 +1,18 @@ +--- binutils.orig/ld/emultempl/elf32.em 2019-07-22 13:25:51.601030174 +0100 ++++ binutils-2.32/ld/emultempl/elf32.em 2019-07-22 13:27:36.070394830 +0100 +@@ -2029,10 +2029,12 @@ elf_orphan_compatible (asection *in, ase + if (elf_section_data (out)->this_hdr.sh_info + != elf_section_data (in)->this_hdr.sh_info) + return FALSE; +- /* We can't merge two sections with differing SHF_EXCLUDE when doing +- a relocatable link. */ ++ /* We can't merge with member of output section group nor merge two ++ sections with differing SHF_EXCLUDE when doing a relocatable link. */ + if (bfd_link_relocatable (&link_info) +- && ((elf_section_flags (out) ^ elf_section_flags (in)) & SHF_EXCLUDE) != 0) ++ && (elf_next_in_group (out) != NULL ++ || ((elf_section_flags (out) ^ elf_section_flags (in)) ++ & SHF_EXCLUDE) != 0)) + return FALSE; + return _bfd_elf_match_sections_by_type (link_info.output_bfd, out, + in->owner, in); diff --git a/binutils.spec b/binutils.spec index c2bc8a5..31ae338 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.32 -Release: 17%{?dist} +Release: 18%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -230,6 +230,10 @@ Patch22: binutils-gas-build-note-relocs.patch # Lifetime: Fixed in 2.33 Patch23: binutils-do-not-warn-about-debuginfo-files.patch +# Purpose: Stops the linker from merging section groups with different exclusion flags. +# Lifetime: Fixed in 2.33 +Patch24: binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -379,6 +383,7 @@ Conflicts: gcc-c++ < 4.0.0 %patch21 -p1 %patch22 -p1 %patch23 -p1 +%patch24 -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 ? @@ -775,6 +780,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Mon Jul 22 2019 Nick Clifton - 2.32-18 +- Stops the linker from merging section groups with different SHF_EXCLUDE flags. (#1730906) + * Tue Jul 02 2019 Nick Clifton - 2.32-17 - Stop the BFD library from complaining about sections found inside debuginfo files. (PR 24717) From 9b3321d4338738de11895187406770fb3103e465 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 24 Jul 2019 19:17:27 +0000 Subject: [PATCH 05/16] - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- binutils.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/binutils.spec b/binutils.spec index 31ae338..827e8f4 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.32 -Release: 18%{?dist} +Release: 19%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -780,6 +780,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Wed Jul 24 2019 Fedora Release Engineering - 2.32-19 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + * Mon Jul 22 2019 Nick Clifton - 2.32-18 - Stops the linker from merging section groups with different SHF_EXCLUDE flags. (#1730906) From f3c54369c5e4e79cd59bc76d673a608f25e86edc Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Fri, 2 Aug 2019 18:44:25 +0200 Subject: [PATCH 06/16] Fix ld -Map not to produce corrupt ELF notes (#1736114) --- binutils-rh1736114.patch | 158 +++++++++++++++++++++++++++++++++++++++ binutils.spec | 10 ++- 2 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 binutils-rh1736114.patch diff --git a/binutils-rh1736114.patch b/binutils-rh1736114.patch new file mode 100644 index 0000000..b47dde9 --- /dev/null +++ b/binutils-rh1736114.patch @@ -0,0 +1,158 @@ +Backup from binutils-2_32-branch upstream: + +commit df010caac3b33b1d38b6d67024091854c3f77c77 +Author: H.J. Lu +Date: Mon Jun 24 11:08:40 2019 -0700 + + elf: Remove the property after reporting its removal + + commit d2ef37ebd9f771d06edf1fdea37970f60b242b2d + Author: H.J. Lu + Date: Fri Dec 7 08:30:30 2018 -0800 + + elf: Report property change when merging properties + + failed to remove the property after reporting it has been removed. This + patch corrects it. + + bfd/ + + PR ld/24721 + * elf-properties.c (elf_merge_gnu_property_list): Remove the + property after reporting property removal. + + ld/ + + PR ld/24721 + * testsuite/ld-x86-64/x86-64.exp: Run PR ld/24721 tests. + * testsuite/ld-x86-64/pr24721-x32.d: New file. + * testsuite/ld-x86-64/pr24721.d: Likewise. + * testsuite/ld-x86-64/pr24721.map: Likewise. + * testsuite/ld-x86-64/pr24721a.s: Likewise. + * testsuite/ld-x86-64/pr24721b.s: Likewise. + + (cherry picked from commit f93ab3a0b8039a1667a666f013cca50b03d67f9b) + +Conflicts: + ld/testsuite/ld-x86-64/x86-64.exp + (Missing backports of PR24151, PR24458.) + +diff --git a/bfd/elf-properties.c b/bfd/elf-properties.c +index 5e48d75faa269453..4a9907ff7edad5e0 100644 +--- a/bfd/elf-properties.c ++++ b/bfd/elf-properties.c +@@ -322,12 +322,10 @@ elf_merge_gnu_property_list (struct bfd_link_info *info, bfd *first_pbfd, + (bfd_vma) p->property.pr_type, first_pbfd, abfd); + } + } +- else +- { +- /* Remove this property. */ +- *lastp = p->next; +- continue; +- } ++ ++ /* Remove this property. */ ++ *lastp = p->next; ++ continue; + } + else if (number_p) + { +diff --git a/ld/testsuite/ld-x86-64/pr24721-x32.d b/ld/testsuite/ld-x86-64/pr24721-x32.d +new file mode 100644 +index 0000000000000000..9b067efdc11a4824 +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/pr24721-x32.d +@@ -0,0 +1,6 @@ ++#source: pr24721a.s ++#source: pr24721b.s ++#as: --x32 -mx86-used-note=no ++#ld: -r -m elf32_x86_64 -Map tmpdir/pr24721.map ++#readelf: -n ++#map: pr24721.map +diff --git a/ld/testsuite/ld-x86-64/pr24721.d b/ld/testsuite/ld-x86-64/pr24721.d +new file mode 100644 +index 0000000000000000..efa88db2b3c7e9c5 +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/pr24721.d +@@ -0,0 +1,6 @@ ++#source: pr24721a.s ++#source: pr24721b.s ++#as: --64 -defsym __64_bit__=1 -mx86-used-note=no ++#ld: -r -melf_x86_64 -Map tmpdir/pr24721.map ++#readelf: -n ++#map: pr24721.map +diff --git a/ld/testsuite/ld-x86-64/pr24721.map b/ld/testsuite/ld-x86-64/pr24721.map +new file mode 100644 +index 0000000000000000..9e63fff27557b983 +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/pr24721.map +@@ -0,0 +1,3 @@ ++#... ++Removed property 0xc0000002 to merge tmpdir/pr24721a.o \(0x1\) and tmpdir/pr24721b.o \(not found\) ++#pass +diff --git a/ld/testsuite/ld-x86-64/pr24721a.s b/ld/testsuite/ld-x86-64/pr24721a.s +new file mode 100644 +index 0000000000000000..b229d19b02dc9809 +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/pr24721a.s +@@ -0,0 +1,34 @@ ++ .text ++ .globl foo ++ .type foo,@function ++ .p2align 4 ++foo: ++ ret ++ ++ .section ".note.gnu.property", "a" ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++ .long 1f - 0f /* name length */ ++ .long 5f - 2f /* data length */ ++ .long 5 /* note type */ ++0: .asciz "GNU" /* vendor name */ ++1: ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++2: .long 0xc0000002 /* pr_type. */ ++ .long 4f - 3f /* pr_datasz. */ ++3: ++ .long 0x1 ++4: ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++5: +diff --git a/ld/testsuite/ld-x86-64/pr24721b.s b/ld/testsuite/ld-x86-64/pr24721b.s +new file mode 100644 +index 0000000000000000..3d11691166751bfa +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/pr24721b.s +@@ -0,0 +1,6 @@ ++ .text ++ .globl bar ++ .type bar,@function ++ .p2align 4 ++bar: ++ ret +diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp +index 0d65801a942dbddd..3e02531e6f90aff9 100644 +--- a/ld/testsuite/ld-x86-64/x86-64.exp ++++ b/ld/testsuite/ld-x86-64/x86-64.exp +@@ -424,6 +424,8 @@ run_dump_test "pr23486d-x32" + run_dump_test "pr23854" + run_dump_test "pr23930" + run_dump_test "pr23930-x32" ++run_dump_test "pr24721" ++run_dump_test "pr24721-x32" + + if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} { + return diff --git a/binutils.spec b/binutils.spec index 827e8f4..e48cf3b 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.32 -Release: 19%{?dist} +Release: 20%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -234,6 +234,10 @@ Patch23: binutils-do-not-warn-about-debuginfo-files.patch # Lifetime: Fixed in 2.33 Patch24: binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch +# Purpose: Fix -Map and property merging +# Lifetime: Fixed in 2.33 +Patch25: binutils-rh1736114.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -384,6 +388,7 @@ Conflicts: gcc-c++ < 4.0.0 %patch22 -p1 %patch23 -p1 %patch24 -p1 +%patch25 -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 ? @@ -780,6 +785,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Fri Aug 2 2019 Florian Weimer - 2.32-20 +- Fix ld -Map not to produce corrupt ELF notes (#1736114) + * Wed Jul 24 2019 Fedora Release Engineering - 2.32-19 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild From 9dc3a9d58cf73195a1c224e1f49a9cd892f80256 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 5 Aug 2019 17:02:57 +0100 Subject: [PATCH 07/16] Stop strip from complaining if the first build note is not a version note. Resolves: #1736114 --- ...tils-objcopy-gnu-build-version-notes.patch | 57 +++++++++++++++++++ binutils.spec | 11 +++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 binutils-objcopy-gnu-build-version-notes.patch diff --git a/binutils-objcopy-gnu-build-version-notes.patch b/binutils-objcopy-gnu-build-version-notes.patch new file mode 100644 index 0000000..f3f5bd4 --- /dev/null +++ b/binutils-objcopy-gnu-build-version-notes.patch @@ -0,0 +1,57 @@ +--- binutils.orig/binutils/objcopy.c 2019-08-05 16:17:56.908552690 +0100 ++++ binutils-2.32/binutils/objcopy.c 2019-08-05 16:18:14.985435014 +0100 +@@ -1988,7 +1988,6 @@ merge_gnu_build_notes (bfd * abfd, asect + unsigned long previous_open_end = 0; + long relsize; + +- + relsize = bfd_get_reloc_upper_bound (abfd, sec); + if (relsize > 0) + { +@@ -2005,7 +2004,8 @@ merge_gnu_build_notes (bfd * abfd, asect + } + + /* Make a copy of the notes and convert to our internal format. +- Minimum size of a note is 12 bytes. */ ++ Minimum size of a note is 12 bytes. Also locate the version ++ notes and check them. */ + pnote = pnotes = (objcopy_internal_note *) xcalloc ((size / 12), sizeof (* pnote)); + while (remain >= 12) + { +@@ -2174,12 +2174,10 @@ merge_gnu_build_notes (bfd * abfd, asect + attribute_type_byte = version_1_seen ? 1 : 3; + val_start = attribute_type_byte + 1; + +- /* The first note should be the first version note. */ +- if (pnotes[0].note.namedata[attribute_type_byte] != GNU_BUILD_ATTRIBUTE_VERSION) +- { +- err = _("bad GNU build attribute notes: first note not version note"); +- goto done; +- } ++ /* We used to require that the first note be a version note, ++ but this is no longer enforced. Due to the problems with ++ linking sections with the same name (eg .gnu.build.note.hot) ++ we cannot guarantee that the first note will be a version note. */ + + /* Now merge the notes. The rules are: + 1. Preserve the ordering of the notes. +@@ -2196,8 +2194,9 @@ merge_gnu_build_notes (bfd * abfd, asect + with a non-empty description field must also be preserved *OR* the + description field of the note must be changed to contain the starting + address to which it refers. +- 6. Notes with the same start and end address can be deleted. */ +- for (pnote = pnotes + 1; pnote < pnotes_end; pnote ++) ++ 6. Notes with the same start and end address can be deleted. ++ 7. FIXME: Elminate duplicate version notes - even function specific ones ? */ ++ for (pnote = pnotes; pnote < pnotes_end; pnote ++) + { + int note_type; + objcopy_internal_note * back; +@@ -2225,7 +2224,6 @@ merge_gnu_build_notes (bfd * abfd, asect + && back->note.namesz == pnote->note.namesz + && memcmp (back->note.namedata, pnote->note.namedata, pnote->note.namesz) == 0) + { +- fprintf (stderr, "DUP FUNXC\n"); + duplicate_found = TRUE; + pnote->note.type = 0; + break; diff --git a/binutils.spec b/binutils.spec index e48cf3b..ccb6900 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.32 -Release: 20%{?dist} +Release: 21%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -238,6 +238,11 @@ Patch24: binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch # Lifetime: Fixed in 2.33 Patch25: binutils-rh1736114.patch +# Purpose: Change objcopy/strip so that they do not complain if the +# first note in a sequence of build notes is not a version note. +# Lifetime: Fixed in 2.33 +Patch26: binutils-objcopy-gnu-build-version-notes.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -389,6 +394,7 @@ Conflicts: gcc-c++ < 4.0.0 %patch23 -p1 %patch24 -p1 %patch25 -p1 +%patch26 -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 ? @@ -785,6 +791,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Mon Aug 05 2019 Nick Clifton - 2.32-21 +- Stop strip from complaining if the first build note is not a version note. (#1736114) + * Fri Aug 2 2019 Florian Weimer - 2.32-20 - Fix ld -Map not to produce corrupt ELF notes (#1736114) From 1f0862a7b6ed25ffb3746df6370663aed931e015 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 6 Aug 2019 15:08:35 +0100 Subject: [PATCH 08/16] Stop GOLD from seg-faulting on a corrupt input with a fuzzed section offset. Resolves: #1735605 --- binutils-CVE-2019-1010204.patch | 15 +++++++++++++++ binutils.spec | 11 ++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 binutils-CVE-2019-1010204.patch diff --git a/binutils-CVE-2019-1010204.patch b/binutils-CVE-2019-1010204.patch new file mode 100644 index 0000000..56434b1 --- /dev/null +++ b/binutils-CVE-2019-1010204.patch @@ -0,0 +1,15 @@ +--- binutils.orig/gold/fileread.cc 2019-08-06 14:22:08.669313110 +0100 ++++ binutils-2.32/gold/fileread.cc 2019-08-06 14:22:28.799177543 +0100 +@@ -381,6 +381,12 @@ File_read::do_read(off_t start, section_ + ssize_t bytes; + if (this->whole_file_view_ != NULL) + { ++ // See PR 23765 for an example of a testcase that triggers this error. ++ if (((ssize_t) start) < 0) ++ gold_fatal(_("%s: read failed, starting offset (%#llx) less than zero"), ++ this->filename().c_str(), ++ static_cast(start)); ++ + bytes = this->size_ - start; + if (static_cast(bytes) >= size) + { diff --git a/binutils.spec b/binutils.spec index ccb6900..0664680 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.32 -Release: 21%{?dist} +Release: 22%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -243,6 +243,11 @@ Patch25: binutils-rh1736114.patch # Lifetime: Fixed in 2.33 Patch26: binutils-objcopy-gnu-build-version-notes.patch +# Purpose: Add a check to the GOLD linker for a corrupt input file +# with a fuzzed section offset. +# Lifetime: Fixed in 2.33 +Patch27: binutils-CVE-2019-1010204.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -395,6 +400,7 @@ Conflicts: gcc-c++ < 4.0.0 %patch24 -p1 %patch25 -p1 %patch26 -p1 +%patch27 -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 ? @@ -791,6 +797,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Tue Aug 06 2019 Nick Clifton - 2.32-22 +- Stop GOLD from seg-faulting on a corrupt input with a fuzzed section offset. (#1735605) + * Mon Aug 05 2019 Nick Clifton - 2.32-21 - Stop strip from complaining if the first build note is not a version note. (#1736114) From 79f83cf3ce2928e79c73b26d0a1f4e084f632c5a Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 9 Aug 2019 14:51:53 +0100 Subject: [PATCH 09/16] Fix potential integer overflow in GOLD. Resolves: #1739491 --- binutils-CVE-2019-14250.patch | 17 +++++++++++++++++ binutils.spec | 10 +++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 binutils-CVE-2019-14250.patch diff --git a/binutils-CVE-2019-14250.patch b/binutils-CVE-2019-14250.patch new file mode 100644 index 0000000..c37b92e --- /dev/null +++ b/binutils-CVE-2019-14250.patch @@ -0,0 +1,17 @@ +--- binutils.orig/libiberty/simple-object-elf.c 2019-08-09 14:13:51.677330065 +0100 ++++ binutils-2.32/libiberty/simple-object-elf.c 2019-08-09 14:14:31.177076298 +0100 +@@ -549,6 +549,14 @@ simple_object_elf_match (unsigned char h + return NULL; + } + ++ if (eor->shstrndx == 0) ++ { ++ *errmsg = "invalid ELF shstrndx == 0"; ++ *err = 0; ++ XDELETE (eor); ++ return NULL; ++ } ++ + return (void *) eor; + } + diff --git a/binutils.spec b/binutils.spec index 0664680..405d37a 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.32 -Release: 22%{?dist} +Release: 23%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -248,6 +248,10 @@ Patch26: binutils-objcopy-gnu-build-version-notes.patch # Lifetime: Fixed in 2.33 Patch27: binutils-CVE-2019-1010204.patch +# Purpose: Add check to libiberty library in order to prevent an integer overflow in the gold linker. +# Lifetime: Fixed in 2.33 +Patch28: binutils-CVE-2019-14250.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -401,6 +405,7 @@ Conflicts: gcc-c++ < 4.0.0 %patch25 -p1 %patch26 -p1 %patch27 -p1 +%patch28 -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 ? @@ -797,6 +802,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Fri Aug 09 2019 Nick Clifton - 2.32-23 +- Fix potential integer overflow in GOLD. (#1739491) + * Tue Aug 06 2019 Nick Clifton - 2.32-22 - Stop GOLD from seg-faulting on a corrupt input with a fuzzed section offset. (#1735605) From 6a63423c3732360ef732f62ca9b16bc9a55a7198 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 13 Aug 2019 14:53:31 +0100 Subject: [PATCH 10/16] Fix potential integer overflow in readelf. Resolves: #1740470 --- binutils-CVE-2019-14444.patch | 11 +++++++++++ binutils.spec | 10 +++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 binutils-CVE-2019-14444.patch diff --git a/binutils-CVE-2019-14444.patch b/binutils-CVE-2019-14444.patch new file mode 100644 index 0000000..ad554f5 --- /dev/null +++ b/binutils-CVE-2019-14444.patch @@ -0,0 +1,11 @@ +--- binutils.orig/binutils/readelf.c 2019-08-13 10:03:33.518792590 +0100 ++++ binutils-2.32/binutils/readelf.c 2019-08-13 10:04:22.885418269 +0100 +@@ -13234,7 +13234,7 @@ apply_relocations (Filedata * + } + + rloc = start + rp->r_offset; +- if ((rloc + reloc_size) > end || (rloc < start)) ++ if (rloc >= end || (rloc + reloc_size) > end || (rloc < start)) + { + warn (_("skipping invalid relocation offset 0x%lx in section %s\n"), + (unsigned long) rp->r_offset, diff --git a/binutils.spec b/binutils.spec index 405d37a..1ffacd2 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.32 -Release: 23%{?dist} +Release: 24%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -252,6 +252,10 @@ Patch27: binutils-CVE-2019-1010204.patch # Lifetime: Fixed in 2.33 Patch28: binutils-CVE-2019-14250.patch +# Purpose: Add check to readelf in order to prevent an integer overflow. +# Lifetime: Fixed in 2.33 +Patch29: binutils-CVE-2019-14444.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -406,6 +410,7 @@ Conflicts: gcc-c++ < 4.0.0 %patch26 -p1 %patch27 -p1 %patch28 -p1 +%patch29 -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 ? @@ -802,6 +807,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Tue Aug 13 2019 Nick Clifton - 2.32-24 +- Fix potential integer overflow in readelf. (#1740470) + * Fri Aug 09 2019 Nick Clifton - 2.32-23 - Fix potential integer overflow in GOLD. (#1739491) From 60374778c38b9028ce62cabbd67dc07dbe80bc1b Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 24 Sep 2019 10:01:17 +0100 Subject: [PATCH 11/16] Fix building with gcc-10. --- binutils-gcc-10-fixes.patch | 10 ++++++++++ binutils.spec | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 binutils-gcc-10-fixes.patch diff --git a/binutils-gcc-10-fixes.patch b/binutils-gcc-10-fixes.patch new file mode 100644 index 0000000..ba3576e --- /dev/null +++ b/binutils-gcc-10-fixes.patch @@ -0,0 +1,10 @@ +--- binutils.orig/gold/descriptors.cc 2019-09-24 09:43:51.200071784 +0100 ++++ binutils-2.32/gold/descriptors.cc 2019-09-24 09:44:24.028874593 +0100 +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + #include + + #include "debug.h" diff --git a/binutils.spec b/binutils.spec index 1ffacd2..a76aa32 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.32 -Release: 24%{?dist} +Release: 25%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -256,6 +256,10 @@ Patch28: binutils-CVE-2019-14250.patch # Lifetime: Fixed in 2.33 Patch29: binutils-CVE-2019-14444.patch +# Purpose: Fix for building with gcc-10. +# Lifetime: Fixed in 2.34 +Patch30: binutils-gcc-10-fixes.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -411,6 +415,7 @@ Conflicts: gcc-c++ < 4.0.0 %patch27 -p1 %patch28 -p1 %patch29 -p1 +%patch30 -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 ? @@ -807,6 +812,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Tue Sep 24 2019 Nick Clifton - 2.32-25 +- Fix building with gcc-10. + * Tue Aug 13 2019 Nick Clifton - 2.32-24 - Fix potential integer overflow in readelf. (#1740470) From 6f8976d0f95a056a1e219d36047753f8ce0eace7 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 25 Sep 2019 16:35:16 +0100 Subject: [PATCH 12/16] Add an option to build using clang instead of gcc. --- binutils.spec | 98 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 33 deletions(-) diff --git a/binutils.spec b/binutils.spec index a76aa32..8ff42e8 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.32 -Release: 25%{?dist} +Release: 26%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -11,35 +11,52 @@ URL: https://sourceware.org/binutils # Binutils SPEC file. Can be invoked with the following parameters: # --define "binutils_target arm-linux-gnu" to create arm-linux-gnu-binutils. -# --with=bootstrap: Build with minimal dependencies. -# --with=debug: Build without optimizations and without splitting the debuginfo. -# --without=docs: Skip building documentation. -# --without=testsuite: Do not run the testsuite. Default is to run it. -# --with=testsuite: Run the testsuite. Default when --with=debug is not to run it. +# --with=bootstrap Build with minimal dependencies. +# --with=debug Build without optimizations and without splitting +# the debuginfo into a separate file. +# --without=docs Skip building documentation. +# --without=testsuite Do not run the testsuite. Default is to run it. +# --with=testsuite Run the testsuite. Default when --with=debug is not +# to run it. +# --without=gold Disable building of the GOLD linker. #---Start of Configure Options----------------------------------------------- -# Do not create deterministic archives by default (cf: BZ 1195883) +# Use clang as the build time compiler rather than gcc. +%define build_using_clang 0 + +# Create deterministic archives (ie ones without timestamps). +# Default is off because of BZ 1195883. %define enable_deterministic_archives 0 # Enable support for GCC LTO compilation. +# Disable if it is necessary to work around bugs in LTO. %define enable_lto 1 -# Disable the default generation of compressed debug sections. +# Enable the compression of debug sections as default behaviour of the +# assembler and linker. This option is disabled for now. The assembler and +# linker have command line options to override the default behaviour. %define default_compress_debug 0 # Default to read-only-relocations (relro) in shared binaries. +# This is enabled as a security feature. %define default_relro 1 -# Disable the default generation of GNU Build notes by the assembler. -# This has turned out to be problematic for the i686 architecture. -# although the exact reason has not been determined. (See BZ 1572485) -# It also breaks building EFI binaries on AArch64, as these cannot have -# relocations against absolute symbols. +# Enable the default generation of GNU Build notes by the assembler. +# This option is disabled as it has turned out to be problematic for the i686 +# architecture, although the exact reason has not been determined. (See +# BZ 1572485). It also breaks building EFI binaries on AArch64, as these +# cannot have relocations against absolute symbols. %define default_generate_notes 0 -# Use "--without gold" to exclude the gold linker. -# The default is to include it. +# Enable thread support in the GOLD linker (if it is being built). This is +# particularly important if plugins to the linker intend to use threads +# themselves. See BZ 1636479 for more details. This option is made +# configurable in case there is ever a need to disable thread support. +%define enable_threading 1 + +#----End of Configure Options------------------------------------------------ + # Note - in the future the gold linker may become deprecated. %ifnarch riscv64 %bcond_without gold @@ -48,14 +65,6 @@ URL: https://sourceware.org/binutils %bcond_with gold %endif -# Enable thread support in the GOLD linker. This is particularly -# important if plugins to the linker intend to use threads themselves. -# See BZ 1636479 for more details. This option is made configurable -# in case there is ever a need to disable thread support. -%define enable_threading 1 - -#----End of Configure Options------------------------------------------------ - # Default: Not bootstrapping. %bcond_with bootstrap # Default: Not debug @@ -230,33 +239,35 @@ Patch22: binutils-gas-build-note-relocs.patch # Lifetime: Fixed in 2.33 Patch23: binutils-do-not-warn-about-debuginfo-files.patch -# Purpose: Stops the linker from merging section groups with different exclusion flags. +# Purpose: Stops the linker from merging section groups with different +# exclusion flags. # Lifetime: Fixed in 2.33 Patch24: binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch -# Purpose: Fix -Map and property merging +# Purpose: Fix -Map and property merging # Lifetime: Fixed in 2.33 Patch25: binutils-rh1736114.patch -# Purpose: Change objcopy/strip so that they do not complain if the -# first note in a sequence of build notes is not a version note. +# Purpose: Change objcopy/strip so that they do not complain if the +# first note in a sequence of build notes is not a version note. # Lifetime: Fixed in 2.33 Patch26: binutils-objcopy-gnu-build-version-notes.patch -# Purpose: Add a check to the GOLD linker for a corrupt input file -# with a fuzzed section offset. +# Purpose: Add a check to the GOLD linker for a corrupt input file +# with a fuzzed section offset. # Lifetime: Fixed in 2.33 Patch27: binutils-CVE-2019-1010204.patch -# Purpose: Add check to libiberty library in order to prevent an integer overflow in the gold linker. +# Purpose: Add check to libiberty library in order to prevent an integer +# overflow in the gold linker. # Lifetime: Fixed in 2.33 Patch28: binutils-CVE-2019-14250.patch -# Purpose: Add check to readelf in order to prevent an integer overflow. +# Purpose: Add check to readelf in order to prevent an integer overflow. # Lifetime: Fixed in 2.33 Patch29: binutils-CVE-2019-14444.patch -# Purpose: Fix for building with gcc-10. +# Purpose: Fix for building with gcc-10. # Lifetime: Fixed in 2.34 Patch30: binutils-gcc-10-fixes.patch @@ -281,7 +292,13 @@ Requires: binutils-gold >= %{version} %endif # Perl, sed and touch are all used in the %%prep section of this spec file. -BuildRequires: gcc, perl, sed, coreutils +BuildRequires: perl, sed, coreutils + +%if %{build_using_clang} +BuildRequires: clang +%else +BuildRequires: gcc +%endif %if %{without bootstrap} BuildRequires: gettext, flex, zlib-devel @@ -373,7 +390,10 @@ BuildRequires: bison, m4, gcc-c++ # The GOLD testsuite needs a static libc++ BuildRequires: libstdc++-static +%if ! %{build_using_clang} +BuildRequires: gcc-c++ Conflicts: gcc-c++ < 4.0.0 +%endif # The higher of these two numbers determines the default ld. %{!?ld_gold_priority:%global ld_gold_priority 30} @@ -459,6 +479,11 @@ touch */configure %build echo target is %{binutils_target} +%if %{build_using_clang} +# Clang does not support the -fstack-clash-protection option. +%global optflags %(echo %{optflags} | sed 's/-fstack-clash-protection//') +%endif + %ifarch %{power64} export CFLAGS="$RPM_OPT_FLAGS -Wno-error" %else @@ -514,6 +539,10 @@ export LDFLAGS=$RPM_LD_FLAGS # We could optimize the cross builds size by --enable-shared but the produced # binaries may be less convenient in the embedded environment. %configure \ +%if %{build_using_clang} + CC=clang \ + CXX=clang++ \ +%endif --quiet \ --build=%{_target_platform} --host=%{_target_platform} \ --target=%{binutils_target} \ @@ -812,6 +841,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Wed Sep 25 2019 Nick Clifton - 2.32-26 +- Add an option to build using clang instead of gcc. + * Tue Sep 24 2019 Nick Clifton - 2.32-25 - Fix building with gcc-10. From 70ab9c2b90378fb16a90fc3b41886bb4bf38139a Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 4 Oct 2019 10:59:30 +0100 Subject: [PATCH 13/16] Remove support for old file formats (ihex, tekhex, verilog) as they are a constant source of CVEs. --- binutils-remove-old-formats.patch | 90 +++++++++++++++++++++++++++++++ binutils.spec | 10 +++- 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 binutils-remove-old-formats.patch diff --git a/binutils-remove-old-formats.patch b/binutils-remove-old-formats.patch new file mode 100644 index 0000000..5cbd785 --- /dev/null +++ b/binutils-remove-old-formats.patch @@ -0,0 +1,90 @@ +diff -rup binutils.orig/bfd/Makefile.am binutils-2.32/bfd/Makefile.am +--- binutils.orig/bfd/Makefile.am 2019-10-04 09:38:45.255326417 +0100 ++++ binutils-2.32/bfd/Makefile.am 2019-10-04 09:43:18.295336820 +0100 +@@ -74,7 +74,7 @@ BFD32_LIBS = \ + coff-bfd.lo compress.lo corefile.lo elf-properties.lo format.lo \ + hash.lo init.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo \ + section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo \ +- binary.lo ihex.lo srec.lo tekhex.lo verilog.lo ++ binary.lo srec.lo + + BFD64_LIBS = archive64.lo + +@@ -83,7 +83,7 @@ BFD32_LIBS_CFILES = \ + compress.c corefile.c elf-properties.c format.c hash.c \ + init.c libbfd.c linker.c merge.c opncls.c reloc.c \ + section.c simple.c stab-syms.c stabs.c syms.c targets.c \ +- binary.c ihex.c srec.c tekhex.c verilog.c ++ binary.c srec.c + + BFD64_LIBS_CFILES = archive64.c + +diff -rup binutils.orig/bfd/Makefile.in binutils-2.32/bfd/Makefile.in +--- binutils.orig/bfd/Makefile.in 2019-10-04 09:38:45.262326366 +0100 ++++ binutils-2.32/bfd/Makefile.in 2019-10-04 09:44:04.951996839 +0100 +@@ -185,8 +185,7 @@ am__objects_1 = archive.lo archures.lo b + cache.lo coff-bfd.lo compress.lo corefile.lo elf-properties.lo \ + format.lo hash.lo init.lo libbfd.lo linker.lo merge.lo \ + opncls.lo reloc.lo section.lo simple.lo stab-syms.lo stabs.lo \ +- syms.lo targets.lo binary.lo ihex.lo srec.lo tekhex.lo \ +- verilog.lo ++ syms.lo targets.lo binary.lo srec.lo + am_libbfd_la_OBJECTS = $(am__objects_1) + libbfd_la_OBJECTS = $(am_libbfd_la_OBJECTS) + AM_V_lt = $(am__v_lt_@AM_V@) +@@ -498,7 +497,7 @@ BFD32_LIBS = \ + coff-bfd.lo compress.lo corefile.lo elf-properties.lo format.lo \ + hash.lo init.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo \ + section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo \ +- binary.lo ihex.lo srec.lo tekhex.lo verilog.lo ++ binary.lo srec.lo + + BFD64_LIBS = archive64.lo + BFD32_LIBS_CFILES = \ +@@ -506,7 +505,7 @@ BFD32_LIBS_CFILES = \ + compress.c corefile.c elf-properties.c format.c hash.c \ + init.c libbfd.c linker.c merge.c opncls.c reloc.c \ + section.c simple.c stab-syms.c stabs.c syms.c targets.c \ +- binary.c ihex.c srec.c tekhex.c verilog.c ++ binary.c srec.c + + BFD64_LIBS_CFILES = archive64.c + +@@ -1514,7 +1513,6 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386bsd.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386lynx.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386msdos.Plo@am__quote@ +-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihex.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/init.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/irix-core.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbfd.Plo@am__quote@ +@@ -1566,11 +1564,9 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stabs.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syms.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/targets.Plo@am__quote@ +-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tekhex.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trad-core.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vax1knetbsd.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vaxnetbsd.Plo@am__quote@ +-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verilog.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-alpha.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-lib.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-misc.Plo@am__quote@ +diff -rup binutils.orig/bfd/targets.c binutils-2.32/bfd/targets.c +--- binutils.orig/bfd/targets.c 2019-10-04 09:38:45.268326323 +0100 ++++ binutils-2.32/bfd/targets.c 2019-10-04 09:42:54.118512989 +0100 +@@ -1289,14 +1289,8 @@ static const bfd_target * const _bfd_tar + /* Always support S-records, for convenience. */ + &srec_vec, + &symbolsrec_vec, +-/* And verilog. */ +- &verilog_vec, +-/* And tekhex */ +- &tekhex_vec, + /* Likewise for binary output. */ + &binary_vec, +-/* Likewise for ihex. */ +- &ihex_vec, + + /* Add any required traditional-core-file-handler. */ + diff --git a/binutils.spec b/binutils.spec index 8ff42e8..dd9f475 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.32 -Release: 26%{?dist} +Release: 27%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -271,6 +271,10 @@ Patch29: binutils-CVE-2019-14444.patch # Lifetime: Fixed in 2.34 Patch30: binutils-gcc-10-fixes.patch +# Purpose: Remove support for old file formats (ihex, tekhex, verilog) +# Lifetime: Permanent. +Patch31: binutils-remove-old-formats.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -436,6 +440,7 @@ Conflicts: gcc-c++ < 4.0.0 %patch28 -p1 %patch29 -p1 %patch30 -p1 +%patch31 -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 ? @@ -841,6 +846,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Fri Oct 04 2019 Nick Clifton - 2.32-27 +- Remove support for old file formats (ihex, tekhex, verilog) as they are a constant source of CVEs. + * Wed Sep 25 2019 Nick Clifton - 2.32-26 - Add an option to build using clang instead of gcc. From 31bd4965addde853f72b5b04a90e172054fa488e Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 14 Oct 2019 13:24:26 +0100 Subject: [PATCH 14/16] Rebase to GNU Binutils 2.33.1. - Retire: binutils-CVE-2019-9073.patch - Retire: binutils-CVE-2019-9074.patch - Retire: binutils-CVE-2019-9075.patch - Retire: binutils-CVE-2019-9077.patch - Retire: binutils-disassembling-efi-files.patch - Retire: binutils-CVE-2019-9071.patch - Retire: binutils-gas-build-note-relocs.patch - Retire: binutils-do-not-warn-about-debuginfo-files.patch - Retire: binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch - Retire: binutils-rh1736114.patch - Retire: binutils-objcopy-gnu-build-version-notes.patch - Retire: binutils-CVE-2019-14250.patch - Retire: binutils-CVE-2019-14444.patch - Retire: binutils-gcc-10-fixes.patch - Retire: binutils-remove-old-formats.patch - Retire: binutils-aarch64-gold-PLT-for-MOVW_ABS.patch --- .gitignore | 1 + binutils-CVE-2019-14250.patch | 17 -- binutils-CVE-2019-14444.patch | 11 -- binutils-CVE-2019-9071.patch | 110 ------------ binutils-CVE-2019-9073.patch | 13 -- binutils-CVE-2019-9074.patch | 32 ---- binutils-CVE-2019-9075.patch | 73 -------- binutils-CVE-2019-9077.patch | 16 -- binutils-aarch64-gold-PLT-for-MOVW_ABS.patch | 20 --- binutils-disassembling-efi-files.patch | 39 ----- ...t-merge-differing-SHF_EXCLUDE-groups.patch | 18 -- ...ls-do-not-warn-about-debuginfo-files.patch | 68 -------- binutils-fix-testsuite-failures.patch | 24 --- binutils-gas-build-note-relocs.patch | 55 ------ binutils-gcc-10-fixes.patch | 10 -- ...tils-objcopy-gnu-build-version-notes.patch | 57 ------- binutils-remove-old-formats.patch | 90 ---------- binutils-rh1736114.patch | 158 ------------------ binutils.spec | 124 ++++---------- sources | 2 +- 20 files changed, 30 insertions(+), 908 deletions(-) delete mode 100644 binutils-CVE-2019-14250.patch delete mode 100644 binutils-CVE-2019-14444.patch delete mode 100644 binutils-CVE-2019-9071.patch delete mode 100644 binutils-CVE-2019-9073.patch delete mode 100644 binutils-CVE-2019-9074.patch delete mode 100644 binutils-CVE-2019-9075.patch delete mode 100644 binutils-CVE-2019-9077.patch delete mode 100644 binutils-aarch64-gold-PLT-for-MOVW_ABS.patch delete mode 100644 binutils-disassembling-efi-files.patch delete mode 100644 binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch delete mode 100644 binutils-do-not-warn-about-debuginfo-files.patch delete mode 100644 binutils-gas-build-note-relocs.patch delete mode 100644 binutils-gcc-10-fixes.patch delete mode 100644 binutils-objcopy-gnu-build-version-notes.patch delete mode 100644 binutils-remove-old-formats.patch delete mode 100644 binutils-rh1736114.patch diff --git a/.gitignore b/.gitignore index a64e6ef..8dba18d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ build-sources /binutils-2.31.1.tar.xz /binutils-special-sections-in-groups.patch /binutils-2.32.tar.xz +/binutils-2.33.1.tar.xz diff --git a/binutils-CVE-2019-14250.patch b/binutils-CVE-2019-14250.patch deleted file mode 100644 index c37b92e..0000000 --- a/binutils-CVE-2019-14250.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- binutils.orig/libiberty/simple-object-elf.c 2019-08-09 14:13:51.677330065 +0100 -+++ binutils-2.32/libiberty/simple-object-elf.c 2019-08-09 14:14:31.177076298 +0100 -@@ -549,6 +549,14 @@ simple_object_elf_match (unsigned char h - return NULL; - } - -+ if (eor->shstrndx == 0) -+ { -+ *errmsg = "invalid ELF shstrndx == 0"; -+ *err = 0; -+ XDELETE (eor); -+ return NULL; -+ } -+ - return (void *) eor; - } - diff --git a/binutils-CVE-2019-14444.patch b/binutils-CVE-2019-14444.patch deleted file mode 100644 index ad554f5..0000000 --- a/binutils-CVE-2019-14444.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- binutils.orig/binutils/readelf.c 2019-08-13 10:03:33.518792590 +0100 -+++ binutils-2.32/binutils/readelf.c 2019-08-13 10:04:22.885418269 +0100 -@@ -13234,7 +13234,7 @@ apply_relocations (Filedata * - } - - rloc = start + rp->r_offset; -- if ((rloc + reloc_size) > end || (rloc < start)) -+ if (rloc >= end || (rloc + reloc_size) > end || (rloc < start)) - { - warn (_("skipping invalid relocation offset 0x%lx in section %s\n"), - (unsigned long) rp->r_offset, diff --git a/binutils-CVE-2019-9071.patch b/binutils-CVE-2019-9071.patch deleted file mode 100644 index f4ef3bc..0000000 --- a/binutils-CVE-2019-9071.patch +++ /dev/null @@ -1,110 +0,0 @@ ---- binutils.orig/libiberty/cp-demangle.c 2019-04-10 10:31:27.854997707 +0100 -+++ binutils-2.31.1/libiberty/cp-demangle.c 2019-04-10 16:00:35.820350978 +0100 -@@ -858,7 +858,7 @@ CP_STATIC_IF_GLIBCPP_V3 - int - cplus_demangle_fill_name (struct demangle_component *p, const char *s, int len) - { -- if (p == NULL || s == NULL || len == 0) -+ if (p == NULL || s == NULL || len <= 0) - return 0; - p->d_printing = 0; - p->type = DEMANGLE_COMPONENT_NAME; -@@ -4032,7 +4032,7 @@ d_growable_string_callback_adapter (cons - are larger than the actual numbers encountered. */ - - static void --d_count_templates_scopes (int *num_templates, int *num_scopes, -+d_count_templates_scopes (struct d_print_info *dpi, - const struct demangle_component *dc) - { - if (dc == NULL) -@@ -4052,13 +4052,13 @@ d_count_templates_scopes (int *num_templ - break; - - case DEMANGLE_COMPONENT_TEMPLATE: -- (*num_templates)++; -+ dpi->num_copy_templates++; - goto recurse_left_right; - - case DEMANGLE_COMPONENT_REFERENCE: - case DEMANGLE_COMPONENT_RVALUE_REFERENCE: - if (d_left (dc)->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM) -- (*num_scopes)++; -+ dpi->num_saved_scopes++; - goto recurse_left_right; - - case DEMANGLE_COMPONENT_QUAL_NAME: -@@ -4122,42 +4122,42 @@ d_count_templates_scopes (int *num_templ - case DEMANGLE_COMPONENT_TAGGED_NAME: - case DEMANGLE_COMPONENT_CLONE: - recurse_left_right: -- d_count_templates_scopes (num_templates, num_scopes, -- d_left (dc)); -- d_count_templates_scopes (num_templates, num_scopes, -- d_right (dc)); -+ /* PR 89394 - Check for too much recursion. */ -+ if (dpi->recursion > DEMANGLE_RECURSION_LIMIT) -+ /* FIXME: There ought to be a way to report to the -+ user that the recursion limit has been reached. */ -+ return; -+ -+ ++ dpi->recursion; -+ d_count_templates_scopes (dpi, d_left (dc)); -+ d_count_templates_scopes (dpi, d_right (dc)); -+ -- dpi->recursion; - break; - - case DEMANGLE_COMPONENT_CTOR: -- d_count_templates_scopes (num_templates, num_scopes, -- dc->u.s_ctor.name); -+ d_count_templates_scopes (dpi, dc->u.s_ctor.name); - break; - - case DEMANGLE_COMPONENT_DTOR: -- d_count_templates_scopes (num_templates, num_scopes, -- dc->u.s_dtor.name); -+ d_count_templates_scopes (dpi, dc->u.s_dtor.name); - break; - - case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: -- d_count_templates_scopes (num_templates, num_scopes, -- dc->u.s_extended_operator.name); -+ d_count_templates_scopes (dpi, dc->u.s_extended_operator.name); - break; - - case DEMANGLE_COMPONENT_FIXED_TYPE: -- d_count_templates_scopes (num_templates, num_scopes, -- dc->u.s_fixed.length); -+ d_count_templates_scopes (dpi, dc->u.s_fixed.length); - break; - - case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: - case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: -- d_count_templates_scopes (num_templates, num_scopes, -- d_left (dc)); -+ d_count_templates_scopes (dpi, d_left (dc)); - break; - - case DEMANGLE_COMPONENT_LAMBDA: - case DEMANGLE_COMPONENT_DEFAULT_ARG: -- d_count_templates_scopes (num_templates, num_scopes, -- dc->u.s_unary_num.sub); -+ d_count_templates_scopes (dpi, dc->u.s_unary_num.sub); - break; - } - } -@@ -4192,8 +4192,12 @@ d_print_init (struct d_print_info *dpi, - dpi->next_copy_template = 0; - dpi->num_copy_templates = 0; - -- d_count_templates_scopes (&dpi->num_copy_templates, -- &dpi->num_saved_scopes, dc); -+ d_count_templates_scopes (dpi, dc); -+ /* If we did not reach the recursion limit, then reset the -+ current recursion value back to 0, so that we can print -+ the templates. */ -+ if (dpi->recursion < DEMANGLE_RECURSION_LIMIT) -+ dpi->recursion = 0; - dpi->num_copy_templates *= dpi->num_saved_scopes; - - dpi->current_template = NULL; diff --git a/binutils-CVE-2019-9073.patch b/binutils-CVE-2019-9073.patch deleted file mode 100644 index 37256f4..0000000 --- a/binutils-CVE-2019-9073.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- binutils.orig/binutils/objdump.c 2019-02-25 16:12:30.394056901 +0000 -+++ binutils-2.31.1/binutils/objdump.c 2019-02-25 16:13:07.224778005 +0000 -@@ -2993,7 +2993,9 @@ dump_bfd_header (bfd *abfd) - static void - dump_bfd_private_header (bfd *abfd) - { -- bfd_print_private_bfd_data (abfd, stdout); -+ if (!bfd_print_private_bfd_data (abfd, stdout)) -+ non_fatal (_("warning: private headers incomplete: %s"), -+ bfd_errmsg (bfd_get_error ())); - } - - static void diff --git a/binutils-CVE-2019-9074.patch b/binutils-CVE-2019-9074.patch deleted file mode 100644 index 84f0fd5..0000000 --- a/binutils-CVE-2019-9074.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- binutils.orig/bfd/pei-x86_64.c 2019-02-25 16:12:29.798061414 +0000 -+++ binutils-2.31.1/bfd/pei-x86_64.c 2019-02-25 17:09:02.783425236 +0000 -@@ -541,7 +541,7 @@ pex64_bfd_print_pdata_section (bfd *abfd - /* virt_size might be zero for objects. */ - if (stop == 0 && strcmp (abfd->xvec->name, "pe-x86-64") == 0) - { -- stop = (datasize / onaline) * onaline; -+ stop = datasize; - virt_size_is_zero = TRUE; - } - else if (datasize < stop) -@@ -551,8 +551,8 @@ pex64_bfd_print_pdata_section (bfd *abfd - _("Warning: %s section size (%ld) is smaller than virtual size (%ld)\n"), - pdata_section->name, (unsigned long) datasize, - (unsigned long) stop); -- /* Be sure not to read passed datasize. */ -- stop = datasize / onaline; -+ /* Be sure not to read past datasize. */ -+ stop = datasize; - } - - /* Display functions table. */ -@@ -724,8 +724,7 @@ pex64_bfd_print_pdata_section (bfd *abfd - altent += imagebase; - - if (altent >= pdata_vma -- && (altent + PDATA_ROW_SIZE <= pdata_vma -- + pei_section_data (abfd, pdata_section)->virt_size)) -+ && altent - pdata_vma + PDATA_ROW_SIZE <= stop) - { - pex64_get_runtime_function - (abfd, &arf, &pdata[altent - pdata_vma]); diff --git a/binutils-CVE-2019-9075.patch b/binutils-CVE-2019-9075.patch deleted file mode 100644 index ec3e8ca..0000000 --- a/binutils-CVE-2019-9075.patch +++ /dev/null @@ -1,73 +0,0 @@ -diff -rup binutils.orig/bfd/archive64.c binutils-2.31.1/bfd/archive64.c ---- binutils.orig/bfd/archive64.c 2019-02-26 11:17:11.882530151 +0000 -+++ binutils-2.31.1/bfd/archive64.c 2019-02-26 11:19:18.422488805 +0000 -@@ -100,8 +100,6 @@ _bfd_archive_64_bit_slurp_armap (bfd *ab - return FALSE; - carsyms = ardata->symdefs; - stringbase = ((char *) ardata->symdefs) + carsym_size; -- stringbase[stringsize] = 0; -- stringend = stringbase + stringsize; - - raw_armap = (bfd_byte *) bfd_alloc (abfd, ptrsize); - if (raw_armap == NULL) -@@ -115,15 +113,17 @@ _bfd_archive_64_bit_slurp_armap (bfd *ab - goto release_raw_armap; - } - -+ stringend = stringbase + stringsize; -+ *stringend = 0; - for (i = 0; i < nsymz; i++) - { - carsyms->file_offset = bfd_getb64 (raw_armap + i * 8); - carsyms->name = stringbase; -- if (stringbase < stringend) -- stringbase += strlen (stringbase) + 1; -+ stringbase += strlen (stringbase); -+ if (stringbase != stringend) -+ ++stringbase; - ++carsyms; - } -- *stringbase = '\0'; - - ardata->symdef_count = nsymz; - ardata->first_file_filepos = bfd_tell (abfd); -diff -rup binutils.orig/bfd/archive.c binutils-2.31.1/bfd/archive.c ---- binutils.orig/bfd/archive.c 2019-02-26 11:17:11.884530134 +0000 -+++ binutils-2.31.1/bfd/archive.c 2019-02-26 11:18:33.354859687 +0000 -@@ -1014,6 +1014,7 @@ do_slurp_coff_armap (bfd *abfd) - int *raw_armap, *rawptr; - struct artdata *ardata = bfd_ardata (abfd); - char *stringbase; -+ char *stringend; - bfd_size_type stringsize; - bfd_size_type parsed_size; - carsym *carsyms; -@@ -1073,22 +1074,20 @@ do_slurp_coff_armap (bfd *abfd) - } - - /* OK, build the carsyms. */ -- for (i = 0; i < nsymz && stringsize > 0; i++) -+ stringend = stringbase + stringsize; -+ *stringend = 0; -+ for (i = 0; i < nsymz; i++) - { - bfd_size_type len; - - rawptr = raw_armap + i; - carsyms->file_offset = swap ((bfd_byte *) rawptr); - carsyms->name = stringbase; -- /* PR 17512: file: 4a1d50c1. */ -- len = strnlen (stringbase, stringsize); -- if (len < stringsize) -- len ++; -- stringbase += len; -- stringsize -= len; -+ stringbase += strlen (stringbase); -+ if (stringbase != stringend) -+ ++stringbase; - carsyms++; - } -- *stringbase = 0; - - ardata->symdef_count = nsymz; - ardata->first_file_filepos = bfd_tell (abfd); diff --git a/binutils-CVE-2019-9077.patch b/binutils-CVE-2019-9077.patch deleted file mode 100644 index 1790bfa..0000000 --- a/binutils-CVE-2019-9077.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- binutils.orig/binutils/readelf.c 2019-02-26 11:17:12.414525772 +0000 -+++ binutils-2.31.1/binutils/readelf.c 2019-02-26 12:11:40.642876742 +0000 -@@ -16009,6 +16009,13 @@ process_mips_specific (Filedata * fileda - return FALSE; - } - -+ /* PR 24243 */ -+ if (sect->sh_size < sizeof (* eopt)) -+ { -+ error (_("The MIPS options section is too small.\n")); -+ return FALSE; -+ } -+ - eopt = (Elf_External_Options *) get_data (NULL, filedata, options_offset, 1, - sect->sh_size, _("options")); - if (eopt) diff --git a/binutils-aarch64-gold-PLT-for-MOVW_ABS.patch b/binutils-aarch64-gold-PLT-for-MOVW_ABS.patch deleted file mode 100644 index 2cdb734..0000000 --- a/binutils-aarch64-gold-PLT-for-MOVW_ABS.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- binutils.orig/gold/aarch64.cc 2019-05-21 11:24:07.642560743 +0100 -+++ binutils-2.32/gold/aarch64.cc 2019-05-21 11:25:02.425157682 +0100 -@@ -6496,6 +6496,17 @@ Target_aarch64::Scan:: - gold_error(_("%s: unsupported reloc %u in pos independent link."), - object->name().c_str(), r_type); - } -+ // Make a PLT entry if necessary. -+ if (gsym->needs_plt_entry()) -+ { -+ target->make_plt_entry(symtab, layout, gsym); -+ // Since this is not a PC-relative relocation, we may be -+ // taking the address of a function. In that case we need to -+ // set the entry in the dynamic symbol table to the address of -+ // the PLT entry. -+ if (gsym->is_from_dynobj() && !parameters->options().shared()) -+ gsym->set_needs_dynsym_value(); -+ } - break; - - case elfcpp::R_AARCH64_LD_PREL_LO19: // 273 diff --git a/binutils-disassembling-efi-files.patch b/binutils-disassembling-efi-files.patch deleted file mode 100644 index 75d4275..0000000 --- a/binutils-disassembling-efi-files.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff -rup binutils.orig/bfd/coffgen.c binutils-2.31.1/bfd/coffgen.c ---- binutils.orig/bfd/coffgen.c 2019-03-06 08:49:19.500586870 +0000 -+++ binutils-2.31.1/bfd/coffgen.c 2019-03-06 08:49:45.798394582 +0000 -@@ -2289,7 +2289,7 @@ coff_find_nearest_line_with_names (bfd * - information. So try again, using a bias against the address sought. */ - if (coff_data (abfd)->dwarf2_find_line_info != NULL) - { -- bfd_signed_vma bias; -+ bfd_signed_vma bias = 0; - - /* Create a cache of the result for the next call. */ - if (sec_data == NULL && section->owner == abfd) -@@ -2301,10 +2301,11 @@ coff_find_nearest_line_with_names (bfd * - - if (sec_data != NULL && sec_data->saved_bias) - bias = sec_data->saved_bias; -- else -+ else if (symbols) - { - bias = _bfd_dwarf2_find_symbol_bias (symbols, - & coff_data (abfd)->dwarf2_find_line_info); -+ - if (sec_data) - { - sec_data->saved_bias = TRUE; -Only in binutils-2.31.1/bfd: coffgen.c.orig -diff -rup binutils.orig/bfd/dwarf2.c binutils-2.31.1/bfd/dwarf2.c ---- binutils.orig/bfd/dwarf2.c 2019-03-06 08:49:19.498586884 +0000 -+++ binutils-2.31.1/bfd/dwarf2.c 2019-03-06 08:49:45.799394575 +0000 -@@ -4463,7 +4463,7 @@ _bfd_dwarf2_find_symbol_bias (asymbol ** - - stash = (struct dwarf2_debug *) *pinfo; - -- if (stash == NULL) -+ if (stash == NULL || symbols == NULL) - return 0; - - for (unit = stash->all_comp_units; unit; unit = unit->next_unit) -Only in binutils-2.31.1/bfd: dwarf2.c.orig diff --git a/binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch b/binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch deleted file mode 100644 index e0653f9..0000000 --- a/binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- binutils.orig/ld/emultempl/elf32.em 2019-07-22 13:25:51.601030174 +0100 -+++ binutils-2.32/ld/emultempl/elf32.em 2019-07-22 13:27:36.070394830 +0100 -@@ -2029,10 +2029,12 @@ elf_orphan_compatible (asection *in, ase - if (elf_section_data (out)->this_hdr.sh_info - != elf_section_data (in)->this_hdr.sh_info) - return FALSE; -- /* We can't merge two sections with differing SHF_EXCLUDE when doing -- a relocatable link. */ -+ /* We can't merge with member of output section group nor merge two -+ sections with differing SHF_EXCLUDE when doing a relocatable link. */ - if (bfd_link_relocatable (&link_info) -- && ((elf_section_flags (out) ^ elf_section_flags (in)) & SHF_EXCLUDE) != 0) -+ && (elf_next_in_group (out) != NULL -+ || ((elf_section_flags (out) ^ elf_section_flags (in)) -+ & SHF_EXCLUDE) != 0)) - return FALSE; - return _bfd_elf_match_sections_by_type (link_info.output_bfd, out, - in->owner, in); diff --git a/binutils-do-not-warn-about-debuginfo-files.patch b/binutils-do-not-warn-about-debuginfo-files.patch deleted file mode 100644 index bfe8135..0000000 --- a/binutils-do-not-warn-about-debuginfo-files.patch +++ /dev/null @@ -1,68 +0,0 @@ -diff -rup binutils.orig/bfd/elf-bfd.h binutils-2.32/bfd/elf-bfd.h ---- binutils.orig/bfd/elf-bfd.h 2019-07-02 16:03:41.758007318 +0100 -+++ binutils-2.32/bfd/elf-bfd.h 2019-07-02 16:04:02.025862020 +0100 -@@ -2749,6 +2749,8 @@ extern bfd_vma elf64_r_sym (bfd_vma); - extern bfd_vma elf32_r_info (bfd_vma, bfd_vma); - extern bfd_vma elf32_r_sym (bfd_vma); - -+extern bfd_boolean is_debuginfo_file (bfd *); -+ - /* Large common section. */ - extern asection _bfd_elf_large_com_section; - -Only in binutils-2.32/bfd: elf-bfd.h.orig -diff -rup binutils.orig/bfd/elf.c binutils-2.32/bfd/elf.c ---- binutils.orig/bfd/elf.c 2019-07-02 16:03:42.101004858 +0100 -+++ binutils-2.32/bfd/elf.c 2019-07-02 16:04:23.909705141 +0100 -@@ -5807,6 +5807,35 @@ assign_file_positions_for_load_sections - return TRUE; - } - -+/* Determine if a bfd is a debuginfo file. Unfortunately there -+ is no defined method for detecting such files, so we have to -+ use heuristics instead. */ -+ -+bfd_boolean -+is_debuginfo_file (bfd *abfd) -+{ -+ if (abfd == NULL || bfd_get_flavour (abfd) != bfd_target_elf_flavour) -+ return FALSE; -+ -+ Elf_Internal_Shdr **start_headers = elf_elfsections (abfd); -+ Elf_Internal_Shdr **end_headers = start_headers + elf_numsections (abfd); -+ Elf_Internal_Shdr **headerp; -+ -+ for (headerp = start_headers; headerp < end_headers; headerp ++) -+ { -+ Elf_Internal_Shdr *header = * headerp; -+ -+ /* Debuginfo files do not have any allocated SHT_PROGBITS sections. -+ The only allocated sections are SHT_NOBITS or SHT_NOTES. */ -+ if ((header->sh_flags & SHF_ALLOC) == SHF_ALLOC -+ && header->sh_type != SHT_NOBITS -+ && header->sh_type != SHT_NOTE) -+ return FALSE; -+ } -+ -+ return TRUE; -+} -+ - /* Assign file positions for the other sections. */ - - static bfd_boolean -@@ -5840,7 +5869,13 @@ assign_file_positions_for_non_load_secti - BFD_ASSERT (hdr->sh_offset == hdr->bfd_section->filepos); - else if ((hdr->sh_flags & SHF_ALLOC) != 0) - { -- if (hdr->sh_size != 0) -+ if (hdr->sh_size != 0 -+ /* PR 24717 - debuginfo files are known to be not strictly -+ compliant with the ELF standard. In particular they often -+ have .note.gnu.property sections that are outside of any -+ loadable segment. This is not a problem for such files, -+ so do not warn about them. */ -+ && ! is_debuginfo_file (abfd)) - _bfd_error_handler - /* xgettext:c-format */ - (_("%pB: warning: allocated section `%s' not in segment"), -Only in binutils-2.32/bfd: elf.c.orig diff --git a/binutils-fix-testsuite-failures.patch b/binutils-fix-testsuite-failures.patch index c171343..57d61c4 100644 --- a/binutils-fix-testsuite-failures.patch +++ b/binutils-fix-testsuite-failures.patch @@ -8,16 +8,6 @@ diff -rup binutils-2.32.orig/ld/testsuite/ld-plugin/plugin-10.d binutils-2.32/ld +#... hook called: cleanup. #... -diff -rup binutils-2.32.orig/ld/testsuite/ld-plugin/plugin-12.d binutils-2.32/ld/testsuite/ld-plugin/plugin-12.d ---- binutils-2.32.orig/ld/testsuite/ld-plugin/plugin-12.d 2019-02-15 13:33:21.976627309 +0000 -+++ binutils-2.32/ld/testsuite/ld-plugin/plugin-12.d 2019-02-15 13:47:04.060076132 +0000 -@@ -1,5 +1,5 @@ - #... --.*: symbol `func' definition: 0, visibility: 0, resolution: 2 -+.*: symbol `func' definition: 0, visibility: 0, resolution: . - .*: symbol `func1' definition: 0, visibility: 1, resolution: 3 - .*: symbol `func2' definition: 0, visibility: 2, resolution: 3 - .*: symbol `func3' definition: 0, visibility: 3, resolution: 3 diff -rup binutils-2.32.orig/ld/testsuite/ld-plugin/plugin-13.d binutils-2.32/ld/testsuite/ld-plugin/plugin-13.d --- binutils-2.32.orig/ld/testsuite/ld-plugin/plugin-13.d 2019-02-15 13:33:21.980627277 +0000 +++ binutils-2.32/ld/testsuite/ld-plugin/plugin-13.d 2019-02-15 13:41:30.189692800 +0000 @@ -289,20 +279,6 @@ diff -rup binutils-2.32.orig/ld/testsuite/ld-plugin/plugin-11.d binutils-2.32/ld +#... hook called: cleanup. #... -diff -rup binutils-2.32.orig/ld/testsuite/ld-plugin/plugin-12.d binutils-2.32/ld/testsuite/ld-plugin/plugin-12.d ---- binutils-2.32.orig/ld/testsuite/ld-plugin/plugin-12.d 2019-02-15 14:10:58.912710532 +0000 -+++ binutils-2.32/ld/testsuite/ld-plugin/plugin-12.d 2019-02-15 14:13:18.464583848 +0000 -@@ -1,6 +1,6 @@ - #... --.*: symbol `func' definition: 0, visibility: 0, resolution: . --.*: symbol `func1' definition: 0, visibility: 1, resolution: 3 --.*: symbol `func2' definition: 0, visibility: 2, resolution: 3 --.*: symbol `func3' definition: 0, visibility: 3, resolution: 3 -+.*: symbol `_?func' definition: 0, visibility: 0, resolution: . -+.*: symbol `_?func1' definition: 0, visibility: 1, resolution: 3 -+.*: symbol `_?func2' definition: 0, visibility: 2, resolution: 3 -+.*: symbol `_?func3' definition: 0, visibility: 3, resolution: 3 - #pass diff -rup binutils-2.32.orig/ld/testsuite/ld-plugin/plugin-18.d binutils-2.32/ld/testsuite/ld-plugin/plugin-18.d --- binutils-2.32.orig/ld/testsuite/ld-plugin/plugin-18.d 2019-02-15 14:10:58.942710289 +0000 +++ binutils-2.32/ld/testsuite/ld-plugin/plugin-18.d 2019-02-15 14:15:20.030602369 +0000 diff --git a/binutils-gas-build-note-relocs.patch b/binutils-gas-build-note-relocs.patch deleted file mode 100644 index 52a4c0b..0000000 --- a/binutils-gas-build-note-relocs.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- binutils.orig/gas/write.c 2019-07-01 16:23:28.133707500 +0100 -+++ binutils-2.32/gas/write.c 2019-07-01 16:24:50.699130611 +0100 -@@ -1891,7 +1891,8 @@ create_obj_attrs_section (void) - static void - create_note_reloc (segT sec, - symbolS * sym, -- bfd_size_type offset, -+ bfd_size_type note_offset, -+ bfd_size_type desc2_offset, - int reloc_type, - bfd_vma addend, - char * note) -@@ -1901,10 +1902,10 @@ create_note_reloc (segT sec, - reloc = XNEW (struct reloc_list); - - /* We create a .b type reloc as resolve_reloc_expr_symbols() has already been called. */ -- reloc->u.b.sec = sec; -- reloc->u.b.s = symbol_get_bfdsym (sym); -+ reloc->u.b.sec = sec; -+ reloc->u.b.s = symbol_get_bfdsym (sym); - reloc->u.b.r.sym_ptr_ptr = & reloc->u.b.s; -- reloc->u.b.r.address = offset; -+ reloc->u.b.r.address = note_offset + desc2_offset; - reloc->u.b.r.addend = addend; - reloc->u.b.r.howto = bfd_reloc_type_lookup (stdoutput, reloc_type); - -@@ -1929,12 +1930,12 @@ create_note_reloc (segT sec, - if (target_big_endian) - { - if (bfd_arch_bits_per_address (stdoutput) <= 32) -- note[offset + 3] = addend; -+ note[desc2_offset + 3] = addend; - else -- note[offset + 7] = addend; -+ note[desc2_offset + 7] = addend; - } - else -- note[offset] = addend; -+ note[desc2_offset] = addend; - } - } - -@@ -2037,10 +2038,10 @@ maybe_generate_build_notes (void) - memcpy (note + 12, "GA$3a1", 8); - - /* Create a relocation to install the start address of the note... */ -- create_note_reloc (sec, sym, total_size + 20, desc_reloc, 0, note); -+ create_note_reloc (sec, sym, total_size, 20, desc_reloc, 0, note); - - /* ...and another one to install the end address. */ -- create_note_reloc (sec, sym, total_size + desc2_offset, desc_reloc, -+ create_note_reloc (sec, sym, total_size, desc2_offset, desc_reloc, - bfd_get_section_size (bsym->section), - note); - diff --git a/binutils-gcc-10-fixes.patch b/binutils-gcc-10-fixes.patch deleted file mode 100644 index ba3576e..0000000 --- a/binutils-gcc-10-fixes.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- binutils.orig/gold/descriptors.cc 2019-09-24 09:43:51.200071784 +0100 -+++ binutils-2.32/gold/descriptors.cc 2019-09-24 09:44:24.028874593 +0100 -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include - #include - - #include "debug.h" diff --git a/binutils-objcopy-gnu-build-version-notes.patch b/binutils-objcopy-gnu-build-version-notes.patch deleted file mode 100644 index f3f5bd4..0000000 --- a/binutils-objcopy-gnu-build-version-notes.patch +++ /dev/null @@ -1,57 +0,0 @@ ---- binutils.orig/binutils/objcopy.c 2019-08-05 16:17:56.908552690 +0100 -+++ binutils-2.32/binutils/objcopy.c 2019-08-05 16:18:14.985435014 +0100 -@@ -1988,7 +1988,6 @@ merge_gnu_build_notes (bfd * abfd, asect - unsigned long previous_open_end = 0; - long relsize; - -- - relsize = bfd_get_reloc_upper_bound (abfd, sec); - if (relsize > 0) - { -@@ -2005,7 +2004,8 @@ merge_gnu_build_notes (bfd * abfd, asect - } - - /* Make a copy of the notes and convert to our internal format. -- Minimum size of a note is 12 bytes. */ -+ Minimum size of a note is 12 bytes. Also locate the version -+ notes and check them. */ - pnote = pnotes = (objcopy_internal_note *) xcalloc ((size / 12), sizeof (* pnote)); - while (remain >= 12) - { -@@ -2174,12 +2174,10 @@ merge_gnu_build_notes (bfd * abfd, asect - attribute_type_byte = version_1_seen ? 1 : 3; - val_start = attribute_type_byte + 1; - -- /* The first note should be the first version note. */ -- if (pnotes[0].note.namedata[attribute_type_byte] != GNU_BUILD_ATTRIBUTE_VERSION) -- { -- err = _("bad GNU build attribute notes: first note not version note"); -- goto done; -- } -+ /* We used to require that the first note be a version note, -+ but this is no longer enforced. Due to the problems with -+ linking sections with the same name (eg .gnu.build.note.hot) -+ we cannot guarantee that the first note will be a version note. */ - - /* Now merge the notes. The rules are: - 1. Preserve the ordering of the notes. -@@ -2196,8 +2194,9 @@ merge_gnu_build_notes (bfd * abfd, asect - with a non-empty description field must also be preserved *OR* the - description field of the note must be changed to contain the starting - address to which it refers. -- 6. Notes with the same start and end address can be deleted. */ -- for (pnote = pnotes + 1; pnote < pnotes_end; pnote ++) -+ 6. Notes with the same start and end address can be deleted. -+ 7. FIXME: Elminate duplicate version notes - even function specific ones ? */ -+ for (pnote = pnotes; pnote < pnotes_end; pnote ++) - { - int note_type; - objcopy_internal_note * back; -@@ -2225,7 +2224,6 @@ merge_gnu_build_notes (bfd * abfd, asect - && back->note.namesz == pnote->note.namesz - && memcmp (back->note.namedata, pnote->note.namedata, pnote->note.namesz) == 0) - { -- fprintf (stderr, "DUP FUNXC\n"); - duplicate_found = TRUE; - pnote->note.type = 0; - break; diff --git a/binutils-remove-old-formats.patch b/binutils-remove-old-formats.patch deleted file mode 100644 index 5cbd785..0000000 --- a/binutils-remove-old-formats.patch +++ /dev/null @@ -1,90 +0,0 @@ -diff -rup binutils.orig/bfd/Makefile.am binutils-2.32/bfd/Makefile.am ---- binutils.orig/bfd/Makefile.am 2019-10-04 09:38:45.255326417 +0100 -+++ binutils-2.32/bfd/Makefile.am 2019-10-04 09:43:18.295336820 +0100 -@@ -74,7 +74,7 @@ BFD32_LIBS = \ - coff-bfd.lo compress.lo corefile.lo elf-properties.lo format.lo \ - hash.lo init.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo \ - section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo \ -- binary.lo ihex.lo srec.lo tekhex.lo verilog.lo -+ binary.lo srec.lo - - BFD64_LIBS = archive64.lo - -@@ -83,7 +83,7 @@ BFD32_LIBS_CFILES = \ - compress.c corefile.c elf-properties.c format.c hash.c \ - init.c libbfd.c linker.c merge.c opncls.c reloc.c \ - section.c simple.c stab-syms.c stabs.c syms.c targets.c \ -- binary.c ihex.c srec.c tekhex.c verilog.c -+ binary.c srec.c - - BFD64_LIBS_CFILES = archive64.c - -diff -rup binutils.orig/bfd/Makefile.in binutils-2.32/bfd/Makefile.in ---- binutils.orig/bfd/Makefile.in 2019-10-04 09:38:45.262326366 +0100 -+++ binutils-2.32/bfd/Makefile.in 2019-10-04 09:44:04.951996839 +0100 -@@ -185,8 +185,7 @@ am__objects_1 = archive.lo archures.lo b - cache.lo coff-bfd.lo compress.lo corefile.lo elf-properties.lo \ - format.lo hash.lo init.lo libbfd.lo linker.lo merge.lo \ - opncls.lo reloc.lo section.lo simple.lo stab-syms.lo stabs.lo \ -- syms.lo targets.lo binary.lo ihex.lo srec.lo tekhex.lo \ -- verilog.lo -+ syms.lo targets.lo binary.lo srec.lo - am_libbfd_la_OBJECTS = $(am__objects_1) - libbfd_la_OBJECTS = $(am_libbfd_la_OBJECTS) - AM_V_lt = $(am__v_lt_@AM_V@) -@@ -498,7 +497,7 @@ BFD32_LIBS = \ - coff-bfd.lo compress.lo corefile.lo elf-properties.lo format.lo \ - hash.lo init.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo \ - section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo \ -- binary.lo ihex.lo srec.lo tekhex.lo verilog.lo -+ binary.lo srec.lo - - BFD64_LIBS = archive64.lo - BFD32_LIBS_CFILES = \ -@@ -506,7 +505,7 @@ BFD32_LIBS_CFILES = \ - compress.c corefile.c elf-properties.c format.c hash.c \ - init.c libbfd.c linker.c merge.c opncls.c reloc.c \ - section.c simple.c stab-syms.c stabs.c syms.c targets.c \ -- binary.c ihex.c srec.c tekhex.c verilog.c -+ binary.c srec.c - - BFD64_LIBS_CFILES = archive64.c - -@@ -1514,7 +1513,6 @@ distclean-compile: - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386bsd.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386lynx.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386msdos.Plo@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihex.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/init.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/irix-core.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbfd.Plo@am__quote@ -@@ -1566,11 +1564,9 @@ distclean-compile: - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stabs.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syms.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/targets.Plo@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tekhex.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trad-core.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vax1knetbsd.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vaxnetbsd.Plo@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verilog.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-alpha.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-lib.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vms-misc.Plo@am__quote@ -diff -rup binutils.orig/bfd/targets.c binutils-2.32/bfd/targets.c ---- binutils.orig/bfd/targets.c 2019-10-04 09:38:45.268326323 +0100 -+++ binutils-2.32/bfd/targets.c 2019-10-04 09:42:54.118512989 +0100 -@@ -1289,14 +1289,8 @@ static const bfd_target * const _bfd_tar - /* Always support S-records, for convenience. */ - &srec_vec, - &symbolsrec_vec, --/* And verilog. */ -- &verilog_vec, --/* And tekhex */ -- &tekhex_vec, - /* Likewise for binary output. */ - &binary_vec, --/* Likewise for ihex. */ -- &ihex_vec, - - /* Add any required traditional-core-file-handler. */ - diff --git a/binutils-rh1736114.patch b/binutils-rh1736114.patch deleted file mode 100644 index b47dde9..0000000 --- a/binutils-rh1736114.patch +++ /dev/null @@ -1,158 +0,0 @@ -Backup from binutils-2_32-branch upstream: - -commit df010caac3b33b1d38b6d67024091854c3f77c77 -Author: H.J. Lu -Date: Mon Jun 24 11:08:40 2019 -0700 - - elf: Remove the property after reporting its removal - - commit d2ef37ebd9f771d06edf1fdea37970f60b242b2d - Author: H.J. Lu - Date: Fri Dec 7 08:30:30 2018 -0800 - - elf: Report property change when merging properties - - failed to remove the property after reporting it has been removed. This - patch corrects it. - - bfd/ - - PR ld/24721 - * elf-properties.c (elf_merge_gnu_property_list): Remove the - property after reporting property removal. - - ld/ - - PR ld/24721 - * testsuite/ld-x86-64/x86-64.exp: Run PR ld/24721 tests. - * testsuite/ld-x86-64/pr24721-x32.d: New file. - * testsuite/ld-x86-64/pr24721.d: Likewise. - * testsuite/ld-x86-64/pr24721.map: Likewise. - * testsuite/ld-x86-64/pr24721a.s: Likewise. - * testsuite/ld-x86-64/pr24721b.s: Likewise. - - (cherry picked from commit f93ab3a0b8039a1667a666f013cca50b03d67f9b) - -Conflicts: - ld/testsuite/ld-x86-64/x86-64.exp - (Missing backports of PR24151, PR24458.) - -diff --git a/bfd/elf-properties.c b/bfd/elf-properties.c -index 5e48d75faa269453..4a9907ff7edad5e0 100644 ---- a/bfd/elf-properties.c -+++ b/bfd/elf-properties.c -@@ -322,12 +322,10 @@ elf_merge_gnu_property_list (struct bfd_link_info *info, bfd *first_pbfd, - (bfd_vma) p->property.pr_type, first_pbfd, abfd); - } - } -- else -- { -- /* Remove this property. */ -- *lastp = p->next; -- continue; -- } -+ -+ /* Remove this property. */ -+ *lastp = p->next; -+ continue; - } - else if (number_p) - { -diff --git a/ld/testsuite/ld-x86-64/pr24721-x32.d b/ld/testsuite/ld-x86-64/pr24721-x32.d -new file mode 100644 -index 0000000000000000..9b067efdc11a4824 ---- /dev/null -+++ b/ld/testsuite/ld-x86-64/pr24721-x32.d -@@ -0,0 +1,6 @@ -+#source: pr24721a.s -+#source: pr24721b.s -+#as: --x32 -mx86-used-note=no -+#ld: -r -m elf32_x86_64 -Map tmpdir/pr24721.map -+#readelf: -n -+#map: pr24721.map -diff --git a/ld/testsuite/ld-x86-64/pr24721.d b/ld/testsuite/ld-x86-64/pr24721.d -new file mode 100644 -index 0000000000000000..efa88db2b3c7e9c5 ---- /dev/null -+++ b/ld/testsuite/ld-x86-64/pr24721.d -@@ -0,0 +1,6 @@ -+#source: pr24721a.s -+#source: pr24721b.s -+#as: --64 -defsym __64_bit__=1 -mx86-used-note=no -+#ld: -r -melf_x86_64 -Map tmpdir/pr24721.map -+#readelf: -n -+#map: pr24721.map -diff --git a/ld/testsuite/ld-x86-64/pr24721.map b/ld/testsuite/ld-x86-64/pr24721.map -new file mode 100644 -index 0000000000000000..9e63fff27557b983 ---- /dev/null -+++ b/ld/testsuite/ld-x86-64/pr24721.map -@@ -0,0 +1,3 @@ -+#... -+Removed property 0xc0000002 to merge tmpdir/pr24721a.o \(0x1\) and tmpdir/pr24721b.o \(not found\) -+#pass -diff --git a/ld/testsuite/ld-x86-64/pr24721a.s b/ld/testsuite/ld-x86-64/pr24721a.s -new file mode 100644 -index 0000000000000000..b229d19b02dc9809 ---- /dev/null -+++ b/ld/testsuite/ld-x86-64/pr24721a.s -@@ -0,0 +1,34 @@ -+ .text -+ .globl foo -+ .type foo,@function -+ .p2align 4 -+foo: -+ ret -+ -+ .section ".note.gnu.property", "a" -+.ifdef __64_bit__ -+ .p2align 3 -+.else -+ .p2align 2 -+.endif -+ .long 1f - 0f /* name length */ -+ .long 5f - 2f /* data length */ -+ .long 5 /* note type */ -+0: .asciz "GNU" /* vendor name */ -+1: -+.ifdef __64_bit__ -+ .p2align 3 -+.else -+ .p2align 2 -+.endif -+2: .long 0xc0000002 /* pr_type. */ -+ .long 4f - 3f /* pr_datasz. */ -+3: -+ .long 0x1 -+4: -+.ifdef __64_bit__ -+ .p2align 3 -+.else -+ .p2align 2 -+.endif -+5: -diff --git a/ld/testsuite/ld-x86-64/pr24721b.s b/ld/testsuite/ld-x86-64/pr24721b.s -new file mode 100644 -index 0000000000000000..3d11691166751bfa ---- /dev/null -+++ b/ld/testsuite/ld-x86-64/pr24721b.s -@@ -0,0 +1,6 @@ -+ .text -+ .globl bar -+ .type bar,@function -+ .p2align 4 -+bar: -+ ret -diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp -index 0d65801a942dbddd..3e02531e6f90aff9 100644 ---- a/ld/testsuite/ld-x86-64/x86-64.exp -+++ b/ld/testsuite/ld-x86-64/x86-64.exp -@@ -424,6 +424,8 @@ run_dump_test "pr23486d-x32" - run_dump_test "pr23854" - run_dump_test "pr23930" - run_dump_test "pr23930-x32" -+run_dump_test "pr24721" -+run_dump_test "pr24721-x32" - - if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} { - return diff --git a/binutils.spec b/binutils.spec index dd9f475..6d6395a 100644 --- a/binutils.spec +++ b/binutils.spec @@ -1,8 +1,8 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} -Version: 2.32 -Release: 27%{?dist} +Version: 2.33.1 +Release: 1%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -183,97 +183,26 @@ Patch10: binutils-attach-to-group.patch # Purpose: Stop gold from complaining about relocs in the .gnu.build.attribute # section that reference symbols in discarded sections. -# Lifetime: Fixed in 2.33 (maybe) +# Lifetime: Fixed in 2.34 (maybe) Patch11: binutils-gold-ignore-discarded-note-relocs.patch # Purpose: Allow OS specific sections in section groups. -# Lifetime: Might be fixed in 2.33 +# Lifetime: Might be fixed in 2.34 (maybe) Patch12: binutils-special-sections-in-groups.patch # Purpose: Fix linker testsuite failures. -# Lifetime: Fixed in 2.33 (possibly) +# Lifetime: Fixed in 2.34 (maybe) Patch13: binutils-fix-testsuite-failures.patch -# Purpose: Improve objdump's handling of corrupt input files. -# Lifetime: Fixed in 2.33 -Patch14: binutils-CVE-2019-9073.patch - -# Purpose: Stop illegal memory access parsing corrupt PE files. -# Lifetime: Fixed in 2.33 -Patch15: binutils-CVE-2019-9074.patch - -# Purpose: Stop illegal memory access parsing corrupt archives. -# Lifetime: Fixed in 2.33 -Patch16: binutils-CVE-2019-9075.patch - -# Purpose: Stop illegal memory access parsing a corrupt MIPS binary. -# Lifetime: Fixed in 2.33 -Patch17: binutils-CVE-2019-9077.patch - -# Purpose: Stop a seg-fault when disassembling an EFI binary. -# Lifetime: Fixed in 2.33 -Patch18: binutils-disassembling-efi-files.patch - -# Purpose: Fix a stack exhaustion problem in libiberty's name demangling code. -# Lifetime: Fixed in 2.33 -Patch19: binutils-CVE-2019-9071.patch - -# Purpose: Have the GOLD linker for AArch64 generate PLT entries for MOVW_ABS -# relocations if necessary. -# Lifetime: Fixed in 2.33 -Patch20: binutils-aarch64-gold-PLT-for-MOVW_ABS.patch - # Purpose: Stop gold from aborting when input sections with the same name # have different flags. -# Lifetime: Fixed in 2.33 (probably) -Patch21: binutils-gold-mismatched-section-flags.patch - -# Purpose: Corrcect a memory corruption when generating relocs for build -# notes in the assembler. -# Lifetime: Fixed in 2.33 -Patch22: binutils-gas-build-note-relocs.patch - -# Purpose: Stop the BFD library from issueing warning messages about allocated -# sections being found outside of loadable segments, if they are -# found inside debuginfo files. -# Lifetime: Fixed in 2.33 -Patch23: binutils-do-not-warn-about-debuginfo-files.patch - -# Purpose: Stops the linker from merging section groups with different -# exclusion flags. -# Lifetime: Fixed in 2.33 -Patch24: binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch - -# Purpose: Fix -Map and property merging -# Lifetime: Fixed in 2.33 -Patch25: binutils-rh1736114.patch - -# Purpose: Change objcopy/strip so that they do not complain if the -# first note in a sequence of build notes is not a version note. -# Lifetime: Fixed in 2.33 -Patch26: binutils-objcopy-gnu-build-version-notes.patch +# Lifetime: Fixed in 2.34 (maybe) +Patch14: binutils-gold-mismatched-section-flags.patch # Purpose: Add a check to the GOLD linker for a corrupt input file # with a fuzzed section offset. -# Lifetime: Fixed in 2.33 -Patch27: binutils-CVE-2019-1010204.patch - -# Purpose: Add check to libiberty library in order to prevent an integer -# overflow in the gold linker. -# Lifetime: Fixed in 2.33 -Patch28: binutils-CVE-2019-14250.patch - -# Purpose: Add check to readelf in order to prevent an integer overflow. -# Lifetime: Fixed in 2.33 -Patch29: binutils-CVE-2019-14444.patch - -# Purpose: Fix for building with gcc-10. -# Lifetime: Fixed in 2.34 -Patch30: binutils-gcc-10-fixes.patch - -# Purpose: Remove support for old file formats (ihex, tekhex, verilog) -# Lifetime: Permanent. -Patch31: binutils-remove-old-formats.patch +# Lifetime: Fixed in 2.34 (maybe) +Patch15: binutils-CVE-2019-1010204.patch #---------------------------------------------------------------------------- @@ -425,22 +354,6 @@ Conflicts: gcc-c++ < 4.0.0 %patch13 -p1 %patch14 -p1 %patch15 -p1 -%patch16 -p1 -%patch17 -p1 -%patch18 -p1 -%patch19 -p1 -%patch20 -p1 -%patch21 -p1 -%patch22 -p1 -%patch23 -p1 -%patch24 -p1 -%patch25 -p1 -%patch26 -p1 -%patch27 -p1 -%patch28 -p1 -%patch29 -p1 -%patch30 -p1 -%patch31 -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 ? @@ -846,6 +759,25 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Mon Oct 14 2019 Nick Clifton - 2.33-1 +- Rebase to GNU Binutils 2.33.1. +- Retire: binutils-CVE-2019-9073.patch +- Retire: binutils-CVE-2019-9074.patch +- Retire: binutils-CVE-2019-9075.patch +- Retire: binutils-CVE-2019-9077.patch +- Retire: binutils-disassembling-efi-files.patch +- Retire: binutils-CVE-2019-9071.patch +- Retire: binutils-gas-build-note-relocs.patch +- Retire: binutils-do-not-warn-about-debuginfo-files.patch +- Retire: binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch +- Retire: binutils-rh1736114.patch +- Retire: binutils-objcopy-gnu-build-version-notes.patch +- Retire: binutils-CVE-2019-14250.patch +- Retire: binutils-CVE-2019-14444.patch +- Retire: binutils-gcc-10-fixes.patch +- Retire: binutils-remove-old-formats.patch +- Retire: binutils-aarch64-gold-PLT-for-MOVW_ABS.patch + * Fri Oct 04 2019 Nick Clifton - 2.32-27 - Remove support for old file formats (ihex, tekhex, verilog) as they are a constant source of CVEs. diff --git a/sources b/sources index d8b1d0b..033cd31 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (binutils-2.32.tar.xz) = d326408f12a03d9a61a9de56584c2af12f81c2e50d2d7e835d51565df8314df01575724afa1e43bd0db45cfc9916b41519b67dfce03232aa4978704492a6994a +SHA512 (binutils-2.33.1.tar.xz) = b7a6767c6c7ca6b5cafa7080e6820b7bb3a53b7148348c438d99905defbdf0d30c9744a484ee01c9441a8153901808513366b15ba9533e20c9673c262ade36ac SHA512 (binutils-2.19.50.0.1-output-format.sed) = 2f8686b0c8af13c98cda056824c2820416f6e2d003f70b78ccf5314525b9ee3684d421dfa83e638a2d42d06ea4d4bdaf5226b64d6ec26f7ff59c44ffb2a23dd2 From 11b5d51d9459bef2168fa2332358feb7532ce713 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 28 Oct 2019 12:30:39 +0000 Subject: [PATCH 15/16] Improve objdump's ability to merge GNU build attribute notes. --- binutils-improved-note-merging.patch | 1865 ++++++++++++++++++++++++++ binutils.spec | 10 +- 2 files changed, 1874 insertions(+), 1 deletion(-) create mode 100644 binutils-improved-note-merging.patch diff --git a/binutils-improved-note-merging.patch b/binutils-improved-note-merging.patch new file mode 100644 index 0000000..8bdc785 --- /dev/null +++ b/binutils-improved-note-merging.patch @@ -0,0 +1,1865 @@ +diff -rupN binutils.orig/binutils/objcopy.c binutils-2.33.1/binutils/objcopy.c +--- binutils.orig/binutils/objcopy.c 2019-10-28 11:01:40.438071332 +0000 ++++ binutils-2.33.1/binutils/objcopy.c 2019-10-28 11:05:27.697446056 +0000 +@@ -97,8 +97,14 @@ static int deterministic = -1; /* Enabl + static int status = 0; /* Exit status. */ + + static bfd_boolean merge_notes = FALSE; /* Merge note sections. */ +-static bfd_byte * merged_notes = NULL; /* Contents on note section undergoing a merge. */ +-static bfd_size_type merged_size = 0; /* New, smaller size of the merged note section. */ ++ ++typedef struct merged_note_section ++{ ++ asection * sec; /* The section that is being merged. */ ++ bfd_byte * contents;/* New contents of the section. */ ++ bfd_size_type size; /* New size of the section. */ ++ struct merged_note_section * next; /* Link to next merged note section. */ ++} merged_note_section; + + enum strip_action + { +@@ -1283,7 +1289,7 @@ is_update_section (bfd *abfd ATTRIBUTE_U + } + + static bfd_boolean +-is_merged_note_section (bfd * abfd, asection * sec) ++is_mergeable_note_section (bfd * abfd, asection * sec) + { + if (merge_notes + && bfd_get_flavour (abfd) == bfd_target_elf_flavour +@@ -1292,9 +1298,9 @@ is_merged_note_section (bfd * abfd, asec + We should add support for more note types. */ + && ((elf_section_data (sec)->this_hdr.sh_flags & SHF_GNU_BUILD_NOTE) != 0 + /* Old versions of GAS (prior to 2.27) could not set the section +- flags to OS-specific values, so we also accept sections with the +- expected name. */ +- || (strcmp (sec->name, GNU_BUILD_ATTRS_SECTION_NAME) == 0))) ++ flags to OS-specific values, so we also accept sections that ++ start with the expected name. */ ++ || (CONST_STRNEQ (sec->name, GNU_BUILD_ATTRS_SECTION_NAME)))) + return TRUE; + + return FALSE; +@@ -1917,56 +1923,81 @@ copy_unknown_object (bfd *ibfd, bfd *obf + return TRUE; + } + +-/* Returns the number of bytes needed to store VAL. */ +- +-static inline unsigned int +-num_bytes (unsigned long val) +-{ +- unsigned int count = 0; +- +- /* FIXME: There must be a faster way to do this. */ +- while (val) +- { +- count ++; +- val >>= 8; +- } +- return count; +-} +- + typedef struct objcopy_internal_note + { + Elf_Internal_Note note; ++ unsigned long padded_namesz; + bfd_vma start; + bfd_vma end; +- bfd_boolean modified; + } objcopy_internal_note; + +-/* Returns TRUE if a gap does, or could, exist between the address range +- covered by PNOTE1 and PNOTE2. */ ++#define DEBUG_MERGE 0 ++ ++#if DEBUG_MERGE ++#define merge_debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__) ++#else ++#define merge_debug(format, ...) ++#endif ++ ++/* Returns TRUE iff PNOTE1 overlaps or adjoins PNOTE2. */ + + static bfd_boolean +-gap_exists (objcopy_internal_note * pnote1, +- objcopy_internal_note * pnote2) ++overlaps_or_adjoins (objcopy_internal_note * pnote1, ++ objcopy_internal_note * pnote2) + { +- /* Without range end notes, we assume that a gap might exist. */ +- if (pnote1->end == 0 || pnote2->end == 0) ++ if (pnote1->end < pnote2->start) ++ /* FIXME: Alignment of 16 bytes taken from x86_64 binaries. ++ Really we should extract the alignment of the section ++ covered by the notes. */ ++ return BFD_ALIGN (pnote1->end, 16) < pnote2->start; ++ ++ if (pnote2->end < pnote2->start) ++ return BFD_ALIGN (pnote2->end, 16) < pnote1->start; ++ ++ if (pnote1->end < pnote2->end) + return TRUE; + +- /* FIXME: Alignment of 16 bytes taken from x86_64 binaries. +- Really we should extract the alignment of the section covered by the notes. */ +- return BFD_ALIGN (pnote1->end, 16) < pnote2->start; ++ if (pnote2->end < pnote1->end) ++ return TRUE; ++ ++ return FALSE; ++} ++ ++/* Returns TRUE iff NEEDLE is fully contained by HAYSTACK. */ ++ ++static bfd_boolean ++contained_by (objcopy_internal_note * needle, ++ objcopy_internal_note * haystack) ++{ ++ return needle->start >= haystack->start && needle->end <= haystack->end; + } + + static bfd_boolean + is_open_note (objcopy_internal_note * pnote) + { +- return (pnote->note.type == NT_GNU_BUILD_ATTRIBUTE_OPEN); ++ return pnote->note.type == NT_GNU_BUILD_ATTRIBUTE_OPEN; + } + + static bfd_boolean + is_func_note (objcopy_internal_note * pnote) + { +- return (pnote->note.type == NT_GNU_BUILD_ATTRIBUTE_FUNC); ++ return pnote->note.type == NT_GNU_BUILD_ATTRIBUTE_FUNC; ++} ++ ++static bfd_boolean ++is_deleted_note (objcopy_internal_note * pnote) ++{ ++ return pnote->note.type == 0; ++} ++ ++static bfd_boolean ++is_version_note (objcopy_internal_note * pnote) ++{ ++ return (pnote->note.namesz > 4 ++ && pnote->note.namedata[0] == 'G' ++ && pnote->note.namedata[1] == 'A' ++ && pnote->note.namedata[2] == '$' ++ && pnote->note.namedata[3] == GNU_BUILD_ATTRIBUTE_VERSION); + } + + static bfd_boolean +@@ -1979,11 +2010,97 @@ is_64bit (bfd * abfd) + return elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64; + } + ++/* This sorting function is used to get the notes into an order ++ that makes merging easy. */ ++ ++static int ++compare_gnu_build_notes (const void * data1, const void * data2) ++{ ++ objcopy_internal_note * pnote1 = (objcopy_internal_note *) data1; ++ objcopy_internal_note * pnote2 = (objcopy_internal_note *) data2; ++ ++ /* Sort notes based upon the attribute they record. */ ++ int cmp = memcmp (pnote1->note.namedata + 3, ++ pnote2->note.namedata + 3, ++ pnote1->note.namesz < pnote2->note.namesz ? ++ pnote1->note.namesz - 3 : pnote2->note.namesz - 3); ++ if (cmp) ++ return cmp; ++ ++ if (pnote1->end < pnote2->start) ++ return -1; ++ if (pnote1->start > pnote2->end) ++ return 1; ++ ++ /* Overlaps - we should merge the two ranges. */ ++ if (pnote1->start < pnote2->start) ++ return -1; ++ if (pnote1->end > pnote2->end) ++ return 1; ++ ++ /* Put OPEN notes before function notes. */ ++ if (is_open_note (pnote1) && ! is_open_note (pnote2)) ++ return -1; ++ if (! is_open_note (pnote1) && is_open_note (pnote2)) ++ return 1; ++ ++ return 0; ++} ++ ++/* This sorting function is used to get the notes into an order ++ that makes eliminating address ranges easier. */ ++ ++static int ++sort_gnu_build_notes (const void * data1, const void * data2) ++{ ++ objcopy_internal_note * pnote1 = (objcopy_internal_note *) data1; ++ objcopy_internal_note * pnote2 = (objcopy_internal_note *) data2; ++ ++ if (pnote1->note.type != pnote2->note.type) ++ { ++ /* Move deleted notes to the end. */ ++ if (is_deleted_note (pnote1)) /* 1: OFD 2: OFD */ ++ return 1; ++ ++ /* Move OPEN notes to the start. */ ++ if (is_open_note (pnote1)) /* 1: OF 2: OFD */ ++ return -1; ++ ++ if (is_deleted_note (pnote2)) /* 1: F 2: O D */ ++ return -1; ++ ++ return 1; /* 1: F 2: O */ ++ } ++ ++ /* Sort by starting address. */ ++ if (pnote1->start < pnote2->start) ++ return -1; ++ if (pnote1->start > pnote2->start) ++ return 1; ++ ++ /* Then by end address (bigger range first). */ ++ if (pnote1->end > pnote2->end) ++ return -1; ++ if (pnote1->end < pnote2->end) ++ return 1; ++ ++ /* Then by attribute type. */ ++ if (pnote1->note.namesz > 4 ++ && pnote2->note.namesz > 4 ++ && pnote1->note.namedata[3] != pnote2->note.namedata[3]) ++ return pnote1->note.namedata[3] - pnote2->note.namedata[3]; ++ ++ return 0; ++} ++ + /* Merge the notes on SEC, removing redundant entries. + Returns the new, smaller size of the section upon success. */ + + static bfd_size_type +-merge_gnu_build_notes (bfd * abfd, asection * sec, bfd_size_type size, bfd_byte * contents) ++merge_gnu_build_notes (bfd * abfd, ++ asection * sec, ++ bfd_size_type size, ++ bfd_byte * contents) + { + objcopy_internal_note * pnotes_end; + objcopy_internal_note * pnotes = NULL; +@@ -1992,11 +2109,8 @@ merge_gnu_build_notes (bfd * abfd, asect + unsigned version_1_seen = 0; + unsigned version_2_seen = 0; + unsigned version_3_seen = 0; +- bfd_boolean duplicate_found = FALSE; + const char * err = NULL; + bfd_byte * in = contents; +- int attribute_type_byte; +- int val_start; + unsigned long previous_func_start = 0; + unsigned long previous_open_start = 0; + unsigned long previous_func_end = 0; +@@ -2015,20 +2129,33 @@ merge_gnu_build_notes (bfd * abfd, asect + relcount = bfd_canonicalize_reloc (abfd, sec, relpp, isympp); + free (relpp); + if (relcount != 0) +- goto done; ++ { ++ if (! is_strip) ++ non_fatal (_("%s[%s]: Cannot merge - there are relocations against this section"), ++ bfd_get_filename (abfd), bfd_section_name (abfd, sec)); ++ goto done; ++ } + } + + /* Make a copy of the notes and convert to our internal format. + Minimum size of a note is 12 bytes. Also locate the version + notes and check them. */ +- pnote = pnotes = (objcopy_internal_note *) xcalloc ((size / 12), sizeof (* pnote)); ++ pnote = pnotes = (objcopy_internal_note *) ++ xcalloc ((size / 12), sizeof (* pnote)); + while (remain >= 12) + { + bfd_vma start, end; + +- pnote->note.namesz = (bfd_get_32 (abfd, in ) + 3) & ~3; +- pnote->note.descsz = (bfd_get_32 (abfd, in + 4) + 3) & ~3; +- pnote->note.type = bfd_get_32 (abfd, in + 8); ++ pnote->note.namesz = bfd_get_32 (abfd, in); ++ pnote->note.descsz = bfd_get_32 (abfd, in + 4); ++ pnote->note.type = bfd_get_32 (abfd, in + 8); ++ pnote->padded_namesz = (pnote->note.namesz + 3) & ~3; ++ ++ if (((pnote->note.descsz + 3) & ~3) != pnote->note.descsz) ++ { ++ err = _("corrupt GNU build attribute note: description size not a factor of 4"); ++ goto done; ++ } + + if (pnote->note.type != NT_GNU_BUILD_ATTRIBUTE_OPEN + && pnote->note.type != NT_GNU_BUILD_ATTRIBUTE_FUNC) +@@ -2037,7 +2164,7 @@ merge_gnu_build_notes (bfd * abfd, asect + goto done; + } + +- if (pnote->note.namesz + pnote->note.descsz + 12 > remain) ++ if (pnote->padded_namesz + pnote->note.descsz + 12 > remain) + { + err = _("corrupt GNU build attribute note: note too big"); + goto done; +@@ -2050,21 +2177,17 @@ merge_gnu_build_notes (bfd * abfd, asect + } + + pnote->note.namedata = (char *)(in + 12); +- pnote->note.descdata = (char *)(in + 12 + pnote->note.namesz); ++ pnote->note.descdata = (char *)(in + 12 + pnote->padded_namesz); + +- remain -= 12 + pnote->note.namesz + pnote->note.descsz; +- in += 12 + pnote->note.namesz + pnote->note.descsz; ++ remain -= 12 + pnote->padded_namesz + pnote->note.descsz; ++ in += 12 + pnote->padded_namesz + pnote->note.descsz; + + if (pnote->note.namesz > 2 + && pnote->note.namedata[0] == '$' + && pnote->note.namedata[1] == GNU_BUILD_ATTRIBUTE_VERSION + && pnote->note.namedata[2] == '1') + ++ version_1_seen; +- else if (pnote->note.namesz > 4 +- && pnote->note.namedata[0] == 'G' +- && pnote->note.namedata[1] == 'A' +- && pnote->note.namedata[2] == '$' +- && pnote->note.namedata[3] == GNU_BUILD_ATTRIBUTE_VERSION) ++ else if (is_version_note (pnote)) + { + if (pnote->note.namedata[4] == '2') + ++ version_2_seen; +@@ -2170,11 +2293,18 @@ merge_gnu_build_notes (bfd * abfd, asect + + if (version_1_seen == 0 && version_2_seen == 0 && version_3_seen == 0) + { ++#if 0 + err = _("bad GNU build attribute notes: no known versions detected"); + goto done; ++#else ++ /* This happens with glibc. No idea why. */ ++ non_fatal (_("%s[%s]: Warning: version note missing - assuming version 3"), ++ bfd_get_filename (abfd), bfd_section_name (abfd, sec)); ++ version_3_seen = 2; ++#endif + } + +- if ((version_1_seen > 0 && version_2_seen > 0) ++ if ( (version_1_seen > 0 && version_2_seen > 0) + || (version_1_seen > 0 && version_3_seen > 0) + || (version_2_seen > 0 && version_3_seen > 0)) + { +@@ -2182,270 +2312,215 @@ merge_gnu_build_notes (bfd * abfd, asect + goto done; + } + +- /* Merging is only needed if there is more than one version note... */ +- if (version_1_seen == 1 || version_2_seen == 1 || version_3_seen == 1) +- goto done; +- +- attribute_type_byte = version_1_seen ? 1 : 3; +- val_start = attribute_type_byte + 1; +- +- /* We used to require that the first note be a version note, +- but this is no longer enforced. Due to the problems with +- linking sections with the same name (eg .gnu.build.note.hot) +- we cannot guarantee that the first note will be a version note. */ ++ /* We are now only supporting the merging v3+ notes ++ - it makes things much simpler. */ ++ if (version_3_seen == 0) ++ { ++ merge_debug ("%s: skipping merge - not using v3 notes", bfd_section_name (abfd, sec)); ++ goto done; ++ } ++ ++ merge_debug ("Merging section %s which contains %ld notes\n", ++ sec->name, pnotes_end - pnotes); ++ ++ /* Sort the notes. */ ++ qsort (pnotes, pnotes_end - pnotes, sizeof (* pnotes), ++ compare_gnu_build_notes); ++ ++#if DEBUG_MERGE ++ merge_debug ("Results of initial sort:\n"); ++ for (pnote = pnotes; pnote < pnotes_end; pnote ++) ++ merge_debug ("offset %#08lx range %#08lx..%#08lx type %ld attribute %d namesz %ld\n", ++ (pnote->note.namedata - (char *) contents) - 12, ++ pnote->start, pnote->end, ++ pnote->note.type, ++ pnote->note.namedata[3], ++ pnote->note.namesz ++ ); ++#endif + + /* Now merge the notes. The rules are: +- 1. Preserve the ordering of the notes. +- 2. Preserve any NT_GNU_BUILD_ATTRIBUTE_FUNC notes. +- 3. Eliminate any NT_GNU_BUILD_ATTRIBUTE_OPEN notes that have the same +- full name field as the immediately preceeding note with the same type +- of name and whose address ranges coincide. +- IE - if there are gaps in the coverage of the notes, then these gaps +- must be preserved. +- 4. Combine the numeric value of any NT_GNU_BUILD_ATTRIBUTE_OPEN notes +- of type GNU_BUILD_ATTRIBUTE_STACK_SIZE. +- 5. If an NT_GNU_BUILD_ATTRIBUTE_OPEN note is going to be preserved and +- its description field is empty then the nearest preceeding OPEN note +- with a non-empty description field must also be preserved *OR* the +- description field of the note must be changed to contain the starting +- address to which it refers. +- 6. Notes with the same start and end address can be deleted. +- 7. FIXME: Elminate duplicate version notes - even function specific ones ? */ ++ 1. If a note has a zero range, it can be eliminated. ++ 2. If two notes have the same namedata then: ++ 2a. If one note's range is fully covered by the other note ++ then it can be deleted. ++ 2b. If one note's range partially overlaps or adjoins the ++ other note then if they are both of the same type (open ++ or func) then they can be merged and one deleted. If ++ they are of different types then they cannot be merged. */ + for (pnote = pnotes; pnote < pnotes_end; pnote ++) + { +- int note_type; +- objcopy_internal_note * back; +- objcopy_internal_note * prev_open_with_range = NULL; ++ /* Skip already deleted notes. ++ FIXME: Can this happen ? We are scanning forwards and ++ deleting backwards after all. */ ++ if (is_deleted_note (pnote)) ++ continue; + +- /* Rule 6 - delete 0-range notes. */ ++ /* Rule 1 - delete 0-range notes. */ + if (pnote->start == pnote->end) + { +- duplicate_found = TRUE; ++ merge_debug ("Delete note at offset %#08lx - empty range\n", ++ (pnote->note.namedata - (char *) contents) - 12); + pnote->note.type = 0; + continue; + } + +- /* Rule 2 - preserve function notes. */ +- if (! is_open_note (pnote)) +- { +- int iter; +- +- /* Check to see if there is an identical previous function note. +- This can happen with overlays for example. */ +- for (iter = 0, back = pnote -1; back >= pnotes; back --) +- { +- if (back->start == pnote->start +- && back->end == pnote->end +- && back->note.namesz == pnote->note.namesz +- && memcmp (back->note.namedata, pnote->note.namedata, pnote->note.namesz) == 0) +- { +- duplicate_found = TRUE; +- pnote->note.type = 0; +- break; +- } +- +- /* Don't scan too far back however. */ +- if (iter ++ > 16) +- break; +- } +- continue; +- } +- +- note_type = pnote->note.namedata[attribute_type_byte]; +- +- /* Scan backwards from pnote, looking for duplicates. +- Clear the type field of any found - but do not delete them just yet. */ +- for (back = pnote - 1; back >= pnotes; back --) +- { +- int back_type = back->note.namedata[attribute_type_byte]; +- +- /* If this is the first open note with an address +- range that we have encountered then record it. */ +- if (prev_open_with_range == NULL +- && back->note.descsz > 0 +- && ! is_func_note (back)) +- prev_open_with_range = back; ++ int iter; ++ objcopy_internal_note * back; + +- if (! is_open_note (back)) +- continue; +- +- /* If the two notes are different then keep on searching. */ +- if (back_type != note_type) ++ /* Rule 2: Check to see if there is an identical previous note. */ ++ for (iter = 0, back = pnote - 1; back >= pnotes; back --) ++ { ++ if (is_deleted_note (back)) + continue; + +- /* Rule 4 - combine stack size notes. */ +- if (back_type == GNU_BUILD_ATTRIBUTE_STACK_SIZE) ++ /* Our sorting function should have placed all identically ++ attributed notes together, so if we see a note of a different ++ attribute type stop searching. */ ++ if (back->note.namesz != pnote->note.namesz ++ || memcmp (back->note.namedata, ++ pnote->note.namedata, pnote->note.namesz) != 0) ++ break; ++ ++ if (back->start == pnote->start ++ && back->end == pnote->end) + { +- unsigned char * name; +- unsigned long note_val; +- unsigned long back_val; +- unsigned int shift; +- unsigned int bytes; +- unsigned long byte; +- +- for (shift = 0, note_val = 0, +- bytes = pnote->note.namesz - val_start, +- name = (unsigned char *) pnote->note.namedata + val_start; +- bytes--;) +- { +- byte = (* name ++) & 0xff; +- note_val |= byte << shift; +- shift += 8; +- } +- +- for (shift = 0, back_val = 0, +- bytes = back->note.namesz - val_start, +- name = (unsigned char *) back->note.namedata + val_start; +- bytes--;) +- { +- byte = (* name ++) & 0xff; +- back_val |= byte << shift; +- shift += 8; +- } +- +- back_val += note_val; +- if (num_bytes (back_val) >= back->note.namesz - val_start) +- { +- /* We have a problem - the new value requires more bytes of +- storage in the name field than are available. Currently +- we have no way of fixing this, so we just preserve both +- notes. */ +- continue; +- } +- +- /* Write the new val into back. */ +- name = (unsigned char *) back->note.namedata + val_start; +- while (name < (unsigned char *) back->note.namedata +- + back->note.namesz) +- { +- byte = back_val & 0xff; +- * name ++ = byte; +- if (back_val == 0) +- break; +- back_val >>= 8; +- } +- +- duplicate_found = TRUE; ++ merge_debug ("Delete note at offset %#08lx - duplicate of note at offset %#08lx\n", ++ (pnote->note.namedata - (char *) contents) - 12, ++ (back->note.namedata - (char *) contents) - 12); + pnote->note.type = 0; + break; + } + +- /* Rule 3 - combine identical open notes. */ +- if (back->note.namesz == pnote->note.namesz +- && memcmp (back->note.namedata, +- pnote->note.namedata, back->note.namesz) == 0 +- && ! gap_exists (back, pnote)) ++ /* Rule 2a. */ ++ if (contained_by (pnote, back)) + { +- duplicate_found = TRUE; ++ merge_debug ("Delete note at offset %#08lx - fully contained by note at %#08lx\n", ++ (pnote->note.namedata - (char *) contents) - 12, ++ (back->note.namedata - (char *) contents) - 12); + pnote->note.type = 0; ++ break; ++ } + +- if (pnote->end > back->end) +- back->end = pnote->end; ++#if DEBUG_MERGE ++ /* This should not happen as we have sorted the ++ notes with earlier starting addresses first. */ ++ if (contained_by (back, pnote)) ++ merge_debug ("ERROR: UNEXPECTED CONTAINMENT\n"); ++#endif ++ ++ /* Rule 2b. */ ++ if (overlaps_or_adjoins (back, pnote) ++ && is_func_note (back) == is_func_note (pnote)) ++ { ++ merge_debug ("Delete note at offset %#08lx - merge into note at %#08lx\n", ++ (pnote->note.namedata - (char *) contents) - 12, ++ (back->note.namedata - (char *) contents) - 12); + +- if (version_3_seen) +- back->modified = TRUE; ++ back->end = back->end > pnote->end ? back->end : pnote->end; ++ back->start = back->start < pnote->start ? back->start : pnote->start; ++ pnote->note.type = 0; + break; + } + +- /* Rule 5 - Since we are keeping this note we must check to see +- if its description refers back to an earlier OPEN version +- note that has been scheduled for deletion. If so then we +- must make sure that version note is also preserved. */ +- if (version_3_seen) +- { +- /* As of version 3 we can just +- move the range into the note. */ +- pnote->modified = TRUE; +- pnote->note.type = NT_GNU_BUILD_ATTRIBUTE_FUNC; +- back->modified = TRUE; +- back->note.type = NT_GNU_BUILD_ATTRIBUTE_FUNC; +- } +- else ++ /* Don't scan too far back however. */ ++ if (iter ++ > 16) + { +- if (pnote->note.descsz == 0 +- && prev_open_with_range != NULL +- && prev_open_with_range->note.type == 0) +- prev_open_with_range->note.type = NT_GNU_BUILD_ATTRIBUTE_OPEN; ++ /* FIXME: Not sure if this can ever be triggered. */ ++ merge_debug ("ITERATION LIMIT REACHED\n"); ++ break; + } +- +- /* We have found a similar attribute but the details do not match. +- Stop searching backwards. */ +- break; + } +- } +- +- if (duplicate_found) +- { +- bfd_byte * new_contents; +- bfd_byte * old; +- bfd_byte * new; +- bfd_size_type new_size; +- bfd_vma prev_start = 0; +- bfd_vma prev_end = 0; +- +- /* Eliminate the duplicates. */ +- new = new_contents = xmalloc (size); +- for (pnote = pnotes, old = contents; +- pnote < pnotes_end; +- pnote ++) +- { +- bfd_size_type note_size = 12 + pnote->note.namesz + pnote->note.descsz; +- +- if (pnote->note.type != 0) ++#if DEBUG_MERGE ++ if (! is_deleted_note (pnote)) ++ merge_debug ("Unable to do anything with note at %#08lx\n", ++ (pnote->note.namedata - (char *) contents) - 12); ++#endif ++ } ++ ++ /* Resort the notes. */ ++ merge_debug ("Final sorting of notes\n"); ++ qsort (pnotes, pnotes_end - pnotes, sizeof (* pnotes), sort_gnu_build_notes); ++ ++ /* Reconstruct the ELF notes. */ ++ bfd_byte * new_contents; ++ bfd_byte * old; ++ bfd_byte * new; ++ bfd_size_type new_size; ++ bfd_vma prev_start = 0; ++ bfd_vma prev_end = 0; ++ ++ new = new_contents = xmalloc (size); ++ for (pnote = pnotes, old = contents; ++ pnote < pnotes_end; ++ pnote ++) ++ { ++ bfd_size_type note_size = 12 + pnote->padded_namesz + pnote->note.descsz; ++ ++ if (! is_deleted_note (pnote)) ++ { ++ /* Create the note, potentially using the ++ address range of the previous note. */ ++ if (pnote->start == prev_start && pnote->end == prev_end) ++ { ++ bfd_put_32 (abfd, pnote->note.namesz, new); ++ bfd_put_32 (abfd, 0, new + 4); ++ bfd_put_32 (abfd, pnote->note.type, new + 8); ++ new += 12; ++ memcpy (new, pnote->note.namedata, pnote->note.namesz); ++ if (pnote->note.namesz < pnote->padded_namesz) ++ memset (new + pnote->note.namesz, 0, pnote->padded_namesz - pnote->note.namesz); ++ new += pnote->padded_namesz; ++ } ++ else + { +- if (pnote->modified) ++ bfd_put_32 (abfd, pnote->note.namesz, new); ++ bfd_put_32 (abfd, is_64bit (abfd) ? 16 : 8, new + 4); ++ bfd_put_32 (abfd, pnote->note.type, new + 8); ++ new += 12; ++ memcpy (new, pnote->note.namedata, pnote->note.namesz); ++ if (pnote->note.namesz < pnote->padded_namesz) ++ memset (new + pnote->note.namesz, 0, pnote->padded_namesz - pnote->note.namesz); ++ new += pnote->padded_namesz; ++ if (is_64bit (abfd)) + { +- /* If the note has been modified then we must copy it by +- hand, potentially adding in a new description field. */ +- if (pnote->start == prev_start && pnote->end == prev_end) +- { +- bfd_put_32 (abfd, pnote->note.namesz, new); +- bfd_put_32 (abfd, 0, new + 4); +- bfd_put_32 (abfd, pnote->note.type, new + 8); +- new += 12; +- memcpy (new, pnote->note.namedata, pnote->note.namesz); +- new += pnote->note.namesz; +- } +- else +- { +- bfd_put_32 (abfd, pnote->note.namesz, new); +- bfd_put_32 (abfd, is_64bit (abfd) ? 16 : 8, new + 4); +- bfd_put_32 (abfd, pnote->note.type, new + 8); +- new += 12; +- memcpy (new, pnote->note.namedata, pnote->note.namesz); +- new += pnote->note.namesz; +- if (is_64bit (abfd)) +- { +- bfd_put_64 (abfd, pnote->start, new); +- bfd_put_64 (abfd, pnote->end, new + 8); +- new += 16; +- } +- else +- { +- bfd_put_32 (abfd, pnote->start, new); +- bfd_put_32 (abfd, pnote->end, new + 4); +- new += 8; +- } +- } ++ bfd_put_64 (abfd, pnote->start, new); ++ bfd_put_64 (abfd, pnote->end, new + 8); ++ new += 16; + } + else + { +- memcpy (new, old, note_size); +- new += note_size; ++ bfd_put_32 (abfd, pnote->start, new); ++ bfd_put_32 (abfd, pnote->end, new + 4); ++ new += 8; + } ++ + prev_start = pnote->start; + prev_end = pnote->end; + } +- +- old += note_size; + } + +- new_size = new - new_contents; +- memcpy (contents, new_contents, new_size); +- size = new_size; +- free (new_contents); ++ old += note_size; + } + ++#if DEBUG_MERGE ++ merge_debug ("Results of merge:\n"); ++ for (pnote = pnotes; pnote < pnotes_end; pnote ++) ++ if (! is_deleted_note (pnote)) ++ merge_debug ("offset %#08lx range %#08lx..%#08lx type %ld attribute %d namesz %ld\n", ++ (pnote->note.namedata - (char *) contents) - 12, ++ pnote->start, pnote->end, ++ pnote->note.type, ++ pnote->note.namedata[3], ++ pnote->note.namesz ++ ); ++#endif ++ ++ new_size = new - new_contents; ++ memcpy (contents, new_contents, new_size); ++ size = new_size; ++ free (new_contents); ++ + done: + if (err) + { +@@ -2784,52 +2859,61 @@ copy_object (bfd *ibfd, bfd *obfd, const + } + } + ++ merged_note_section * merged_note_sections = NULL; + if (merge_notes) + { + /* This palaver is necessary because we must set the output + section size first, before its contents are ready. */ +- osec = bfd_get_section_by_name (ibfd, GNU_BUILD_ATTRS_SECTION_NAME); +- if (osec && is_merged_note_section (ibfd, osec)) ++ for (osec = ibfd->sections; osec != NULL; osec = osec->next) + { +- bfd_size_type size; +- +- size = bfd_get_section_size (osec); ++ if (! is_mergeable_note_section (ibfd, osec)) ++ continue; ++ ++ bfd_size_type size = bfd_section_size (ibfd, osec); + if (size == 0) + { +- bfd_nonfatal_message (NULL, ibfd, osec, _("warning: note section is empty")); +- merge_notes = FALSE; ++ bfd_nonfatal_message (NULL, ibfd, osec, ++ _("warning: note section is empty")); ++ continue; + } +- else if (! bfd_get_full_section_contents (ibfd, osec, & merged_notes)) ++ ++ merged_note_section * merged = xmalloc (sizeof * merged); ++ merged->contents = NULL; ++ if (! bfd_get_full_section_contents (ibfd, osec, & merged->contents)) + { +- bfd_nonfatal_message (NULL, ibfd, osec, _("warning: could not load note section")); +- free (merged_notes); +- merged_notes = NULL; +- merge_notes = FALSE; ++ bfd_nonfatal_message (NULL, ibfd, osec, ++ _("warning: could not load note section")); ++ free (merged->contents); ++ free (merged); ++ continue; + } +- else ++ ++ merged->size = merge_gnu_build_notes (ibfd, osec, size, ++ merged->contents); ++ if (merged->size == size) ++ { ++ /* Merging achieves nothing. */ ++ merge_debug ("Merge of section %s achieved nothing - skipping\n", ++ bfd_section_name (obfd, osec)); ++ free (merged->contents); ++ free (merged); ++ continue; ++ } ++ ++ if (osec->output_section == NULL ++ || !bfd_set_section_size (obfd, osec->output_section, merged->size)) + { +- merged_size = merge_gnu_build_notes (ibfd, osec, size, merged_notes); +- if (merged_size == size) +- { +- /* Merging achieves nothing. */ +- free (merged_notes); +- merged_notes = NULL; +- merge_notes = FALSE; +- merged_size = 0; +- } +- else +- { +- if (osec->output_section == NULL +- || ! bfd_set_section_size (obfd, osec->output_section, merged_size)) +- { +- bfd_nonfatal_message (NULL, obfd, osec, _("warning: failed to set merged notes size")); +- free (merged_notes); +- merged_notes = NULL; +- merge_notes = FALSE; +- merged_size = 0; +- } +- } ++ bfd_nonfatal_message (NULL, obfd, osec, ++ _("warning: failed to set merged notes size")); ++ free (merged->contents); ++ free (merged); ++ continue; + } ++ ++ /* Add section to list of merged sections. */ ++ merged->sec = osec; ++ merged->next = merged_note_sections; ++ merged_note_sections = merged; + } + } + +@@ -3155,23 +3239,72 @@ copy_object (bfd *ibfd, bfd *obfd, const + } + } + +- if (merge_notes) ++ if (merged_note_sections != NULL) + { +- osec = bfd_get_section_by_name (obfd, GNU_BUILD_ATTRS_SECTION_NAME); +- if (osec && is_merged_note_section (obfd, osec)) ++ merged_note_section * merged = NULL; ++ ++ for (osec = obfd->sections; osec != NULL; osec = osec->next) + { +- if (! bfd_set_section_contents (obfd, osec, merged_notes, 0, merged_size)) ++ if (! is_mergeable_note_section (obfd, osec)) ++ continue; ++ ++ if (merged == NULL) ++ merged = merged_note_sections; ++ ++ /* It is likely that output sections are in the same order ++ as the input sections, but do not assume that this is ++ the case. */ ++ if (strcmp (bfd_section_name (obfd, merged->sec), ++ bfd_section_name (obfd, osec)) != 0) ++ { ++ for (merged = merged_note_sections; ++ merged != NULL; ++ merged = merged->next) ++ if (strcmp (bfd_section_name (obfd, merged->sec), ++ bfd_section_name (obfd, osec)) == 0) ++ break; ++ ++ if (merged == NULL) ++ { ++ bfd_nonfatal_message ++ (NULL, obfd, osec, ++ _("error: failed to copy merged notes into output")); ++ continue; ++ } ++ } ++ ++ if (! is_mergeable_note_section (obfd, osec)) ++ { ++ bfd_nonfatal_message ++ (NULL, obfd, osec, ++ _("error: failed to copy merged notes into output")); ++ continue; ++ } ++ ++ if (! bfd_set_section_contents (obfd, osec, merged->contents, 0, ++ merged->size)) + { +- bfd_nonfatal_message (NULL, obfd, osec, _("error: failed to copy merged notes into output")); ++ bfd_nonfatal_message ++ (NULL, obfd, osec, ++ _("error: failed to copy merged notes into output")); + return FALSE; + } ++ ++ merged = merged->next; ++ } ++ ++ /* Free the memory. */ ++ merged_note_section * next; ++ for (merged = merged_note_sections; merged != NULL; merged = next) ++ { ++ next = merged->next; ++ free (merged->contents); ++ free (merged); + } +- else if (! is_strip) +- bfd_nonfatal_message (NULL, obfd, osec, _("could not find any mergeable note sections")); +- free (merged_notes); +- merged_notes = NULL; +- merge_notes = FALSE; + } ++ else if (merge_notes && ! is_strip) ++ non_fatal (_("%s: Could not find any mergeable note sections"), ++ bfd_get_filename (ibfd)); + + if (gnu_debuglink_filename != NULL) + { +@@ -3962,7 +4095,7 @@ skip_section (bfd *ibfd, sec_ptr isectio + + /* When merging a note section we skip the copying of the contents, + but not the copying of the relocs associated with the contents. */ +- if (skip_copy && is_merged_note_section (ibfd, isection)) ++ if (skip_copy && is_mergeable_note_section (ibfd, isection)) + return TRUE; + + flags = bfd_get_section_flags (ibfd, isection); +diff -rupN binutils.orig/binutils/testsuite/binutils-all/note-2-32.d binutils-2.33.1/binutils/testsuite/binutils-all/note-2-32.d +--- binutils.orig/binutils/testsuite/binutils-all/note-2-32.d 2019-10-28 11:01:40.448071260 +0000 ++++ binutils-2.33.1/binutils/testsuite/binutils-all/note-2-32.d 2019-10-28 11:01:52.413985684 +0000 +@@ -6,12 +6,11 @@ + + #... + [ ]+Owner[ ]+Data size[ ]+Description +-[ ]+\$1[ ]+0x00000004[ ]+OPEN[ ]+Applies to region from 0x100 \(note1.s\) +-[ ]+\$gcc 7.0.1[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 +-[ ]+\+true[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 +-[ ]+\*static[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 +-[ ]+\*0x0[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 +-[ ]+\$1[ ]+0x00000004[ ]+OPEN[ ]+Applies to region from 0x104 \(note2.s\) +-[ ]+!false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x104 +-[ ]+\*pic[ ]+0x00000004[ ]+func[ ]+Applies to region from 0x104 \(func1\) ++[ ]+GA\$3p1[ ]+0x00000008[ ]+OPEN[ ]+Applies to region from 0x100 to 0x10b \(note1.s\) ++[ ]+GA\$gcc 7.0.1[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x10b ++[ ]+GA\*0x0[ ]+0x00000008[ ]+OPEN[ ]+Applies to region from 0x100 to 0x108 \(note1.s\) ++[ ]+GA\+true[ ]+0x00000008[ ]+OPEN[ ]+Applies to region from 0x100 to 0x104 \(note1.s\) ++[ ]+GA\*static[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x104 ++[ ]+GA!false[ ]+0x00000008[ ]+OPEN[ ]+Applies to region from 0x104 to 0x108 \(note2.s\) ++[ ]+GA\*pic[ ]+0x00000008[ ]+func[ ]+Applies to region from 0x104 to 0x106 \(func1\) + #... +diff -rupN binutils.orig/binutils/testsuite/binutils-all/note-2-32.s binutils-2.33.1/binutils/testsuite/binutils-all/note-2-32.s +--- binutils.orig/binutils/testsuite/binutils-all/note-2-32.s 2019-10-28 11:01:40.454071217 +0000 ++++ binutils-2.33.1/binutils/testsuite/binutils-all/note-2-32.s 2019-10-28 11:01:52.413985684 +0000 +@@ -6,32 +6,37 @@ note1.s: + + .pushsection .gnu.build.attributes, "0x100000", %note + .balign 4 +- .dc.l 4 +- .dc.l 4 ++ .dc.l 8 ++ .dc.l 8 + .dc.l 0x100 +- .asciz "$1" ++ .asciz "GA$3p1" + .dc.l 0x100 ++ .dc.l 0x104 + +- .dc.l 12 ++ .dc.l 14 + .dc.l 0 + .dc.l 0x100 +- .asciz "$gcc 7.0.1" ++ .asciz "GA$gcc 7.0.1" ++ .dc.b 0,0 + +- .dc.l 3 ++ .dc.l 5 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2b, 0x2, 0 +- .dc.b 0 ++ .dc.b 0x47, 0x41, 0x2b, 0x2, 0 ++ .dc.b 0,0,0 + +- .dc.l 4 ++ .dc.l 6 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2a, 0x7, 0, 0 ++ .dc.b 0x47, 0x41, 0x2a, 0x7, 0, 0 ++ .dc.b 0,0 + +- .dc.l 4 ++ .dc.l 6 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2a, 0x6, 0, 0 ++ .dc.b 0x47, 0x41, 0x2a, 0x6, 0, 0 ++ .dc.b 0,0 ++ + .popsection + + +@@ -42,33 +47,38 @@ func1: + .dc.l 0x100 + + .pushsection .gnu.build.attributes, "0x100000", %note +- .dc.l 4 +- .dc.l 4 ++ .dc.l 8 ++ .dc.l 8 + .dc.l 0x100 +- .asciz "$1" ++ .asciz "GA$3p1" + .dc.l 0x104 +- +- .dc.l 12 ++ .dc.l 0x108 ++ ++ .dc.l 14 + .dc.l 0 + .dc.l 0x100 +- .asciz "$gcc 7.0.1" ++ .asciz "GA$gcc 7.0.1" ++ .dc.b 0,0 + +- .dc.l 3 ++ .dc.l 5 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x21, 0x2, 0 +- .dc.b 0 ++ .dc.b 0x47, 0x41, 0x21, 0x2, 0 ++ .dc.b 0,0,0 + +- .dc.l 4 +- .dc.l 4 ++ .dc.l 6 ++ .dc.l 8 + .dc.l 0x101 +- .dc.b 0x2a, 0x7, 1, 0 +- .dc.l 0x104 ++ .dc.b 0x47, 0x41, 0x2a, 0x7, 1, 0 ++ .dc.b 0,0 ++ .dc.l 0x104 ++ .dc.l 0x106 + +- .dc.l 4 ++ .dc.l 6 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2a, 0x6, 0, 0 ++ .dc.b 0x47, 0x41, 0x2a, 0x6, 0, 0 ++ .dc.b 0,0 + .popsection + + +@@ -77,16 +87,18 @@ note3.s: + .dc.l 0x100 + + .pushsection .gnu.build.attributes, "0x100000", %note +- .dc.l 4 +- .dc.l 4 ++ .dc.l 8 ++ .dc.l 8 + .dc.l 0x100 +- .asciz "$1" ++ .asciz "GA$3p1" + .dc.l 0x108 ++ .dc.l 0x10b + +- .dc.l 12 ++ .dc.l 14 + .dc.l 0 + .dc.l 0x100 +- .asciz "$gcc 7.0.1" ++ .asciz "GA$gcc 7.0.1" ++ .dc.b 0,0 + + .popsection + +diff -rupN binutils.orig/binutils/testsuite/binutils-all/note-2-64.d binutils-2.33.1/binutils/testsuite/binutils-all/note-2-64.d +--- binutils.orig/binutils/testsuite/binutils-all/note-2-64.d 2019-10-28 11:01:40.449071253 +0000 ++++ binutils-2.33.1/binutils/testsuite/binutils-all/note-2-64.d 2019-10-28 11:01:52.414985677 +0000 +@@ -10,12 +10,11 @@ + + #... + [ ]+Owner[ ]+Data size[ ]+Description +-[ ]+\$1[ ]+0x00000008[ ]+OPEN[ ]+Applies to region from 0x100 \(note1.s\) +-[ ]+\$gcc 7.0.1[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 +-[ ]+\+true[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 +-[ ]+\*static[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 +-[ ]+\*0x0[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 +-[ ]+\$1[ ]+0x00000008[ ]+OPEN[ ]+Applies to region from 0x104 \(note2.s\) +-[ ]+!false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x104 +-[ ]+\*pic[ ]+0x00000008[ ]+func[ ]+Applies to region from 0x104 \(func1\) ++[ ]+GA\$3p1[ ]+0x00000010[ ]+OPEN[ ]+Applies to region from 0x100 to 0x10b \(note1.s\) ++[ ]+GA\$gcc 7.0.1[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x10b ++[ ]+GA\*0x0[ ]+0x00000010[ ]+OPEN[ ]+Applies to region from 0x100 to 0x108 \(note1.s\) ++[ ]+GA\+true[ ]+0x00000010[ ]+OPEN[ ]+Applies to region from 0x100 to 0x104 \(note1.s\) ++[ ]+GA\*static[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x104 ++[ ]+GA!false[ ]+0x00000010[ ]+OPEN[ ]+Applies to region from 0x104 to 0x108 \(note2.s\) ++[ ]+GA\*pic[ ]+0x00000010[ ]+func[ ]+Applies to region from 0x104 to 0x106 \(func1\) + #... +diff -rupN binutils.orig/binutils/testsuite/binutils-all/note-2-64.s binutils-2.33.1/binutils/testsuite/binutils-all/note-2-64.s +--- binutils.orig/binutils/testsuite/binutils-all/note-2-64.s 2019-10-28 11:01:40.452071232 +0000 ++++ binutils-2.33.1/binutils/testsuite/binutils-all/note-2-64.s 2019-10-28 11:01:52.414985677 +0000 +@@ -6,32 +6,43 @@ note1.s: + + .pushsection .gnu.build.attributes, "0x100000", %note + .balign 4 +- .dc.l 4 + .dc.l 8 ++ .dc.l 16 + .dc.l 0x100 +- .asciz "$1" ++ .asciz "GA$3p1" + .8byte 0x100 ++ .8byte 0x104 + +- .dc.l 12 ++ .dc.l 14 + .dc.l 0 + .dc.l 0x100 +- .asciz "$gcc 7.0.1" ++ .asciz "GA$gcc 7.0.1" ++ .dc.b 0,0 ++ ++ .dc.l 5 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2b, 0x2, 0 ++ .dc.b 0,0,0 + +- .dc.l 3 ++ .dc.l 6 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2b, 0x2, 0 +- .dc.b 0 ++ .dc.b 0x47, 0x41, 0x2a, 0x7, 0, 0 ++ .dc.b 0,0 + +- .dc.l 4 ++ .dc.l 6 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2a, 0x7, 0, 0 ++ .dc.b 0x47, 0x41, 0x2a, 0x6, 0, 0 ++ .dc.b 0,0 + +- .dc.l 4 ++ .dc.l 6 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2a, 0x6, 0, 0 ++ .dc.b 0x47, 0x41, 0x2a, 0x7, 0, 0 ++ .dc.b 0,0 ++ + .popsection + + +@@ -43,33 +54,38 @@ func1: + .dc.l 0x100 + + .pushsection .gnu.build.attributes, "0x100000", %note +- .dc.l 4 +- .dc.l 8 ++ .dc.l 8 ++ .dc.l 16 + .dc.l 0x100 +- .asciz "$1" ++ .asciz "GA$3p1" + .8byte 0x104 ++ .8byte 0x108 + +- .dc.l 12 ++ .dc.l 14 + .dc.l 0 + .dc.l 0x100 +- .asciz "$gcc 7.0.1" +- +- .dc.l 3 ++ .asciz "GA$gcc 7.0.1" ++ .dc.b 0,0 ++ ++ .dc.l 5 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x21, 0x2, 0 +- .dc.b 0 ++ .dc.b 0x47, 0x41, 0x21, 0x2, 0 ++ .dc.b 0,0,7 + +- .dc.l 4 +- .dc.l 8 ++ .dc.l 6 ++ .dc.l 16 + .dc.l 0x101 +- .dc.b 0x2a, 0x7, 1, 0 ++ .dc.b 0x47, 0x41, 0x2a, 0x7, 1, 0 ++ .dc.b 0,0 + .8byte 0x104 ++ .8byte 0x106 + +- .dc.l 4 ++ .dc.l 6 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2a, 0x6, 0, 0 ++ .dc.b 0x47, 0x41, 0x2a, 0x6, 0, 0 ++ .dc.b 0,0 + .popsection + + +@@ -78,15 +94,17 @@ note3.s: + .dc.l 0x100 + + .pushsection .gnu.build.attributes, "0x100000", %note +- .dc.l 4 +- .dc.l 8 ++ .dc.l 8 ++ .dc.l 16 + .dc.l 0x100 +- .asciz "$1" ++ .asciz "GA$3p1" + .8byte 0x108 ++ .8byte 0x10b + +- .dc.l 12 ++ .dc.l 14 + .dc.l 0 + .dc.l 0x100 +- .asciz "$gcc 7.0.1" ++ .asciz "GA$gcc 7.0.1" ++ .dc.b 0,0 + + .popsection +diff -rupN binutils.orig/binutils/testsuite/binutils-all/note-3-32.d binutils-2.33.1/binutils/testsuite/binutils-all/note-3-32.d +--- binutils.orig/binutils/testsuite/binutils-all/note-3-32.d 2019-10-28 11:01:40.456071203 +0000 ++++ binutils-2.33.1/binutils/testsuite/binutils-all/note-3-32.d 2019-10-28 11:01:52.414985677 +0000 +@@ -7,12 +7,12 @@ + #... + Displaying notes found in: .gnu.build.attributes + [ ]+Owner[ ]+Data size[ ]+Description +-[ ]+GA\$2p1[ ]+0x0000000.[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 \(note_1.s\) +-[ ]+GA\$gcc 6.3.1 20161221[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 +-[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 ++[ ]+GA\$3p1[ ]+0x0000000.[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 \(note_1.s\) + [ ]+GA\*off[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 +-[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 ++[ ]+GA\$gcc 6.3.1 20161221[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 ++[ ]+GA\*0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 + [ ]+GA\*PIC[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 + [ ]+GA\!false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 +-[ ]+GA\*0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 ++[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 ++[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 + #... +diff -rupN binutils.orig/binutils/testsuite/binutils-all/note-3-32.s binutils-2.33.1/binutils/testsuite/binutils-all/note-3-32.s +--- binutils.orig/binutils/testsuite/binutils-all/note-3-32.s 2019-10-28 11:01:40.451071238 +0000 ++++ binutils-2.33.1/binutils/testsuite/binutils-all/note-3-32.s 2019-10-28 11:01:52.414985677 +0000 +@@ -9,10 +9,11 @@ note_1.s: + .balign 4 + + .dc.l 8 +- .dc.l 4 ++ .dc.l 8 + .dc.l 0x100 +- .asciz "GA$2p1" +- .dc.l note_1.s ++ .asciz "GA$3p1" ++ .dc.l 0x100 /* note_1.s */ ++ .dc.l 0x122 /* note_1.s end */ + + .dc.l 23 + .dc.l 0 +@@ -55,4 +56,12 @@ note_1.s: + .dc.l 0x100 + .dc.b 0x47, 0x41, 0x2a, 0x6, 0xf2, 0x3, 0x38, 0xee, 0xce, 0xfa, 0x5e, 0x3c, 0 + .dc.b 0, 0, 0 ++ ++ .dc.l 5 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x21, 0x8, 0 ++ .dc.b 0, 0, 0 ++ ++ + .popsection +diff -rupN binutils.orig/binutils/testsuite/binutils-all/note-3-64.d binutils-2.33.1/binutils/testsuite/binutils-all/note-3-64.d +--- binutils.orig/binutils/testsuite/binutils-all/note-3-64.d 2019-10-28 11:01:40.452071232 +0000 ++++ binutils-2.33.1/binutils/testsuite/binutils-all/note-3-64.d 2019-10-28 11:01:52.414985677 +0000 +@@ -7,12 +7,12 @@ + #... + Displaying notes found in: .gnu.build.attributes + [ ]+Owner[ ]+Data size[ ]+Description +-[ ]+GA\$2p1[ ]+0x0000000.[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 \(note_1.s\) +-[ ]+GA\$gcc 6.3.1 20161221[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 +-[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 ++[ ]+GA\$3p1[ ]+0x00000010[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 \(note_1.s\) + [ ]+GA\*off[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 +-[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 ++[ ]+GA\$gcc 6.3.1 20161221[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 ++[ ]+GA\*0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 + [ ]+GA\*PIC[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 + [ ]+GA\!false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 +-[ ]+GA\*0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 ++[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 ++[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 + #... +diff -rupN binutils.orig/binutils/testsuite/binutils-all/note-3-64.s binutils-2.33.1/binutils/testsuite/binutils-all/note-3-64.s +--- binutils.orig/binutils/testsuite/binutils-all/note-3-64.s 2019-10-28 11:01:40.450071246 +0000 ++++ binutils-2.33.1/binutils/testsuite/binutils-all/note-3-64.s 2019-10-28 11:01:52.414985677 +0000 +@@ -9,10 +9,11 @@ note_1.s: + .balign 4 + + .dc.l 8 +- .dc.l 8 ++ .dc.l 16 + .dc.l 0x100 +- .asciz "GA$2p1" +- .8byte note_1.s ++ .asciz "GA$3p1" ++ .8byte 0x100 /* note_1.s */ ++ .8byte 0x122 /* note_1 end */ + + .dc.l 23 + .dc.l 0 +@@ -55,4 +56,11 @@ note_1.s: + .dc.l 0x100 + .dc.b 0x47, 0x41, 0x2a, 0x6, 0xf2, 0x3, 0x38, 0xee, 0xce, 0xfa, 0x5e, 0x3c, 0 + .dc.b 0, 0, 0 ++ ++ .dc.l 6 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x7, 0x2, 0 ++ .dc.b 0, 0 ++ + .popsection +diff -rupN binutils.orig/binutils/testsuite/binutils-all/note-4-32.d binutils-2.33.1/binutils/testsuite/binutils-all/note-4-32.d +--- binutils.orig/binutils/testsuite/binutils-all/note-4-32.d 2019-10-28 11:01:40.453071224 +0000 ++++ binutils-2.33.1/binutils/testsuite/binutils-all/note-4-32.d 2019-10-28 11:01:52.414985677 +0000 +@@ -8,12 +8,12 @@ + Displaying notes found in: .gnu.build.attributes + [ ]+Owner[ ]+Data size[ ]+Description + [ ]+GA\$3p3[ ]+0x00000008[ ]+OPEN[ ]+Applies to region from 0x10. to 0x110 \(note_4.s\) +-[ ]+GA\$gcc 7.2.1 20170915[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x10. to 0x110 +-[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x10. to 0x110 + [ ]+GA\*off[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x10. to 0x110 +-[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x10. to 0x110 ++[ ]+GA\$gcc 7.2.1 20170915[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x10. to 0x110 ++[ ]+GA\*0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x10. to 0x110 + [ ]+GA\*PIC[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x10. to 0x110 + [ ]+GA\!false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x10. to 0x110 +-[ ]+GA\*0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x10. to 0x110 ++[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x10. to 0x110 ++[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x10. to 0x110 + [ ]+GA\*strong[ ]+0x00000008[ ]+func[ ]+Applies to region from 0x10. to 0x10c.* + #... +diff -rupN binutils.orig/binutils/testsuite/binutils-all/note-4-32.s binutils-2.33.1/binutils/testsuite/binutils-all/note-4-32.s +--- binutils.orig/binutils/testsuite/binutils-all/note-4-32.s 2019-10-28 11:01:40.448071260 +0000 ++++ binutils-2.33.1/binutils/testsuite/binutils-all/note-4-32.s 2019-10-28 11:01:52.414985677 +0000 +@@ -18,8 +18,8 @@ note_4.s_end: + .dc.l 8 + .dc.l 0x100 + .asciz "GA$3p3" +- .dc.l note_4.s - 2 +- .dc.l note_4.s_end ++ .dc.l 0x100 /* note_4.s - 2 */ ++ .dc.l 0x110 /* note_4.s_end */ + + .dc.l 23 + .dc.l 0 +@@ -63,12 +63,18 @@ note_4.s_end: + .dc.b 0x47, 0x41, 0x2a, 0x6, 0xf2, 0x3, 0x38, 0xee, 0xce, 0xfa, 0x5e, 0x3c, 0 + .dc.b 0, 0, 0 + ++ .dc.l 5 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x21, 0x8, 0 ++ .dc.b 0, 0, 0 ++ + .dc.l 6 + .dc.l 8 + .dc.l 0x101 + .dc.b 0x47, 0x41, 0x2a, 0x2, 0x3, 0 + .dc.b 0, 0 +- .dc.l bar +- .dc.l bar_end ++ .dc.l 0x108 /* bar */ ++ .dc.l 0x10c /* bar_end */ + + .popsection +diff -rupN binutils.orig/binutils/testsuite/binutils-all/note-4-64.d binutils-2.33.1/binutils/testsuite/binutils-all/note-4-64.d +--- binutils.orig/binutils/testsuite/binutils-all/note-4-64.d 2019-10-28 11:01:40.448071260 +0000 ++++ binutils-2.33.1/binutils/testsuite/binutils-all/note-4-64.d 2019-10-28 11:01:52.414985677 +0000 +@@ -8,12 +8,12 @@ + Displaying notes found in: .gnu.build.attributes + [ ]+Owner[ ]+Data size[ ]+Description + [ ]+GA\$3p3[ ]+0x00000010[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120 \(note_4.s\) +-[ ]+GA\$gcc 7.2.1 20170915[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120 +-[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120 + [ ]+GA\*off[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120 +-[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120 ++[ ]+GA\$gcc 7.2.1 20170915[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120 ++[ ]+GA\*0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120 + [ ]+GA\*PIC[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120 + [ ]+GA\!false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120 +-[ ]+GA\*0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120 +-[ ]+GA\*strong[ ]+0x00000010[ ]+func[ ]+Applies to region from 0x110 to 0x11c.* ++[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120 ++[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120 ++[ ]+GA\*strong[ ]+0x00000010[ ]+func[ ]+Applies to region from 0x110 to 0x120.* + #... +diff -rupN binutils.orig/binutils/testsuite/binutils-all/note-4-64.s binutils-2.33.1/binutils/testsuite/binutils-all/note-4-64.s +--- binutils.orig/binutils/testsuite/binutils-all/note-4-64.s 2019-10-28 11:01:40.447071267 +0000 ++++ binutils-2.33.1/binutils/testsuite/binutils-all/note-4-64.s 2019-10-28 11:01:52.421985627 +0000 +@@ -22,8 +22,8 @@ note_4.s_end: + .dc.l 16 + .dc.l 0x100 + .asciz "GA$3p3" +- .8byte note_4.s - 2 +- .8byte note_4.s_end ++ .8byte 0x100 /* note_4.s - 2 */ ++ .8byte 0x120 /* note_4.s_end */ + + .dc.l 23 + .dc.l 0 +@@ -68,11 +68,17 @@ note_4.s_end: + .dc.b 0, 0, 0 + + .dc.l 6 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x7, 0x2, 0 ++ .dc.b 0, 0 ++ ++ .dc.l 6 + .dc.l 16 + .dc.l 0x101 + .dc.b 0x47, 0x41, 0x2a, 0x2, 0x3, 0 + .dc.b 0, 0 +- .8byte bar +- .8byte bar_end ++ .8byte 0x110 /* bar */ ++ .8byte 0x120 /* bar_end */ + + .popsection +diff -rupN binutils.orig/binutils/testsuite/binutils-all/objcopy.exp binutils-2.33.1/binutils/testsuite/binutils-all/objcopy.exp +--- binutils.orig/binutils/testsuite/binutils-all/objcopy.exp 2019-10-28 11:01:40.450071246 +0000 ++++ binutils-2.33.1/binutils/testsuite/binutils-all/objcopy.exp 2019-10-28 11:01:52.421985627 +0000 +@@ -1108,10 +1108,12 @@ if [is_elf_format] { + run_dump_test "note-2-64" + run_dump_test "note-3-64" + run_dump_test "note-4-64" ++ run_dump_test "note-6-64" + } else { + run_dump_test "note-2-32" + run_dump_test "note-3-32" + run_dump_test "note-4-32" ++ run_dump_test "note-6-32" + } + run_dump_test "note-5" + } +--- /dev/null 2019-10-25 08:17:39.968055193 +0100 ++++ fred/binutils/testsuite/binutils-all/note-6-32.s 2019-10-25 14:35:54.248969792 +0100 +@@ -0,0 +1,145 @@ ++ .text ++ .org 0x100 ++ .global note_test ++note_test: ++note_1_start: ++ .word 0 ++note_1_end: ++note_2_start: ++ .word 0 ++note_2_end: ++note_3_start: ++ .word 0 ++note_3_end: ++note_test_end: ++ .size note_test, note_test_end - note_test ++ ++ .pushsection .gnu.build.attributes, "", %note ++ .balign 4 ++ ++ .dc.l 8 ++ .dc.l 8 ++ .dc.l 0x100 ++ .asciz "GA$3p1" ++ .4byte 0x100 /* note_1_start */ ++ .4byte 0x102 /* note_1_end */ ++ ++ .dc.l 23 ++ .dc.l 0 ++ .dc.l 0x100 ++ .asciz "GA$gcc 8.3.1 20190507" ++ .dc.b 0 ++ ++ .dc.l 10 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x47, 0x4f, 0x57, 0, 0, 0x7, 0 ++ .dc.b 0, 0 ++ ++ .dc.l 6 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0 ++ .dc.b 0, 0 ++ ++ .dc.l 13 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x46, 0x4f, 0x52, 0x54, 0x49, 0x46, 0x59, 0, 0xff, 0 ++ .dc.b 0, 0, 0 ++ ++ .dc.l 6 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x7, 0x2, 0 ++ .dc.b 0, 0 ++ ++ .dc.l 5 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x21, 0x8, 0 ++ .dc.b 0, 0, 0 ++ ++ .dc.l 13 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x6, 0xf2, 0x3, 0x38, 0xee, 0xce, 0xfa, 0x5e, 0x3c, 0 ++ .dc.b 0, 0, 0 ++ ++ ++ .dc.l 8 ++ .dc.l 8 ++ .dc.l 0x100 ++ .asciz "GA$3p1" ++ .4byte 0x102 /* note_2_start */ ++ .4byte 0x106 /* note_3_end */ ++ ++ .dc.l 23 ++ .dc.l 0 ++ .dc.l 0x100 ++ .asciz "GA$gcc 8.3.1 20190507" ++ .dc.b 0 ++ ++ .dc.l 10 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x47, 0x4f, 0x57, 0, 0, 0x7, 0 ++ .dc.b 0, 0 ++ ++ .dc.l 6 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0 ++ .dc.b 0, 0 ++ ++ .dc.l 13 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x46, 0x4f, 0x52, 0x54, 0x49, 0x46, 0x59, 0, 0xff, 0 ++ .dc.b 0, 0, 0 ++ ++ .dc.l 6 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x7, 0x2, 0 ++ .dc.b 0, 0 ++ ++ .dc.l 5 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x21, 0x8, 0 ++ .dc.b 0, 0, 0 ++ ++ .dc.l 13 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x6, 0xf2, 0x3, 0x38, 0xee, 0xce, 0xfa, 0x5e, 0x3c, 0 ++ .dc.b 0, 0, 0 ++ ++ ++ .dc.l 8 ++ .dc.l 8 ++ .dc.l 0x101 ++ .asciz "GA$3p1" ++ .4byte 0x102 /* note_2_start */ ++ .4byte 0x104 /* note_2_end */ ++ ++ .dc.l 16 ++ .dc.l 0 ++ .dc.l 0x101 ++ .asciz "GA$hello world" ++ ++ ++ .dc.l 8 ++ .dc.l 8 ++ .dc.l 0x101 ++ .asciz "GA$3p1" ++ .4byte 0x104 /* note_3_start */ ++ .4byte 0x106 /* note_3_end */ ++ ++ .dc.l 16 ++ .dc.l 0 ++ .dc.l 0x101 ++ .asciz "GA$hello world" ++ ++ .popsection +--- /dev/null 2019-10-25 08:17:39.968055193 +0100 ++++ fred/binutils/testsuite/binutils-all/note-6-32.d 2019-10-25 14:37:59.481089241 +0100 +@@ -0,0 +1,20 @@ ++#PROG: objcopy ++#readelf: --notes --wide ++#objcopy: --merge-notes ++#name: v3 gnu build attribute note merging (32-bit) ++#source: note-6-32.s ++ ++#... ++Displaying notes found in: .gnu.build.attributes ++[ ]+Owner[ ]+Data size[ ]+Description ++[ ]+GA\$3p1[ ]+0x00000008[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 \(note_test\) ++[ ]+GA\*off[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\$gcc 8.3.1 20190507[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\*0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\*PIC[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\!false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\$3p1[ ]+0x00000008[ ]+func[ ]+Applies to region from 0x102 to 0x106 ++[ ]+GA\$hello world[ ]+0x00000000[ ]+func[ ]+Applies to region from 0x102 to 0x106 ++#... +--- /dev/null 2019-10-25 08:17:39.968055193 +0100 ++++ fred/binutils/testsuite/binutils-all/note-6-64.d 2019-10-25 13:50:10.733181842 +0100 +@@ -0,0 +1,20 @@ ++#PROG: objcopy ++#readelf: --notes --wide ++#objcopy: --merge-notes ++#name: v3 gnu build attribute note merging (64-bit) ++#source: note-6-64.s ++ ++#... ++Displaying notes found in: .gnu.build.attributes ++[ ]+Owner[ ]+Data size[ ]+Description ++[ ]+GA\$3p1[ ]+0x00000010[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 \(note_test\) ++[ ]+GA\*off[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\$gcc 8.3.1 20190507[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\*0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\*PIC[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\!false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x106 ++[ ]+GA\$3p1[ ]+0x00000010[ ]+func[ ]+Applies to region from 0x102 to 0x106 ++[ ]+GA\$hello world[ ]+0x00000000[ ]+func[ ]+Applies to region from 0x102 to 0x106 ++#... +--- /dev/null 2019-10-25 08:17:39.968055193 +0100 ++++ fred/binutils/testsuite/binutils-all/note-6-64.s 2019-10-25 14:36:31.670706667 +0100 +@@ -0,0 +1,145 @@ ++ .text ++ .org 0x100 ++ .global note_test ++note_test: ++note_1_start: ++ .word 0 ++note_1_end: ++note_2_start: ++ .word 0 ++note_2_end: ++note_3_start: ++ .word 0 ++note_3_end: ++note_test_end: ++ .size note_test, note_test_end - note_test ++ ++ .pushsection .gnu.build.attributes, "", %note ++ .balign 4 ++ ++ .dc.l 8 ++ .dc.l 16 ++ .dc.l 0x100 ++ .asciz "GA$3p1" ++ .8byte 0x100 /* note_1_start */ ++ .8byte 0x102 /* note_1_end */ ++ ++ .dc.l 23 ++ .dc.l 0 ++ .dc.l 0x100 ++ .asciz "GA$gcc 8.3.1 20190507" ++ .dc.b 0 ++ ++ .dc.l 10 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x47, 0x4f, 0x57, 0, 0, 0x7, 0 ++ .dc.b 0, 0 ++ ++ .dc.l 6 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0 ++ .dc.b 0, 0 ++ ++ .dc.l 13 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x46, 0x4f, 0x52, 0x54, 0x49, 0x46, 0x59, 0, 0xff, 0 ++ .dc.b 0, 0, 0 ++ ++ .dc.l 6 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x7, 0x2, 0 ++ .dc.b 0, 0 ++ ++ .dc.l 5 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x21, 0x8, 0 ++ .dc.b 0, 0, 0 ++ ++ .dc.l 13 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x6, 0xf2, 0x3, 0x38, 0xee, 0xce, 0xfa, 0x5e, 0x3c, 0 ++ .dc.b 0, 0, 0 ++ ++ ++ .dc.l 8 ++ .dc.l 16 ++ .dc.l 0x100 ++ .asciz "GA$3p1" ++ .8byte 0x102 /* note_2_start */ ++ .8byte 0x106 /* note_3_end */ ++ ++ .dc.l 23 ++ .dc.l 0 ++ .dc.l 0x100 ++ .asciz "GA$gcc 8.3.1 20190507" ++ .dc.b 0 ++ ++ .dc.l 10 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x47, 0x4f, 0x57, 0, 0, 0x7, 0 ++ .dc.b 0, 0 ++ ++ .dc.l 6 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0 ++ .dc.b 0, 0 ++ ++ .dc.l 13 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x46, 0x4f, 0x52, 0x54, 0x49, 0x46, 0x59, 0, 0xff, 0 ++ .dc.b 0, 0, 0 ++ ++ .dc.l 6 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x7, 0x2, 0 ++ .dc.b 0, 0 ++ ++ .dc.l 5 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x21, 0x8, 0 ++ .dc.b 0, 0, 0 ++ ++ .dc.l 13 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x47, 0x41, 0x2a, 0x6, 0xf2, 0x3, 0x38, 0xee, 0xce, 0xfa, 0x5e, 0x3c, 0 ++ .dc.b 0, 0, 0 ++ ++ ++ .dc.l 8 ++ .dc.l 16 ++ .dc.l 0x101 ++ .asciz "GA$3p1" ++ .8byte 0x102 /* note_2_start */ ++ .8byte 0x104 /* note_2_end */ ++ ++ .dc.l 16 ++ .dc.l 0 ++ .dc.l 0x101 ++ .asciz "GA$hello world" ++ ++ ++ .dc.l 8 ++ .dc.l 16 ++ .dc.l 0x101 ++ .asciz "GA$3p1" ++ .8byte 0x104 /* note_3_start */ ++ .8byte 0x106 /* note_3_end */ ++ ++ .dc.l 16 ++ .dc.l 0 ++ .dc.l 0x101 ++ .asciz "GA$hello world" ++ ++ .popsection diff --git a/binutils.spec b/binutils.spec index 6d6395a..e3afbad 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.33.1 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -204,6 +204,10 @@ Patch14: binutils-gold-mismatched-section-flags.patch # Lifetime: Fixed in 2.34 (maybe) Patch15: binutils-CVE-2019-1010204.patch +# Purpose: Improve objdump's ability to merge GNU build attribute notes. +# Lifetime: Fixed in 2.34 +Patch16: binutils-improved-note-merging.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -354,6 +358,7 @@ Conflicts: gcc-c++ < 4.0.0 %patch13 -p1 %patch14 -p1 %patch15 -p1 +%patch16 -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 ? @@ -759,6 +764,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Mon Oct 28 2019 Nick Clifton - 2.33-2 +- Improve objdump's ability to merge GNU build attribute notes. + * Mon Oct 14 2019 Nick Clifton - 2.33-1 - Rebase to GNU Binutils 2.33.1. - Retire: binutils-CVE-2019-9073.patch From dd470499969c6412d411dff90ae4fccfcae5e3cc Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 30 Oct 2019 16:56:10 +0000 Subject: [PATCH 16/16] Fix the verification of the installed linker symlink. Resolves: #1767000 --- binutils.spec | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/binutils.spec b/binutils.spec index e3afbad..bf0e6f0 100644 --- a/binutils.spec +++ b/binutils.spec @@ -2,7 +2,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.33.1 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -335,7 +335,7 @@ Conflicts: gcc-c++ < 4.0.0 # The higher of these two numbers determines the default ld. %{!?ld_gold_priority:%global ld_gold_priority 30} -%endif # with gold +%endif %%# with gold %{!?ld_bfd_priority: %global ld_bfd_priority 50} @@ -727,7 +727,8 @@ exit 0 %license COPYING COPYING3 COPYING3.LIB COPYING.LIB %doc README %{_bindir}/%{?cross}[!l]* -%{_bindir}/%{?cross}ld +# %%verify(symlink) does not work for some reason, so using "owner" instead. +%verify(owner) %{_bindir}/%{?cross}ld %{_bindir}/%{?cross}ld.bfd %if %{with docs} @@ -764,6 +765,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Wed Oct 30 2019 Nick Clifton - 2.33-3 +- Fix the verification of the installed linker symlink. (#1767000) + * Mon Oct 28 2019 Nick Clifton - 2.33-2 - Improve objdump's ability to merge GNU build attribute notes.