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