diff --git a/binutils-reloc-symtab.patch b/binutils-reloc-symtab.patch new file mode 100644 index 0000000..cfeca7c --- /dev/null +++ b/binutils-reloc-symtab.patch @@ -0,0 +1,48 @@ +diff -rup binutils.orig/bfd/elf.c binutils-2.37/bfd/elf.c +--- binutils.orig/bfd/elf.c 2023-03-30 15:32:51.853932063 +0100 ++++ binutils-2.37/bfd/elf.c 2023-03-30 15:34:02.346807048 +0100 +@@ -3928,15 +3928,23 @@ assign_section_numbers (bfd *abfd, struc + { + case SHT_REL: + case SHT_RELA: +- /* A reloc section which we are treating as a normal BFD +- section. sh_link is the section index of the symbol +- table. sh_info is the section index of the section to +- which the relocation entries apply. We assume that an +- allocated reloc section uses the dynamic symbol table. +- FIXME: How can we be sure? */ +- s = bfd_get_section_by_name (abfd, ".dynsym"); +- if (s != NULL) +- d->this_hdr.sh_link = elf_section_data (s)->this_idx; ++ /* sh_link is the section index of the symbol table. ++ sh_info is the section index of the section to which the ++ relocation entries apply. */ ++ if (d->this_hdr.sh_link == 0) ++ { ++ /* FIXME maybe: If this is a reloc section which we are ++ treating as a normal section then we likely should ++ not be assuming its sh_link is .dynsym or .symtab. */ ++ if ((sec->flags & SEC_ALLOC) != 0) ++ { ++ s = bfd_get_section_by_name (abfd, ".dynsym"); ++ if (s != NULL) ++ d->this_hdr.sh_link = elf_section_data (s)->this_idx; ++ } ++ else ++ d->this_hdr.sh_link = elf_onesymtab (abfd); ++ } + + s = elf_get_reloc_section (sec); + if (s != NULL) +diff -rup binutils.orig/binutils/objcopy.c binutils-2.37/binutils/objcopy.c +--- binutils.orig/binutils/objcopy.c 2023-03-30 15:32:50.801933929 +0100 ++++ binutils-2.37/binutils/objcopy.c 2023-03-30 15:34:26.746764718 +0100 +@@ -2219,7 +2219,7 @@ merge_gnu_build_notes (bfd * ab + { + if (pnote->note.namedata[4] == '2') + ++ version_2_seen; +- else if (pnote->note.namedata[4] == '3') ++ else if (pnote->note.namedata[4] == '3' || pnote->note.namedata[4] == '4') + ++ version_3_seen; + else + { diff --git a/binutils.spec b/binutils.spec index 66cdf4b..8d84e00 100644 --- a/binutils.spec +++ b/binutils.spec @@ -39,7 +39,7 @@ Summary: A GNU collection of binary utilities Name: binutils%{?name_cross}%{?_with_debug:-debug} Version: 2.37 -Release: 37%{?dist} +Release: 38%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -382,6 +382,12 @@ Patch41: binutils-CVE-38128-dwarf-abbrev-parsing.patch # Purpose: Stop readelf from incorrectly decoding ELF files with no sections. # Lifetime: Fixed in 2.40 Patch42: binutils-readelf-no-sections.patch + +# Purpose: Stop the linker from associating allocated reloc sections with +# the .symtab section , which prevents it from being stripped. +# Lifetime: Fixed in 2.41 +Patch43: binutils-reloc-symtab.patch + #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -995,6 +1001,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Thu Mar 30 2023 Nick Clifton - 2.37-38 +- Linker: Do not associate allocated reloc sections with the .symtab section. (#2166419) + * Wed Nov 16 2022 Yara Ahmad - 2.37-37 - Fic configuration of s390x binutils so that it does not include support for extraneous targets. (#2139143) - Fix readelf's decoding of files with no sections. (#2131609)