Blame SOURCES/binutils-gold-note-segment.patch

13ae24
Only in binutils-2.30/gold: ChangeLog.orig
13ae24
Only in binutils-2.30/gold: ChangeLog.rej
13ae24
diff -rup binutils.orig/gold/layout.cc binutils-2.30/gold/layout.cc
13ae24
--- binutils.orig/gold/layout.cc	2018-08-14 16:18:17.928466978 +0100
13ae24
+++ binutils-2.30/gold/layout.cc	2018-08-14 16:23:15.811244776 +0100
13ae24
@@ -474,7 +474,8 @@ Layout::Layout(int number_of_input_files
13ae24
     input_section_position_(),
13ae24
     input_section_glob_(),
13ae24
     incremental_base_(NULL),
13ae24
-    free_list_()
13ae24
+    free_list_(),
13ae24
+    gnu_properties_()
13ae24
 {
13ae24
   // Make space for more than enough segments for a typical file.
13ae24
   // This is just for efficiency--it's OK if we wind up needing more.
13ae24
@@ -2182,11 +2183,243 @@ Layout::layout_gnu_stack(bool seen_gnu_s
13ae24
     }
13ae24
 }
13ae24
 
13ae24
+// Read a value with given size and endianness.
13ae24
+
13ae24
+static inline uint64_t
13ae24
+read_sized_value(size_t size, const unsigned char* buf, bool is_big_endian,
13ae24
+		 const Object* object)
13ae24
+{
13ae24
+  uint64_t val = 0;
13ae24
+  if (size == 4)
13ae24
+    {
13ae24
+      if (is_big_endian)
13ae24
+	val = elfcpp::Swap<32, true>::readval(buf);
13ae24
+      else
13ae24
+	val = elfcpp::Swap<32, false>::readval(buf);
13ae24
+    }
13ae24
+  else if (size == 8)
13ae24
+    {
13ae24
+      if (is_big_endian)
13ae24
+	val = elfcpp::Swap<64, true>::readval(buf);
13ae24
+      else
13ae24
+	val = elfcpp::Swap<64, false>::readval(buf);
13ae24
+    }
13ae24
+  else
13ae24
+    {
13ae24
+      gold_warning(_("%s: in .note.gnu.property section, "
13ae24
+		     "pr_datasz must be 4 or 8"),
13ae24
+		   object->name().c_str());
13ae24
+    }
13ae24
+  return val;
13ae24
+}
13ae24
+
13ae24
+// Write a value with given size and endianness.
13ae24
+
13ae24
+static inline void
13ae24
+write_sized_value(uint64_t value, size_t size, unsigned char* buf,
13ae24
+		  bool is_big_endian)
13ae24
+{
13ae24
+  if (size == 4)
13ae24
+    {
13ae24
+      if (is_big_endian)
13ae24
+	elfcpp::Swap<32, true>::writeval(buf, static_cast<uint32_t>(value));
13ae24
+      else
13ae24
+	elfcpp::Swap<32, false>::writeval(buf, static_cast<uint32_t>(value));
13ae24
+    }
13ae24
+  else if (size == 8)
13ae24
+    {
13ae24
+      if (is_big_endian)
13ae24
+	elfcpp::Swap<64, true>::writeval(buf, value);
13ae24
+      else
13ae24
+	elfcpp::Swap<64, false>::writeval(buf, value);
13ae24
+    }
13ae24
+  else
13ae24
+    {
13ae24
+      // We will have already complained about this.
13ae24
+    }
13ae24
+}
13ae24
+
13ae24
+// Handle the .note.gnu.property section at layout time.
13ae24
+
13ae24
+void
13ae24
+Layout::layout_gnu_property(unsigned int note_type,
13ae24
+			    unsigned int pr_type,
13ae24
+			    size_t pr_datasz,
13ae24
+			    const unsigned char* pr_data,
13ae24
+			    const Object* object)
13ae24
+{
13ae24
+  // We currently support only the one note type.
13ae24
+  gold_assert(note_type == elfcpp::NT_GNU_PROPERTY_TYPE_0);
13ae24
+
13ae24
+  if (pr_type >= elfcpp::GNU_PROPERTY_LOPROC
13ae24
+      && pr_type < elfcpp::GNU_PROPERTY_HIPROC)
13ae24
+    {
13ae24
+      // Target-dependent property value; call the target to record.
13ae24
+      const int size = parameters->target().get_size();
13ae24
+      const bool is_big_endian = parameters->target().is_big_endian();
13ae24
+      if (size == 32)
13ae24
+        {
13ae24
+          if (is_big_endian)
13ae24
+            {
13ae24
+#ifdef HAVE_TARGET_32_BIG
13ae24
+	      parameters->sized_target<32, true>()->
13ae24
+		  record_gnu_property(note_type, pr_type, pr_datasz, pr_data,
13ae24
+				      object);
13ae24
+#else
13ae24
+	      gold_unreachable();
13ae24
+#endif
13ae24
+            }
13ae24
+          else
13ae24
+            {
13ae24
+#ifdef HAVE_TARGET_32_LITTLE
13ae24
+	      parameters->sized_target<32, false>()->
13ae24
+		  record_gnu_property(note_type, pr_type, pr_datasz, pr_data,
13ae24
+				      object);
13ae24
+#else
13ae24
+	      gold_unreachable();
13ae24
+#endif
13ae24
+            }
13ae24
+        }
13ae24
+      else if (size == 64)
13ae24
+        {
13ae24
+          if (is_big_endian)
13ae24
+            {
13ae24
+#ifdef HAVE_TARGET_64_BIG
13ae24
+	      parameters->sized_target<64, true>()->
13ae24
+		  record_gnu_property(note_type, pr_type, pr_datasz, pr_data,
13ae24
+				      object);
13ae24
+#else
13ae24
+	      gold_unreachable();
13ae24
+#endif
13ae24
+            }
13ae24
+          else
13ae24
+            {
13ae24
+#ifdef HAVE_TARGET_64_LITTLE
13ae24
+	      parameters->sized_target<64, false>()->
13ae24
+		  record_gnu_property(note_type, pr_type, pr_datasz, pr_data,
13ae24
+				      object);
13ae24
+#else
13ae24
+	      gold_unreachable();
13ae24
+#endif
13ae24
+            }
13ae24
+        }
13ae24
+      else
13ae24
+        gold_unreachable();
13ae24
+      return;
13ae24
+    }
13ae24
+
13ae24
+  Gnu_properties::iterator pprop = this->gnu_properties_.find(pr_type);
13ae24
+  if (pprop == this->gnu_properties_.end())
13ae24
+    {
13ae24
+      Gnu_property prop;
13ae24
+      prop.pr_datasz = pr_datasz;
13ae24
+      prop.pr_data = new unsigned char[pr_datasz];
13ae24
+      memcpy(prop.pr_data, pr_data, pr_datasz);
13ae24
+      this->gnu_properties_[pr_type] = prop;
13ae24
+    }
13ae24
+  else
13ae24
+    {
13ae24
+      const bool is_big_endian = parameters->target().is_big_endian();
13ae24
+      switch (pr_type)
13ae24
+	{
13ae24
+	case elfcpp::GNU_PROPERTY_STACK_SIZE:
13ae24
+	  // Record the maximum value seen.
13ae24
+	  {
13ae24
+	    uint64_t val1 = read_sized_value(pprop->second.pr_datasz,
13ae24
+					     pprop->second.pr_data,
13ae24
+					     is_big_endian, object);
13ae24
+	    uint64_t val2 = read_sized_value(pr_datasz, pr_data,
13ae24
+					     is_big_endian, object);
13ae24
+	    if (val2 > val1)
13ae24
+	      write_sized_value(val2, pprop->second.pr_datasz,
13ae24
+				pprop->second.pr_data, is_big_endian);
13ae24
+	  }
13ae24
+	  break;
13ae24
+	case elfcpp::GNU_PROPERTY_NO_COPY_ON_PROTECTED:
13ae24
+	  // No data to merge.
13ae24
+	  break;
13ae24
+	default:
13ae24
+	  gold_warning(_("%s: unknown program property type %d "
13ae24
+			 "in .note.gnu.property section"),
13ae24
+		       object->name().c_str(), pr_type);
13ae24
+	}
13ae24
+    }
13ae24
+}
13ae24
+
13ae24
+// Merge per-object properties with program properties.
13ae24
+// This lets the target identify objects that are missing certain
13ae24
+// properties, in cases where properties must be ANDed together.
13ae24
+
13ae24
+void
13ae24
+Layout::merge_gnu_properties(const Object* object)
13ae24
+{
13ae24
+  const int size = parameters->target().get_size();
13ae24
+  const bool is_big_endian = parameters->target().is_big_endian();
13ae24
+  if (size == 32)
13ae24
+    {
13ae24
+      if (is_big_endian)
13ae24
+	{
13ae24
+#ifdef HAVE_TARGET_32_BIG
13ae24
+	  parameters->sized_target<32, true>()->merge_gnu_properties(object);
13ae24
+#else
13ae24
+	  gold_unreachable();
13ae24
+#endif
13ae24
+	}
13ae24
+      else
13ae24
+	{
13ae24
+#ifdef HAVE_TARGET_32_LITTLE
13ae24
+	  parameters->sized_target<32, false>()->merge_gnu_properties(object);
13ae24
+#else
13ae24
+	  gold_unreachable();
13ae24
+#endif
13ae24
+	}
13ae24
+    }
13ae24
+  else if (size == 64)
13ae24
+    {
13ae24
+      if (is_big_endian)
13ae24
+	{
13ae24
+#ifdef HAVE_TARGET_64_BIG
13ae24
+	  parameters->sized_target<64, true>()->merge_gnu_properties(object);
13ae24
+#else
13ae24
+	  gold_unreachable();
13ae24
+#endif
13ae24
+	}
13ae24
+      else
13ae24
+	{
13ae24
+#ifdef HAVE_TARGET_64_LITTLE
13ae24
+	  parameters->sized_target<64, false>()->merge_gnu_properties(object);
13ae24
+#else
13ae24
+	  gold_unreachable();
13ae24
+#endif
13ae24
+	}
13ae24
+    }
13ae24
+  else
13ae24
+    gold_unreachable();
13ae24
+}
13ae24
+
13ae24
+// Add a target-specific property for the output .note.gnu.property section.
13ae24
+
13ae24
+void
13ae24
+Layout::add_gnu_property(unsigned int note_type,
13ae24
+			 unsigned int pr_type,
13ae24
+			 size_t pr_datasz,
13ae24
+			 const unsigned char* pr_data)
13ae24
+{
13ae24
+  gold_assert(note_type == elfcpp::NT_GNU_PROPERTY_TYPE_0);
13ae24
+
13ae24
+  Gnu_property prop;
13ae24
+  prop.pr_datasz = pr_datasz;
13ae24
+  prop.pr_data = new unsigned char[pr_datasz];
13ae24
+  memcpy(prop.pr_data, pr_data, pr_datasz);
13ae24
+  this->gnu_properties_[pr_type] = prop;
13ae24
+}
13ae24
+
13ae24
 // Create automatic note sections.
13ae24
 
13ae24
 void
13ae24
 Layout::create_notes()
13ae24
 {
13ae24
+  this->create_gnu_properties_note();
13ae24
   this->create_gold_note();
13ae24
   this->create_stack_segment();
13ae24
   this->create_build_id();
13ae24
@@ -3010,6 +3243,58 @@ Layout::create_note(const char* name, in
13ae24
   return os;
13ae24
 }
13ae24
 
13ae24
+// Create a .note.gnu.property section to record program properties
13ae24
+// accumulated from the input files.
13ae24
+
13ae24
+void
13ae24
+Layout::create_gnu_properties_note()
13ae24
+{
13ae24
+  parameters->target().finalize_gnu_properties(this);
13ae24
+
13ae24
+  if (this->gnu_properties_.empty())
13ae24
+    return;
13ae24
+
13ae24
+  const unsigned int size = parameters->target().get_size();
13ae24
+  const bool is_big_endian = parameters->target().is_big_endian();
13ae24
+
13ae24
+  // Compute the total size of the properties array.
13ae24
+  size_t descsz = 0;
13ae24
+  for (Gnu_properties::const_iterator prop = this->gnu_properties_.begin();
13ae24
+       prop != this->gnu_properties_.end();
13ae24
+       ++prop)
13ae24
+    {
13ae24
+      descsz = align_address(descsz + 8 + prop->second.pr_datasz, size / 8);
13ae24
+    }
13ae24
+
13ae24
+  // Create the note section.
13ae24
+  size_t trailing_padding;
13ae24
+  Output_section* os = this->create_note("GNU", elfcpp::NT_GNU_PROPERTY_TYPE_0,
13ae24
+					 ".note.gnu.property", descsz,
13ae24
+					 true, &trailing_padding);
13ae24
+  if (os == NULL)
13ae24
+    return;
13ae24
+  gold_assert(trailing_padding == 0);
13ae24
+
13ae24
+  // Allocate and fill the properties array.
13ae24
+  unsigned char* desc = new unsigned char[descsz];
13ae24
+  unsigned char* p = desc;
13ae24
+  for (Gnu_properties::const_iterator prop = this->gnu_properties_.begin();
13ae24
+       prop != this->gnu_properties_.end();
13ae24
+       ++prop)
13ae24
+    {
13ae24
+      size_t datasz = prop->second.pr_datasz;
13ae24
+      size_t aligned_datasz = align_address(prop->second.pr_datasz, size / 8);
13ae24
+      write_sized_value(prop->first, 4, p, is_big_endian);
13ae24
+      write_sized_value(datasz, 4, p + 4, is_big_endian);
13ae24
+      memcpy(p + 8, prop->second.pr_data, datasz);
13ae24
+      if (aligned_datasz > datasz)
13ae24
+        memset(p + 8 + datasz, 0, aligned_datasz - datasz);
13ae24
+      p += 8 + aligned_datasz;
13ae24
+    }
13ae24
+  Output_section_data* posd = new Output_data_const(desc, descsz, 4);
13ae24
+  os->add_output_section_data(posd);
13ae24
+}
13ae24
+
13ae24
 // For an executable or shared library, create a note to record the
13ae24
 // version of gold used to create the binary.
13ae24
 
13ae24
Only in binutils-2.30/gold: layout.cc.orig
13ae24
diff -rup binutils.orig/gold/layout.h binutils-2.30/gold/layout.h
13ae24
--- binutils.orig/gold/layout.h	2018-08-14 16:18:17.926466993 +0100
13ae24
+++ binutils-2.30/gold/layout.h	2018-08-14 16:23:15.811244776 +0100
13ae24
@@ -680,6 +680,25 @@ class Layout
13ae24
   layout_gnu_stack(bool seen_gnu_stack, uint64_t gnu_stack_flags,
13ae24
 		   const Object*);
13ae24
 
13ae24
+  // Layout a .note.gnu.property section.
13ae24
+  void
13ae24
+  layout_gnu_property(unsigned int note_type,
13ae24
+		      unsigned int pr_type,
13ae24
+		      size_t pr_datasz,
13ae24
+		      const unsigned char* pr_data,
13ae24
+		      const Object* object);
13ae24
+
13ae24
+  // Merge per-object properties with program properties.
13ae24
+  void
13ae24
+  merge_gnu_properties(const Object* object);
13ae24
+
13ae24
+  // Add a target-specific property for the output .note.gnu.property section.
13ae24
+  void
13ae24
+  add_gnu_property(unsigned int note_type,
13ae24
+		   unsigned int pr_type,
13ae24
+		   size_t pr_datasz,
13ae24
+		   const unsigned char* pr_data);
13ae24
+
13ae24
   // Add an Output_section_data to the layout.  This is used for
13ae24
   // special sections like the GOT section.  ORDER is where the
13ae24
   // section should wind up in the output segment.  IS_RELRO is true
13ae24
@@ -1040,6 +1059,10 @@ class Layout
13ae24
   create_note(const char* name, int note_type, const char* section_name,
13ae24
 	      size_t descsz, bool allocate, size_t* trailing_padding);
13ae24
 
13ae24
+  // Create a note section for gnu program properties.
13ae24
+  void
13ae24
+  create_gnu_properties_note();
13ae24
+
13ae24
   // Create a note section for gold version.
13ae24
   void
13ae24
   create_gold_note();
13ae24
@@ -1326,6 +1349,14 @@ class Layout
13ae24
     std::vector<Section_info> section_infos_;
13ae24
   };
13ae24
 
13ae24
+  // Program properties from .note.gnu.property sections.
13ae24
+  struct Gnu_property
13ae24
+  {
13ae24
+    size_t pr_datasz;
13ae24
+    unsigned char* pr_data;
13ae24
+  };
13ae24
+  typedef std::map<unsigned int, Gnu_property> Gnu_properties;
13ae24
+
13ae24
   // The number of input files, for sizing tables.
13ae24
   int number_of_input_files_;
13ae24
   // Information set by scripts or by command line options.
13ae24
@@ -1452,6 +1483,8 @@ class Layout
13ae24
   Incremental_binary* incremental_base_;
13ae24
   // For incremental links, a list of free space within the file.
13ae24
   Free_list free_list_;
13ae24
+  // Program properties.
13ae24
+  Gnu_properties gnu_properties_;
13ae24
 };
