From 98e527a62c6d487453c39bd885ad8378d8a122e8 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Fri, 30 Sep 2005 00:45:47 +0000 Subject: [PATCH] A corresponding fix to 4823: don't deal with MAP_FIXED case directly here; instead uniformly pass all requests to VG_(am_get_advisory), so that layout policy is controlled from one place only. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4824 --- coregrind/m_syswrap/syswrap-x86-linux.c | 50 +++++++++++-------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 034ddb1945..c03601a65d 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -1472,6 +1472,8 @@ PRE(old_mmap) UWord a1, a2, a3, a4, a5, a6; Addr advised; SysRes sres; + Bool mreq_ok; + SysRes sres; UWord* args = (UWord*)ARG1; PRE_REG_READ1(long, "old_mmap", struct mmap_arg_struct *, args); @@ -1494,7 +1496,7 @@ PRE(old_mmap) return; } - if (/*(a4 & VKI_MAP_FIXED) &&*/ !VG_IS_PAGE_ALIGNED(a1)) { + if (!VG_IS_PAGE_ALIGNED(a1)) { /* zap any misaligned addresses. */ SET_STATUS_Failure( VKI_EINVAL ); return; @@ -1502,38 +1504,30 @@ PRE(old_mmap) /* Figure out what kind of allocation constraints there are (fixed/hint/any), and ask aspacem what we should do. */ + mreq.start = a1; + mreq.len = a2; if (a4 & VKI_MAP_FIXED) { - if (!ML_(valid_client_addr)(a1, a2, tid, "mmap2")) { - SET_STATUS_Failure( VKI_EINVAL ); - return; - } + mreq.rkind = MFixed; + } else + if (a1 != 0) { + mreq.rkind = MHint; } else { - MapRequest mreq; - Bool mreq_ok; - - mreq.start = a1; - mreq.len = a2; - - if (a1 != 0) { - mreq.rkind = MHint; - } else { - mreq.rkind = MAny; - } - - /* Enquire ... */ - advised = VG_(am_get_advisory)( &mreq, True/*client*/, &mreq_ok ); - if (!mreq_ok) { - /* Our request was bounced, so we'd better fail. */ - SET_STATUS_Failure( VKI_EINVAL ); - return; - } + mreq.rkind = MAny; + } - /* Otherwise we're OK (so far). Install aspacem's choice of - address, and let the mmap go through. */ - a1 = advised; - a4 |= VKI_MAP_FIXED; + /* Enquire ... */ + advised = VG_(am_get_advisory)( &mreq, True/*client*/, &mreq_ok ); + if (!mreq_ok) { + /* Our request was bounced, so we'd better fail. */ + SET_STATUS_Failure( VKI_EINVAL ); + return; } + /* Otherwise we're OK (so far). Install aspacem's choice of + address, and let the mmap go through. */ + a1 = advised; + a4 |= VKI_MAP_FIXED; + vg_assert(! FAILURE); sres = VG_(am_do_mmap_NO_NOTIFY)(a1, a2, a3, a4, a5, a6); -- 2.47.3