DLL Programmer's Guide for TNS/E Systems

DLLs on a TNS/E System
DLL Programmer’s Guide for TNS/E Systems527252-006
1-8
Finding the Needed Libraries
See Section 3, Dynamic Use of DLLs for further details.
After the program and the initially loaded libraries are running, the program or a loaded
DLL can also call on the loader to dynamically load yet other DLLs. References by the
newly loaded DLLs are resolved among already loaded loadfiles, and subsequent
function calls can retrieve symbols offered by the newly loaded DLLs.
The system automatically arranges loadfiles in virtual memory so there is no address
overlap and interference.
Finding the Needed Libraries
A loadfile must be loaded with all the libraries that it directly references, that is, the
libraries in its libList. However, loading only the directly referenced libraries might not
be enough, because some of these libraries might directly reference still other libraries.
Therefore these other libraries must also be loaded, and they might further require still
other libraries. Proceeding in this way can lead to an arbitrarily long succession of
required libraries, all of which must be loaded to run the given loadfile.
The loader generates a list of all the libraries that must be loaded in order to run a
given loadfile by starting from the libList of that loadfile and proceeding through the
libLists of all the required libraries. This generated list is that loadfile’s loadList, and the
loader orders it in the sequence that these libraries are to be loaded, as discussed in
The SearchList for a Globalized Loadfile on page 4-8. Subsequently, the loader uses
the loadList to control the loading operation.
Among the libraries on its loadList, the loadfile directly references those libraries on its
own libList, while the rest are indirectly referenced libraries. Figure 1-4, below, shows a
more detailed view of what Figure 1-2 on page 1-4 suggests. Figure 1-4 illustrates how
the program directly references libraries A, B, and C, which were specified to the linker
by the programmer and consequently appear in Program’s libList. Also, A directly
references D and E, B directly references F, and C directly references F. The
programmers of A, B, and C stated these requirements for these libraries when each
was linked. Likewise, D and E both directly reference G. Finally, neither F nor G
reference any other libraries.