DLL Programmer's Guide for TNS/R Systems
DLLs on a TNS/R System
DLL Programmer’s Guide for TNS/R Systems—522203-002
1-11
Other Loader Operations
multiple loadfiles define and use the same symbol and you want to ensure that they all
use the same one. If you declare all these loadfiles to be globalized, then the loader
will resolve all these imports to the same exported symbol. However, object files using
globalized or semi-globalized import are likely to take somewhat longer to load,
because the linker is unable to preset bindings for files not seen at link time.
Other Loader Operations
The loader and operating system assign the program being loaded and the libraries in
its loadList to their positions in virtual memory and bind their symbols to their
appropriate definitions in these loadfiles.
Adjusting Symbol Values and Relocating in Virtual Memory
You do not have to relink a loadfile when a DLL it uses use is changed. To
accommodate this, each instance of a DLL must be relocatable in virtual memory when
the DLL is loaded for execution. This requirement is the reason that programs and
DLLs are written in PIC. Virtual instances of a DLL do not depend on being loaded in
any particular location in virtual memory, and they do not depend on any symbols they
reference being loaded in any particular location. For example, you can replace a DLL
with a new one of the same name that provides the same symbols without relinking the
DLL’s clients, even if the locations of these symbols are different in the two DLLs.
Dynamically Loaded DLLs
An important attribute of DLLs is that a running program or DLL can load and open a
previously not-yet-loaded DLL and gain access to the symbols it offers. DLLs invoked
this way are called dynamically loaded DLLs; they are further described in Section 3,
Dynamic Use of DLLs.
An important advantage of dynamically loaded DLLs is that their names and their
symbols need not be known when the program is constructed. Using this facility, you
can add to an existing application a new DLL that provides new functionality without
even restarting the application.
Another virtue of dynamic loading is that you do not need to load infrequently used
DLLs when the application is loaded. Instead, you can load and use these DLLs when
required and unload them when they are no longer needed. They can be reloaded
whenever necessary.
User Library
A program, but not a DLL, can be linked to one user library, which is a DLL having a
special relationship to the program. Instead of adding the user library’s name to the
program’s libList, the user-library name is recorded in the program loadfile as an
attribute called libname. But the linker and loader treat this DLL as if it were first in the
program’s libList, and a program’s loadList always begins with the user library if there
is one.