CREATE OWN LIBRARY

Linker

 

Linker definition and passes:

Now after store all resolved and unresolved symbols at the symbol table next linker is enabled to start linking all externals links and solve unresolved symbols by link undefined symbols by system libraries. 

 

 

Linker has been complete there work in two phases:

                                                

Pass 1Initially linker differentiates the symbols like which are define symbols (present in this code) and what are undefined symbols or external references (shared library code) which are not present in this code and coming from external sources. 

 

So, it figures out defined segments and undefined segments in the symbol table. Here in 1st pass linker use two tables:

 

(i) Segment table: Here store the entire segments which will be loaded from external sources and loaded in the main object code after linking. 

(ii) Symbol table: Here find out the unresolved symbol which is going to be resolved.

 

Pass 2: In this pass, the linker tries to solve all unresolved symbol and assign it to a specific address. But these allocated addresses are relocatable addresses

 

Main object code after 2 passes of a linker.

 

 

Previously before linking, C and M was an unresolved symbol but now they get relocatable addresses 10 and 60 after linking was done. 

 

Functionalities of Linker

(i)  Relocation: Relocation of relocatable address to new relocatable address.

(ii) Symbol Resolution: Try to resolve all unresolved symbols which present at the symbol table.