njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1 | #include <unistd.h> |
| 2 | #include <sys/mman.h> |
| 3 | #include <stdio.h> |
| 4 | #include <stdlib.h> |
| 5 | |
| 6 | /* Point of this is that the fd of an PROT_EXEC segment is -1, so Valgrind |
| 7 | shouldn't add it to its list of exe segs, and thus it won't be discarded |
| 8 | upon the munmap() (so no "discard" message). */ |
| 9 | |
| 10 | int main() |
| 11 | { |
| 12 | void* m; |
| 13 | |
mueller | b3a8929 | 2004-01-03 14:24:42 +0000 | [diff] [blame] | 14 | m = mmap(NULL, 100, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 15 | |
| 16 | if (m == (void*)-1) { |
| 17 | fprintf(stderr, "error mmapping\n"); |
| 18 | exit(1); |
| 19 | } |
| 20 | |
| 21 | munmap(m, 100); |
| 22 | |
| 23 | return 0; |
| 24 | } |