DLL Programmer's Guide for TNS/R Systems

Finding Symbol Definitions
DLL Programmers Guide for TNS/R Systems522203-002
4-5
Import Controls and SearchLists
in your loadfile to be exported, and then you can choose which symbols not to export.
See Controlling Which Symbols Your Loadfile Exports on page 5-5.
Import Controls and SearchLists
Just as you have control over the symbol definitions your loadfile offers for export, you
can control the sources from which your loadfile can import symbol definitions. You do
this by setting your loadfile’s import control, which directly affects the range and
sequence of the search that the linker and loader follow in locating needed symbol
definitions. The search range defines which loadfiles are searched for symbol
definitions; the search sequence determines the order in which these loadfiles are
searched.
The search sequence is important, because each symbol reference will be bound to
the first definition found whose name matches the reference. This is how the linker and
loader avoid the dilemma posed by duplicate symbol definitions among loadfiles in the
search range, which would otherwise be ambiguous.
The search range and sequence are encapsulated in your loadfile’s searchList, which
is created and used by the linker, when your loadfile is linked, then later recreated and
used by the loader each time your loadfile is loaded. The searchList names the
loadfiles to be searched for symbol definitions in the order they are to be searched.
The setting of your loadfile’s import control tells the linker and loader how to build your
loadfile’s searchList. The allowed settings are localized, globalized, and semi-
globalized. You choose the setting for the loadfile you are linking by inserting one of
the following options:
-b localized
-b globalized
-b semi_globalized or its synonym, -b symbolic
These are one-time options. If you do not insert one of these options, then by default,
the linker produces a localized loadfile.
The SearchList for a Localized Loadfile
In the localized case with no re-exportation, the only loadfiles available to resolve
symbols are those listed in the importing loadfile’s libList. Hence, the searchList begins
with the loadfile itself followed by names taken from the libList in the order listed.
However, a DLL can also make available symbols exported by any library in its libList
by re-exporting that library, so a localized loadfile could import symbols from libraries
not in its libList. A localized loadfile’s searchList is developed starting with this loadfile
itself, adding its libList (as above), appending to this the names of re-exported libraries,
then appending the names of the libraries those re-exported libraries re-export, and so
forth. This process is defined in the following algorithm, which the linker uses when
linking a localized loadfile and the loader uses when loading it. The algorithm is
illustrated in the example that comes after it.