Every shared library has two parts: the host library used for linking that resides on the host machine and the target library used for execution that resides on the target machine. The host machine is the machine on which an a.out file is built; the target machine is the machine on which the file is run. The host and target may be the same machine, but it is not a requirement.
The host library is just like a non-shared library. Each of its members (typically a complete object file) defines text and data symbols in its symbol table. The link editor searches this file when a shared library is used during the compilation of a program.
The search is for definitions of symbols referenced in the program but not defined there. However, the link editor does not copy the library code defining the symbols into the program's object file. Instead, it uses the library members to locate the definitions and then places symbols in the file that tell where the library code is. The result is the special section in the a.out file shown in ``Processes using an archive and a shared library'' as .lib.
The target library, used for execution, resembles an a.out file. During execution, if a process needs a shared library, this file is read. The .lib section in the a.out file tells which shared libraries are needed. When the UNIX system executes the a.out file, it uses this section to bring the appropriate library code into the address space of the process. In this way, before the process starts to run, all required library code has been made available.
Shared libraries enable the sharing of .text sections in the target library, which is where text symbols are defined. Although processes that use the shared library have their own virtual address spaces, they share a single physical copy of the library's text among them.
The target library cannot share its .data sections. Each process using data from the library has its own private data region that mirrors the .data section of the target library. Processes that share text do not share data and stack area in order that they do not interfere with one another.
As suggested above, the target library is a lot like an a.out file, which can also share its text, but not its data. Processes must have execute permission for a target library in order to execute an a.out file that uses the library.