Bug 606194 - Use mmap given addresses if necessary, r=taras a=blocking-fennec
authorMichael Wu <mwu@mozilla.com>
Thu, 03 Feb 2011 12:10:02 -0500
changeset 61848 d62ae33c94d7ce71f2bb126a4eaf0a5b7a1dae66
parent 61847 f1f0bf6fedbbe884eecc2699799c357628286f7f
child 61849 30d1de20ece27bf8b53d7745960e13b4b4bc0f8c
push idunknown
push userunknown
push dateunknown
reviewerstaras, blocking-fennec
bugs606194
milestone2.0b12pre
Bug 606194 - Use mmap given addresses if necessary, r=taras a=blocking-fennec
other-licenses/android/linker.c
--- a/other-licenses/android/linker.c
+++ b/other-licenses/android/linker.c
@@ -823,30 +823,40 @@ get_lib_extents(int fd, const char *name
  *
  * Returns:
  *     -1 on failure, and 0 on success.  On success, si->base will contain
  *     the virtual address at which the library will be mapped.
  */
 
 static int reserve_mem_region(soinfo *si)
 {
+#ifdef MOZ_LINKER
+    static int mapping_collision = 0;
+    if (mapping_collision)
+        si->base = NULL;
+#endif
     void *base = mmap((void *)si->base, si->size, PROT_READ | PROT_EXEC,
                       MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
     if (base == MAP_FAILED) {
         DL_ERR("%5d can NOT map (%sprelinked) library '%s' at 0x%08x "
               "as requested, will try general pool: %d (%s)",
               pid, (si->base ? "" : "non-"), si->name, si->base,
               errno, strerror(errno));
         return -1;
     } else if (base != (void *)si->base) {
+#ifdef MOZ_LINKER
+        mapping_collision = 1;
+        si->base = base;
+#else
         DL_ERR("OOPS: %5d %sprelinked library '%s' mapped at 0x%08x, "
               "not at 0x%08x", pid, (si->ba_index < 0 ? "" : "non-"),
               si->name, (unsigned)base, si->base);
         munmap(base, si->size);
         return -1;
+#endif
     }
     return 0;
 }
 
 static int
 alloc_mem_region(soinfo *si)
 {
     if (si->base) {