13ae24
 
13ae24
 // This task handles writing out data in output sections which is not
13ae24
Only in binutils-2.30/gold: layout.h.orig
13ae24
diff -rup binutils.orig/gold/object.cc binutils-2.30/gold/object.cc
13ae24
--- binutils.orig/gold/object.cc	2018-08-14 16:18:17.929466971 +0100
13ae24
+++ binutils-2.30/gold/object.cc	2018-08-14 16:23:15.812244769 +0100
13ae24
@@ -1313,6 +1313,102 @@ Sized_relobj_file<size, big_endian>::lay
13ae24
     this->set_relocs_must_follow_section_writes();
13ae24
 }
13ae24
 
13ae24
+// Layout an input .note.gnu.property section.
13ae24
+
13ae24
+// This note section has an *extremely* non-standard layout.
13ae24
+// The gABI spec says that ELF-64 files should have 8-byte fields and
13ae24
+// 8-byte alignment in the note section, but the Gnu tools generally
13ae24
+// use 4-byte fields and 4-byte alignment (see the comment for
13ae24
+// Layout::create_note).  This section uses 4-byte fields (i.e.,
13ae24
+// namesz, descsz, and type are always 4 bytes), the name field is
13ae24
+// padded to a multiple of 4 bytes, but the desc field is padded
13ae24
+// to a multiple of 4 or 8 bytes, depending on the ELF class.
13ae24
+// The individual properties within the desc field always use
13ae24
+// 4-byte pr_type and pr_datasz fields, but pr_data is padded to
13ae24
+// a multiple of 4 or 8 bytes, depending on the ELF class.
13ae24
+
13ae24
+template<int size, bool big_endian>
13ae24
+void
13ae24
+Sized_relobj_file<size, big_endian>::layout_gnu_property_section(
13ae24
+    Layout* layout,
13ae24
+    unsigned int shndx)
13ae24
+{
13ae24
+  section_size_type contents_len;
13ae24
+  const unsigned char* pcontents = this->section_contents(shndx,
13ae24
+							  &contents_len,
13ae24
+							  false);
13ae24
+  const unsigned char* pcontents_end = pcontents + contents_len;
13ae24
+
13ae24
+  // Loop over all the notes in this section.
13ae24
+  while (pcontents < pcontents_end)
13ae24
+    {
13ae24
+      if (pcontents + 16 > pcontents_end)
13ae24
+	{
13ae24
+	  gold_warning(_("%s: corrupt .note.gnu.property section "
13ae24
+			 "(note too short)"),
13ae24
+		       this->name().c_str());
13ae24
+	  return;
13ae24
+	}
13ae24
+
13ae24
+      size_t namesz = elfcpp::Swap<32, big_endian>::readval(pcontents);
13ae24
+      size_t descsz = elfcpp::Swap<32, big_endian>::readval(pcontents + 4);
13ae24
+      unsigned int ntype = elfcpp::Swap<32, big_endian>::readval(pcontents + 8);
13ae24
+      const unsigned char* pname = pcontents + 12;
13ae24
+
13ae24
+      if (namesz != 4 || strcmp(reinterpret_cast<const char*>(pname), "GNU") != 0)
13ae24
+	{
13ae24
+	  gold_warning(_("%s: corrupt .note.gnu.property section "
13ae24
+			 "(name is not 'GNU')"),
13ae24
+		       this->name().c_str());
13ae24
+	  return;
13ae24
+	}
13ae24
+
13ae24
+      if (ntype != elfcpp::NT_GNU_PROPERTY_TYPE_0)
13ae24
+	{
13ae24
+	  gold_warning(_("%s: unsupported note type %d "
13ae24
+			 "in .note.gnu.property section"),
13ae24
+		       this->name().c_str(), ntype);
13ae24
+	  return;
13ae24
+	}
13ae24
+
13ae24
+      size_t aligned_namesz = align_address(namesz, 4);
13ae24
+      const unsigned char* pdesc = pname + aligned_namesz;
13ae24
+
13ae24
+      if (pdesc + descsz > pcontents + contents_len)
13ae24
+	{
13ae24
+	  gold_warning(_("%s: corrupt .note.gnu.property section"),
13ae24
+		       this->name().c_str());
13ae24
+	  return;
13ae24
+	}
13ae24
+
13ae24
+      const unsigned char* pprop = pdesc;
13ae24
+
13ae24
+      // Loop over the program properties in this note.
13ae24
+      while (pprop < pdesc + descsz)
13ae24
+	{
13ae24
+	  if (pprop + 8 > pdesc + descsz)
13ae24
+	    {
13ae24
+	      gold_warning(_("%s: corrupt .note.gnu.property section"),
13ae24
+			   this->name().c_str());
13ae24
+	      return;
13ae24
+	    }
13ae24
+	  unsigned int pr_type = elfcpp::Swap<32, big_endian>::readval(pprop);
13ae24
+	  size_t pr_datasz = elfcpp::Swap<32, big_endian>::readval(pprop + 4);
13ae24
+	  pprop += 8;
13ae24
+	  if (pprop + pr_datasz > pdesc + descsz)
13ae24
+	    {
13ae24
+	      gold_warning(_("%s: corrupt .note.gnu.property section"),
13ae24
+			   this->name().c_str());
13ae24
+	      return;
13ae24
+	    }
13ae24
+	  layout->layout_gnu_property(ntype, pr_type, pr_datasz, pprop, this);
13ae24
+	  pprop += align_address(pr_datasz, size / 8);
13ae24
+	}
13ae24
+
13ae24
+      pcontents = pdesc + align_address(descsz, size / 8);
13ae24
+    }
13ae24
+}
13ae24
+
13ae24
 // Lay out the input sections.  We walk through the sections and check
