Bug 824715 - Correctly calculate next page offset in custom linker; r=glandium
☠☠ backed out by 22e38c3125e9 ☠ ☠
authorJim Chen <nchen@mozilla.com>
Fri, 28 Dec 2012 15:29:44 -0500
changeset 126284 10b47593c4d740146d3bcce087bc134ee42b64d5
parent 126283 35a0599d087a817b64c1ac67d550667d6bf6670e
child 126285 a47d98073d4ebbde9ef59e33a57acf3ae331d72e
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs824715
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 824715 - Correctly calculate next page offset in custom linker; r=glandium
mozglue/linker/CustomElf.cpp
--- a/mozglue/linker/CustomElf.cpp
+++ b/mozglue/linker/CustomElf.cpp
@@ -434,17 +434,17 @@ CustomElf::LoadSegment(const Phdr *pt_lo
    * of the page p_filesz is in, memory is nulled out.
    * Above the end of that page, and up to p_memsz, we already have nulled out
    * memory because we mapped anonymous memory on the whole library virtual
    * address space. We just need to adjust this anonymous memory protection
    * flags. */
   if (pt_load->p_memsz > pt_load->p_filesz) {
     Addr file_end = pt_load->p_vaddr + pt_load->p_filesz;
     Addr mem_end = pt_load->p_vaddr + pt_load->p_memsz;
-    Addr next_page = (file_end & ~(PAGE_SIZE - 1)) + PAGE_SIZE;
+    Addr next_page = (file_end + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
     if (mem_end > next_page) {
       if (mprotect(GetPtr(next_page), mem_end - next_page, prot) < 0) {
         log("%s: Failed to mprotect", GetPath());
         return false;
       }
     }
   }
   return true;