summaryrefslogtreecommitdiff
path: root/usr/src/test/os-tests/tests/secflags/addrs.c
blob: 02677f206d71905f1d04521356c2db27f8e24f38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <sys/mman.h>

#include <stdlib.h>
#include <unistd.h>
#include <err.h>

int
main(int argc, char **argv)
{
	int stack = 0;
	void *heap = NULL;
	void *mapping = NULL;

	if ((heap = malloc(10)) == NULL)
		err(1, "couldn't allocate");

	if ((mapping = mmap((caddr_t)0, 10, (PROT_READ | PROT_WRITE),
	    MAP_ANON|MAP_PRIVATE, -1, 0)) == (void*)-1)
		err(1, "couldn't map");

	printf("  stack: 0x%p\n", &stack);
	printf("   heap: 0x%p\n", heap);
	printf("mapping: 0x%p\n", mapping);
	printf("   text: 0x%p\n", &main);
	return (0);
}