13ae24
 // whether they should be included in the link.  If they should, we
13ae24
 // pass them to the Layout object, which will return an output section
13ae24
@@ -1565,6 +1661,14 @@ Sized_relobj_file<size, big_endian>::do_
13ae24
 	      omit[i] = true;
13ae24
 	    }
13ae24
 
13ae24
+	  // Handle .note.gnu.property sections.
13ae24
+	  if (sh_type == elfcpp::SHT_NOTE
13ae24
+	      && strcmp(name, ".note.gnu.property") == 0)
13ae24
+	    {
13ae24
+	      this->layout_gnu_property_section(layout, i);
13ae24
+	      omit[i] = true;
13ae24
+	    }
13ae24
+
13ae24
 	  bool discard = omit[i];
13ae24
 	  if (!discard)
13ae24
 	    {
13ae24
@@ -1781,7 +1885,10 @@ Sized_relobj_file<size, big_endian>::do_
13ae24
     }
13ae24
 
13ae24
   if (!is_pass_two)
13ae24
-    layout->layout_gnu_stack(seen_gnu_stack, gnu_stack_flags, this);
13ae24
+    {
13ae24
+      layout->merge_gnu_properties(this);
13ae24
+      layout->layout_gnu_stack(seen_gnu_stack, gnu_stack_flags, this);
13ae24
+    }
13ae24
 
13ae24
   // Handle the .eh_frame sections after the other sections.
