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

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