Linkers and Loaders

Linkers and Loaders

The basic job of linkers and loaders in computers is binding abstract names written by programmers to more concrete ones.

An example is taking a name written by a programmer,

getLine

and bind it to,

location 450 bytes from the  beginning of the executable code in the module iosys

A Short History of Adress Binding

In earlier days, programmers would write out the symbolic programs on sheets of paper, hand assemble them into machine code and then toggle the machine code into the computer or punch it on paper or cards. If an instruction had to be added or deleted, the whole program had to be hand-inspected and the affected addresses adjusted.

Assemblers solved this problem by letting programmers write programs in terms of symbolic names and the assembler binding the names to machine addresses. If the program changed, the programmer had to reassemble it but the assembler did the work of assigning the addresses.

Linkers assigned relative memory addresses and address binding while loaders did a final relocation step to assign actual addresses.

Programs running on a computer share a lot of common code which might take up a lot of memory. Overlay was a technique that was used to improve run time performance and also preserve memory. In overlaying, different parts of the program share the same memory with each overlay loaded on demand when another part of the program needs it. This technique allowed a program to be larger than the available computer memory.

Current systems provide shared libraries for programs to use which improves run time performance and saves a lot of disk space. Shared static libraries are those which are bound to specific addresses at the time the library is built. If any part of the library changes, relinking has to be done.

On the other hand, in dynamically linked libraries (DLLs), library symbols and sections are not bound to actual addresses until the program that is using the library starts running.