13ae24
   gold_assert(!is_pass_one || eh_frame_sections.empty());
13ae24
Only in binutils-2.30/gold: object.cc.orig
13ae24
diff -rup binutils.orig/gold/object.h binutils-2.30/gold/object.h
13ae24
--- binutils.orig/gold/object.h	2018-08-14 16:18:17.926466993 +0100
13ae24
+++ binutils-2.30/gold/object.h	2018-08-14 16:18:47.793244187 +0100
13ae24
@@ -2647,6 +2647,10 @@ class Sized_relobj_file : public Sized_r
13ae24
 			  unsigned int shndx, const typename This::Shdr&,
13ae24
 			  unsigned int reloc_shndx, unsigned int reloc_type);
13ae24
 
13ae24
+  // Layout an input .note.gnu.property section.
13ae24
+  void
13ae24
+  layout_gnu_property_section(Layout* layout, unsigned int shndx);
13ae24
+
13ae24
   // Write section data to the output file.  Record the views and
13ae24
   // sizes in VIEWS for use when relocating.
13ae24
   void
13ae24
Only in binutils-2.30/gold: object.h.orig
13ae24
diff -rup binutils.orig/gold/target.h binutils-2.30/gold/target.h
13ae24
--- binutils.orig/gold/target.h	2018-08-14 16:18:17.928466978 +0100
13ae24
+++ binutils-2.30/gold/target.h	2018-08-14 16:23:15.812244769 +0100
13ae24
@@ -504,6 +504,11 @@ class Target
13ae24
   should_include_section(elfcpp::Elf_Word sh_type) const
13ae24
   { return this->do_should_include_section(sh_type); }
13ae24
 
13ae24
+  // Finalize the target-specific properties in the .note.gnu.property section.
13ae24
+  void
13ae24
+  finalize_gnu_properties(Layout* layout) const
13ae24
+  { this->do_finalize_gnu_properties(layout); }
13ae24
+
13ae24
  protected:
13ae24
   // This struct holds the constant information for a child class.  We
13ae24
   // use a struct to avoid the overhead of virtual function calls for
13ae24
@@ -807,6 +812,11 @@ class Target
13ae24
   do_should_include_section(elfcpp::Elf_Word) const
13ae24
   { return true; }
13ae24
 
13ae24
+  // Finalize the target-specific properties in the .note.gnu.property section.
13ae24
+  virtual void
13ae24
+  do_finalize_gnu_properties(Layout*) const
13ae24
+  { }
13ae24
+
13ae24
  private:
13ae24
   // The implementations of the four do_make_elf_object virtual functions are
13ae24
   // almost identical except for their sizes and endianness.  We use a template.
13ae24
@@ -1126,6 +1136,17 @@ class Sized_target : public Target
13ae24
     return elfcpp::elf_r_sym<size>(rel.get_r_info());
13ae24
   }
13ae24
 
13ae24
+  // Record a target-specific program property in the .note.gnu.property
13ae24
+  // section.
13ae24
+  virtual void
13ae24
+  record_gnu_property(int, int, size_t, const unsigned char*, const Object*)
13ae24
+  { }
13ae24
+
13ae24
+  // Merge the target-specific program properties from the current object.
13ae24
+  virtual void
13ae24
+  merge_gnu_properties(const Object*)
13ae24
+  { }
13ae24
+
13ae24
  protected:
13ae24
   Sized_target(const Target::Target_info* pti)
13ae24
     : Target(pti)
13ae24
Only in binutils-2.30/gold: target.h.orig
13ae24
Only in binutils-2.30/gold/testsuite: gnu_property_a.S
13ae24
Only in binutils-2.30/gold/testsuite: gnu_property_b.S
13ae24
Only in binutils-2.30/gold/testsuite: gnu_property_c.S
13ae24
Only in binutils-2.30/gold/testsuite: gnu_property_main.c
13ae24
Only in binutils-2.30/gold/testsuite: gnu_property_test.sh
13ae24
diff -rup binutils.orig/gold/testsuite/Makefile.am binutils-2.30/gold/testsuite/Makefile.am
13ae24
--- binutils.orig/gold/testsuite/Makefile.am	2018-08-14 16:18:17.930466963 +0100
13ae24
+++ binutils-2.30/gold/testsuite/Makefile.am	2018-08-14 16:23:15.812244769 +0100
13ae24
@@ -3121,6 +3121,23 @@ exception_x86_64_bnd_2.o: exception_test
13ae24
 	$(CXXCOMPILE) -c -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $<
13ae24
 endif DEFAULT_TARGET_X86_64
13ae24
 
13ae24
+if DEFAULT_TARGET_X86_64
13ae24
+check_SCRIPTS += gnu_property_test.sh
13ae24
+check_DATA += gnu_property_test.stdout
13ae24
+gnu_property_test.stdout: gnu_property_test
13ae24
+	$(TEST_READELF) -n $< >$@
13ae24
+gnu_property_test: gcctestdir/ld gnu_property_a.o gnu_property_b.o gnu_property_c.o
13ae24
+	gcctestdir/ld -o $@ gnu_property_a.o gnu_property_b.o gnu_property_c.o
13ae24
+gnu_property_main.o: gnu_property_main.c
13ae24
+	$(COMPILE) -c -o $@ $<
13ae24
+gnu_property_a.o: gnu_property_a.S
13ae24
+	$(COMPILE) -c -o $@ $<
13ae24
+gnu_property_b.o: gnu_property_b.S
13ae24
+	$(COMPILE) -c -o $@ $<
13ae24
+gnu_property_c.o: gnu_property_c.S
13ae24
+	$(COMPILE) -c -o $@ $<
13ae24
+endif DEFAULT_TARGET_X86_64
13ae24
+
13ae24
 check_PROGRAMS += pr22266
13ae24
 pr22266: pr22266_main.o pr22266_ar.o gcctestdir/ld
13ae24
 	$(LINK) -Bgcctestdir/ pr22266_main.o pr22266_ar.o
13ae24
Only in binutils-2.30/gold/testsuite: Makefile.am.orig
13ae24
diff -rup binutils.orig/gold/testsuite/Makefile.in binutils-2.30/gold/testsuite/Makefile.in
13ae24
--- binutils.orig/gold/testsuite/Makefile.in	2018-08-14 16:18:17.939466896 +0100
13ae24
+++ binutils-2.30/gold/testsuite/Makefile.in	2018-08-14 16:23:15.813244761 +0100
13ae24
@@ -814,28 +814,30 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	two_file_test_tmp_4.o \
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	two_file_test_5.a \
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	two_file_test_6.a
13ae24
-@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_84 = pr22266
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_84 = gnu_property_test.sh
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_85 = gnu_property_test.stdout
13ae24
+@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_86 = pr22266
13ae24
 
13ae24
 # These tests work with native and cross linkers.
13ae24
 
13ae24
 # Test script section order.
13ae24
-@NATIVE_OR_CROSS_LINKER_TRUE@am__append_85 = script_test_10.sh
13ae24
-@NATIVE_OR_CROSS_LINKER_TRUE@am__append_86 = script_test_10.stdout
13ae24
-@NATIVE_OR_CROSS_LINKER_TRUE@am__append_87 = script_test_10
13ae24
+@NATIVE_OR_CROSS_LINKER_TRUE@am__append_87 = script_test_10.sh
13ae24
+@NATIVE_OR_CROSS_LINKER_TRUE@am__append_88 = script_test_10.stdout
13ae24
+@NATIVE_OR_CROSS_LINKER_TRUE@am__append_89 = script_test_10
13ae24
 
13ae24
 # These tests work with cross linkers only.
13ae24
-@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_88 = split_i386.sh
13ae24
-@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_89 = split_i386_1.stdout split_i386_2.stdout \
13ae24
+@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_90 = split_i386.sh
13ae24
+@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_91 = split_i386_1.stdout split_i386_2.stdout \
13ae24
 @DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_i386_3.stdout split_i386_4.stdout split_i386_r.stdout
13ae24
 
13ae24
-@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_90 = split_i386_1 split_i386_2 split_i386_3 \
13ae24
+@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_92 = split_i386_1 split_i386_2 split_i386_3 \
13ae24
 @DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_i386_4 split_i386_r
13ae24
 
