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-7
Loader
to the loader. This process, called linking or executing a link, must be applied to
linkfiles after they have been compiled and before they can be loaded for execution.
You invoke the linker by a single command, ld, and control it by items you enter in its
command stream, which comprises the options, file names, and parameters that
modify the ld command.
Later, the loader brings together programs with their required libraries in structures like
that shown in Figure 1-2 on page 1-4. To enable the linker to find the required libraries
when it links a loadfile, the loadfile’s programmer must enter in the command stream
the names of libraries that can provide symbols that this loadfile needs. From these
names, the linker creates in the loadfile a libList, which lists the names and certain
attributes of each of these libraries. A library that is listed in a loadfile’s libList is said to
be directly referenced by that loadfile.
In simple compile-and-link operations, the compiler runs the linker automatically. When
it does this, the compiler tells the linker the names of certain standard libraries. If those
are the only libraries required, you need do nothing more. But if you require other
libraries, you can tell the compiler to pass them to the linker, or, you can run the linker
yourself. In the latter case you must provide to the linker with the required library
names, including the ones the compiler would have automatically done for you.
The linker can run on a TNS/R machine in either the Guardian or OSS environment.
It can also run on Win32 support machines. In this document, these support machines
are called auxiliary systems. The object file produced can only be run on TNS/R
systems.
The nld linker is used on TNS/R and auxiliary systems to link conventional non-PIC
programs.
Loader
Once a program and its DLLs have been processed by the PIC linker, they can be
loaded for execution by a special library program (the run-time linker rld) that works
with the operating system. This combined facility of rld and the operating system that
loads programs and libraries into virtual memory for execution is called, in this
document, the loader.
Required libraries are not statically linked with the program. Instead, at load time, the
program and its DLLs are brought into virtual memory, and the loader resolves
references among them. The loader does not alter the stored file image of the loadfile;
rather, it changes only the loaded memory image of the loadfile’s tables and other
initialized data. So this load-time adjustment might be repeated every time a program
and its DLLs are loaded.
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.