mmap & MAP_FIXED
From: Antonio Musumeci (bile_at_landofbile.com)
Date: 10/28/04
- Previous message: el cintura partida: "Re: advanced Makefile tutorial"
- Next in thread: John Reiser: "Re: mmap & MAP_FIXED"
- Reply: John Reiser: "Re: mmap & MAP_FIXED"
- Reply: Antonio Musumeci: "Re: mmap & MAP_FIXED"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Oct 2004 07:38:15 -0700
i'm not sure if this is a mmap or ld-linux bug... or if it's just a
no-no and shouldnt work regardless.
pagesize = getpagesize();
fd = open("mapped_data", O_CREAT|O_RDWR, 0666);
lseek(fd, pagesize-1, SEEK_SET);
write(fd, "X", 1);
ptr = mmap(0, pagesize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
printf("%p\n", ptr);
for(i = 1; i < 10; i++)
{
lseek(fd, ((pagesize*(i+1))-1), SEEK_SET);
write(fd, "X", 1);
ptr = mmap(ptr+pagesize, pagesize, PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED, fd, pagesize*i);
printf("%p\n", ptr);
strcpy(ptr, "HNC");
}
When dynamically compiled... i get this
0xb7feb000
0xb7fec000
Program received signal SIGSEGV, Segmentation fault.
0xb7ff3c50 in _dl_rtld_di_serinfo () from /lib/ld-linux.so.2
the seg is at the strcpy but if i remove it it will give the same
fault when it exits. this code works however when statically compiled.
This is similar to what gdb's mmalloc does/did... but that also fails
the same way.
Linux 2.6.9, glibc 2.3.3, gcc 3.3.4
any ideas?
- Previous message: el cintura partida: "Re: advanced Makefile tutorial"
- Next in thread: John Reiser: "Re: mmap & MAP_FIXED"
- Reply: John Reiser: "Re: mmap & MAP_FIXED"
- Reply: Antonio Musumeci: "Re: mmap & MAP_FIXED"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|