Blame SOURCES/binutils-do-not-warn-about-debuginfo-files.patch

7db648
diff -rup binutils.orig/bfd/elf-bfd.h binutils-2.30/bfd/elf-bfd.h
7db648
--- binutils.orig/bfd/elf-bfd.h	2020-04-06 13:08:43.081659992 +0100
7db648
+++ binutils-2.30/bfd/elf-bfd.h	2020-04-06 13:09:17.040517295 +0100
7db648
@@ -2722,6 +2722,8 @@ extern unsigned int _bfd_elf_symbol_sect
7db648
   (bfd *, elf_symbol_type *);
7db648
 
7db648
 
7db648
+extern bfd_boolean is_debuginfo_file (bfd *);
7db648
+
7db648
 /* Large common section.  */
7db648
 extern asection _bfd_elf_large_com_section;
7db648
 
7db648
Only in binutils-2.30/bfd: elf-bfd.h.orig
7db648
diff -rup binutils.orig/bfd/elf.c binutils-2.30/bfd/elf.c
7db648
--- binutils.orig/bfd/elf.c	2020-04-06 13:08:43.104659896 +0100
7db648
+++ binutils-2.30/bfd/elf.c	2020-04-06 13:09:17.042517287 +0100
7db648
@@ -5749,6 +5749,35 @@ assign_file_positions_for_load_sections
7db648
 #define IS_TBSS(s) \
7db648
   ((s->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) == SEC_THREAD_LOCAL)
7db648
 
7db648
+/* Determine if a bfd is a debuginfo file.  Unfortunately there
7db648
+   is no defined method for detecting such files, so we have to
7db648
+   use heuristics instead.  */
7db648
+
7db648
+bfd_boolean
7db648
+is_debuginfo_file (bfd *abfd)
7db648
+{
7db648
+  if (abfd == NULL || bfd_get_flavour (abfd) != bfd_target_elf_flavour)
7db648
+    return FALSE;
7db648
+
7db648
+  Elf_Internal_Shdr **start_headers = elf_elfsections (abfd);
7db648
+  Elf_Internal_Shdr **end_headers = start_headers + elf_numsections (abfd);
7db648
+  Elf_Internal_Shdr **headerp;
7db648
+
7db648
+  for (headerp = start_headers; headerp < end_headers; headerp ++)
7db648
+    {
7db648
+      Elf_Internal_Shdr *header = * headerp;
7db648
+
7db648
+      /* Debuginfo files do not have any allocated SHT_PROGBITS sections.
7db648
+	 The only allocated sections are SHT_NOBITS or SHT_NOTES.  */
7db648
+      if ((header->sh_flags & SHF_ALLOC) == SHF_ALLOC
7db648
+	  && header->sh_type != SHT_NOBITS
7db648
+	  && header->sh_type != SHT_NOTE)
7db648
+	return FALSE;
7db648
+    }
7db648
+
7db648
+  return TRUE;
7db648
+}
7db648
+
7db648
 /* Assign file positions for the other sections.  */
7db648
 
7db648
 static bfd_boolean
7db648
@@ -5782,7 +5811,13 @@ assign_file_positions_for_non_load_secti
7db648
 	BFD_ASSERT (hdr->sh_offset == hdr->bfd_section->filepos);
7db648
       else if ((hdr->sh_flags & SHF_ALLOC) != 0)
7db648
 	{
7db648
-	  if (hdr->sh_size != 0)
7db648
+	  if (hdr->sh_size != 0
7db648
+	      /* PR 24717 - debuginfo files are known to be not strictly
7db648
+		 compliant with the ELF standard.  In particular they often
7db648
+		 have .note.gnu.property sections that are outside of any
7db648
+		 loadable segment.  This is not a problem for such files,
7db648
+		 so do not warn about them.  */
7db648
+	      && ! is_debuginfo_file (abfd))
7db648
 	    _bfd_error_handler
7db648
 	      /* xgettext:c-format */
7db648
 	      (_("%B: warning: allocated section `%s' not in segment"),
7db648
Only in binutils-2.30/bfd: elf.c.orig