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

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