In my program I create simple pthread to explore how it will look like in memory and what system calls will be called:
void *foo() {
printf("test");
}
int main() {
pthread_t a;
pthread_create(&a, NULL, foo, NULL);
pthread_join(a, NULL);
while(true);
}
Using strace I see that it leaves little space before stack without any permissions:
mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7fc67e53e000
mprotect(0x7fc67e53f000, 8388608, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0x7fc67ed3dfb0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7fc67ed3e9d0, tls=0x7fc67ed3e700, child_tidptr=0x7fc67ed3e9d0) = 9020
In /proc/[pid]/maps it looks like that:
7fc67e53e000-7fc67e53f000 ---p 00000000 00:00 0
7fc67e53f000-7fc67ed3f000 rw-p 00000000 00:00 0
My question is for what purpose os using this ---p
segment?