Don't align start of segment unless alignment is larger than page size.
authorCary Coutant <ccoutant@google.com>
Fri, 9 Jan 2015 23:55:50 +0000 (15:55 -0800)
committerCary Coutant <ccoutant@google.com>
Fri, 9 Jan 2015 23:58:39 +0000 (15:58 -0800)
This fixes an issue where a page-aligned data section, combined with -z relro,
could lead to a gap between text and data segments larger than a page, and
we would fail to overlap the segments in the file.

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

gold/ChangeLog
gold/layout.cc

index 93529fe5364e951373781db27df22358da398bbe..1e73aa8effb34a22de0827052034e8bdd52d6979 100644 (file)
@@ -1,3 +1,8 @@
+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.
+
 2015-01-06  H.J. Lu  <hongjiu.lu@intel.com>
            Cary Coutant  <ccoutant@google.com>
 
index acc03b21e19bf09cbb035709abdfb79945e56e7b..bcdaac825dbc83c7c2526f439f7e0a6bcd270adb 100644 (file)
@@ -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)
This page took 0.049734 seconds and 4 git commands to generate.