0

Suppose I have the following bash script

#!/usr/bin/bash

ls *.py

Now I run strace -f ./test.sh, I see the following in the output:

[pid 25916] execve("/usr/bin/ls", ["ls", "test2.py", "test.py"], [/* 28 vars */]) = 0
[pid 25916] brk(NULL)                   = 0x1c7a000
[pid 25916] mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb616ae000
[pid 25916] access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
[pid 25916] open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3

I undertand the brk() part from this answer, but what about the mmap() call?

Is that mapping of the process image (partial)? Or by the time brk() is called, the new child process's image has already been replaced?

  • 1
    That's all stuff done by the dynamic linker (/lib*/ld-linux*), without any deep meaning -- the mmap is just allocating a chunk of anonymous memory, probably to read the content of /etc/ld.so.cache into it in order to parse it. –  Aug 20 '19 at 11:58
  • Thanks, but isn't the mmap pre the cache file? – CppLearner Aug 20 '19 at 12:17

0 Answers0