 Today, we are going to discuss the topic of linkers and their specifications. At the end of this session, a student will able to demonstrate how linking is actually done and what are the requirements involved to develop a particular linker. The background that we observe is the code of any target program cannot be executed even if it is in machine language. It needs to be combined with codes of library routines before execution. Programs may wish to invoke other programs written in programming language. The code has to be similar and combined with codes of these programs. Therefore, a solution to all these is a linker. Now let us think and answer what is expected actually from a linker. A linker is a system program that combines code of target program with codes of other programs and library routines. Thus, a linker cannot be changed and it is the designer who designs the particular linker and is given as a program which is irrevocably changeable to facilitate linking language translator builds an object module. This object module contains the target code and information of programs that need to be invoked during the execution. A linker extracts information and this information is synchronized so that we develop a proper linking between the various programs. Thus, it produces a program that can execute without assistance and this program is called popularly as a binary program. How does the whole system work? A language translator needs address of the first memory word of the target program. This is called the origin. The origin might be changed after the program execution. At this time it is called as translated origin. The origin might be changed sometimes by the linker under conditions that the same set of translated address used in many modules of the binary program is formed and the operating system may sometimes require the program to be executed from a specified area of memory. This change in origin of the program leads to the change in execution start addresses and subsequently to addresses assigned to symbols defined in it. Thus, as a result, we have three types of origins, one the translated origin which is specified in the origin or the start statement, the linked origin which is assigned by the linker when producing binary program and the load origin which is assigned by loader when loading binary program in the memory. What is program reallocation and why it is required? Program expects some instructions and data to occupy memory words with specified address. Address specific program, it contains address specific instructions, address constants, program reallocation is the action of modifying address sensitive instructions such that the program executes correctly from designated area of memory. What are the conditions for reallocation? The first condition is when linked origin is not equal to translated origin. Here reallocation is performed by the linker. If load origin is not equal to linked origin, reallocation is performed by loader and such loaders are called. Let us see what program reallocation is. Program expects some instruction and data to occupy memory words with specific addresses. Such programs are called as address specific. They contain address sensitive instructions, address constants. This program reallocation is the action of modifying address sensitive instructions such that the program executes correctly from a designated area of memory. Now what are the conditions under which reallocation is done? First, when linked origin is not equal to translated origin, a reallocation is performed by the linker. If load origin is not equal to linked origin, then reallocation is performed by the loader and such loaders are called as reallocation loaders. If load origin and linked origin are the same, then no reallocation is required and such loaders are called as absolute loaders. Let us perform an analysis to understand what this reallocation actually is. Consider a program P which has after translation a translated origin T origin P, a linked origin L origin of P and the symbol in P that is the program SYMB. A translated time address called T symbol and linked address L symbol. Thus a reallocation factor for the program is L origin of P minus T origin of P. Now this can amount to be positive, negative or zero. Sometimes the offset of the symbol in P may be considered in the calculation of the reallocation factor. Constring this offset to be D from the origin, we have now T of the symbol to be equal to translated origin of P plus D of the symbol which is the offset. And L symbol is equal to L origin of P plus D symbol which is equal to T origin of P plus reallocation factor of P plus D symbol from the first equation which is of the reallocation factor. This is equal to T origin of P plus D symbol plus reallocation factor. Here we are rearranging the last term to come to the second term. Now combining the first term and the second term, we know that T origin of P plus D symbol is equal to T symbol from the first equation on this slide. Plus reallocation factor of P. After doing this calculations, let us now understand what actually linking is doing. A program is considered as a unit termed as a program unit which is a routine to be linked with other programs. Applications may consist of many such routines forming a set of program units. Now a program unit may require other programs during executions. Therefore we have to use two types of definitions. The first one is a public definition which is a symbol defined in the program unit is referenced by other program units. And an external reference which is referenced to symbol not defined in the program unit not containing reference. Thus linking is an action of putting correct linked addresses in those instructions of a program that contain external references. After doing this we now go to form what a machine binary program is. It is a machine language program comprising of various program units such that the program unit has been relocated according to the conditions of relocation to an area whose starting address matches with its linked origin. And each external reference in a program unit has been resolved. For my references I have used. Thank you.