Hardware Reference
In-Depth Information
Dynamic Linking in UNIX
The UNIX system has a mechanism similar in essence to DLLs in Windows. It
is called a shared library . Like a DLL file, a shared library is an archive file con-
taining multiple procedures or data modules that are present in memory at run time
and can be bound to multiple processes at the same time. The standard C library
and much of the networking code are shared libraries.
UNIX supports only implicit linking, so a shared library consist of two parts: a
host library , which is statically linked with the executable file, and a target
library , which is called at run time. While the details differ, the concepts are es-
sentially the same as with DLLs.
7.5 SUMMARY
Although most programs can and should be written in a high-level language,
occasional situations exist in which assembly language is needed, at least in part.
Programs for resource-poor computers such as smart cards and embedded proc-
essors in small consumer devices like clock radios are potential candidates. An as-
sembly language program is a symbolic representation for some underlying ma-
chine language program.
It is translated to the machine language by a program
called an assembler.
When extremely fast execution is critical to the success of some application, a
better approach than writing everything in assembly language is to first write the
whole program in a high-level language, then measure where it is spending its
time, and finally rewrite only those portions of the program that are heavily used.
In practice, a small fraction of the code is usually responsible for a large fraction of
the execution time.
Many assemblers have a macro facility that allows the programmer to give
commonly used code sequences symbolic names for subsequent inclusion. Usual-
ly, these macros can be parameterized in a straightforward way. Macros are imple-
mented by a kind of literal string-processing algorithm.
Most assemblers are two pass. Pass one is devoted to building up a symbol ta-
ble for labels, literals, and explicitly declared identifiers. The symbols can either
be kept unsorted and then searched linearly, first sorted and then searched using bi-
nary search, or hashed. If symbols do not need to be deleted during pass one,
hashing is usually the best method. Pass two does the code generation. Some
pseudoinstructions are carried out on pass one and some on pass two.
Independently-assembled programs can be linked together to form an ex-
ecutable binary program that can be run. This work is done by the linker. Its pri-
mary tasks are relocation and binding of names. Dynamic linking is a technique in
which certain procedures are not linked until they are actually called. Windows
DLLs and UNIX shared libraries use dynamic linking.
 
 
Search WWH ::




Custom Search