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] Fix problem causing internal error when -z max-page-size is used.


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

commit be2884c1ea9b96fdb04c6d244d9e7aa1b654a47a
Author: Cary Coutant <ccoutant@gmail.com>
Date:   Thu Dec 1 19:00:30 2016 -0800

    Fix problem causing internal error when -z max-page-size is used.
    
    If the default starting address is less than the new ABI page size,
    we end up misaligning the file header, causing an internal error.
    
    gold/
    	PR gold/20834
    	* target.h (Target::default_text_segment_address): Bump default
    	start address up to ABI page size.

Diff:
---
 gold/ChangeLog |  6 ++++++
 gold/target.h  | 12 +++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index ab1181a..ea7b9f8 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,11 @@
 2016-12-01  Cary Coutant  <ccoutant@gmail.com>
 
+	PR gold/20834
+	* target.h (Target::default_text_segment_address): Bump default
+	start address up to ABI page size.
+
+2016-12-01  Cary Coutant  <ccoutant@gmail.com>
+
 	PR gold/18989
 	* options.cc (General_options::object_format_to_string): New function.
 	(General_options::copy_from_posdep_options): New function.
diff --git a/gold/target.h b/gold/target.h
index 8e801e1..51402c2 100644
--- a/gold/target.h
+++ b/gold/target.h
@@ -119,9 +119,19 @@ class Target
   { return this->pti_->dynamic_linker; }
 
   // Return the default address to use for the text segment.
+  // If a -z max-page-size argument has set the ABI page size
+  // to a value larger than the default starting address,
+  // bump the starting address up to the page size, to avoid
+  // misaligning the text segment in the file.
   uint64_t
   default_text_segment_address() const
-  { return this->pti_->default_text_segment_address; }
+  {
+    uint64_t addr = this->pti_->default_text_segment_address;
+    uint64_t pagesize = this->abi_pagesize();
+    if (addr < pagesize)
+      addr = pagesize;
+    return addr;
+  }
 
   // Return the ABI specified page size.
   uint64_t


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