I have this subtle question about virtual memory. In one book I read this quote
When the ELF file is executed, the text and the two data segments are loaded into separate areas of virtual memory
But if we for example compile a C program consisting of two source file without linking it will produce two object files. And in both object files addressing starts from zero. Then if we link both object files into one executable and inspect it we will observe that addressing no longer starts from zero, rather some address is already assigned to each of the segments. And as I understand this assigned address is a virtual memory address. So I have two questions:
- So am I correct that it is the linker that requests some virtual memory range from OS and assigns it to program segments?
- What does the author of the quote mean when he said that virtual address is assigned when the process is executed?