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-3
Position-Independent Code (PIC) and Conventional
Code in TNS/R
Position-Independent Code (PIC) and Conventional Code in
TNS/R
Code that can be relocated in virtual memory at load time without alteration is called
position-independent code (PIC). If you use DLLs in your application, your program
and these DLLs are PIC. All references in PIC files to global or external symbols are
made indirectly through addresses stored in a data area so that the loader can find and
bind them to reflect their virtual-memory locations at load time without modifying code.
The TNS/R compilers can generate PIC files, the PIC linker (ld) creates either PIC
programs or DLLs, and the loader and operating system load and bind the results.
However, TNS/R systems can run conventional non-PIC programs and SRLs as well
as PIC programs and DLLs; and by default, the TNS/R compilers generate non-PIC
code. The non-PIC linker, nld, links these conventional programs, and the operating
system statically binds them to fixed virtual addresses for execution. Unlike DLLs,
these conventional loadfiles cannot have their addresses modified at load time.
What is a DLL?
A DLL is a type of library that is constructed of PIC. When using DLLs on TNS/R, a
complete, executable application comprises one (main) program and zero or more
DLLs. The program is the root of the application, while the DLLs provide functions and
data needed by the program or other DLLs. DLLs allow you to structure your
applications in functional units (the DLLs). A DLL might be a library that supports a
single program, or it might be available to a project or a group with common
computational needs, or it might be a library that is available to all users.
Figure 1-2, below, shows an application comprising a program and the DLLs that it
requires in order to run. Some of these (A, B, and C) offer symbol definitions that the
program itself may need; others offer symbol definitions that the various libraries, but
not the program, may need.
A, B, and C might be libraries that, along with Program, constitute the basic logic of the
application. D and E might be libraries of supporting routines for A. F and G might be
more general-purpose libraries.
A DLL is written as an ordinary program with no main procedure and is designated a
DLL in the course of construction.