This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gold commit] Aligning segments in gold


On Fri, Jan 9, 2015 at 3:24 PM, Ian Lance Taylor <iant@google.com> wrote:
> On Fri, Jan 9, 2015 at 3:01 PM, Cary Coutant <ccoutant@google.com> wrote:
>>> (*p)->maximum_alignment is going to feed into the p_align field.  It
>>> sounds like you are saying that it's OK if a phdr is not aligned
>>> according to what its p_align field says.  Is that right?
>>
>> Right. Segments aren't expected to begin at p_align boundaries (and
>> typically don't). From the gABI:
>>
>> p_align
>>     As ``Program Loading'' describes in this chapter of the processor
>> supplement, loadable process segments must have congruent values for
>> p_vaddr and p_offset, modulo the page size. This member gives the
>> value to which the segments are aligned in memory and in the file.
>> Values 0 and 1 mean no alignment is required. Otherwise, p_align
>> should be a positive, integral power of 2, and p_vaddr should equal
>> p_offset, modulo p_align.
>>
>> While "This member gives the value to which the segments are aligned
>> in memory and in the file" might be read to imply otherwise, I think
>> the last sentence is generally understood to mean that p_offset and
>> p_vaddr are not individually required to be aligned at a p_align
>> boundary.
>
> Ah, right.
>
> OK, original messages sounds good to me.

OK, thanks for looking at it. I've committed the patch.

-cary


2015-01-09  Cary Coutant  <ccoutant@google.com>

        * layout.cc (Layout::set_segment_offsets): Don't align start of segment
        unless alignment is larger than page size.

diff --git a/gold/layout.cc b/gold/layout.cc
index acc03b2..bcdaac8 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -3524,7 +3524,9 @@ Layout::set_segment_offsets(const Target*
target, Output_segment* load_seg,
              // put them on different pages in memory. We will revisit this
              // decision once we know the size of the segment.

-             addr = align_address(addr, (*p)->maximum_alignment());
+             uint64_t max_align = (*p)->maximum_alignment();
+             if (max_align > abi_pagesize)
+               addr = align_address(addr, max_align);
              aligned_addr = addr;

              if (load_seg == *p)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]