/* 189 */ SyscallDesc("putpmsg", unimplementedFunc),
/* 190 */ SyscallDesc("vfork", unimplementedFunc),
/* 191 */ SyscallDesc("ugetrlimit", ignoreFunc),
- /* 192 */ SyscallDesc("mmap2", mmapFunc<X86Linux32>),
+ /* 192 */ SyscallDesc("mmap2", mmap2Func<X86Linux32>),
/* 193 */ SyscallDesc("truncate64", truncate64Func),
/* 194 */ SyscallDesc("ftruncate64", ftruncate64Func),
/* 195 */ SyscallDesc("stat64", stat64Func<X86Linux32>),
return result;
}
-
-/// Target mmap() handler.
+/// Real mmap handler.
template <class OS>
SyscallReturn
-mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
+mmapImpl(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc,
+ bool is_mmap2)
{
int index = 0;
Addr start = p->getSyscallArg(tc, index);
int tgt_fd = p->getSyscallArg(tc, index);
int offset = p->getSyscallArg(tc, index);
- DPRINTF_SYSCALL(Verbose, "mmap(0x%x, len %d, prot %d, flags %d, fd %d, "
- "offs %d)\n", start, length, prot, tgt_flags, tgt_fd,
- offset);
+ if (is_mmap2)
+ offset *= TheISA::PageBytes;
if (start & (TheISA::PageBytes - 1) ||
offset & (TheISA::PageBytes - 1) ||
return start;
}
+/// Target mmap() handler.
+template <class OS>
+SyscallReturn
+mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
+{
+ return mmapImpl<OS>(desc, num, p, tc, false);
+}
+
+/// Target mmap2() handler.
+template <class OS>
+SyscallReturn
+mmap2Func(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
+{
+ return mmapImpl<OS>(desc, num, p, tc, true);
+}
+
/// Target getrlimit() handler.
template <class OS>
SyscallReturn