Plumb 64-bit file offsets throughout the address space manager.
Untested.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4844 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_aspacemgr/aspacemgr.c b/coregrind/m_aspacemgr/aspacemgr.c
index 155f352..f788def 100644
--- a/coregrind/m_aspacemgr/aspacemgr.c
+++ b/coregrind/m_aspacemgr/aspacemgr.c
@@ -225,9 +225,10 @@
 // UNLESS YOU KNOW WHAT YOU ARE DOING.
 
 SysRes VG_(am_do_mmap_NO_NOTIFY)( Addr start, SizeT length, UInt prot, 
-                                  UInt flags, UInt fd, OffT offset)
+                                  UInt flags, UInt fd, Off64T offset)
 {
    SysRes res;
+   aspacem_assert(VG_IS_PAGE_ALIGNED(offset));
 #  if defined(VGP_x86_linux) || defined(VGP_ppc32_linux)
    res = VG_(do_syscall6)(__NR_mmap2, (UWord)start, length,
                           prot, flags, fd, offset / VKI_PAGE_SIZE);
@@ -1785,7 +1786,7 @@
 
 Bool
 VG_(am_notify_client_mmap)( Addr a, SizeT len, UInt prot, UInt flags,
-                            Int fd, SizeT offset )
+                            Int fd, Off64T offset )
 {
    HChar    buf[VKI_PATH_MAX];
    UInt     dev, ino;
@@ -1795,6 +1796,7 @@
    aspacem_assert(len > 0);
    aspacem_assert(VG_IS_PAGE_ALIGNED(a));
    aspacem_assert(VG_IS_PAGE_ALIGNED(len));
+   aspacem_assert(VG_IS_PAGE_ALIGNED(offset));
 
    /* Discard is needed if any of the just-trashed range had T. */
    needDiscard = any_Ts_in_range( a, len );
@@ -1921,7 +1923,7 @@
    segment array accordingly. */
 
 SysRes VG_(am_mmap_file_fixed_client)
-     ( Addr start, SizeT length, UInt prot, Int fd, SizeT offset )
+     ( Addr start, SizeT length, UInt prot, Int fd, Off64T offset )
 {
    SysRes     sres;
    NSegment   seg;
@@ -1932,7 +1934,9 @@
    HChar      buf[VKI_PATH_MAX];
 
    /* Not allowable. */
-   if (length == 0 || !VG_IS_PAGE_ALIGNED(start))
+   if (length == 0 
+       || !VG_IS_PAGE_ALIGNED(start)
+       || !VG_IS_PAGE_ALIGNED(offset))
       return VG_(mk_SysRes_Error)( VKI_EINVAL );
 
    /* Ask for an advisory.  If it's negative, fail immediately. */
@@ -2172,7 +2176,7 @@
    mapping in object files to read their debug info.  */
 
 SysRes VG_(am_mmap_file_float_valgrind) ( SizeT length, UInt prot, 
-                                          Int fd, SizeT offset )
+                                          Int fd, Off64T offset )
 {
    SysRes     sres;
    NSegment   seg;
@@ -2183,7 +2187,7 @@
    HChar      buf[VKI_PATH_MAX];
  
    /* Not allowable. */
-   if (length == 0)
+   if (length == 0 || !VG_IS_PAGE_ALIGNED(offset))
       return VG_(mk_SysRes_Error)( VKI_EINVAL );
 
    /* Ask for an advisory.  If it's negative, fail immediately. */
@@ -2791,6 +2795,19 @@
 
 static Int readhex ( const Char* buf, UWord* val )
 {
+   /* Read a word-sized hex number. */
+   Int n = 0;
+   *val = 0;
+   while (hexdigit(*buf) >= 0) {
+      *val = (*val << 4) + hexdigit(*buf);
+      n++; buf++;
+   }
+   return n;
+}
+
+static Int readhex64 ( const Char* buf, ULong* val )
+{
+   /* Read a potentially 64-bit hex number. */
    Int n = 0;
    *val = 0;
    while (hexdigit(*buf) >= 0) {
@@ -2877,7 +2894,8 @@
    UChar* filename;
    UChar  rr, ww, xx, pp, ch, tmp;
    UInt	  ino, prot;
-   UWord  foffset, maj, min;
+   UWord  maj, min;
+   ULong  foffset;
 
    read_procselfmaps_into_buf();
 
@@ -2917,7 +2935,7 @@
       j = readchar(&procmap_buf[i], &ch);
       if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
 
-      j = readhex(&procmap_buf[i], &foffset);
+      j = readhex64(&procmap_buf[i], &foffset);
       if (j > 0) i += j; else goto syntaxerror;
 
       j = readchar(&procmap_buf[i], &ch);
diff --git a/coregrind/m_syswrap/priv_syswrap-generic.h b/coregrind/m_syswrap/priv_syswrap-generic.h
index d99af6e..5c059dc 100644
--- a/coregrind/m_syswrap/priv_syswrap-generic.h
+++ b/coregrind/m_syswrap/priv_syswrap-generic.h
@@ -242,7 +242,7 @@
 extern void   ML_(generic_PRE_sys_shmctl)       ( TId, UW, UW, UW );
 extern void   ML_(generic_POST_sys_shmctl)      ( TId, UW, UW, UW, UW );
 
-extern SysRes ML_(generic_PRE_sys_mmap)         ( TId, UW, UW, UW, UW, UW, UW );
+extern SysRes ML_(generic_PRE_sys_mmap)         ( TId, UW, UW, UW, UW, UW, Off64T );
 
 #undef TId
 #undef UW
diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c
index c003003..1e38533 100644
--- a/coregrind/m_syswrap/syswrap-generic.c
+++ b/coregrind/m_syswrap/syswrap-generic.c
@@ -143,7 +143,7 @@
 */
 void 
 ML_(notify_aspacem_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot, 
-                                       UInt flags, Int fd, ULong offset )
+                                       UInt flags, Int fd, Off64T offset )
 {
    Bool rr, ww, xx, d;
 
@@ -1741,7 +1741,7 @@
 SysRes
 ML_(generic_PRE_sys_mmap) ( ThreadId tid,
                             UWord arg1, UWord arg2, UWord arg3,
-                            UWord arg4, UWord arg5, UWord arg6 )
+                            UWord arg4, UWord arg5, Off64T arg6 )
 {
    Addr       advised;
    SysRes     sres;
diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c
index 4c7d051..6f4b230 100644
--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c
+++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c
@@ -869,7 +869,8 @@
                  unsigned long, prot,  unsigned long, flags,
                  unsigned long, fd,    unsigned long, offset);
 
-   r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6 );
+   r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5, 
+                                       (Off64T)ARG6 );
    SET_STATUS_from_SysRes(r);
 }
 
