在程序的执行过程中,主要的作用是由两个称为Linker和Loader 的实用程序发挥作用。
1.链接器:
链接器是一种特殊的程序,它将编译器/汇编器生成的目标文件和其他代码段组合起来以生成可执行文件。 .exe 扩展名。在目标文件中,链接器搜索并附加执行文件所需的所有库。它调节将保存来自每个模块的代码的内存空间。它还合并两个或多个单独的目标程序并在它们之间建立链接。通常,链接器有两种类型:
1. Linkage Editor
2. Dynamic Linker
2. 装载机:
加载器是一种特殊的程序,它从链接器获取目标代码的输入,将其加载到主内存中,并准备好这些代码供计算机执行。 Loader 为程序分配内存空间。即使它解决了对象之间的符号引用。它负责在操作系统中加载程序和库。嵌入式计算机系统没有加载器。其中,代码通过 ROM 执行。有以下几种加载方案:
1. Absolute Loaders
2. Reloacting Loaders
3. Direct Linking Loaders
4. Bootstrap Loaders
链接器和加载器的区别:
S.No. | LINKER | LOADER |
---|---|---|
1 | The main function of Linker is to generate executable files. | Whereas main objective of Loader is to load executable files to main memory. |
2 | The linker takes input of object code generated by compiler/assembler. | And the loader takes input of executable files generated by linker. |
3 | Linking can be defined as process of combining various pieces of codes and source code to obtain executable code. | Loading can be defined as process of loading executable codes to main memory for further execution. |
4 | Linkers are of 2 types: Linkage Editor and Dynamic Linker. | Loaders are of 4 types: Absolute, Relocating, Direct Linking, Bootstrap. |
5 | Another use of linker is to combine all object modules. | It helps in allocating the address to executable codes/files. |
6 | Linker is also responsible for arranging objects in program’s address space. | Loader is also responsible for adjusting references which are used within the program. |