Linker: Do not associate allocated reloc sections with the .symtab section. (#2166419)

This commit is contained in:
Nick Clifton 2023-03-30 15:13:57 +01:00
parent 6bfd06790b
commit b11a13f3f3
2 changed files with 59 additions and 1 deletions

View File

@ -0,0 +1,50 @@
--- binutils.orig/bfd/elf.c 2023-03-30 10:01:40.824181703 +0100
+++ binutils-2.40/bfd/elf.c 2023-03-30 10:02:23.103135337 +0100
@@ -3877,21 +3877,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
- if there is one. Otherwise we guess the normal symbol
- table. FIXME: How can we be sure? */
- if (d->this_hdr.sh_link == 0 && (sec->flags & SEC_ALLOC) != 0)
+ /* 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)
{
- s = bfd_get_section_by_name (abfd, ".dynsym");
- if (s != NULL)
- d->this_hdr.sh_link = elf_section_data (s)->this_idx;
+ /* 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);
}
- if (d->this_hdr.sh_link == 0)
- d->this_hdr.sh_link = elf_onesymtab (abfd);
s = elf_get_reloc_section (sec);
if (s != NULL)
--- binutils.orig/binutils/objcopy.c 2023-03-30 10:01:41.063181441 +0100
+++ binutils-2.40/binutils/objcopy.c 2023-03-30 12:25:41.439108276 +0100
@@ -2256,7 +2256,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
{

View File

@ -2,7 +2,7 @@
Summary: A GNU collection of binary utilities Summary: A GNU collection of binary utilities
Name: binutils%{?_with_debug:-debug} Name: binutils%{?_with_debug:-debug}
Version: 2.39 Version: 2.39
Release: 10%{?dist} Release: 11%{?dist}
License: GPLv3+ License: GPLv3+
URL: https://sourceware.org/binutils URL: https://sourceware.org/binutils
@ -287,6 +287,11 @@ Patch24: binutils-CVE-2022-4285.patch
# Lifetime: Fixed in 2.41 # Lifetime: Fixed in 2.41
Patch25: binutils-objcopy-note-merge-speedup.patch Patch25: binutils-objcopy-note-merge-speedup.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
Patch26: binutils-reloc-symtab.patch
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
Provides: bundled(libiberty) Provides: bundled(libiberty)
@ -1217,6 +1222,9 @@ exit 0
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
%changelog %changelog
* Thu Mar 30 2023 Nick Clifton <nickc@redhat.com> - 2.39-11
- Linker: Do not associate allocated reloc sections with the .symtab section. (#2166419)
* Tue Jan 31 2023 Nick Clifton <nickc@redhat.com> - 2.39-10 * Tue Jan 31 2023 Nick Clifton <nickc@redhat.com> - 2.39-10
- Spec File: Add (disabled by default) support for cross-builds of the binutils. - Spec File: Add (disabled by default) support for cross-builds of the binutils.