13ae24
-@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_91 = split_x86_64.sh \
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_93 = split_x86_64.sh \
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	bnd_plt_1.sh \
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	bnd_ifunc_1.sh \
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	bnd_ifunc_2.sh
13ae24
-@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_92 = split_x86_64_1.stdout \
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_94 = split_x86_64_1.stdout \
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_x86_64_2.stdout \
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_x86_64_3.stdout \
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_x86_64_4.stdout \
13ae24
@@ -843,14 +845,14 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	bnd_plt_1.stdout \
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	bnd_ifunc_1.stdout \
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	bnd_ifunc_2.stdout
13ae24
-@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_93 = split_x86_64_1 split_x86_64_2 split_x86_64_3 \
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_95 = split_x86_64_1 split_x86_64_2 split_x86_64_3 \
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_x86_64_4 split_x86_64_r
13ae24
 
13ae24
-@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_94 = split_x32.sh
13ae24
-@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_95 = split_x32_1.stdout split_x32_2.stdout \
13ae24
+@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_96 = split_x32.sh
13ae24
+@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_97 = split_x32_1.stdout split_x32_2.stdout \
13ae24
 @DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_x32_3.stdout split_x32_4.stdout split_x32_r.stdout
13ae24
 
13ae24
-@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_96 = split_x32_1 split_x32_2 split_x32_3 \
13ae24
+@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_98 = split_x32_1 split_x32_2 split_x32_3 \
13ae24
 @DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_x32_4 split_x32_r
13ae24
 
13ae24
 
13ae24
@@ -871,7 +873,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E
13ae24
 # Check Thumb to ARM farcall veneers
13ae24
 
13ae24
 # Check handling of --target1-abs, --target1-rel and --target2 options
13ae24
-@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_97 = arm_abs_global.sh \
13ae24
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_99 = arm_abs_global.sh \
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_branch_in_range.sh \
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_branch_out_of_range.sh \
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_fix_v4bx.sh \
13ae24
@@ -894,7 +896,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_target2_got_rel.sh
13ae24
 
13ae24
 # The test demonstrates why the constructor of a target object should not access options.
13ae24
-@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_98 = arm_abs_global.stdout \
13ae24
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_100 = arm_abs_global.stdout \
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_bl_in_range.stdout \
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_bl_out_of_range.stdout \
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	thumb_bl_in_range.stdout \
13ae24
@@ -947,7 +949,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_target2_abs.stdout \
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_target2_got_rel.stdout \
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_target_lazy_init
13ae24
-@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_99 = arm_abs_global \
13ae24
+@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_101 = arm_abs_global \
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_bl_in_range \
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_bl_out_of_range \
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	thumb_bl_in_range \
13ae24
@@ -998,20 +1000,20 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_target2_abs \
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_target2_got_rel \
13ae24
 @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	arm_target_lazy_init
13ae24
-@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_100 = aarch64_reloc_none.sh \
13ae24
+@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_102 = aarch64_reloc_none.sh \
13ae24
 @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	aarch64_relocs.sh \
13ae24
 @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	pr21430.sh \
13ae24
 @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	aarch64_tlsdesc.sh
13ae24
-@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_101 = aarch64_reloc_none.stdout \
13ae24
+@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_103 = aarch64_reloc_none.stdout \
13ae24
 @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	aarch64_relocs.stdout \
13ae24
 @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	pr21430.stdout \
13ae24
 @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	aarch64_tlsdesc.stdout
13ae24
-@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_102 = aarch64_reloc_none \
13ae24
+@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_104 = aarch64_reloc_none \
13ae24
 @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	aarch64_relocs \
13ae24
 @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	pr21430 \
13ae24
 @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	aarch64_tlsdesc
13ae24
-@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_103 = split_s390.sh
13ae24
-@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_104 = split_s390_z1.stdout split_s390_z2.stdout split_s390_z3.stdout \
13ae24
+@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_105 = split_s390.sh
13ae24
+@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_106 = split_s390_z1.stdout split_s390_z2.stdout split_s390_z3.stdout \
13ae24
 @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_s390_z4.stdout split_s390_n1.stdout split_s390_n2.stdout \
13ae24
 @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_s390_a1.stdout split_s390_a2.stdout split_s390_z1_ns.stdout \
13ae24
 @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_s390_z2_ns.stdout split_s390_z3_ns.stdout split_s390_z4_ns.stdout \
13ae24
@@ -1023,7 +1025,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E
13ae24
 @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_s390x_z4_ns.stdout split_s390x_n1_ns.stdout \
13ae24
 @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_s390x_n2_ns.stdout split_s390x_r.stdout
13ae24
 
13ae24
-@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_105 = split_s390_z1 split_s390_z2 split_s390_z3 \
13ae24
+@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_107 = split_s390_z1 split_s390_z2 split_s390_z3 \
13ae24
 @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_s390_z4 split_s390_n1 split_s390_n2 split_s390_a1 \
13ae24
 @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_s390_a2 split_s390_z1_ns split_s390_z2_ns split_s390_z3_ns \
13ae24
 @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_s390_z4_ns split_s390_n1_ns split_s390_n2_ns split_s390_r \
13ae24
@@ -1032,10 +1034,10 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E
13ae24
 @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_s390x_z1_ns split_s390x_z2_ns split_s390x_z3_ns \
13ae24
 @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@	split_s390x_z4_ns split_s390x_n1_ns split_s390x_n2_ns split_s390x_r
13ae24
 
13ae24
-@DEFAULT_TARGET_X86_64_TRUE@am__append_106 = *.dwo *.dwp
13ae24
-@DEFAULT_TARGET_X86_64_TRUE@am__append_107 = dwp_test_1.sh \
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@am__append_108 = *.dwo *.dwp
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@am__append_109 = dwp_test_1.sh \
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@	dwp_test_2.sh
13ae24
-@DEFAULT_TARGET_X86_64_TRUE@am__append_108 = dwp_test_1.stdout \
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@am__append_110 = dwp_test_1.stdout \
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@	dwp_test_2.stdout
13ae24
 subdir = testsuite
13ae24
 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
13ae24
@@ -2828,9 +2830,9 @@ MOSTLYCLEANFILES = *.so *.syms *.stdout
13ae24
 	$(am__append_34) $(am__append_37) $(am__append_41) \
13ae24
 	$(am__append_47) $(am__append_51) $(am__append_52) \
13ae24
 	$(am__append_58) $(am__append_78) $(am__append_81) \
13ae24
-	$(am__append_83) $(am__append_87) $(am__append_90) \
13ae24
-	$(am__append_93) $(am__append_96) $(am__append_99) \
13ae24
-	$(am__append_102) $(am__append_105) $(am__append_106)
13ae24
+	$(am__append_83) $(am__append_89) $(am__append_92) \
13ae24
+	$(am__append_95) $(am__append_98) $(am__append_101) \
13ae24
+	$(am__append_104) $(am__append_107) $(am__append_108)
13ae24
 
13ae24
 # We will add to these later, for each individual test.  Note
13ae24
 # that we add each test under check_SCRIPTS or check_PROGRAMS;
