Fix problem causing internal error when -z max-page-size is used.
authorCary Coutant <ccoutant@gmail.com>
Fri, 2 Dec 2016 03:00:30 +0000 (19:00 -0800)
committerCary Coutant <ccoutant@gmail.com>
Fri, 2 Dec 2016 03:00:30 +0000 (19:00 -0800)
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.

gold/ChangeLog
gold/target.h

index ab1181ad2e8b04db4ba877b3998143467789405f..ea7b9f8be3912b6b97bab266af7b242317dfd5a8 100644 (file)
@@ -1,3 +1,9 @@
+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
index 8e801e18278e3f0f9d5321381b8b028fbda06692..51402c20deef19ec07264d234f65aa5f57d29509 100644 (file)
@@ -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
This page took 0.026888 seconds and 4 git commands to generate.