November 13, 2017

Linker and Loader

❑ Linker(Linkage editor, Linking editor, link editor, ld, ld.so) : This links object files to make an executable file.
❍ Function of Linker
- Symbol resolution : This selects symbols to avoid duplicate names.
* Symbol : Variables, Funtions
* Symbols with duplicate names are selected by a rule(strong, weak).
- Relocation : This merges memory sections of the same type into a single section and modifies symbol references.
❍ Static linking : This copies all libraries used in the program into the executable file. The actual linking occurs at compile-time.
❍ Dynamic linking : This records names of shared libraries in the executable file. The actual linking occurs at run-time.

❑ Loader(execve, ld, ld.so) : It loads the executable into memory and run it.
❍ Function of Loader
- Relocation : This merges memory sections of the same type into a single section and modifies symbol references.
- Loading : This loads the program into memory.
❍ Type of loader : Compile-and-go, Absolute, Bootstrap, Relocate, linking, Dynamic, etc.




※ Depending on the operating system, the function and meaning of the linker and loader may differ.

※ Linking can be done at link-time(by linker), compile-time(by compiler), load-time(by loader), or run-time(by application).

※ Software build process : Preprocessed file(*.i)(by Preprocessor) → Assembly code(*.s)(by Compiler) → Object file(*.o)(by Assembler) → Executable file(*.out)(by Linker)