From: Nicholas Nethercote Date: Tue, 26 Oct 2004 16:30:01 +0000 (+0000) Subject: Tweak as_mmap for the possibility of a PIE-supporting system with a 4GB user X-Git-Tag: svn/VALGRIND_3_0_0~1441 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=df61e3043df991d030f64eb201e6804b53b8bd1f;p=thirdparty%2Fvalgrind.git Tweak as_mmap for the possibility of a PIE-supporting system with a 4GB user space. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2855 --- diff --git a/corecheck/tests/Makefile.am b/corecheck/tests/Makefile.am index fa0c30ffa9..26cac4fdd4 100644 --- a/corecheck/tests/Makefile.am +++ b/corecheck/tests/Makefile.am @@ -4,7 +4,7 @@ ## blocking syscalls, etc. ##--------------------------------------------------------------------------- -noinst_SCRIPTS = filter_stderr filter_fdleak +noinst_SCRIPTS = filter_stderr filter_as_mmap filter_fdleak EXTRA_DIST = $(noinst_SCRIPTS) \ as_mmap.stderr.exp as_mmap.stderr.exp2 as_mmap.vgtest \ diff --git a/corecheck/tests/as_mmap.c b/corecheck/tests/as_mmap.c index da40a8612a..2d9f04e96e 100644 --- a/corecheck/tests/as_mmap.c +++ b/corecheck/tests/as_mmap.c @@ -6,21 +6,30 @@ int main() char local; char *top = (char *)(((unsigned long)&local + 0x0fffffff) & ~0x0fffffff); + fprintf(stderr, "1\n"); if (mmap((void *)0x00000000, 0x10000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0) == MAP_FAILED) - perror("mmap @ 0x00000000"); + fprintf(stderr, "mmap @ 0x00000000\n"); + + fprintf(stderr, "2\n"); if (mmap((void *)0x00010000, 0x10000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0) == MAP_FAILED) - perror("mmap @ 0x00010000"); + fprintf(stderr, "mmap @ 0x00010000\n"); + + fprintf(stderr, "3\n"); if (mmap((void *)0x50000000, 0x10000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0) == MAP_FAILED) - perror("mmap @ 0x50000000"); + fprintf(stderr, "mmap @ 0x50000000\n"); + + fprintf(stderr, "4\n"); if (mmap(top, 0x10000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0) == MAP_FAILED) - perror("mmap @ top"); + fprintf(stderr, "mmap @ top\n"); + + fprintf(stderr, "5\n"); if (mmap(top+0x08000000, 0x10000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0) == MAP_FAILED) - perror("mmap @ top+.5G"); + fprintf(stderr, "mmap @ top+.5G\n"); return 0; } diff --git a/corecheck/tests/as_mmap.stderr.exp b/corecheck/tests/as_mmap.stderr.exp index e5314c8ded..bc52d12630 100644 --- a/corecheck/tests/as_mmap.stderr.exp +++ b/corecheck/tests/as_mmap.stderr.exp @@ -1,9 +1,14 @@ -Warning: client syscall mmap2 tried to modify addresses 0x0-0x10000 -mmap @ 0x00000000: Cannot allocate memory -Warning: client syscall mmap2 tried to modify addresses 0xB0000000-0xB0010000 -mmap @ top: Cannot allocate memory -Warning: client syscall mmap2 tried to modify addresses 0xB8000000-0xB8010000 -mmap @ top+.5G: Cannot allocate memory +1 +Warning: client syscall mmap2 tried to modify addresses 0x........-0x........ +mmap @ 0x........ +2 +3 +4 +Warning: client syscall mmap2 tried to modify addresses 0x........-0x........ +mmap @ top +5 +Warning: client syscall mmap2 tried to modify addresses 0x........-0x........ +mmap @ top+.5G ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) diff --git a/corecheck/tests/as_mmap.stderr.exp2 b/corecheck/tests/as_mmap.stderr.exp2 index d400151966..2400662114 100644 --- a/corecheck/tests/as_mmap.stderr.exp2 +++ b/corecheck/tests/as_mmap.stderr.exp2 @@ -1,8 +1,13 @@ +1 Warning: client syscall mmap tried to modify addresses 0x0-0x10000 mmap @ 0x00000000: Cannot allocate memory +2 +3 +4 Warning: client syscall mmap tried to modify addresses 0xB0000000-0xB0010000 mmap @ top: Cannot allocate memory +5 Warning: client syscall mmap tried to modify addresses 0xB8000000-0xB8010000 mmap @ top+.5G: Cannot allocate memory diff --git a/corecheck/tests/as_mmap.vgtest b/corecheck/tests/as_mmap.vgtest index 13cb4513c1..b9c615445e 100644 --- a/corecheck/tests/as_mmap.vgtest +++ b/corecheck/tests/as_mmap.vgtest @@ -1 +1,2 @@ prog: as_mmap +stderr_filter: filter_as_mmap diff --git a/corecheck/tests/filter_as_mmap b/corecheck/tests/filter_as_mmap new file mode 100755 index 0000000000..e188381266 --- /dev/null +++ b/corecheck/tests/filter_as_mmap @@ -0,0 +1,8 @@ +#! /bin/sh + +dir=`dirname $0` + +$dir/../../tests/filter_stderr_basic | + +# Anonymise addresses +$dir/../../tests/filter_addresses