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
This commit is contained in:
Nicholas Nethercote 2004-10-26 16:30:01 +00:00
parent 1475455567
commit df61e3043d
6 changed files with 40 additions and 12 deletions

View File

@ -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 \

View File

@ -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;
}

View File

@ -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)

View File

@ -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

View File

@ -1 +1,2 @@
prog: as_mmap
stderr_filter: filter_as_mmap

8
corecheck/tests/filter_as_mmap Executable file
View File

@ -0,0 +1,8 @@
#! /bin/sh
dir=`dirname $0`
$dir/../../tests/filter_stderr_basic |
# Anonymise addresses
$dir/../../tests/filter_addresses