What is the use of /dev/zero in ELF files?

136 Views Asked by At

The Advanced Bash Scripting Guide states that

In addition to all the above, /dev/zero is needed by ELF (Executable and Linking Format) UNIX/Linux binaries.

However I cannot find documentation about such dependency anywhere.

Actually I was unable to find it into the ELF loaders of the Linux kernel too.

Do such dependency still exists? And if so, how is /dev/zero used?

1

There are 1 best solutions below

0
On BEST ANSWER

And if so, how is /dev/zero used?

Before MAP_ANONYMOUS was common, /dev/zero was used to get a set of zeroed out pages (for the .bss section).

But now it's just mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0), and strace /bin/date |& grep zero shows no output (i.e. /dev/zero is not used at all).