Blame SOURCES/binutils-gold-mismatched-section-flags.patch

8d443f
diff -rup binutils.orig/gold/layout.cc binutils-2.32/gold/layout.cc
8d443f
--- binutils.orig/gold/layout.cc	2019-06-24 14:37:36.013086899 +0100
8d443f
+++ binutils-2.32/gold/layout.cc	2019-06-24 14:41:40.054517479 +0100
8d443f
@@ -868,6 +868,7 @@ Layout::get_output_section(const char* n
8d443f
 		  && (same_name->flags() & elfcpp::SHF_TLS) == 0)
8d443f
 		os = same_name;
8d443f
 	    }
8d443f
+#if 0 /* BZ 1722715, PR 17556.  */
8d443f
 	  else if ((flags & elfcpp::SHF_TLS) == 0)
8d443f
 	    {
8d443f
 	      elfcpp::Elf_Xword zero_flags = 0;
8d443f
@@ -878,6 +879,7 @@ Layout::get_output_section(const char* n
8d443f
 	      if (p != this->section_name_map_.end())
8d443f
 		os = p->second;
8d443f
 	    }
8d443f
+#endif
8d443f
 	}
8d443f
 
8d443f
       if (os == NULL)
8d443f
diff -rup binutils.orig/gold/object.cc binutils-2.32/gold/object.cc
8d443f
--- binutils.orig/gold/object.cc	2019-06-24 14:37:36.012086906 +0100
8d443f
+++ binutils-2.32/gold/object.cc	2019-06-24 14:39:59.287165501 +0100
8d443f
@@ -1644,6 +1644,13 @@ Sized_relobj_file<size, big_endian>::do_
8d443f
 	      omit[i] = true;
8d443f
 	    }
8d443f
 
8d443f
+	  // Skip empty sections without flags.
8d443f
+	  if (!(shdr.get_sh_flags() & ~elfcpp::SHF_GROUP)
8d443f
+	      && !shdr.get_sh_size())
8d443f
+	    {
8d443f
+	      omit[i] = true;
8d443f
+	    }
8d443f
+
8d443f
 	  bool discard = omit[i];
8d443f
 	  if (!discard)
8d443f
 	    {