I read that in modern OSes, the memory address binding is "dynamic" and occurs at run-time. But since we use virtual memory schemes, and each process gets its own virtual user memory space, why do we still late, run-time binding? Can't we do compile-time address binding, because the virtual page address will be mapped to a physical page?
We do use link-time binding for executables on most OSes, where an executable can have itself mapped to a fixed virtual address. It can have absolute addresses embedded all over the place without needing relocation at run-time. And yes, this is because different processes can use the same virtual addresses. Systems without virtual memory need each process to use different addresses.
This is not the case for libraries: Libraries can't know what range of addresses will be free in any given process that wants to load it, so it has to use position-independent code.
OS X also requires PIC for executables. I've never looked up why; maybe they want to be able to do ASLR.
I might be totally mistaken, but I think I remember reading that Win9x didn't require position-independent code, and installing a DLL involved coordinating with other installed DLLs on the system to find absolute address ranges that could be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With