Definition of Loader
Definition of Loader
Loader is utility program which takes object code as input prepares it for
execution and loads the executable code into the memory. Thus loader is
actually responsible for initiating the execution process.
Functions of Loader:
The loader is responsible for the activities such as allocation, linking,
relocation and loading
1) It allocates the space for program in the memory, by calculating the
size of the program. This activity is called allocation.
2) It resolves the symbolic references (code/data) between the object
modules by assigning all the user subroutine and library subroutine
addresses. This activity is called linking.
3) There are some address dependent locations in the program, such
address constants must be adjusted according to allocated space, such
activity done by loader is called relocation.
4) Finally it places all the machine instructions and data of corresponding
programs and subroutines into the memory. Thus program now becomes
ready for execution, this activity is called loading.
Loader Schemes:
Based on the various functionalities of loader, there are various types of
loaders:
1) “compile and go” loader: 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. The typical example is WATFOR-77, it’s a FORTRAN compiler
which uses such “load and go” scheme. This loading scheme is also
called as “assemble and go”.
Advantages:
• This scheme is simple to implement. Because assembler is placed at one
part of the memory and loader simply loads assembled machine
instructions into the memory.
Disadvantages:
• In this scheme some portion of memory is occupied by assembler which
is simply a wastage of memory. As this scheme is combination of
assembler and loader activities, this combination program occupies large
block of memory.
• There is no production of .obj file, the source code is directly converted
to executable form. Hence even though there is no modification in the
source program it needs to be assembled and executed each time, which
then becomes a time consuming activity.
• It cannot handle multiple source programs or multiple programs written
in different languages. This is because assembler can translate one source
language to other target language.
• For a programmer it is very difficult to make an orderly modulator
program and also it becomes difficult to maintain such program, and the
“compile and go” loader cannot handle such programs.
• The execution time will be more in this scheme as every time program
is assembled and then executed.