13ae24
@@ -2839,18 +2841,18 @@ check_SCRIPTS = $(am__append_2) $(am__ap
13ae24
 	$(am__append_29) $(am__append_35) $(am__append_42) \
13ae24
 	$(am__append_45) $(am__append_49) $(am__append_53) \
13ae24
 	$(am__append_56) $(am__append_62) $(am__append_73) \
13ae24
-	$(am__append_76) $(am__append_79) $(am__append_85) \
13ae24
-	$(am__append_88) $(am__append_91) $(am__append_94) \
13ae24
-	$(am__append_97) $(am__append_100) $(am__append_103) \
13ae24
-	$(am__append_107)
13ae24
+	$(am__append_76) $(am__append_79) $(am__append_84) \
13ae24
+	$(am__append_87) $(am__append_90) $(am__append_93) \
13ae24
+	$(am__append_96) $(am__append_99) $(am__append_102) \
13ae24
+	$(am__append_105) $(am__append_109)
13ae24
 check_DATA = $(am__append_3) $(am__append_20) $(am__append_24) \
13ae24
 	$(am__append_30) $(am__append_36) $(am__append_43) \
13ae24
 	$(am__append_46) $(am__append_50) $(am__append_54) \
13ae24
 	$(am__append_57) $(am__append_63) $(am__append_74) \
13ae24
-	$(am__append_77) $(am__append_80) $(am__append_86) \
13ae24
-	$(am__append_89) $(am__append_92) $(am__append_95) \
13ae24
-	$(am__append_98) $(am__append_101) $(am__append_104) \
13ae24
-	$(am__append_108)
13ae24
+	$(am__append_77) $(am__append_80) $(am__append_85) \
13ae24
+	$(am__append_88) $(am__append_91) $(am__append_94) \
13ae24
+	$(am__append_97) $(am__append_100) $(am__append_103) \
13ae24
+	$(am__append_106) $(am__append_110)
13ae24
 BUILT_SOURCES = $(am__append_40)
13ae24
 TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
13ae24
 
13ae24
@@ -5737,6 +5739,8 @@ exception_x86_64_bnd_test.log: exception
13ae24
 	@p='exception_x86_64_bnd_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
13ae24
 pr22266.log: pr22266$(EXEEXT)
13ae24
 	@p='pr22266$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
13ae24
+gnu_property_test.sh.log: gnu_property_test.sh
13ae24
+	@p='gnu_property_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
13ae24
 .test.log:
13ae24
 	@p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post)
13ae24
 @am__EXEEXT_TRUE@.test$(EXEEXT).log:
13ae24
@@ -7394,6 +7403,18 @@ uninstall-am:
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(CXXCOMPILE) -c -fpic -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $<
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_2.o: exception_test_2.cc gcctestdir/as
13ae24
 @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(CXXCOMPILE) -c -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $<
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@gnu_property_test.stdout: gnu_property_test
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(TEST_READELF) -n $< >$@
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@gnu_property_test: gcctestdir/ld gnu_property_a.o gnu_property_b.o gnu_property_c.o
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	gcctestdir/ld -o $@ gnu_property_a.o gnu_property_b.o gnu_property_c.o
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@gnu_property_main.o: gnu_property_main.c
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c -o $@ $<
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@gnu_property_a.o: gnu_property_a.S
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c -o $@ $<
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@gnu_property_b.o: gnu_property_b.S
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c -o $@ $<
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@gnu_property_c.o: gnu_property_c.S
13ae24
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c -o $@ $<
13ae24
 @GCC_TRUE@@NATIVE_LINKER_TRUE@pr22266: pr22266_main.o pr22266_ar.o gcctestdir/ld
13ae24
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	$(LINK) -Bgcctestdir/ pr22266_main.o pr22266_ar.o
13ae24
 @GCC_TRUE@@NATIVE_LINKER_TRUE@pr22266_ar.o: pr22266_a.o gcctestdir/ld
13ae24
Only in binutils-2.30/gold/testsuite: Makefile.in.orig
13ae24
Only in binutils-2.30/gold/testsuite: Makefile.in.rej
13ae24
diff -rup binutils.orig/gold/x86_64.cc binutils-2.30/gold/x86_64.cc
13ae24
--- binutils.orig/gold/x86_64.cc	2018-08-14 16:18:17.926466993 +0100
13ae24
+++ binutils-2.30/gold/x86_64.cc	2018-08-14 16:23:26.758163112 +0100
13ae24
@@ -590,7 +590,8 @@ class Target_x86_64 : public Sized_targe
13ae24
       got_tlsdesc_(NULL), global_offset_table_(NULL), rela_dyn_(NULL),
13ae24
       rela_irelative_(NULL), copy_relocs_(elfcpp::R_X86_64_COPY),
13ae24
       got_mod_index_offset_(-1U), tlsdesc_reloc_info_(),
13ae24
-      tls_base_symbol_defined_(false)
13ae24
+      tls_base_symbol_defined_(false), isa_1_used_(0), isa_1_needed_(0),
13ae24
+      feature_1_(0), object_feature_1_(0), seen_first_object_(false)
13ae24
   { }
13ae24
 
13ae24
   // Hook for a new output section.
13ae24
@@ -1188,6 +1189,20 @@ class Target_x86_64 : public Sized_targe
13ae24
 				  this->rela_dyn_section(layout));
13ae24
   }
13ae24
 
13ae24
+  // Record a target-specific program property in the .note.gnu.property
13ae24
+  // section.
13ae24
+  void
13ae24
+  record_gnu_property(int, int, size_t, const unsigned char*, const Object*);
13ae24
+
13ae24
+  // Merge the target-specific program properties from the current object.
13ae24
+  void
13ae24
+  merge_gnu_properties(const Object*);
13ae24
+
13ae24
+  // Finalize the target-specific program properties and add them back to
13ae24
+  // the layout.
13ae24
+  void
13ae24
+  do_finalize_gnu_properties(Layout*) const;
13ae24
+
13ae24
   // Information about this specific target which we pass to the
13ae24
   // general Target structure.
13ae24
   static const Target::Target_info x86_64_info;
13ae24
@@ -1245,6 +1260,17 @@ class Target_x86_64 : public Sized_targe
13ae24
   std::vector<Tlsdesc_info> tlsdesc_reloc_info_;
13ae24
   // True if the _TLS_MODULE_BASE_ symbol has been defined.
13ae24
   bool tls_base_symbol_defined_;
13ae24
+  // Target-specific program properties, from .note.gnu.property section.
13ae24
+  // Each bit represents a specific feature.
13ae24
+  uint32_t isa_1_used_;
13ae24
+  uint32_t isa_1_needed_;
13ae24
+  uint32_t feature_1_;
13ae24
+  // Target-specific properties from the current object.
13ae24
+  // These bits get ANDed into FEATURE_1_ after all properties for the object
13ae24
+  // have been processed.
13ae24
+  uint32_t object_feature_1_;
13ae24
+  // Whether we have seen our first object, for use in initializing FEATURE_1_.
13ae24
+  bool seen_first_object_;
13ae24
 };
13ae24
 
13ae24
 template<>
13ae24
@@ -1431,6 +1457,93 @@ Target_x86_64<size>::rela_irelative_sect
13ae24
   return this->rela_irelative_;
13ae24
 }
13ae24
 
13ae24
+// Record a target-specific program property from the .note.gnu.property
13ae24
+// section.
13ae24
+template<int size>
13ae24
+void
13ae24
+Target_x86_64<size>::record_gnu_property(
13ae24
+    int, int pr_type,
13ae24
+    size_t pr_datasz, const unsigned char* pr_data,
13ae24
+    const Object* object)
13ae24
+{
13ae24
+  uint32_t val = 0;
13ae24
+
13ae24
+  switch (pr_type)
13ae24
+    {
13ae24
+    case elfcpp::GNU_PROPERTY_X86_ISA_1_USED:
13ae24
+    case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED:
13ae24
+    case elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND:
13ae24
+      if (pr_datasz != 4)
13ae24
+	{
13ae24
+	  gold_warning(_("%s: corrupt .note.gnu.property section "
13ae24
+			 "(pr_datasz for property %d is not 4)"),
13ae24
+		       object->name().c_str(), pr_type);
13ae24
+	  return;
13ae24
+	}
13ae24
+      val = elfcpp::Swap<32, false>::readval(pr_data);
13ae24
+      break;
13ae24
+    default:
13ae24
+      gold_warning(_("%s: unknown program property type 0x%x "
13ae24
+		     "in .note.gnu.property section"),
13ae24
+		   object->name().c_str(), pr_type);
13ae24
+      break;
13ae24
+    }
13ae24
+
13ae24
+  switch (pr_type)
13ae24
+    {
13ae24
+    case elfcpp::GNU_PROPERTY_X86_ISA_1_USED:
13ae24
+      this->isa_1_used_ |= val;
13ae24
+      break;
13ae24
+    case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED:
13ae24
+      this->isa_1_needed_ |= val;
13ae24
+      break;
13ae24
+    case elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND:
13ae24
+      // If we see multiple feature props in one object, OR them together.
13ae24
+      this->object_feature_1_ |= val;
13ae24
+      break;
13ae24
+    }
13ae24
+}
13ae24
+
13ae24
+// Merge the target-specific program properties from the current object.
13ae24
+template<int size>
13ae24
+void
13ae24
+Target_x86_64<size>::merge_gnu_properties(const Object*)
13ae24
+{
13ae24
+  if (this->seen_first_object_)
13ae24
+    this->feature_1_ &= this->object_feature_1_;
13ae24
+  else
13ae24
+    {
13ae24
+      this->feature_1_ = this->object_feature_1_;
13ae24
+      this->seen_first_object_ = true;
13ae24
+    }
13ae24
+  this->object_feature_1_ = 0;
13ae24
+}
13ae24
+
13ae24
+static inline void
13ae24
+add_property(Layout* layout, unsigned int pr_type, uint32_t val)
13ae24
+{
13ae24
+  unsigned char buf[4];
13ae24
+  elfcpp::Swap<32, false>::writeval(buf, val);
13ae24
+  layout->add_gnu_property(elfcpp::NT_GNU_PROPERTY_TYPE_0, pr_type, 4, buf);
13ae24
+}
13ae24
+
13ae24
+// Finalize the target-specific program properties and add them back to
13ae24
+// the layout.
13ae24
+template<int size>
13ae24
+void
13ae24
+Target_x86_64<size>::do_finalize_gnu_properties(Layout* layout) const
13ae24
+{
13ae24
+  if (this->isa_1_used_ != 0)
13ae24
+    add_property(layout, elfcpp::GNU_PROPERTY_X86_ISA_1_USED,
13ae24
+		 this->isa_1_used_);
13ae24
+  if (this->isa_1_needed_ != 0)
13ae24
+    add_property(layout, elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED,
13ae24
+		 this->isa_1_needed_);
13ae24
+  if (this->feature_1_ != 0)
13ae24
+    add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND,
13ae24
+		 this->feature_1_);
13ae24
+}
13ae24
+
13ae24
 // Write the first three reserved words of the .got.plt section.
