Page 60 - DLIS108_INFORMATION_AND_COMMUNICATION_TECHNOLOGY_APPLICATIONS
P. 60
VED1
e\L-lovely-eng\comm6-1.pmd IInd 16-9-11 IIIrd 27-12-11 IVth 4-1-12
Unit 6: Computer Software
Some programming languages may use a feature called smart linking wherein the linker is aware of
or integrated with the compiler, such that the linker knows how external references are used, and Notes
code in a library that is never actually used, even though internally referenced, can be discarded
from the compiled application. For example, a program that only uses integers for arithmetic, or
does no arithmetic operations at all, can exclude floating-point library routines. This smart-linking
feature can lead to smaller application file sizes and reduced memory usage.
When linking is done during the creation of an executable or another object file, it is known as static
linking or early binding. In this case, the linking is usually done by a linker, but may also be done
by the compiler. A static library, also known as an archive, is one intended to be statically linked.
Originally, only static libraries existed. Static linking must be performed when any modules are
recompiled.
All of the modules required by a program are sometimes statically linked and copied into the
executable file. This process, and the resulting stand-alone file, is known as a static build of the
program. A static build may not need any further relocation if virtual memory is used and no
address space layout randomization is desired.
Memory Sharing
Library code may be shared in memory by multiple processes as well as on disk. If virtual memory
is used, processes execute the same physical page of RAM, mapped into the different address spaces
of each process. This has advantages. For instance on the OpenStep system, applications were often
only a few hundred kilobytes in size and loaded quickly; the majority of their code was located in
libraries that had already been loaded for other purposes by the operating system.There is a cost,
however; shared code must be specifically written to run in a multitasking environment. In some
older environments such as 16-bit Windows or MPE for the HP 3000, only stack based data (local)
was allowed, or other significant restrictions were placed on writing a shared library.
Programs can accomplish RAM sharing by using position independent code as in Unix, which
leads to a complex but flexible architecture, or by using common virtual addresses as in Windows
and OS/2. These systems make sure, by various tricks like pre-mapping the address space and
reserving slots for each shared library, that code has a great probability of being shared. A third
alternative is single-level store, as used by the IBM System/38 and its successors. This allows position-
dependent code but places no significant restrictions on where code can be placed or how it can be
shared.
In some cases different versions of shared libraries can cause problems, especially when libraries of
different versions have the same file name, and different applications installed on a system each
require a specific version. Such a scenario is known as DLL hell, named after the Windows and OS/
2 DLL file. Most modern operating systems after 2001, have clean-up methods to eliminate such
situations.
Dynamic Linking
Dynamic linking or late binding refers to linking performed while a program is being loaded (load
time) or executed (run time), rather than when the executable file is created. A dynamically linked
library (dynamic-link library or DLL under Windows and OS/2; dynamic shared object or DSO
under Unix-like systems) is a library intended for dynamic linking. Only a minimum amount of
work is done by the linker when the executable file is created; it only records what library routines
the program needs and the index names or numbers of the routines in the library. The majority of
the work of linking is done at the time the application is loaded (load time) or during execution (run
LOVELY PROFESSIONAL UNIVERSITY 55