]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Plumb 64-bit file offsets throughout the address space manager.
authorJulian Seward <jseward@acm.org>
Sun, 2 Oct 2005 17:01:41 +0000 (17:01 +0000)
committerJulian Seward <jseward@acm.org>
Sun, 2 Oct 2005 17:01:41 +0000 (17:01 +0000)
Untested.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4844

coregrind/m_aspacemgr/aspacemgr.c
coregrind/m_syswrap/priv_syswrap-generic.h
coregrind/m_syswrap/syswrap-generic.c
coregrind/m_syswrap/syswrap-ppc32-linux.c
coregrind/m_syswrap/syswrap-x86-linux.c
coregrind/pub_core_aspacemgr.h
include/pub_tool_basics.h

index 155f35216d7229b40827597dbdb7a1493a4d7aa7..f788def234d0524ea35126c45aed58bcd86e18c5 100644 (file)
@@ -225,9 +225,10 @@ UInt aspacem_sprintf ( HChar* buf, const HChar *format, ... )
 // 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 @@ Addr VG_(am_get_advisory_client_simple) ( Addr start, SizeT len,
 
 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 @@ VG_(am_notify_client_mmap)( Addr a, SizeT len, UInt prot, UInt flags,
    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 @@ Bool VG_(am_notify_munmap)( Addr start, SizeT len )
    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 @@ SysRes VG_(am_mmap_file_fixed_client)
    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 @@ void* VG_(am_shadow_alloc)(SizeT size)
    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 @@ SysRes VG_(am_mmap_file_float_valgrind) ( SizeT length, UInt prot,
    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 readchar ( const Char* buf, Char* ch )
 
 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 @@ static void parse_procselfmaps (
    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 @@ static void parse_procselfmaps (
       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);
index d99af6e398c832316bae69c5c6ff3a8b6f1a2ff3..5c059dc1ffe6694e8353cc7cbf8b5435c522014f 100644 (file)
@@ -242,7 +242,7 @@ extern void   ML_(generic_POST_sys_shmdt)       ( TId, UW, UW );
 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
index c0030036d47b9b4afe6ef7c9d1b7484505671769..1e385336cc6bb5dda3eea5f3d0dc9e883b91770b 100644 (file)
@@ -143,7 +143,7 @@ void page_align_addr_and_len( Addr* a, SizeT* len)
 */
 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 @@ ML_(generic_POST_sys_shmctl) ( ThreadId tid,
 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;
index 4c7d051f4c4bb40bb1d5b0a3d4d98cd3cc39135d..6f4b230f4f91ea2148cfb968275f0007cd1c47e2 100644 (file)
@@ -869,7 +869,8 @@ PRE(sys_mmap)
                  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 @@ PRE(sys_mmap2)
                  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);
 }
 
index 797e257516a562b1d18bed062e6575eaf7deb1c2..adb7d33e1cee5f128e3fa430dba32b16c75bc018 100644 (file)
@@ -1483,7 +1483,7 @@ PRE(old_mmap)
    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 @@ PRE(sys_mmap2)
                  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);
 }
 
index 788319a62bcecc919ec4d44cceec2c06de0031da..6bf343ec4172c3e4c82edd29150995ea91ee8ef5 100644 (file)
@@ -153,7 +153,7 @@ extern Addr VG_(am_get_advisory_client_simple)
    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 @@ extern Bool VG_(am_notify_munmap)( Addr start, SizeT len );
    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 @@ extern SysRes VG_(am_do_mmap_NO_NOTIFY)
 /* 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 @@ extern SysRes VG_(am_mmap_anon_float_valgrind)( SizeT cszB );
    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.
index 7af5240e93a850d9ce109b2b96466e1e2b81adeb..2733007303d977249865e126803a4b3b6ad08ba0 100644 (file)
@@ -81,6 +81,8 @@ typedef  Word                 SSizeT;     // 32             64
 
 typedef  Word                   OffT;     // 32             64
 
+typedef ULong                 Off64T;     // 64             64
+
 #if !defined(NULL)
 #  define NULL ((void*)0)
 #endif