13ae24
 // The remainder of the section is written while writing the PLT
13ae24
 // in Output_data_plt_i386::do_write.
13ae24
Only in binutils-2.30/gold: x86_64.cc.orig
13ae24
--- /dev/null	2018-08-14 08:11:42.835432884 +0100
13ae24
+++ binutils-2.30/gold/testsuite/gnu_property_a.S	2018-08-14 16:23:15.813244761 +0100
13ae24
@@ -0,0 +1,46 @@
13ae24
+#define NT_GNU_PROPERTY_TYPE_0 5
13ae24
+
13ae24
+#define GNU_PROPERTY_STACK_SIZE 1
13ae24
+#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
13ae24
+#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
13ae24
+#define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
13ae24
+
13ae24
+#if __SIZEOF_PTRDIFF_T__  == 8
13ae24
+# define ALIGN 3
13ae24
+#elif __SIZEOF_PTRDIFF_T__  == 4
13ae24
+# define ALIGN 2
13ae24
+#endif
13ae24
+
13ae24
+	.text
13ae24
+	.globl _start
13ae24
+_start:
13ae24
+	ret
13ae24
+
13ae24
+        .section ".note.gnu.property", "a"
13ae24
+        .p2align ALIGN
13ae24
+
13ae24
+        .long 1f - 0f           /* name length */
13ae24
+        .long 5f - 2f           /* data length */
13ae24
+        .long NT_GNU_PROPERTY_TYPE_0    /* note type */
13ae24
+0:      .asciz "GNU"            /* vendor name */
13ae24
+1:
13ae24
+        .p2align ALIGN
13ae24
+2:      .long GNU_PROPERTY_STACK_SIZE   /* pr_type.  */
13ae24
+        .long 4f - 3f   /* pr_datasz.  */
13ae24
+3:
13ae24
+        .dc.a 0x800     /* Stack size.  */
13ae24
+4:
13ae24
+        .p2align ALIGN
13ae24
+	.long GNU_PROPERTY_X86_ISA_1_USED
13ae24
+	.long 4
13ae24
+	.byte 0x01,0x10,0x00,0x00
13ae24
+        .p2align ALIGN
13ae24
+	.long GNU_PROPERTY_X86_ISA_1_NEEDED
13ae24
+	.long 4
13ae24
+	.byte 0x01,0x10,0x00,0x00
13ae24
+        .p2align ALIGN
13ae24
+	.long GNU_PROPERTY_X86_FEATURE_1_AND
13ae24
+	.long 4
13ae24
+	.byte 0x01,0x00,0x00,0x00
13ae24
+        .p2align ALIGN
13ae24
+5:
13ae24
--- /dev/null	2018-08-14 08:11:42.835432884 +0100
13ae24
+++ binutils-2.30/gold/testsuite/gnu_property_b.S	2018-08-14 16:18:47.795244173 +0100
13ae24
@@ -0,0 +1,38 @@
13ae24
+#define NT_GNU_PROPERTY_TYPE_0 5
13ae24
+
13ae24
+#define GNU_PROPERTY_STACK_SIZE 1
13ae24
+#define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
13ae24
+#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
13ae24
+#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
13ae24
+#define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
13ae24
+
13ae24
+#if __SIZEOF_PTRDIFF_T__  == 8
13ae24
+# define ALIGN 3
13ae24
+#elif __SIZEOF_PTRDIFF_T__  == 4
13ae24
+# define ALIGN 2
13ae24
+#endif
13ae24
+
13ae24
+        .section ".note.gnu.property", "a"
13ae24
+        .p2align ALIGN
13ae24
+        .long 1f - 0f           /* name length */
13ae24
+        .long 3f - 2f           /* data length */
13ae24
+        .long NT_GNU_PROPERTY_TYPE_0    /* note type */
13ae24
+0:      .asciz "GNU"            /* vendor name */
13ae24
+1:
13ae24
+        .p2align ALIGN
13ae24
+2:      .long GNU_PROPERTY_NO_COPY_ON_PROTECTED /* pr_type.  */
13ae24
+        .long 0 /* pr_datasz.  */
13ae24
+        .p2align ALIGN
13ae24
+	.long GNU_PROPERTY_X86_ISA_1_USED
13ae24
+	.long 4
13ae24
+	.byte 0x01,0x11,0x00,0x00
13ae24
+        .p2align ALIGN
13ae24
+	.long GNU_PROPERTY_X86_ISA_1_NEEDED
13ae24
+	.long 4
13ae24
+	.byte 0x01,0x11,0x00,0x00
13ae24
+        .p2align ALIGN
13ae24
+	.long GNU_PROPERTY_X86_FEATURE_1_AND
13ae24
+	.long 4
13ae24
+	.byte 0x03,0x00,0x00,0x00
13ae24
+        .p2align ALIGN
13ae24
+3:
13ae24
--- /dev/null	2018-08-14 08:11:42.835432884 +0100
13ae24
+++ binutils-2.30/gold/testsuite/gnu_property_c.S	2018-08-14 16:18:47.795244173 +0100
13ae24
@@ -0,0 +1,44 @@
13ae24
+#define NT_GNU_PROPERTY_TYPE_0 5
13ae24
+
13ae24
+#define GNU_PROPERTY_STACK_SIZE 1
13ae24
+#define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
13ae24
+#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
13ae24
+#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
13ae24
+#define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
13ae24
+
13ae24
+#if __SIZEOF_PTRDIFF_T__  == 8
13ae24
+# define ALIGN 3
13ae24
+#elif __SIZEOF_PTRDIFF_T__  == 4
13ae24
+# define ALIGN 2
13ae24
+#endif
13ae24
+
13ae24
+        .section ".note.gnu.property", "a"
13ae24
+        .p2align ALIGN
13ae24
+        .long 1f - 0f           /* name length */
13ae24
+        .long 5f - 2f           /* data length */
13ae24
+        .long NT_GNU_PROPERTY_TYPE_0    /* note type */
13ae24
+0:      .asciz "GNU"            /* vendor name */
13ae24
+1:
13ae24
+        .p2align ALIGN
13ae24
+2:      .long GNU_PROPERTY_STACK_SIZE   /* pr_type.  */
13ae24
+        .long 4f - 3f   /* pr_datasz.  */
13ae24
+3:
13ae24
+        .dc.a 0x111100  /* Stack size.  */
13ae24
+4:
13ae24
+        .p2align ALIGN
13ae24
+        .long GNU_PROPERTY_NO_COPY_ON_PROTECTED /* pr_type.  */
13ae24
+        .long 0 /* pr_datasz.  */
13ae24
+        .p2align ALIGN
13ae24
+	.long GNU_PROPERTY_X86_ISA_1_USED
13ae24
+	.long 4
13ae24
+	.byte 0x11,0x10,0x00,0x00
13ae24
+        .p2align ALIGN
13ae24
+	.long GNU_PROPERTY_X86_ISA_1_NEEDED
13ae24
+	.long 4
13ae24
+	.byte 0x11,0x10,0x00,0x00
13ae24
+        .p2align ALIGN
13ae24
+	.long GNU_PROPERTY_X86_FEATURE_1_AND
13ae24
+	.long 4
13ae24
+	.byte 0x01,0x00,0x00,0x00
13ae24
+        .p2align ALIGN
13ae24
+5:
13ae24
--- /dev/null	2018-08-14 08:11:42.835432884 +0100
13ae24
+++ binutils-2.30/gold/testsuite/gnu_property_main.c	2018-08-14 16:18:47.795244173 +0100
13ae24
@@ -0,0 +1,5 @@
13ae24
+int
13ae24
+main(void)
13ae24
+{
13ae24
+  return 0;
13ae24
+}
13ae24
--- /dev/null	2018-08-14 08:11:42.835432884 +0100
13ae24
+++ binutils-2.30/gold/testsuite/gnu_property_test.sh	2018-08-14 16:18:47.795244173 +0100
13ae24
@@ -0,0 +1,64 @@
13ae24
+#!/bin/sh
13ae24
+
13ae24
+# gnu_property_test.sh -- test .note.gnu.property section.
13ae24
+
13ae24
+# Copyright (C) 2018 Free Software Foundation, Inc.
13ae24
+# Written by Cary Coutant <ccoutant@gmail.com>.
13ae24
+
13ae24
+# This file is part of gold.
13ae24
+
13ae24
+# This program is free software; you can redistribute it and/or modify
13ae24
+# it under the terms of the GNU General Public License as published by
13ae24
+# the Free Software Foundation; either version 3 of the License, or
13ae24
+# (at your option) any later version.
13ae24
+
13ae24
+# This program is distributed in the hope that it will be useful,
13ae24
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13ae24
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13ae24
+# GNU General Public License for more details.
13ae24
+
13ae24
+# You should have received a copy of the GNU General Public License
13ae24
+# along with this program; if not, write to the Free Software
13ae24
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
13ae24
+# MA 02110-1301, USA.
13ae24
+
13ae24
+# This script checks that after linking the three object files
13ae24
+# gnu_property_[abc].S, each of which contains a .note.gnu.property
13ae24
+# section, the resulting output has only a single such note section,
13ae24
+# and that the properties have been correctly combined.
13ae24
+
13ae24
+check()
13ae24
+{
13ae24
+    if ! grep -q "$2" "$1"
13ae24
+    then
13ae24
+	echo "Did not find expected output in $1:"
13ae24
+	echo "   $2"
13ae24
+	echo ""
13ae24
+	echo "Actual output below:"
13ae24
+	cat "$1"
13ae24
+	exit 1
13ae24
+    fi
13ae24
+}
13ae24
+
13ae24
+check_count()
13ae24
+{
13ae24
+    if test "`grep -c "$2" "$1"`" != "$3"
13ae24
+    then
13ae24
+	echo "Did not find correct number of note sections in $1:"
13ae24
+	echo "   $2"
13ae24
+	echo ""
13ae24
+	echo "Actual output below:"
13ae24
+	cat "$1"
13ae24
+	exit 1
13ae24
+    fi
13ae24
+}
13ae24
+
13ae24
+check_count gnu_property_test.stdout "GNU\s*0x[0-9a-f]*\s*NT_GNU_PROPERTY_TYPE_0" 1
13ae24
+
13ae24
+check gnu_property_test.stdout "stack size: 0x111100"
13ae24
+check gnu_property_test.stdout "no copy on protected"
13ae24
+check gnu_property_test.stdout "x86 ISA used: i486, SSE2, SSE4_2, AVX512CD"
13ae24
+check gnu_property_test.stdout "x86 ISA needed: i486, SSE2, SSE4_2, AVX512CD"
13ae24
+check gnu_property_test.stdout "x86 feature: IBT"
13ae24
+
13ae24
+exit 0
13ae24
--- binutils.orig/elfcpp/elfcpp.h	2018-08-14 16:18:18.007466389 +0100
13ae24
+++ binutils-2.30/elfcpp/elfcpp.h	2018-08-14 16:36:27.151339505 +0100
13ae24
@@ -984,7 +984,9 @@ enum
13ae24
   NT_GNU_BUILD_ID = 3,