@@ -887,7 +888,8 @@
                  unsigned long, prot,  unsigned long, flags,
                  unsigned long, fd,    unsigned long, offset);
 
-   r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6 * VKI_PAGE_SIZE );
+   r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5, 
+                                       VKI_PAGE_SIZE * (Of64T)ARG6 );
    SET_STATUS_from_SysRes(r);
 }
 
diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
index 797e257..adb7d33 100644
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
@@ -1483,7 +1483,7 @@
    PRINT("old_mmap ( %p, %llu, %d, %d, %d, %d )",
          a1, (ULong)a2, a3, a4, a5, a6 );
 
-   r = ML_(generic_PRE_sys_mmap)( tid, a1, a2, a3, a4, a5, a6 );
+   r = ML_(generic_PRE_sys_mmap)( tid, a1, a2, a3, a4, a5, (Off64T)a6 );
    SET_STATUS_from_SysRes(r);
 }
 
@@ -1502,7 +1502,8 @@
                  unsigned long, prot,  unsigned long, flags,
                  unsigned long, fd,    unsigned long, offset);
 
-   r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6 * VKI_PAGE_SIZE );
+   r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5, 
+                                       VKI_PAGE_SIZE * (Off64T)ARG6 );
    SET_STATUS_from_SysRes(r);
 }
 
diff --git a/coregrind/pub_core_aspacemgr.h b/coregrind/pub_core_aspacemgr.h
index 788319a..6bf343e 100644
--- a/coregrind/pub_core_aspacemgr.h
+++ b/coregrind/pub_core_aspacemgr.h
@@ -153,7 +153,7 @@
    True, the caller should immediately discard translations from the
    specified address range. */
 extern Bool VG_(am_notify_client_mmap)
-   ( Addr a, SizeT len, UInt prot, UInt flags, Int fd, SizeT offset );
+   ( Addr a, SizeT len, UInt prot, UInt flags, Int fd, Off64T offset );
 
 /* Notifies aspacem that an mprotect was completed successfully.  The
    segment array is updated accordingly.  Note, as with
@@ -181,7 +181,7 @@
    USE IT UNLESS YOU UNDERSTAND the request-notify model used by
    aspacem.  In short, DO NOT USE THIS FUNCTION. */
 extern SysRes VG_(am_do_mmap_NO_NOTIFY)
-   ( Addr start, SizeT length, UInt prot, UInt flags, UInt fd, OffT offset);
+   ( Addr start, SizeT length, UInt prot, UInt flags, UInt fd, Off64T offset);
 
 
 //--------------------------------------------------------------
@@ -195,7 +195,7 @@
 /* Map a file at a fixed address for the client, and update the
    segment array accordingly. */
 extern SysRes VG_(am_mmap_file_fixed_client)
-   ( Addr start, SizeT length, UInt prot, Int fd, SizeT offset );
+   ( Addr start, SizeT length, UInt prot, Int fd, Off64T offset );
 
 /* Map anonymously at a fixed address for the client, and update
    the segment array accordingly. */
@@ -215,7 +215,7 @@
    segment array accordingly.  This is used by V for transiently
    mapping in object files to read their debug info.  */
 extern SysRes VG_(am_mmap_file_float_valgrind)
-   ( SizeT length, UInt prot, Int fd, SizeT offset );
+   ( SizeT length, UInt prot, Int fd, Off64T offset );
 
 /* Unmap the given address range and update the segment array
    accordingly.  This fails if the range isn't valid for the client.
diff --git a/include/pub_tool_basics.h b/include/pub_tool_basics.h
index 7af5240..2733007 100644
--- a/include/pub_tool_basics.h
+++ b/include/pub_tool_basics.h
@@ -81,6 +81,8 @@
 
 typedef  Word                   OffT;     // 32             64
 
+typedef ULong                 Off64T;     // 64             64
+
 #if !defined(NULL)
 #  define NULL ((void*)0)
 #endif