0% found this document useful (0 votes)
10 views

Assdcdd

The document discusses loaders and linkers. Loaders are responsible for loading programs into memory and preparing them for execution. Linkers link programs and libraries together by resolving external references. The document describes different types of loaders like absolute and direct linking loaders and their design and working.

Uploaded by

bihod71717
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Assdcdd

The document discusses loaders and linkers. Loaders are responsible for loading programs into memory and preparing them for execution. Linkers link programs and libraries together by resolving external references. The document describes different types of loaders like absolute and direct linking loaders and their design and working.

Uploaded by

bihod71717
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

SPCC

CH- 4
Loader and linker
Loader
Loader is the part of an operating system that is responsible for
loading programs and libraries. It is one of the essential stages in
the process of starting a program, as it places programs into
memory and prepares them for execution.
Functions of Loader
linking
Relocation
• 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.
• Linker performs relocation if – Linked Origin ≠ Translated
Origin
• • Loader performs relocation if – Load Origin ≠ Linked Origin
• Type of Loader
1. Assemble and Go loader
2. General loading scheme
3. Absolute Loader
4. Direct linking Loader
Design of Absolute loader

• The absolute loader is a kind of loader in which relocated


object files are created, loader accepts these files and places
them at a specified location in the memory. This type
of loader is called absolute loader because
no relocating information is needed, rather it is obtained
from the programmer or assembler.
TXT Card

Card Type Count Address contain

TRANSFER Card

Card Type Count Address contain

1 0
DLL : Direct Linking Loader
• It is Re-locatable 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.
– ESD-External Symbol Directory
– TXT-Actual assembled program
– RLD-Relocation and Linkage directory module
– END-End module
• ESD-External Symbol Directory

Symbol Type ID Relative length


Add

• 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
• Segment Definition (SD):-It is name of the program which return prior to
start keyword.
• Local Definition (LD):-This are the symbols which are define in the
program.
• 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.
• TXT Card
Count Relative Add content

• Text portion of object module contains the


re-locatable machine language instruction and data that were
produced during translation.
• RLD (Relocation and Linkage Directory card)
ESD ID Length Flag Rel. Add

• It contains information about those location of the program


whose contains depend on address at which the program is
placed.
It contains following information:
• The address of each operand that needs to be changed due to
relocation
• By what it has to changed
• The operation to be performed
• End Card
It specifies that start of execute of the of the
object program and end of object module.
• 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.

linker
• Any usable program written in any language has to use
functions / subroutines. These functions could be either
user defined functions or they can be library functions.
• For example, consider a program written in C language such
a program may contain calls to functions like printf( ).
During program execution main program calls the function
1) The linking process makes address of modules known to
each other so that transfer of control takes place.

2) Passing of parameters is handled by the linker.

3) An external variable can be defined in one module and can


be used in another module
Static linking: -
• A static linker takes object files produced by the
compiler including library functions and produces
and executable file. The executable file contains a
copy of every subroutine (user defined or library
function.) The biggest disadvantage of the static
linking is that each executable file contains its
own copy of the library routines. If many
programs containing same library routines are
executed then memory is wasted.
• Dynamic Linking: -
Dynamic linking defers much of the linking process until a
program starts running. Dynamic linking involves the
following steps:
1) A reference to an external module during run time
causes the loader to find the target module and load it.
2) Perform relocation during run time
Dynamic linking permits a program to load and unload
routines at run time.

You might also like