Академический Документы
Профессиональный Документы
Культура Документы
Overview
Basic Functions
Features (Machine Dependent & Independent)
Design Options
Overview[1]
• Characteristic
• The object code is produced directly in memory for immediate execution after assembly
• Advantage
• Simple, useful for program development and testing
“Compile/Assemble-and-Go” loader[4]
• Disadvantages
• Memory wastage (portion of the memory is occupied by assembler)
• Whenever the assembly program is to be executed, it has to be assembled again (There
is no production of .obj file) More execution time
• Programs have to be coded in the same language (can’t handle multiple source program
written in different languages)
• Difficult to make an orderly modulator program
General Loader[1]
• Advantages:
• The program need not be retranslated each time while running it. This is because
initially when source program gets executed an object program gets generated.
• There is no wastage of memory, because assembler is not placed in the memory, instead
of it, loader occupies some portion of the memory.
• It is possible to write source program with multiple programs and multiple languages,
because the source programs are first converted to object programs always, and loader
accepts these object modules to convert it to executable form.
Absolute Loader[1]
• Absolute loader is a kind of loader in which relocated object files are created,
loader accepts these files and places them at specified locations in the
memory.
• This type of loader is called absolute because no relocation information is
needed; rather it is obtained from the programmer or assembler.
• Assembler should have knowledge of memory management.
Absolute Loader[2]
Absolute Loader[3]
• Motivation
• efficient sharing of the machine with larger memory and when several independent
programs are to be run together
• support the use of subroutine libraries efficiently
• Two methods for specifying relocation
• modification record (Fig. 3.4, 3.5)
• relocation bit (Fig. 3.6, 3.7)
• each instruction is associated with one relocation bit
• these relocation bits in a Text record is gathered into bit masks
Program Relocation[2]
• A Modification recordis used to describe each part of the object code that
must be changed when the program is relocated.
• For complex machines Modification record
col 1: M
• Also called RLD specification col 2-7: relocation address
col 8-9: length (halfbyte)
• Relocation and Linkage Directory col 10: flag (+/-)
col 11-17: segment name
Program Relocation[3]
Program Relocation[4]
• The inter dependency of the segments can be specified by a tree like structure called static
overlay structures.
• The overlay structure contain multiple root/nodes and edges. Each node represents the
segment.
• The specification of required amount of memory is also essential in this structure.
Two pass Direct Linking Loader
• Pass 1:
• Assign addresses to all external symbols
• Variables
• PROGADDR (program load address) f rom OS
• CSADDR (control section address)
• CSLTH (control section length)
• ESTAB
Pass 2 Program Logic
Pass 2:
» perform the actual loading,
relocation, and linking
Modification record
» lookup the symbol in ESTAB
End record for a main program
» transfer address
Improve Efficiency[1]
• Use local searching instead of multiple searches of ESTAB for the same
symbol
• assign a reference number to each external symbol
• the reference number is used in Modification records
• Implementation
• 01: control section name
• other: external reference symbols
Improve Efficiency[2], Example
PROGB PROGC
Machine-Independent Loader Features
• Many loaders allow the user to specify options that modify the standard
processing
• Many loaders have a special command language
• A separate input file to loader
• Embedded in the primary input stream
• In source program
Loader Options[2]
1. Linking Loaders
• All linking and relocation at runtime
2. Linkage Editor
• Perform linking prior to load time
3. Dynamic linking
• Linking function is performed at execution time
4. Bootstrap loader
• Be used to run stand-alone programs independent of the operating system or the system loader
Linkage Editors[1]
• A linkage editor
• Resolution of external references and library searching are only performed once
• In the linked version of programs
• All external references are resolved, and relocation is indicated by some mechanism such as
modification records or a bit mask
• External references is often retained in the linked program
• To allow subsequent relinking of the program to replace control sections, modify external
references, etc.
Linkage Editors[4]
INCLUDE PLANNER(PROGLIB)
DELETE PROJECT
INCLUDE PROJECT(NEWLIB)
REPLACE PLANNER(PROGLIB)
Linkage Editors[5]
2. Linkage editors can also be used to build packages of subroutines or other control
sections that are generally used together
It could be used to combine the appropriate subroutines into a package with a command
sequence INCLUDE READR(FTNLIB)
INCLUDE WRITER(FTNLIB)
INCLUDE BLOCK(FTNLIB)
INCLUDE DEBLOCK(FTNLIB)
INCLUDE ENCODE(FTNLIB)
INCLUDE DECODE(FTNLIB)
.
.
.
SAVE FTNIO(SUBLIB)
Linkage Editors[6]
3. Linkage editors often allow the user to specify that external references are not to be
resolved by automatic library search
Only the external references between user-written routines would be resolved
Dynamic Linking[1]
• Advantages
• The overhead on the loader is reduced.
• The required subroutine will be load in the main memory only at the time of execution.
• The system can be dynamically reconfigured.
• Disadvantages
• The linking and loading need to be postponed until the execution.
• During the execution if at all any subroutine is needed then the process of execution
needs to be suspended until the required subroutine gets loaded in the main memory.
Bootstrap Loader[1]
• Bootstrap Loader
• A special absolute loader
• Typically single pass
• When a computer is first tuned on or restarted, a special type of absolute loader, called bootstrap loaderis
executed
• This bootstrap loads the first program to be run by the computer -- usually an operating system
• Example (SIC bootstrap loader)
• The bootstrap itself begins at address 0
• It loads the OS starting address 0x80
• No header record or control information, the object code is consecutive bytes of memory
Bootstrap Loader[2]