From: Daniel DOT Diaz AT inria DOT fr (Daniel Diaz) Subject: problems with mmap/munmap - HELP 18 Sep 1997 02:59:14 -0700 Message-ID: <199709180931.LAA07089.cygnus.gnu-win32@margaux.inria.fr> Mime-Version: 1.0 Content-Type: text/plain To: gnu-win32 AT cygnus DOT com Hi, I'm a new user of gnu-win32-gcc, btw congratulations to all people working on this project. I'd like to port a compiler initially written for the unix world. A key feature of my system is that it uses the MMU to avoid to chech stacks overflows. Indeed, i use 3 stacks and to avoid to check for overflows i use the mmap/munmap facility. More precisely I allocate a 'big' space with mmap (MAP_ANONYMOUS) whose size equals to the sum of the size of each stack + 3 pages (obtained by getpagesize()), then I munmap the page which follows each stack. Here is the memory map obtained: +-----------------+ | a free page | <- page given back by munmap +-----------------+ | space for | | stack | | # 3 | | : | +-----------------+ | a free page | <- page given back by munmap +-----------------+ | space for | | stack | | # 2 | | : | +-----------------+ | a free page | <- page given back by munmap +-----------------+ | space for | | stack | | # 1 | | : | +-----------------+ <- address given by mmap When a stack overflows, an attempt to read/write into the munmapped page occurs, the MMU triggers than a signal (SIGSEGV) that i catch to inform the user about the overflow. The problem under gnu-win32-gcc is that i cannot munmap at an address different from the one returned by mmap (so i can only give back the first page, ie. inside the space for the first stack). How could I do ? Where are the docs about mmap ? I have also seen a function mprotect(), could I use it ? Since this mechanism is very important in my implementation I'd really likle to find an efficient solution. Please Help :-) -- Daniel Diaz INRIA Rocquencourt - 78153 Le Chesnay Cedex FRANCE tel: +33 1 39 63 52 67 email: Daniel DOT Diaz AT inria DOT fr ============================================ - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".