xref: /illumos-gate/usr/src/test/os-tests/tests/secflags/addrs.c (revision b1e2e3fb17324e9ddf43db264a0c64da7756d9e6)
1 #include <sys/mman.h>
2 
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include <err.h>
6 
7 int
8 main(int argc, char **argv)
9 {
10 	int stack = 0;
11 	void *heap = NULL;
12 	void *mapping = NULL;
13 
14 	if ((heap = malloc(10)) == NULL)
15 		err(1, "couldn't allocate");
16 
17 	if ((mapping = mmap((caddr_t)0, 10, (PROT_READ | PROT_WRITE),
18 	    MAP_ANON|MAP_PRIVATE, -1, 0)) == (void*)-1)
19 		err(1, "couldn't map");
20 
21 	printf("  stack: 0x%p\n", &stack);
22 	printf("   heap: 0x%p\n", heap);
23 	printf("mapping: 0x%p\n", mapping);
24 	printf("   text: 0x%p\n", &main);
25 	return (0);
26 }
27