Unit III System Software
Unit III System Software
CS 1203 SYSTEM SOFTWARE QUESTION BANK UNIT-III III Sem CSE LOADERS & LINKERS
Definitions
Loading Copies a object program into memory for execution. Relocation Modifies an program so it can be loaded at a location different from the one specified at assembly or compilation. Linking Combines two or more object files and the references between them. Loader System program that performs the loading function. Linker or Linkage Editor Performs the linking function. Compilers & assemblers for a given machine produce files in the same format. 1) Define Loading,Relocation and Linking.
2) What is the basic function of a loader? The most fundamental functions of a loader: Bringing an object program into memory and starting its execution 3) What are the characteristics of an absolute loader? o No linking and relocation needed Records in object program perform Header record Check the Header record for program name, starting address, and length (available memory)
Text record Bring the object program contained in the Text record to the indicated address End record o Transfer control to the address specified in the End record 4) Write an algorithm for an absolute loader. Algorithm for an absolute loader
5) What is a bootstrap loader? When a computer is first tuned on or restarted, a special type of absolute loader, the bootstrap loader loads the first program (usually O.S.) to be run into memory 6) Explain 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 After load the OS, the control is transferred to the instruction at address 80.
Relocatable Program o Modification record Col 1 M Col 2-7 Starting location of the address field to be modified, relative to the beginning of the program (hex) Col 8-9 length of the address field to be modified, in half-bytes E.g M^000007^05 Pass the address modification information to the relocatable loader Beginning address of the program is to be added to a field that begins at addr ox000007 and is 5 bytes in length. Object Program with Relocation by Modification Records
10) What is linking? Linking, which combines two or more separate object programs and supplies the information needed to allow references between them . 11) What are loader design options?
Dynamically loaded must be called via an operating system service request Load-and-call service o OS examines its internal tables to determine whether or not the routine is already loaded o Routine is loaded from library o Control is passed from OS to the called subroutine o Subroutine is finished o Calling to a subroutine which is already in memory Dynamic Linking : Binding of the name to an actual address is delayed from load time until execution time 13) What are the advantages of dynamic linking?
Dynamic Linking
Advantages Load the routines when they are needed, the time and memory space will be saved.
Avoid the necessity of loading the entire library for each execution o i.e. load the routines only when they are needed Allow several executing programs to share one copy of a subroutine or library (Dynamic Link Library, DLL) 11) What is the difference between linking loader and linkage editors? A linking loader performs o All linking and relocation operations o Automatic library search o Loads the linked program directly into memory for execution A linkage editor o Produces a linked version of program (often called a load module or an executable image), which is written to a file or library for later execution o A simple relocating loader can be used to load the linked version of program into memory The loading can be accomplished in one pass with no external symbol table required
A linkage editor o Resolution of external references and library searching are only performed once o 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 o External references is often retained in the linked program
To allow subsequent relinking of the program to replace control sections, modify external references, etc.
Linking loader
Suitable when a program is reassembled for nearly every execution In a program development and testing environment When a program is used so infrequently that it is not worthwhile to store the assembled and linked version.
Linkage editor
If a program is to be executed many times without being reassembled, the use of a linkage editor substantially reduces the overhead required. 14) What are machine independent loader features?
Since the subroutines fetched from a library may themselves contain external references ,the library search process may be repeated. The programmers can override the standard subroutines in the library by supplying their own routines 15) What are machine independent loader features?
Example
INCLUDE READ(UTLIB) INCLUDE WRITE(UTILB) DELETE RDREC, WRREC CHANGE RDREC, READ CHANGE WRREC, WRITE 16) Write short notes on MSDOS - Linker
MS-DOS Linker
MS-DOS assembler (MASM) produce object modules (.OBJ) MS-DOS LINK is a linkage editor that combines one or more modules to produce a complete executable program (.EXE) MS-DOS object module o THEADER similar to Header record in SIC/XE o MODEND similar to End record in SIC/XE
a.c
int a() { return 5; }i nt a1() { return 8; }
b.c
int b() { return 5; }