2015-01-25 Cary Coutant <ccoutant@google.com>
authorCary Coutant <ccoutant@google.com>
Mon, 26 Jan 2015 01:31:32 +0000 (17:31 -0800)
committerCary Coutant <ccoutant@google.com>
Mon, 26 Jan 2015 01:31:32 +0000 (17:31 -0800)
gold/
* output.cc (Output_segment::set_section_addresses): Fix calculation
of size of relro segment.

gold/ChangeLog
gold/output.cc

index 48f46ce9f6f4b143aae13aea429f322fb2fc92b0..946504aedbe6251eb3e68b3705788cc12949efd7 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-25  Cary Coutant  <ccoutant@google.com>
+
+       * output.cc (Output_segment::set_section_addresses): Fix calculation
+       of size of relro segment.
+
 2015-01-22  Alan Modra  <amodra@gmail.com>
 
        * powerpc.cc (Target_powerpc::Scan::local <got relocs>): Correct
index 9a51131255ab9e72f215fe6f460b9bc355cfde2e..e9dd522bdf751cb67163275eb009780bfc417914 100644 (file)
@@ -4311,8 +4311,8 @@ Output_segment::set_section_addresses(const Target* target,
              else
                {
                  // FIXME: This could be faster.
-                 (*p)->set_address_and_file_offset(addr + relro_size,
-                                                   off + relro_size);
+                 (*p)->set_address_and_file_offset(relro_size,
+                                                   relro_size);
                  relro_size += (*p)->data_size();
                  (*p)->reset_address_and_file_offset();
                }
@@ -4332,11 +4332,12 @@ Output_segment::set_section_addresses(const Target* target,
 
       // Align to offset N such that (N + RELRO_SIZE) % PAGE_ALIGN == 0.
       uint64_t desired_align = page_align - (aligned_size % page_align);
-      if (desired_align < *poff % page_align)
-       *poff += page_align - *poff % page_align;
-      *poff += desired_align - *poff % page_align;
-      addr += *poff - orig_off;
-      orig_off = *poff;
+      if (desired_align < off % page_align)
+       off += page_align;
+      off += desired_align - off % page_align;
+      addr += off - orig_off;
+      orig_off = off;
+      *poff = off;
     }
 
   if (!reset && this->are_addresses_set_)