Unit 4
Unit 4
1. Translation of program
2. Linking of program with other programs needed for its execution.
3. Relocation of the program to execute from the specific memory area allocated
to it.
4. Loading of the program in the memory for the purpose of execution.
These steps are performed by different language processors.
Data
Result
Source
Program
Object Binary
Modules Programs
Difference between linker and Loader
Linking Table
ALPHA EXT 518
MAX EXT 519
A PD 540
Design of a Linker
Normal Libraries
Linker
Control Files
Link/Load
map
2. Dynamic linking –
• Dynamic linking is performed during the run time.
• This linking is accomplished by placing the name of a shareable library in the executable
image.
• There is more chances of error and failure chances.
• It require less memory space as multiple program can share a single copy of the library.
Self Relocating Programs
• A self relocating program is a program which can perform the relocation of its
own address sensitive instructions.
• A program containing overlays are called as overlays structured program. Such a program
consist of
1. A permanent resident portion called the root
2. A set of overlays.
read reads one set of data and invokes one of trans_a, trans_b, trans_c
depending on the value of data.
trans_a, trans_b, trans_c are mutually exclusive. Hence they are made into
seperate overlays.
A
Loader
A
| Program loaded
|
|
in memory,
| ready B
B for execution
Data bases
≈ ≈
Different Loading schemes
• Various schemes for accomplishing the four functions of a loader.
• New term segment is introduced, which is a unit of information that is treated as an entity, be
it a program or data.
1. “Complie-and-Go” loaders
2. General Loader Scheme
3. Absolute Loaders
4. Direct linking Loaders
5. Relocating Loaders
6. Linking Loaders
1. “Compile-and-Go” loaders
• In this type of loader, the instruction is read line by line, its machine code is obtained and it is
directly put in the main memory at some known address.
• That means the assembler runs in one part of memory and the assembled machine instructions
and data is directly put into their assigned memory locations.
• After completion of assembly process, assign starting address of the program to the location
counter.
|
|
|
Advantages and Disadvantages of “Compile and Go” loaders
Advantages
• Easy to implement.
Disadvantages
• Portion of memory is wasted because combination of assembler and loader activities, this
combination program occupies large block of memory
• There is no production of .obj file
• It cannot handle multiple source programs or multiple programs written in different languages
• The execution time will be more in this scheme as every time program is assembled and then
executed
2. General Loader Scheme
• In this loader scheme, the source program is converted to object program by some translator
(assembler).
• The loader accepts these object modules and puts machine instruction and data in an
executable form at their assigned memory.
• The loader occupies some portion of main memory.
Source Object
Translator |
Program Program 1 |
|
Executable
object code
|
Loader |
|
Loader Program
Source Object
Translator Program 2 |
Program |
|
Advantages of General Loader Scheme
Object
Code
|
Segment 1 Translator Starting |
|
address
Object code for
segment 1
|
|
Object Code |
• The direct linking loader is the most common type of loader. The loader cannot have the
direct access to the source code.
One disadvantage of a direct linking loader is it is necessary to allocate, relocate, link and
load all of the subroutines each time in order to execute a program.
5. Relocating Loaders
• Another function commonly performed by a loader is that of program re – location.
• Relocation is simply moving a program from one area to another in the storage.
• It referred to adjustment of address field and not to movement of a program.
• The task of relocation is to add some constant value to each relative address in the
segment the part of a loader which performed relocation is called re – location
loader.
• To avoid possible reassembling of all subroutines , When a single subroutines is
changed and to performed the task of allocation and linking of the programmer.
• Output of a relocating loader is the object program and information about all other
programs its references.
6. Linking Loaders
• When program is in development stage then at that time the linking loader
can be used.
Linkers v/s Loaders