From 6f32c52f0335027cd1146c36940a3d3c079c0a54 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Jul 01 2019 16:10:01 +0000 Subject: Stop gas from triggering a seg-fault when creating relocs for build notes. (PR 24748) --- 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)