LOADER
Definition of Loader:
Loader is a system program which is responsible
for preparing the object file to start the execution.
Once the assembler produces an object program, that
program must be placed into memory and executed. It is the
purpose of the loader to assure that object programs are
placed into an executable form.
Functions of Loader
1. Allocation
Allocates space in memory for the program.
In case of Absolute ALP allocation is done by programmer.
In case of Relocatable ALP allocation is done by loader.
2. Linking
Resolve symbolic references between objects.
In case of Absolute ALP linking is done by programmer since,
programmer is aware of runtime address of all symbols.
In case of Relocatable ALP allocation is done by loader and hence
assembler must provide the location at which linking is to be done.
Functions of Loader
3. Relocation
Adjust all address dependant locations, such as
address constant to correspond to the allocated
space. In case of Absolute ALP this is done by
assembler. In case of Relocatable ALP this is done
by loader.
4. Loading
Placing the object program into its assign memory
location. In both the cases this is done by the Loader.
General Loading Scheme
General Loading Scheme
In this, source program is translated
into object program using assembler.
Then it is loaded into main memory
along with source code of loader.
Size of loader is smaller than assembler
code therefore , more space is
available for the object program.
Disadvantage
We have to store source code of loader.
Absolute Loader
The absolute loader reads the object
program line by line and moves the
text of the program into memory.
Object program has
[Link] instruction with memory
address
[Link] of execution point
Absolute Loader
It requires 2 types of records
i ) Text Card
It contains binary image of assembly
program
ii) Transfer Card
It contains starting point execution.
1)TXT Card
Card Type
Count
Address
Content
Text card:It contains information about what is to be loaded.
1. Card Type: It indicate which type of card
0 for Text card.
1 for Transfer card.
2. Count: It indicates amount of information which is to be loaded.
3. Address: It indicates location at which information is to be
loaded.
4 Content: It indicates binary information which is to be loaded.
Transfer Card:Card Type
Count
Address
Content
Transfer Card: It is used to indicate where to
be load the program
Card type is 1.
Count is always 0.
Address: It indicate location from where
execution of object program should begin.
Content: It always kept blank.
Algorithm
Bootstrap Loader
Program residing in EPROM,ROM or other non-volatile memory
Automatically executed by the processor
Reads the hard disk drives boot sector to continue the process of
loading the computer OS
Function of Bootstrap Loader:
Enable the user to select the OS to start
Loading the OS file from the boot partition
Controlling the OS selection process and hardware detection prior to
kernel initialization.
DLL : Direct Linking Loader
It is Relocatable type of loader.
It has advantage of allowing programmer with multiple
procedure segments and giving them complete freedom of
referring data contained in some other segment.
Input to the loader is set of object programs to be linked together
This provides flexible Intersegment Referencing, for doing all
this, DLL required following modules.
1. ESD-External Symbol Directory
2. TXT-Actual assembled program
3. RLD-Relocation and Linkage directory module
4. END-End module
1. ESD-External Symbol Directory
ESD ID
Length
Flag
Relative
Address
ESD card contains information about all symbols that are define in a
program that may be referred somewhere else and vice versa.
There are 3 types of symbols
1. Segment Definition (SD):-It is name of the program which return prior
to start keyword.
2. Local Definition (LD):-This are the symbols which are define in the
program.
3. External Reference(ER):- This are symbols which are referred in the
program but are defining somewhere else.
. ID: - Giving unique no. to all segment definition and external
reference.
. Relative Address:- It is address at which those symbols are define.
. Length: - Size of the symbol.
2. TXT Card
Count
Relative address
Content
Text portion of object module contains the
relocatable machine language instruction and data
that were produced during translation.
RLD(Relocation and Linkage Directory
card )
Symbol
Type
ID
Relative
address
Length
It contains information about those location of the program whose
contains depend on address at which the program is placed.
It contains following information
[Link] address of each operand that needs to be changed due to
relocation
[Link] what it has to changed
[Link] operation to be performed
End Card
It specifies that start of execute of the of the
object program and end of object module.
Design of DLL (Direct Linking Loader)
Direct linking loader requires two passes
to complete the linking process
Pass-I assigns address to all external
symbol
Pass-II performs actual loading
,relocation and linking
In pass-I global external symbol table is
prepared which has external symbol and
corresponding absolute address value.
Two Pass Loader scheme
Pass1 Database
1. Object card: - This card contain object program
in four cards.
i. ESD ii. TXT iii. RLD iv. END
IPLA (Initial program Local Address):-It is the
address obtained by loader from operating system.
GEST (Global External Symbol Table):- It is used to
keep track of addresses that are assign to the
symbol.
Copy file:- it is preferred by pass1 to be used by
pass2.
Load Map:- It is printed listing of GEST table.
Pass2 Database
Copy file:- it is preferred by pass1 to be used by pass2
IPLA (Initial program Local Address):-It is the address
obtained by loader from operating system.
Execution Address (EXADDR):- It indicates the location
from where the execution of object program should
begin.
GEST (Global External Symbol Table):- It is used to
keep track of addresses that are assigning to the
symbol.
Local External Symbol Array(LESA):- It is prepared with
the help of ESD And GEST.