13ae24
   // The version of gold used to link.  Th descriptor is just a
13ae24
   // string.
13ae24
-  NT_GNU_GOLD_VERSION = 4
13ae24
+  NT_GNU_GOLD_VERSION = 4,
13ae24
+  // Program property note, as described in "Linux Extensions to the gABI".
13ae24
+  NT_GNU_PROPERTY_TYPE_0 = 5
13ae24
 };
13ae24
 
13ae24
 // The OS values which may appear in word 0 of a NT_GNU_ABI_TAG note.
13ae24
@@ -999,6 +1001,21 @@ enum
13ae24
   ELF_NOTE_OS_SYLLABLE = 5
13ae24
 };
13ae24
 
13ae24
+// Program property types for NT_GNU_PROPERTY_TYPE_0.
13ae24
+
13ae24
+enum
13ae24
+{
13ae24
+  GNU_PROPERTY_STACK_SIZE = 1,
13ae24
+  GNU_PROPERTY_NO_COPY_ON_PROTECTED = 2,
13ae24
+  GNU_PROPERTY_LOPROC = 0xc0000000,
13ae24
+  GNU_PROPERTY_X86_ISA_1_USED = 0xc0000000,
13ae24
+  GNU_PROPERTY_X86_ISA_1_NEEDED = 0xc0000001,
13ae24
+  GNU_PROPERTY_X86_FEATURE_1_AND = 0xc0000002,
13ae24
+  GNU_PROPERTY_HIPROC = 0xdfffffff,
13ae24
+  GNU_PROPERTY_LOUSER = 0xe0000000,
13ae24
+  GNU_PROPERTY_HIUSER = 0xffffffff
13ae24
+};
13ae24
+
13ae24
 } // End namespace elfcpp.
13ae24
 
13ae24
 // Include internal details after defining the types.
13ae24
--- binutils.orig/elfcpp/x86_64.h	2018-08-14 16:18:18.006466396 +0100
13ae24
+++ binutils-2.30/elfcpp/x86_64.h	2018-08-14 16:36:55.838125405 +0100
13ae24
@@ -103,6 +103,12 @@ enum
13ae24
   R_X86_64_GNU_VTENTRY = 251
13ae24
 };
13ae24
 
13ae24
+// The bit values that can appear in the GNU_PROPERTY_X86_FEATURE_1_AND
13ae24
+// program property.
13ae24
+
13ae24
+const uint64_t GNU_PROPERTY_X86_FEATURE_1_IBT = 1ULL << 0;
13ae24
+const uint64_t GNU_PROPERTY_X86_FEATURE_1_SHSTK = 1ULL << 1;
13ae24
+
13ae24
 } // End namespace elfcpp.
13ae24
 
13ae24
 #endif // !defined(ELFCPP_X86_64_H)
13ae24
--- binutils.orig/gold/object.cc	2018-08-14 16:43:20.553254144 +0100
13ae24
+++ binutils-2.30/gold/object.cc	2018-08-14 16:43:35.275144269 +0100
13ae24
@@ -1618,6 +1618,7 @@ Sized_relobj_file<size, big_endian>::do_
13ae24
   for (unsigned int i = 1; i < shnum; ++i, pshdrs += This::shdr_size)
13ae24
     {
13ae24
       typename This::Shdr shdr(pshdrs);
13ae24
+      unsigned int sh_type = shdr.get_sh_type();
13ae24
 
13ae24
       if (shdr.get_sh_name() >= section_names_size)
13ae24
 	{