📜  编译时和加载时地址绑定的区别

📅  最后修改于: 2021-09-28 10:59:08             🧑  作者: Mango

先决条件 – 地址绑定方法

地址绑定是程序指令和数据与实际物理内存位置的关联。操作系统中有多种类型的地址绑定。

地址绑定有 3 种类型:

  1. 编译时地址绑定
  2. 加载时间地址绑定
  3. 执行时地址绑定

在这里,我们比较编译时间和加载时间地址绑定如下。

编译时地址绑定:
如果编译器负责执行地址绑定,那么它被称为编译时地址绑定。这种类型的地址绑定将在将程序加载到内存之前完成。编译器需要与操作系统内存管理器交互以执行编译时地址绑定。

加载时间地址绑定:
这种类型的地址绑定将在程序加载到内存后完成。加载时地址绑定将由操作内存管理器来完成。

Compile Time 和 Load Time 地址绑定的区别:

Compile Time Address Binding Load Time Address Binding
Compiler is responsible for the compile time address binding. Loader is responsible for the load time address binding.
It generates logical address (virtual address). It generates physical address.
Compile time address binding is done before loading the program into memory. Load time address binding is done after loading the program into memory.
Instructions are translated into absolute address. Absolute address is converted to relocatable address.
Code is compiled here. Instructions are loaded in memory.
It works with logical address. It works with physical address.
It is static address binding. It is also static address binding but in some operating system it supports dynamic address binding.
Compiler interacts with operating system memory manager to perform it. It is done by operating system memory manager itself.