From cbe88f3d8f9457a28c96ff53cb89029fd820361c Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 2 Jul 2019 16:50:58 +0100 Subject: [PATCH] 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)