System Software Loaders

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 32

System Software

H.D.Phaneendra
Assistant Professor
Department of CS&E
The National Institute of Engineering
Mysore – 570023
[email protected]
System Software
•The subject introduces the design and
implementation of system software
•System software consists of a variety of programs that
support the operation of a computer
•operating system, compiler, assembler, macro processor, loader
or linker, debugger, text editor, database management systems,
software engineering tools, ….
Chapter On…

Loaders and Linkers


This Chapter Gives you…
- Basic Loader Functions
- Machine-Dependent Loader Features
- Machine-Independent Loader Features
- Loader Design Options
- Implementation Examples
Role of Loader
Source Object
Object
Translator Loader program
Program ready for
Program execution

Translator – Assembler/Compiler

Memory
Role of Loader
Source Object
Object
Assembler Loader program
Program ready for
Program execution

Memory
Role of Loader and Linker
Memory

Source
Object
Assembler Linker
Program
Program Object
program
ready for
Executable execution

Code

Loader
We know…
• Source Program – Assembly Language
• Object Program - From assembler
- Contains translated instructions and data
values from the source program
• Executable Code - From Linker
• Loader - Loads the executable code to
the specified memory locations and code
gets executed.
We need…three processes
•Loading - which allocates memory location and
brings the object program into memory for
execution - Loader
•Linking- which combines two or more separate
object programs and supplies the information
needed to allow references between them - Linker
•Relocation - which modifies the object program so
that it can be loaded at an address different from
the location originally specified - Linking Loader
Basic Loader Functions

A Loader is a system program that
performs the loading function
•It brings object program into
memory and starts its execution
Type of Loaders
•absolute loader
•bootstrap loader
•relocating loader (relative loader)
•direct linking loader
Absolute Loader
•Operation is very simple
•The object code is loaded to
specified locations in the memory
•At the end the loader jumps to the
specified address to begin
execution of the loaded program
Role of Absolute Loader
1000
Object Absolute Object
Program Loader program
ready for
execution
2000

Memory
Absolute Loader
•Advantage
- Simple and efficient
•Disadvantage
- the need for programmer to
specify the actual address
- difficult to use subroutine
libraries
• We have algorithm – next slide
Begin
read Header record
verify program name and length
read first Text record
while record type is <> ‘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
Object Program
Space for
2 inch x 2 inch
size Picture
Format-1(a) (in PowerPoint)
Object Code Representation
•Each byte of assembled code is given using its
hexadecimal representation in character form
•Easy to read by human beings
•Each byte of object code is stored as a single
byte
•Most machine store object programs in a
binary form
•We must be sure that our file and device
conventions do not cause some of the program
bytes to be interpreted as control characters
A Simple 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
Begin
X=0x80 (the address of the next memory location to
be loaded
Loop
AGETC (and convert it from the ASCII character
code to the value of the hexadecimal digit)
save the value in the high-order 4 bits of S
AGETC
combine the value to form one byte A (A+S)
store the value (in A) to the address in register X
XX+1
End
Subroutine GETC

GETC Aread one character


if A=0x04 then jump to 0x80
if A<48 then GETC
A  A-48 (0x30)
if A<10 then return
A  A-7
return
Machine-Dependent Loader Features
Absolute Loader – Simple and efficient
Disadvantage is – programmer has to
specify the starting address
One program to run – no problem – not for
several
Difficult to use subroutine libraries efficiently
Relocation
Execution of the object program using
any part of the available and sufficient
memory
The object program is loaded into
memory wherever there is room for it
The actual starting address of the object
program is not known until load time
Relocating Loaders
•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
Methods for specifying relocation
•Use of modification record (Fig. 3.4,
3.5)

•Use of 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
Modification Record
Modification record
col 1: M
col 2-7: relocation address
col 8-9: length (halfbyte)
col 10: flag (+/-)
col 11-17: segment name
•For complex machines
•Also called RLD specification
- Relocation and Linkage Directory
HCOPY 000000 001077
T000000 1D17202D69202D48101036…4B105D3F2FEC032010
T00001D130F20160100030F200D4B10105D3E2003454F46
T001035 1DB410B400B44075101000…33200857C003B850
T0010531D3B2FEA1340004F0000F1..53C003DF2008B850
T00070073B2FEF4F000005
M00000705+COPY
M00001405+COPY
M00002705+COPY
E000000 Fig 3.5
Object program with relocation by Modification records
Relocation Bit
•For simple machines
•Relocation bit
- 0: no modification is necessary
- 1: modification is needed
Text record format
Text record
col 1: T
col 2-7: starting address
col 8-9: length (byte)
col 10-12: relocation bits
col 13-72: object code
For absolute loader – No relocation bits
col:10-69 : object code
Twelve-bit mask is used in each Text
record - col:10-12 – relocation bits
- since each text record contains less
than 12 words
- unused words are set to 0
- any value that is to be modified
during relocation must coincide with one of
these 3-byte segments - line 210 ( Fig.
3.6 )
HCOPY 000000 00107A
T0000001EFFC140033481039000036280030300015…3C0003  …
T00001E15E000C00364810610800334C0000…000003000000
T0010391EFFC040030000030…30103FD8105D280030...
T0010570A 8001000364C0000F1001000
T00106119FE0040030E01079…508039DC10792C0036...
E000000
Object program with relocation by bit mask
- FFC - all ten words are to be modified Fig 3.7
- E00 - first three records are to be modified

You might also like