Thursday, 31 May 2012


linking is the process of binding an external reference to the correct link time address.
An application program consisting of a set of program units. A program unit interacts with another program by using addresses of instructions and data in its own instructions.
To realize such interactions both units of program must contain public definitions and external references.
1.Public definition : a symbol defined in a program unit which may be referenced in other program unit.
2.External reference : a reference to a symbol which is not defined in the program unit containing the reference.
Before the execution of program it necessary that for each program unit, every external reference in program units should be bound to the correct link time address.
An external reference is said to be unresolved until linking is performed for it. It is said to be resolved when its linking is completed.
Entry and Extern statements : The entry statement lists the public definitions of a program unit, it lists those symbols defined in the program unit. Which may be referenced in other program units. The extern statements lists the symbols to which external references are made in the program unit.
Binary Program : a binary program is a machine language program comprising a set of program unit.
1.Program unit has relocated to the area starting at its link origin.
2.Linking has been performed for each external reference in program unit.
To form a binary program from a set of object modules, the programmer invokes the linker using the command
Linker <link origin>, <object module names> [,<execution start address>]
Where <link origin> specifies the memory address to be given to the first word of the binary program. <execution start address> is usually a pair (program unit name, offset in program unit ).
The linker converts this into the linked start address.
This is stored with the binary program for use when the program is to be executed.

Object Module
The object module of a program contains all information necessary to relocate and link the program with other programs. The object module of a program consists of 4 components.
1.Header : the header contains translated origin, size and execution start address of program.
2.Program : this component contains the machine language program corresponding to program.
3.Relocation table (RELOCTAB): this table describes Instruction register requirement of program. Each relocation table contains a single field. It stores Translated address of an address sensitive instruction.
4.Linking Table (LINKTAB) : this table contains information concerning the public definition and external references in program.

No comments:

Post a Comment