From: Julian Seward Date: Sun, 2 Oct 2005 17:01:41 +0000 (+0000) Subject: Plumb 64-bit file offsets throughout the address space manager. X-Git-Tag: svn/VALGRIND_3_1_0~384 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7cd9cb3de875621553f077c6bf384236ae0db88;p=thirdparty%2Fvalgrind.git Plumb 64-bit file offsets throughout the address space manager. Untested. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4844 --- diff --git a/coregrind/m_aspacemgr/aspacemgr.c b/coregrind/m_aspacemgr/aspacemgr.c index 155f35216d..f788def234 100644 --- a/coregrind/m_aspacemgr/aspacemgr.c +++ b/coregrind/m_aspacemgr/aspacemgr.c @@ -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); diff --git a/coregrind/m_syswrap/priv_syswrap-generic.h b/coregrind/m_syswrap/priv_syswrap-generic.h index d99af6e398..5c059dc1ff 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_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 diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index c0030036d4..1e385336cc 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -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; diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c index 4c7d051f4c..6f4b230f4f 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -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); } diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 797e257516..adb7d33e1c 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -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); } diff --git a/coregrind/pub_core_aspacemgr.h b/coregrind/pub_core_aspacemgr.h index 788319a62b..6bf343ec41 100644 --- a/coregrind/pub_core_aspacemgr.h +++ b/coregrind/pub_core_aspacemgr.h @@ -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. diff --git a/include/pub_tool_basics.h b/include/pub_tool_basics.h index 7af5240e93..2733007303 100644 --- a/include/pub_tool_basics.h +++ b/include/pub_tool_basics.h @@ -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