[go: up one dir, main page]

0% found this document useful (0 votes)
10 views6 pages

SPCCAS4

The document outlines the functions of a loader, including allocation of memory, linking object modules, relocating addresses, and loading programs into memory. It explains the absolute loader, which places relocated object files at specified memory locations without needing relocating information, and the direct linking loader, which allows for flexible intersegment referencing. Additionally, it details various types of loaders such as absolute, relocating, linking, and direct linking loaders, highlighting their functions, advantages, and suitable applications.

Uploaded by

bayilo7328
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

SPCCAS4

The document outlines the functions of a loader, including allocation of memory, linking object modules, relocating addresses, and loading programs into memory. It explains the absolute loader, which places relocated object files at specified memory locations without needing relocating information, and the direct linking loader, which allows for flexible intersegment referencing. Additionally, it details various types of loaders such as absolute, relocating, linking, and direct linking loaders, highlighting their functions, advantages, and suitable applications.

Uploaded by

bayilo7328
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

Define 4 different functions of loader


The loader plays a crucial role in preparing and initiating the execution of a
program. Here are its four key functions:
1. Allocation:
• The loader allocates memory space for the program's code, data, and
stack.
• It analyzes the program's requirements based on its size and specific
needs.
• The operating system might assist in finding suitable memory locations
based on available resources and memory management policies.
2. Linking:
• The loader resolves external references between different object
modules or libraries.
• During compilation, different parts of a program might be compiled into
separate object files.
• The linker identifies references to symbols (functions, variables) defined
in other modules and combines them into a single executable program.
• This ensures all necessary code and data are available for seamless
execution.
3. Relocation:
• The loader adjusts memory addresses within the program if it's loaded
at a different location than originally anticipated.
• This is necessary because addresses specified in the code might be
relative to the program's starting point in memory.
• The loader rewrites instructions and data references to reflect the actual
memory addresses where the program is loaded.
4. Loading:
• The loader transfers the program's instructions and data from secondary
storage (e.g., disk) to the allocated memory space in main memory.
• This makes the program ready for execution by the CPU.
• The loader might also perform additional tasks like setting up the
program stack, initializing registers, and preparing the program
environment for execution.

2. Explain 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.
The starting address of every module is known to the programmer, this
corresponding starting address is stored in the object file then the task of
loader becomes very simple that is to simply place the executable form of the
machine instructions at the locations mentioned in the object file.
In this scheme, the programmer or assembler should have knowledge of
memory management. The programmer should take care of two things:
Specification of starting address of each module to be used. If some
modification is done in some module then the length of that module may vary.
This causes a change in the starting address of immediate next modules, it's
then the programmer's duty to make necessary changes in the starting address
of respective modules.
While branching from one segment to another the absolute starting address of
respective module is to be known by the programmer so that such address can
be specified at respective JMP instruction.
3. Explain complete design of direct linking loader
The direct linking loader has the advantage of allowing the programmer
multiple procedure segments and multiple data segments and allows complete
freedom in referencing data or instructions contained in other segments. This
provides flexible intersegment referencing and accessing ability ,while at the
same time allowing independent translation of programs.
The translator must give the loader the following information with each
procedure or data segment.
1. The length of segment
2. A list of all symbols in the segment that may be referenced by other
segment and their relative location with in the segment
3. A list of all symbols not defined in the segment but referenced in the
segment
4. Information as to where address constants are located in the segment and a
description of how to revise their values
5. The machine code translation of the source program and the relative
address assigned.
There are four sections to the object desk
1. External symbol directory cards(ESD)
2. Instructions and data cards called text of a program(TXT)
3. Relocation and linkage directory cards (RLD)
4. End card(END)
The ESD cards contain the information necessary to build the external
directory or symbol table. External symbols are symbols that can be referred
beyond the subroutine level.

4.Explain different tpes of loaders in detail


Loaders play a crucial role in system programming and compiler construction
by preparing and initiating the execution of programs. They bridge the gap
between the compiled code and its actual execution by performing several
essential tasks. Here's a detailed explanation of different types of loaders:
1. Absolute Loader:
• Function: Loads a program into predefined memory locations specified
in the object code.
• Implementation: Reads the object code and directly places instructions
and data into the specified memory locations.
• Advantages: Simple and efficient, fast loading times.
• Disadvantages: Limited flexibility (fixed memory locations), error-
prone, not portable.
• Suitable for: Simple systems with static memory allocation and limited
memory constraints.
2. Relocating Loader:
• Function: Loads a program into any available memory
location, dynamically adjusting memory addresses within the code
during the loading process.
• Implementation:
o Identifies the starting memory address where the program will be
loaded.
o Calculates the relocation factor (difference between the assumed
and actual loading addresses).
o Modifies instructions and data references to reflect the actual
memory addresses.
• Advantages: More flexible than absolute loaders, allows program
execution in different memory configurations.
• Disadvantages: Slightly slower due to address relocation overhead.
• Suitable for: Most modern systems with dynamic memory allocation
and diverse hardware configurations.
3. Linking Loader:
• Function: Combines multiple object modules (compiled code fragments)
and libraries into a single executable file, resolving external references
between them.
• Implementation:
o Loads individual object modules and their symbol tables.
o Identifies external symbols (referenced in one module but defined
in another).
o Locates the definition of each external symbol in the
corresponding module.
o Combines the code and data from all modules, adjusting
addresses to ensure proper referencing.
• Advantages: Enables modular program development and reusability of
code libraries.
• Disadvantages: More complex than other loaders, potentially slower for
simple programs.
• Suitable for: Complex software systems with multiple code modules and
dependencies on external libraries.
4. Direct Linking Loader:
• Function: Combines the object code of the main program and any
required libraries into a single executable file during the loading
process.
• Implementation:
o Similar to linking loaders but performs linking and loading in a
single step.
o Searches for and loads referenced libraries during the loading of
the main program.
o Adjusts memory addresses and combines code and data into the
final executable.
• Advantages: Efficient for simple programs, avoids separate linking stage.
• Disadvantages: Limited flexibility, increased memory usage due to
loading all libraries at once.
• Suitable for: Simple programs with well-defined dependencies and
limited library usage.

You might also like