DLL Programmer's Guide for TNS/R Systems

Finding Symbol Definitions
DLL Programmers Guide for TNS/R Systems522203-002
4-8
The SearchList for a Globalized Loadfile
The SearchList for a Globalized Loadfile
For a loadfile with globalized import, the linker's searchList is just its loadList; the
loader's searchList is the loadList of the program. (For dynamic loads, that is the
operating load set, also called the cumulative loadList of the program.)
The resulting loadList, shown at the bottom of Figure 4-2, is thus the searchList; it
gives the sequence followed by the loader to look for exported symbol definitions that
satisfy the import needs of every globalized loadfile loaded with the program.
Because the linker sees only the file it is building and its loadList, the linker searchList
of a DLL differs from the loader searchList, which includes the program and other
libraries it requires. Therefore, any link-time bindings may require revision at load time.
An advantage of globalized import is that the resulting bindings of symbols across
loadfiles more closely resemble those that would occur if all the linkfiles that constitute
the separate loadfiles had been linked into one loadfile. (This observation explains
why "globalized" import is the UNIX default.)
Ambiguity Example 1
Figure 4-3 on page 4-7 shows a case of symbol ambiguity when Program is globalized
and imports a symbol named xray, since both C and D export a symbol named xray. In
linking Program, the linker sees xray in both C and D. However, following the
globalized searchList (Program, UL, A, B, C, H, D, E, F, G), the linker encounters C’s
xray before it encounters D’s xray, so it resolves Program’s need with C’s definition.
Furthermore, if D is globalized and if it also references xray, then the loader assigns
C’s definition to D’s reference as well, preempting the linker’s original assignment of
D’s own definition to D’s reference. Thus, xray is defined the same for Program and D.
If C references xray, it will get its own definition, regardless of whether it is localized or
globalized, because it appears first in both searchLists.