Documente Academic
Documente Profesional
Documente Cultură
2.1 Introduction
2. Linking of the program with other programs needed for its execution.
3. Relocation of the program to execute from the specific memory area allocated to it.
These steps are performed by different language processors. Step 1 is performed by the
translator for language L. Steps 2 and 3 are performed by a linker while step 4 is performed by a
loader.
Data
Data
Results
Object module Binary programs
Fig: 2.1 contain schematic showing steps 1-4 in the execution of a program. The translator
outputs a program form called object module for the program. The linker processes a set of object
modules to produce a ready to execute program form, a Binary program. The loader loads this
program into the memory for the purpose of execution. Object modules and Binary program
forms can be stored in the form of files for repeated use.
The origin of the program may have to be changed by the linker or loader for one
of the two reasons. First, same set of translated addresses may be used by different object modules
constituting a program, for example Object modules of library routines often have the same
translated origin. Memory allocation to such programs would conflict unless their origins are
changed. Secondly an operating system may require that a program should execute from the
specific area of memory. This may require a change in origin. The change in origin leads to the
change in the execution start address and the address assigned to symbols.
The following terminologies are used to refer to the address of a program entity at
different times.
Translated origin: Address of the origin assumed by the Translator. This is the address specified
by the programmer in an ORIGIN statement.
Linked origin: Address of the origin assumed by the linker while producing a binary program.
Load origin: Address of the origin assumed by the loader while loading the program for
execution.
The linked and load origins may differ from the translated origin of a program due to one of the
reasons mentioned earlier.
A Sample assembly program & code is shown below to specify about the address of
program entity.
START 500
ENTRY TOTAL
LOOP 501)
STOP
A DS 1
TOTAL DS 1
END
The translated origin of the program is 500.Translation time address of LOOP is 501.If the
program is loaded for execution in the memory area starting with the address 900.The load time
origin is 900. The load time address of LOOP would be 901.
Let AA be the set of absolute addresses –instruction or data addresses used in the
instruction of a program P.AA=Φ implies that program P assumes its instructions and data to
occupy memory words with specific addresses. Such a program called an Address sensitive
program –contains one or more of the following:
Address sensitive program P can execute correctly only if the start address of the memory
area allocated to it is same as its translated origin. To execute correctly from any other memory
area, the address used in each address sensitive instruction of P must be corrected. Program
relocation is the process of modifying the addresses used in the address sensitive instructions of
the program such that the program can execute correctly from the designated area of memory.
where as loaders do not perform relocation, load origin= linked origin. Such loaders are called as
absolute loaders.
Object module of a program contains all the information necessary to relocate and link the
program with other programs. Object module of a program P consists of four components:
I. Header –The header contains translated origin, size and execution start address of P.
III. Relocation Table (RELOCTAB)- This table contains a single field Translated address is
IV. Linking Table (LINKTAB): This table contains information concerning the public
definitions and external references in P. Each LINKTAB entry contains three fields:
Symbol-Symbolic name
Translated address: For a public definition, this is the address of the first memory word
allocated to the symbol. For external reference, it is the address of memory word which is
required to contain the address of the symbol.
START 500
ENTRY TOTAL
LOOP 501)
STOP
A DS 1
TOTAL DS 1
END
3. Relocation table
500
538
4. Linking table
A PD 540
LOOP does not appear in the linking table because it is not declared as a public definition
2.3 LINKER
The process of merging many object modules to form a single machine language program
is known as linking. Linker performs the function of linking. The need for linking arises because a
program written by a programmer or its translated version does not execute on its own, without
the presence of some other programs in the computer storage. For example a high level language
like FORTRAN, COBOL contains calls on certain standard functions like SIN, COS etc. Every
time a standard function is invoked by the high level language program the control should get
transferred to the appropriate program. Linking process makes addresses of programs unknown to
each other so that such control transfers can take place during execution. In short, Linking is the
Process of binding an external reference to the correct link time address. An external reference is
said to be unresolved until linking is performed for it. It is said to be resolved when its linking is
completed.
Output of the translator is given to the linker .Linker performs the linking of object
modules. Output of the Linker is loaded into memory for execution. Fig: 2.2 shows the process of
linking a program.
An overlay is a part of a program which has the same load origin as some other part of the
program. Overlays are used to reduce the main memory requirement of a program.
Program containing overlays are referred as overlay structured program. Such programs
consist of a permanently resident portion called the root, as set of overlays. Execution begins with
loading root in the memory and given control for the purpose of execution. Other overlays are
loaded as and when needed. Loading of an overlay overwrite a previously loaded overlay with the
same load origin. This reduces the memory requirement of program. It is also makes it possible to
execute the programs whose size exceeds the amount of memory which can be allocated to them.
The manner in which a program can be modified or can modify itself to execute from a
given load origin can be used to classify programs into the following,
2. Relocatable programs
3. Self-relocating programs
Self relocating program is a program which can perform the relocation of its own address
sensitive instructions. It contains the following two provisions for this purpose. A table of
information concerning the address sensitive instructions exists as a part of the program. Code to
perform the relocation of address sensitive instructions exists as a part of the Program. This is
called the relocating logic.
The start address of the relocating logic is specified as the execution start address of the
program. Thus the relocating logic gains control when the program is loaded in memory for
execution. It uses the load address and the information concerning the address sensitive
instructions to perform its own relocation. Execution control is now transferred to the relocated
program. A self-relocating program can execute in any area of the memory. This is important in
time sharing systems where load address of a program is different for different executions.
Relocating
Logic
Program
Program
Program +
Data +
+
Data Data
Relocation
Relocation
Information
information
Fig: 2.3 Program forms and relocability: (a) Non-relocatable program (b) Relocatable program
Two basic schemes used are link and go scheme and link – load-and- go scheme.
Object
module
Ready to execute
Linkage program
Object
Editor
module
Disadvantage:
1. Linkage editor needs to co- exist with the program while performing the linking tasks.
This scheme requires less storage since the linkage editor constructs a ready to execute
form of the program and puts it out on the secondary medium. This ready to execute programs are
stored in the library known as phase library. For executing the program it needs to be loaded into
the main storage without any relocation. Absolut loaders are used to load this program because it
does not require any relocation of the program.
2.6 Loader
Software processor which performs some low level processing of the programs input to it
to produce a ready to execute program. It Load the program in appropriate area in the memory
when it is to be executed. It initiates the execution of the program. Many loaders also support
relocation and linking. Some systems have a linker to perform the linking and a separate loader to
handle relocation and loading. In general it binds the program to its load time addresses.
o Relocation of the program to execute properly from load time storage area
form of the program and puts it out on the secondary medium. Every instruction of this program is
bound at a specific load-time address. For executing the program, it needs to be loaded into the
main storage without any relocation. This task is performed by an absolute loader. The loader is
presented with the text of the program which has been linked for the designated area, load address
of the first word of the program and length of the program.
The loader Performs I/O operations to load the program into the storage. Because of its
simplicity, absolute loader can be coded in very few machine instructions. Hence not much
storage is wasted because of loaders presence in main storage. Another advantage of absolute
loader is that the program can be stored in the library in their ready to execute form. Such library
is known as phase library. Storage resident supervisor of an operating system generally contains
an absolute loader for loading various system components from the phase library. This is
explained in the fig: 2.6.
Object
module Phase library
Linkage Absolute
Editor Loader
Ready to execute
program
Advantages
Disadvantages
Loaders that perform the program relocation is called as relocating loaders. This loader
performs the relocation while loading the program for execution. This permits a program to be
executed in different parts of memory. Relocation of the program is possible due to the ability to
manipulate address sensitive instructions of the program. There are two methods to describe
where in the object program to modify the addresses.
If an object needs too many modification records, it would be more efficient to use a
relocation bit mask to indicate where in the object program should be modified when the object
program is loaded. A relocation bit is associated with each word of object code. Since all SIC
instructions occupy one word, this means that there is one relocation bit for each possible
instruction. If the relocation bit corresponding to a word of object code is set to 1, the program’s
starting address will be added to this word when the program is relocated. It is suitable for a large
number of changes.
Advantages
It provides an efficient sharing of the machine with larger memory when several
independent programs are to be run together. It supports the use of subroutine libraries efficiently.
Disadvantages
When the user is ready to run the linked program, a simple relocating loader can be used
to load the program into memory. The only object code modification necessary is the addition of
an actual load address to relative values within the program. The linkage editor performs
relocation of all control sections relative to the start of the linked program. All items that need to
be modified at load time have values that are relative to the start of the linked program. This
means that the loading can be accomplished in one pass with no external symbol table required. It
is less overhead than using a linking loader. If a program is to be executed many times without
being reassembled, the use of a linkage editor can substantially reduces the overhead required.
Resolution of external references and library searching are only performed once. In contrast a
linking loader searches the libraries and resolves external references every time the program is
executed. Sometimes, however a program is reassembled for nearly every execution. This
situation might occur in a program development and testing environment. It also occurs when a
program is used so less frequently that that it is not worthwhile to store the assembled version in
library. In such a case it is efficient to use a linking loader which avoids the steps of writing and
reading a linked program. Figure 2.6 illustrates the functions of linkage editor.
Linked program produced by the linkage editor is generally in a form that is suitable for
processing by a relocating loader. All external references are resolved and relocation is indicated
by some mechanisms such as modification records or a bit mask. Even though all linking has been
performed, instruction concerning external references is often retained in the linked program. This
allows subsequent relinking of the program to replace control sections, modify external references
etc. If this information is not retained, the linked program cannot be reprocessed by the linkage
editor, it can only be loaded an executed. If the active address at which the program will be loaded
is known in advance, the linkage editor can perform all needed relocation. The result is a linked
program that is an exact image of the way the program will appear in memory during execution
.But this added flexibility of being able to load the program at any location results in a slight
additional overhead for performing relocation at load time. Linkage editors can perform many
useful functions besides simply preparing an object program for execution. It can be used to build
packages of subroutines or other control sections that are generally used together. Compared to
the linking loaders, linkage editor in general tend to offer more flexibility and control when a
corresponding increase in complexity an overhead.
A linking loader performs all linking and relocation operations, including automatic
library search, and loads the linked program into memory for execution. A linkage editor
produces a linked version of the program, which is normally written to a file for later execution.
When program is used less frequently, not worthy to store the assembled version in the
library, the linking loader is used. A loader is unnecessary for interpreted languages, as the
executable code is built up into the memory of the computer.
Comparison of functions of linkage editor and linking loader is shown in the figure 2.8.
Dynamic Linking
Linkage editors perform linking before the program is loaded for execution. Linking
loaders perform these same operations at load time. A subroutine is loaded and linked to the rest
of the program when it is called. It postpones the linking function until execution time. This type
of function is called dynamic linking, dynamic loading, or load on call.
Application
Dynamic linking is often used to allow several executing programs to share one copy of a
subroutine or library. For example, a single copy of the standard C library can be loaded into
memory. All C programs currently in execution can be linked to this one copy, instead of linking
a separate copy into each object program. In an object-oriented system, dynamic linking is often
used for references to software object. This allows the implementation of the object and its
method to be determined at the time the program is run (e.g., C++).The implementation can be
changed at any time, without affecting the program that makes use of the object. Dynamic linking
also makes it possible for one object to be share by several programs.
Advantages
The subroutines that diagnose errors may never need to be called at all.
Without using dynamic linking, these subroutines must be loaded and linked every time
the program is run.
Using dynamic linking can save both space for storing the object program on disk and in
memory, and time for loading the bigger object program.
Dynamic linking make it unnecessary for the program to know the possible set of
subroutines that might be used. The subroutine name might be treated as another input
item.
In fig: 2.9 Instead of executing a JSUB instruction to an external symbol, the program
makes a load-and-call service request to the OS.The parameter of this request is the symbolic
name of the routine to be called.
In fig: 2.10 The OS examines its internal tables to determine whether the subroutine is
already loaded. If needed, the subroutine is loaded from the library. Then control is passed from
the OS to the subroutine being called. When the called subroutine completes its processing, it
returns to its caller (operating system).The OS then returns control to the program that issues the
request. After the subroutine is completed, the memory that was allocated to it may be released.
In Fig: 2.13(a), Control is passed from operating system to the routine being called.
In Fig: 2.13(b), when the called subroutine completes its processing it returns to its caller.
The operating system then returns control to the program that issued the request. This return of
control that enables the operating system to know when the call routine has completed its
execution.
In Fig: 2.13(c), after the subroutine is called, memory allocated to load it may be released
and used for other purposes. However this is not always done immediately. Sometimes it retains
the routine in memory for later use as long as storage is not needed for other processing. If
subroutine is still in memory a second call to it may not require another load operation. Control
may be simply passed from dynamic loader to the called routine.
Control is returned to the loader and later The called subroutine is already
returned to the user program loaded
Test data generators: Test data generators help the programmer in selecting test data
Department of Computer Sciences and Applications, SJCET, Palai P a g e | 42
MODULE II MCA 303 SYSTEM SOFTWARE ADMN 2011 – ‘12
Automated test drivers: Regression testing is done through automated test drives. in this,
program correctness is verified by subjecting it to a standard set of tests after every
modification.
Debug monitors: Helps to obtain the information about localization of error, debug
monitor is used
Source code control: Source code control system help to keep track of modification in the
source code.
5. Program Documentation
Most programming projects suffer from lack of up to date documentation. Automatic
documentation tools are motivated by the desire to overcome this deficiency. These tools work on
the source program to produce different forms of documentation.
Eg: flow charts
2.7.2 EDITOR
An interactive editor is a computer program that allows a user to create and revise a target
document. The document means an object such as computer programs, text, equations tables,
diagrams, photographs etc. The document editing process in an interactive user computer dialogue
designed to accomplish four tasks:
1) Select the part of the target document to be viewed & manipulated.
2) Determine how to format this view online and how to display it.
3) Specify and execute operations that modify the target document.
4) Update the view appropriately.
Selection of the part of the document to be viewed and edited involves first travelling
through the document to locate the area of interest. Travelling implies movement of the editing
context to a new position within the text. The selection of what is to be viewed and manipulated
that is controlled by filtering. Filtering extracts the relevant subset of the target document at the
point of interest, such as the next screenful of text or the next statement. Formatting determines
how the result of the filtering will be seen as a visible representation on a display screen or other
devices. In the actual editing phase, the target document is created or altered with a set of
operations such as insert, delete, replace, move and copy.
Various types of editors are used for editing the document. Mainly two types of editors are
used commonly ie Text editor and graphic editor. Text editor is the most interactive editor used
for editing. Various types of editors and text editors are illustrated in the figure 2.11.
Demerits
Stream Editor
A stream editor views the entire text as a stream of characters. This permits edit operations
to cross line boundaries. Stream editor typically support character line and context orient
commands. In stream editor, the current editing context indicated by the position of text pointer.
This pointer can be manipulated using positioning. Stream editor maintain multiple
representations.
Word Processor
It is a document editor with additional features. It produces well formatted output.
Features of text are merging of text, Searching and replacement of word and Moving sections of
text.
Design of an Editor
The fundamental functions in editing are travelling, editing, viewing and display.
Travelling implies movement of the editing context to a new position within the text. Viewing
implies formatting the text in a manner desired by the user. A simple text editor' may choose to
combine the viewing and display functions.
In editing document, the start of the area to be edited is determined by the current editing
pointer maintained by the editing component. The travelling component of the editor actually
performs the setting of the current editing and viewing pointers. It also determines the point at
which the viewing and editing filters. The current editing pointer can be set or reset explicitly by
the user with travelling commands, such as next paragraph and next screen. When a user issue an
editing command the editing component invokes the editing filter. Editing component filters the
document to generate a new editing buffer based on the current editing pointer as well as on the
editing filter parameters. Filtering may simply consists of the selection of contiguous characters
beginning at the current point. Current viewing pointer determined the start of the area to be
viewed for viewing a document. Current viewing pointer can be set or reset explicitly by the user
with a travelling command or implicitly by the user with a travelling command or implicitly by
the system as a result of the previous editing operation.
Figure 2.17 shows the simple editor.
For a given position of the editing context, the editing and viewing filters operate on the
internal form of text to prepare the forms suitable for editing viewing. When the cursor position
changes, the filters operate on a new portion of text to update the contents of the buffers. As
editing is performed, the editing filter reflects the changes into the internal form and update the
content of the viewing buffer. The editing and viewing buffers are independent in some cases. The
editing and viewing buffer can also partially overlap or one may be completely contained in the
other. For example, the user might specify a search to the end of the document, starting at a
character position in the middle of the screen. In the above example, an editing filter creates an
editing buffer that contains the document from the selected character of the end of the document.
The viewing buffer contains the part of the document that is visible on the screen. Only the last
part of which is in the editing buffer.
Debugging system should provide functions such as tracing and trace back. Tracing can be
used to track the flow of execution logic and data modifications. It can also be based on
conditional expressions. Trace back can show the path by which the current statement was
reached. It can also show which statements have modified a given variable or parameter.
Debugging system have a good program display capabilities. It must be possible to display the
program being debugged, complete with statement numbers. The system should save all the
debugging specifications across such a recompilation, so the user does not need to reissue all of
these debugging commands. Debugging system must be sensitive to the specific languge being
debugged so that procedural, arithmetic and conditional logic can be coded in the syntax of that
language. The debugger should be able to switch its context when a program written in one
language calls a program written in a different language. A debugging system must be able to deal
with optimized code. Application code used in production environments is usually optimized.