This is the mail archive of the binutils-cvs@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]

[binutils-gdb/users/hjl/linux/master] Don't align start of segment unless alignment is larger than page size.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a5cd8f05ca759fdb9b27fc98a08edb5f85369ad9

commit a5cd8f05ca759fdb9b27fc98a08edb5f85369ad9
Author: Cary Coutant <ccoutant@google.com>
Date:   Fri Jan 9 15:55:50 2015 -0800

    Don't align start of segment unless alignment is larger than page size.
    
    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.

Diff:
---
 gold/ChangeLog | 5 +++++
 gold/layout.cc | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index 93529fe..1e73aa8 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -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>
 
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]