]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
ML_(generic_PRE_sys_mmap): In the case of a hinted mapping (for the
authorJulian Seward <jseward@acm.org>
Tue, 9 Jan 2007 16:47:20 +0000 (16:47 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 9 Jan 2007 16:47:20 +0000 (16:47 +0000)
client) which aspacemgr accepts at the hint address but the kernel
declines, try again as a non-hinted mapping.  Fixes ld.so mapping
failures observed on ppc32-linux, although the problem potentially
applies to all Linux targets.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6495

coregrind/m_syswrap/syswrap-generic.c

index 8a9d5f1e34c9f47ed8d19748e24700a6fa4b2d1a..02daf2d83dad79018b99b68dc9947596fe98fc40 100644 (file)
@@ -1888,6 +1888,25 @@ ML_(generic_PRE_sys_mmap) ( ThreadId tid,
                                     arg4 | VKI_MAP_FIXED,
                                     arg5, arg6);
 
+   /* A refinement: it may be that the kernel refused aspacem's choice
+      of address.  If we were originally asked for a hinted mapping,
+      there is still a last chance: try again at any address.
+      Hence: */
+   if (mreq.rkind == MHint && sres.isError) {
+      mreq.start = 0;
+      mreq.len   = arg2;
+      mreq.rkind = MAny;
+      advised = VG_(am_get_advisory)( &mreq, True/*client*/, &mreq_ok );
+      if (!mreq_ok) {
+         /* Our request was bounced, so we'd better fail. */
+         return VG_(mk_SysRes_Error)( VKI_EINVAL );
+      }
+      /* and try again with the kernel */
+      sres = VG_(am_do_mmap_NO_NOTIFY)(advised, arg2, arg3,
+                                       arg4 | VKI_MAP_FIXED,
+                                       arg5, arg6);
+   }
+
    if (!sres.isError) {
       /* Notify aspacem and the tool. */
       ML_(notify_aspacem_and_tool_of_mmap)(