Blame SOURCES/binutils-gold-8-byte-note-segments.patch

8c00d6
diff -rup binutils.orig/gold/layout.cc binutils-2.30/gold/layout.cc
8c00d6
--- binutils.orig/gold/layout.cc	2018-10-09 15:24:05.987282736 +0100
8c00d6
+++ binutils-2.30/gold/layout.cc	2018-10-09 16:08:29.445946736 +0100
8c00d6
@@ -2052,12 +2052,15 @@ Layout::attach_allocated_section_to_segm
8c00d6
   // segment.
8c00d6
   if (os->type() == elfcpp::SHT_NOTE)
8c00d6
     {
8c00d6
+      uint64_t os_align = os->addralign();
8c00d6
+
8c00d6
       // See if we already have an equivalent PT_NOTE segment.
8c00d6
       for (p = this->segment_list_.begin();
8c00d6
 	   p != segment_list_.end();
8c00d6
 	   ++p)
8c00d6
 	{
8c00d6
 	  if ((*p)->type() == elfcpp::PT_NOTE
8c00d6
+	      && (*p)->align() == os_align
8c00d6
 	      && (((*p)->flags() & elfcpp::PF_W)
8c00d6
 		  == (seg_flags & elfcpp::PF_W)))
8c00d6
 	    {
8c00d6
@@ -2071,6 +2074,7 @@ Layout::attach_allocated_section_to_segm
8c00d6
 	  Output_segment* oseg = this->make_output_segment(elfcpp::PT_NOTE,
8c00d6
 							   seg_flags);
8c00d6
 	  oseg->add_output_section_to_nonload(os, seg_flags);
8c00d6
+	  oseg->set_align(os_align);
8c00d6
 	}
8c00d6
     }
8c00d6
 
8c00d6
@@ -3171,6 +3175,10 @@ Layout::create_note(const char* name, in
8c00d6
 #else
8c00d6
   const int size = 32;
8c00d6
 #endif
8c00d6
+  // The NT_GNU_PROPERTY_TYPE_0 note conforms to gABI.
8c00d6
+  const int addralign = ((note_type == elfcpp::NT_GNU_PROPERTY_TYPE_0
8c00d6
+			 ? parameters->target().get_size()
8c00d6
+			 : size) / 8);
8c00d6
 
8c00d6
   // The contents of the .note section.
8c00d6
   size_t namesz = strlen(name) + 1;
8c00d6
@@ -3234,7 +3242,7 @@ Layout::create_note(const char* name, in
8c00d6
     return NULL;
8c00d6
 
8c00d6
   Output_section_data* posd = new Output_data_const_buffer(buffer, notehdrsz,
8c00d6
-							   size / 8,
8c00d6
+							   addralign,
8c00d6
 							   "** note header");
8c00d6
   os->add_output_section_data(posd);
8c00d6
 
8c00d6
@@ -3692,6 +3700,11 @@ Layout::segment_precedes(const Output_se
8c00d6
     {
8c00d6
       if (type1 != type2)
8c00d6
 	return type1 < type2;
8c00d6
+      uint64_t align1 = seg1->align();
8c00d6
+      uint64_t align2 = seg2->align();
8c00d6
+      // Place segments with larger alignments first.
8c00d6
+      if (align1 != align2)
8c00d6
+	return align1 > align2;
8c00d6
       gold_assert(flags1 != flags2
8c00d6
 		  || this->script_options_->saw_phdrs_clause());
8c00d6
       return flags1 < flags2;
8c00d6
diff -rup binutils.orig/gold/output.cc binutils-2.30/gold/output.cc
8c00d6
--- binutils.orig/gold/output.cc	2018-10-09 15:24:05.986282744 +0100
8c00d6
+++ binutils-2.30/gold/output.cc	2018-10-09 16:09:03.749670846 +0100
8c00d6
@@ -4107,6 +4107,7 @@ Output_segment::Output_segment(elfcpp::E
8c00d6
   : vaddr_(0),
8c00d6
     paddr_(0),
8c00d6
     memsz_(0),
8c00d6
+    align_(0),
8c00d6
     max_align_(0),
8c00d6
     min_p_align_(0),
8c00d6
     offset_(0),
8c00d6
diff -rup binutils.orig/gold/output.h binutils-2.30/gold/output.h
8c00d6
--- binutils.orig/gold/output.h	2018-10-09 15:24:05.984282760 +0100
8c00d6
+++ binutils-2.30/gold/output.h	2018-10-09 16:09:45.665333727 +0100
8c00d6
@@ -4676,6 +4676,16 @@ class Output_segment
8c00d6
   offset() const
8c00d6
   { return this->offset_; }
8c00d6
 
8c00d6
+  // Return the segment alignment.
8c00d6
+  uint64_t
8c00d6
+  align() const
8c00d6
+  { return this->align_; }
8c00d6
+
8c00d6
+  // Set the segment alignment.
8c00d6
+  void
8c00d6
+  set_align(uint64_t align)
8c00d6
+  { this->align_ = align; }
8c00d6
+
8c00d6
   // Whether this is a segment created to hold large data sections.
8c00d6
   bool
8c00d6
   is_large_data_segment() const
8c00d6
@@ -4898,6 +4908,8 @@ class Output_segment
8c00d6
   uint64_t paddr_;
8c00d6
   // The size of the segment in memory.
8c00d6
   uint64_t memsz_;
8c00d6
+  // The segment alignment.
8c00d6
+  uint64_t align_;
8c00d6
   // The maximum section alignment.  The is_max_align_known_ field
8c00d6
   // indicates whether this has been finalized.
8c00d6
   uint64_t max_align_;