I am studying for exam tomorrow and I ran across this question:
After we run an executable with strace the following syscalls result regarding standard C lib:
- open("/lib/libc.so.6", "O_RDONLY") = 3
- mmap(NULL, 36803630, PROT_READ | PROT_EXEC, MAP_PRIVATE | MAP_DENYWRITE, 3, 0) = 0x7f312ab35000
- mmap(0x7f312aeae000, 20480, PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x179000) = 0x7f312aeae000
The question is why does the first syscall of mmap uses PROT_READ|PROT_EXEC and the second one PROT_READ|PROT_WRITE.
Please explain me what happens after each mmap call in detail. I don't understand why a process would need to modify libc (write access).