为什么ELF的虚拟地址在映射到virtualspace之前就可以确定?

Why the virtual address of ELF can be determined before it is mapped to virtual space?

链接目标文件生成ELF文件,并确定其虚拟地址。例如.text的虚拟地址是0x8048000。当ELF文件要映射到虚拟space时,另一个ELF已经映射到这个地址。 操作系统应该做什么? 为什么ELF的虚拟地址在映射到虚拟space.

之前就可以确定

每个进程都有自己的私有虚拟地址space——这就是虚拟化的意义所在;它不必对应于程序在物理 RAM 中的实际位置。所以不同进程中的程序运行之间不存在地址冲突。它们可以全部映射到那个地址,每个都有自己的私有地址space。

  1. ELF 告诉 Linux 内核它要放置的位置,如果 Linux 内核接受该地址,它将加载到那里。

    例如0 不起作用,因为太低:Why is the ELF execution entry point virtual address of the form 0x80xxxxx and not zero 0x0?

    ld 使用其配置使用的链接描述文件确定地址:In an ELF file, how does the address for _start get detemined?

  2. 正如 Wyzard 所提到的,每个进程都有自己的虚拟地址 space。

    更准确地说,虚拟地址 spaces 通过分页获得 硬件 支持:How does x86 paging work? 内核设置和使用。