SPCC - 4
SPCC - 4
Loader: A loader is a system software program that performs the loading function. It brings
the object program into memory and starts execution.
Types of Loaders -
● Relocating loaders prevent the need to reassemble all subroutines when only one
subroutine changes, streamlining the programming process.
● These loaders execute the object program by utilising available memory space
efficiently, ensuring smooth program execution.
● They manage the organisation and loading of program components into memory,
reducing the need for extensive reassembly.
● The assembler divides the program into segments, assembling each independently
and providing the loader with details on relocation and references.
● The assembler also supplies the loader with additional information such as the overall
program length and the length of the transfer vector.
● The transfer vector stores names of external subroutines and is crucial for linking
different parts of the program.
● When a subroutine is called, the program transfers control to the corresponding entry
in the transfer vector.
● Finally, the loader calculates the absolute location of each program component in
memory, ensuring precise execution.
Advantages:
● Avoids need to reassemble all subroutines when a single subroutine is changed.
● Performs task of allocation and linking for programmers.
Disadvantages:
● Difficult to implement.
● Algorithms depend on the file structure of the program.
● Slower than absolute loader.
Direct linking loader:
● It is a type of relocatable loader.
● Allowing the programmer multiple procedure segments and multiple data segments
and giving the programmer complete freedom in referencing data or instruction
contained in other segments.
● The programmer is free to reference data or instructions that are contained in the
other segment.
● The direct linking loaders provide flexible intersegment referencing and accessing
ability.
● The loader doesn’t have direct access to source code. It works with object code
generated by assembler.
● Placing code into memory-
o If the addresses of the object code are absolute, the loader can directly place
the code in memory without any additional adjustments.
o If the addresses are relative, it is the responsibility of the assembler to inform
the loader about these relative addresses. The assembler assigns relative
addresses.
● Information provided by assembler to loader -
o Length of program.
o List of symbols (both defined and referenced in this and other segments).
o Address constants – Their location and how to revise their values.
o Machine code translation of source program with relative addresses assigned.
Types of cards in object code:
● External Symbol Directory (ESD):
o It contains information about all symbols that are defined in the present
program, but that may be referenced at some other location.
● Text (TXT):
o Object code of source program
● Relocation and linkage directory (RLD):
o It contains information about location in the program whose contents depend
on the address at which the program is placed.
● END: End of object file and specifies start address for execution.
Dynamic linking and loading:
● Sometimes, a program may require more storage space than the available one.
● Execution of such a program can be possible if all the segments are not required
simultaneously to be present in the main memory.
● In such a situation, only those segments are resident in the memory that are needed
at the time of execution.
What would happen if the required segment were not present in memory?
● Execution process will be delayed until the required segment gets loaded into the
memory.
● The overall effect of this is efficiency of execution gets degraded.
● The efficiency can be improved by selecting all interdependent segments.
● Assembler cannot do this task; the user must specify such dependencies.
● Interdependency of the segments can be specified by a tree-like structure called
overlay structure.
Overlay Structure:
● Contains multiple root nodes and edges.
● Each node represents a segment.
● Memory requirement specification is crucial.
● Segments can coexist in memory if on the same path.
● Program subroutines are required at different times.
● Recognizing mutual exclusivity of subroutines helps identify overlays.
Dynamic loading:
● For overlay structure to work, it is necessary for the module loader to load the
various procedures as they are needed.
● Portion of the loader that intercepts the calls and loads the necessary procedure is
called the overlay supervisor or flipper.
● It is called dynamic loading (load on call).
Dynamic Linking:
● In dynamic linking, loading and linking of external references are postponed until the
execution time.
● Steps involved:
o The assembler generates text, binding, and relocation data from a
source program.
o The loader loads only the main program.
o When the main program executes a transfer instruction to an external address,
the loader is invoked.
o The segment containing the external references is loaded into memory.
Advantages:
● No overhead is incurred.
● System can be dynamically reconfigured.
Disadvantages:
● Overhead and complexity incurred because of postponed binding