Linker Loader
Linker Loader
Linker Loader
Resource Person :
Mrs Rekha A Kulkarni
Asst.Prof At PICT Pune
• Scope and depth of each topic.
• Conceptual points regarding the topic.
• Suggestions on how to conduct practicals.
• What is expected to be taught in classroom.
• Reference books, notes, slides or other course material relevant to the topic.
Linkers and Loaders : Basic Loader functions,General Loader scheme,
absolute loader, Subroutine linkages, relocating loader, Direct linking
Loader,Dsign of absolute loader and direct linking loader.
• Software Tools : Software Tools for program development, editors, debug
monitors, programming environment, user interfaces.
• List of Practical (System Programming and Embedded Lab)
• Write an shell scripting on UNIX / LINUX
• Case Study :
– Android mobile operating system
– Study of System calls to list files, directories
– Study of System calls to handles process
– Basic Linux Commands
• References :
• D.M Dhamdhare Systems Programming and
operating Systems TMH
• J.J Donovan Systems Programming Mcgraw
Hill
• Leland L Beck System Software Pearson
Edition
• Android Wireless Application Development
Pearson Edition : Darcey Conder
Functions of Loader
The loader is a program which accepts the object program prepares these programs for
execution and initiates the execution.
• Linking: Resole symbolic references between object programs. which combines two or
more separate object programs and supplies the information needed to allow references
between them.
• Loading : Physically place the machine instructions and data into memory, brings the
object program into memory for execution
Type of loaders
– assemble-and-go loader
– absolute loader (bootstrap loader)
– relocating loader (relative loader)
– direct linking loader
Assemble-and-go Loader
• Characteristic
– the object code is stored in memory after assembly
– single JUMP instruction
• Advantage
– simple, developing environment
• Disadvantage
– whenever the assembly program is to be executed, it
has to be assembled again
– programs have to be coded in the same language
• General Loader Scheme
Object program
Source Object read y for
Translator
Program Program execution
Source
Program
Source Object
Translator
Program Program
Loader
Design of an Absolute Loader
• Absolute Program
– Advantage
• Simple and efficient
– Disadvantage
• the need for programmer to specify the actual address
• difficult to use subroutine libraries
• Program Logic
Algorithm for an absolute loader
Begin
read Header record
verify program name and length
read first Text record
while record type is not ‘E’ do
begin
{if object code is in character form, convert into internal representation}
move object code to specified location in memory
read next object program record
end
jump to address specified in End record
end
A Simple Bootstrap Loader
• Bootstrap Loader
– When a computer is first tuned on or restarted, a special
type of absolute loader, called bootstrap loader is 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
Relocating Loaders
• 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
– relocation bit
• each instruction is associated with one relocation bit
• these relocation bits in a Text record is gathered into bit masks
Modification Record
• For complex machines
• Also called RLD specification
– Relocation and Linkage Directory
Modification record
col 1: M
col 2-7: relocation address
col 8-9: length (halfbyte)
col 10: flag (+/-)
col 11-17: segment name
Relocation Bit
• For simple machines
• Relocation bit
– 0: no modification is necessary
– 1: modification is needed
Program Linking
• Goal
– Resolve the problems with EXTREF and EXTDEF from different control sections
• Linking
– 1. User, 2. Assembler, 3. Linking loader
• Example
– Program1 and Program2
– Use modification records for both relocation and linking
• address constant
• external reference
Program Logic and Data Structure
• Two Passes Logic
– Pass 1: assign addresses to all external symbols
– Pass 2: perform the actual loading, relocation, and
linking
• ESTAB (external symbol table)
• TXT
Pass 1 Program Logic
• Pass 1:
– assign addresses to all external symbols
• Variables
– PROGADDR (program load address) from OS
– CSADDR (control section address)
– CSLTH (control section length)
– ESTAB
• Fig. 3.11(a)
– Process Define Record
Pass 2 Program Logic
Pass 1:
» perform the actual loading, relocation, and linking
Modification record
» lookup the symbol in ESTAB
End record for a main program
» transfer address
Fig. 3.11(b)
» Process Text record and Modification record
Example of Object program for Direct linking
loader
• ESD,TXT,RLD,END
• ESD : External Symbol Dictionary
• TXT : Text containg actual object code.
• RLD : Relocation and linkage directory.
• END : End of the module.
SOFTWARE TOOLS
• Software tool is system program which Interfaces program
with the entity generating its input data or
• Interfaces the result of a program with the entity consuming
them.
Entity generating the data or consuming the results may be a
program or a user.
• Program Development
• User Interfaces.