3. Introduction
Linker
• A System Software that Combines two or more separate object
programs and supplies the information needed to allow references
between them .
• Two Types
– Dynamic Linking
– Static Linking
• Static Linking:
– Static linkers takes input a collection of relocatable object files and
command line arguments and generate as output a fully linked
executable object file that can be loaded and run.
• Dynamic Linking:
– The addresses of called procedures aren’t bound until the first call.
– Programs can bind to libraries as the programs are running, loading
libraries in the middle of program execution.
– This provides a powerful and high-performance way to extend the
function of programs
– MS Windows extensively uses DLL (Dynamic Linked Libraries)
4. Introduction (Contd..)
Loader
• The loader, which accepts the program form, produced by a translator &
certain other program forms from a library to produce one ready – to –
execute machine language program.
• A unit of input to the loader is known as an object program or an object
module.
• The process of merging many object modules to from a single machine
language program is known as linking.
5. Difference between Linker and Loader
• Linker is a program that takes one or more
objects generated by a compiler and combines
them into a single executable program.
• Loader is the part of an operating system that
is responsible for loading programs from
executables (i.e., executable files) into
memory, preparing them for execution and
then executing them.
6. LOADER
• The loader is program, which accepts the object program , prepares
this program for execution by the computer and initializes
the execution.
• Loader loads the referred resource or file after being Linked to
referrer via a Linker during the execution of program.
• In particular the loader must perform four functions:
1. Allocate space in memory for the program (allocation).
2. Resolve symbolic references between objects decks (linking).
3. Adjust all address dependent locations, such as address constants,
to correspond to the allocated space (relocation).
4. Physically place the machine instructions and data into memory
(loading).
7. Important Terms
• Translation time address: Translation time address is used at
the translation time. This address is assigned by translator
• Linked time address: Link time address is used at the link
time. This address is assigned by linker
• Load time address: Load time address is used at the load
time. This address is assigned by loader
• Translated origin: Address of origin assumed by the translator
• Linked origin: Address of origin assumed by the linker while
producing a binary program
• Load origin: Address of origin assumed by the loader
while loading the program for execution.
8. Relocation of Linking Concept
• Program relocation is the process of modifying the addresses
used in the address sensitive instruction of a program such that
the program can execute correctly from the designated area of
memory.
• If linked origin≠ translated origin, relocation must be
performed by the linker.
• If load origin≠ linked origin, relocation must be performed
by the loader.
9. Relocation of Linking Concept(Contd..)
• Let AA be the set of absolute address - instruction or data addresses
used in the instruction of a program P.
• AA≠ ф implies that program P assumes its instructions and data to
occupy memory words with specific addresses.
• Such a program – called an address sensitive program – contains
one or more of the following:
-An address sensitive instruction: an instruction which uses an
address a∈AA.
-An address constant: a data word which contains an address a∈AA.
• An address sensitive program P can execute correctly only if the start
address of the memory area allocated to it is the same as its
translated origin.
• To execute correctly from any other memory area, the address used
in each address sensitive instruction of P must be ‘corrected’.
31. Linking Loaders
A linking loaders performs
» All linking and relocation operations
» Automatic library search
» Loads the linked program directly into memory for execution
A linkage editor
» Produces a linked version of program (often called a load module or an
executable image which is written to a file or module or an executable
image), which is written to a file or library for later execution
» A simple relocating loader can be used to load the linked version of
program into memory version of program into memory
– The loading can be accomplished in one pass with no external symbol
table required