链接器用内存地址替换符号引用?

Linker replacing symbolic references with memory addresses?

http://blog.jamesdbloom.com/JVMInternals.html我找到这个

C/C++ code is typically compiled to an object file then multiple object files are linked together to product a usable artifact such as an executable or dll. During the linking phase symbolic references in each object file are replaced with an actual memory address relative to the final executable.

如果 OS 运行 可执行文件是负责在运行时分配内存的那个人,那么在链接期间如何确定相对内存地址并且该内存在任何地方分配是免费内存space(我对事情如何运作的理解)。

内存地址相对于最终可执行文件 -- 它们不是绝对的,在链接期间无法确定。

当可执行文件在 Windows 中 运行 时,操作系统会授予它一个 虚拟内存 space固定大小的虚拟地址space,在32位操作系统上通常为4GB。每个进程都有自己的虚拟space,它可以在其中读取和写入数据to/from 内存。然后,可执行文件和任何依赖项被写入此 space,因此它们的位置现在已知并在 VAS 中。现在,在执行时,操作系统将采用链接器提供的相对地址并将它们转换为绝对地址。这些由可执行文件在虚拟内存中的位置决定 space.