summaryrefslogtreecommitdiff
path: root/mem.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-02-18 03:13:07 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-02-18 03:13:07 +0100
commit8dedb0dc9636f64d6d1865a55d06a6fb6c4a04a9 (patch)
tree884ddf0950cbd4be653ab3ee7f783f4755e289c8 /mem.c
parent923255cbe89bd75cedddd4d80a3b446eae4b6700 (diff)
downloadstrace-8dedb0dc9636f64d6d1865a55d06a6fb6c4a04a9.tar.gz
strace-8dedb0dc9636f64d6d1865a55d06a6fb6c4a04a9.tar.bz2
strace-8dedb0dc9636f64d6d1865a55d06a6fb6c4a04a9.tar.xz
Fixes in "new" mmap
* mem.c (sys_mmap): Ensure unsigned expansion of tcp->u_arg[5]. Add page shift of offset for I386. Use tcp->ext_arg[5] as offset for X32. (sys_old_mmap): [X32] Remove this function, X32 doesn't use is. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'mem.c')
-rw-r--r--mem.c49
1 files changed, 7 insertions, 42 deletions
diff --git a/mem.c b/mem.c
index a0cfc52..389e098 100644
--- a/mem.c
+++ b/mem.c
@@ -280,13 +280,8 @@ int sys_old_mmap(struct tcb *tcp)
int
sys_mmap(struct tcb *tcp)
{
- long long offset = tcp->u_arg[5];
+ unsigned long long offset = (unsigned long) tcp->u_arg[5];
- /* FIXME: why only SH64? i386 mmap2 syscall ends up
- * in this function, but does not convert offset
- * from pages to bytes. See test/mmap_offset_decode.c
- * Why SH64 and i386 are handled differently?
- */
#if defined(SH64)
/*
* Old mmap differs from new mmap in specifying the
@@ -295,8 +290,12 @@ sys_mmap(struct tcb *tcp)
* sees bytes in the printout.
*/
offset <<= PAGE_SHIFT;
-#endif
-#if defined(LINUX_MIPSN32)
+#elif defined(I386)
+ /* Try test/mmap_offset_decode.c */
+ offset <<= 12; /* 4096 byte pages */
+#elif defined(LINUX_MIPSN32) || defined(X32)
+ /* Try test/x32_mmap.c */
+ /* At least for X32 it definitely should not be page-shifted! */
offset = tcp->ext_arg[5];
#endif
return print_mmap(tcp, tcp->u_arg, offset);
@@ -304,40 +303,6 @@ sys_mmap(struct tcb *tcp)
#endif /* !HAVE_LONG_LONG_OFF_T */
#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
-# if defined(X32)
-int sys_old_mmap(struct tcb *tcp)
-{
- long u_arg[6];
- if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), (char *) u_arg) == -1)
- return 0;
- if (entering(tcp)) {
- /* addr */
- if (!u_arg[0])
- tprints("NULL, ");
- else
- tprintf("%#lx, ", u_arg[0]);
- /* len */
- tprintf("%lu, ", u_arg[1]);
- /* prot */
- printflags(mmap_prot, u_arg[2], "PROT_???");
- tprints(", ");
- /* flags */
-# ifdef MAP_TYPE
- printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
- addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
-# else
- printflags(mmap_flags, u_arg[3], "MAP_???");
-# endif
- /* fd */
- tprints(", ");
- printfd(tcp, u_arg[4]);
- /* offset */
- tprintf(", %#lx", u_arg[5]);
- }
- return RVAL_HEX;
-}
-# endif
-
/* TODO: comment which arches use this routine.
* For one, does ALPHA on Linux use this??
* From code it seems that it might use 7 or 8 registers,