From: Tom Hughes Date: Thu, 29 Sep 2005 23:26:06 +0000 (+0000) Subject: On x86 and ppc32 the offset argument to mmap2 is specified in pages X-Git-Tag: svn/VALGRIND_3_1_0~407 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=734ffbfb60a7aef5e029e61a29045e1de6a5e2e8;p=thirdparty%2Fvalgrind.git On x86 and ppc32 the offset argument to mmap2 is specified in pages not bytes. This is a horrible kludge of a fix and it should probably be fixed properly with a separate sys_mmap for amd64. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4821 --- diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 86e7dcf500..53c3d2b4cd 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -552,6 +552,7 @@ PRE(sys_mmap2) { Addr advised; SysRes sres; + OffT offset; // Exactly like old_mmap() in x86-linux except: // - all 6 args are passed in regs, rather than in a memory-block. @@ -612,11 +613,17 @@ PRE(sys_mmap2) vg_assert(! FAILURE); +#if defined(VGP_x86_linux) || defined(VGP_ppc32_linux) + offset = ARG6 * VKI_PAGE_SIZE; +#else + offset = ARG6; +#endif + /* Otherwise we're OK (so far). Install aspacem's choice of address, and let the mmap go through. */ sres = VG_(am_do_mmap_NO_NOTIFY)(advised, ARG2, ARG3, ARG4 | VKI_MAP_FIXED, - ARG5, ARG6); + ARG5, offset); SET_STATUS_from_SysRes(sres); if (!sres.isError) { @@ -625,7 +632,7 @@ PRE(sys_mmap2) (Addr)sres.val, /* addr kernel actually assigned */ ARG2, ARG3, ARG4, /* the original flags value */ - ARG5, ARG6 + ARG5, offset ); /* Load symbols? */ VG_(di_notify_mmap)( (Addr)sres.val );