Linker and Libraries Guide

Related Topics

Dynamic Linking

Dynamic linking is a term often used to embrace those portions of the link-editing process that generate dynamic executables and shared objects, together with the runtime linking of these objects to generate a runable process. Dynamic linking allows multiple applications to use the code provided by a shared object by enabling the application to bind to the shared object at runtime.

By separating an application from the services of standard libraries, dynamic linking also increases the portability and extensibility of an application. This separation between the interface of a service and its implementation enables the system to evolve while maintaining application stability, and is a crucial factor in providing an application binary interface (ABI). Dynamic linking is the preferred compilation method for Solaris applications.

Application Binary Interfaces

To enable the asynchronous evolution of system and application components, binary interfaces between these facilities are defined. The Solaris linkers operate upon these interfaces to assemble applications for execution. Although all components handled by the Solaris linkers have binary interfaces, one family of such interfaces of particular interest to applications writers is the System V Application Binary Interface.

The System V Application Binary Interface, or ABI, defines a system interface for compiled application programs. Its purpose is to document a standard binary interface for application programs on systems that implement the System V Interface Definition, Third Edition. Solaris provides for the generation and execution of ABI-conforming applications. On SPARCTM systems, the ABI is contained as a subset of the SPARC(R) Compliance Definition (SCD).

Many of the topics covered in the following chapters are influenced by the ABI. For more detailed information, see the appropriate ABI manuals.

32 and 64-bit Environments

The link-editors operate on 32-bit objects, and on SPARCV9 systems are also capable of operating on 64-bit objects. In fact on SPARC systems the 64-bit link-editor (ld(1)) is capable of generating 32-bit objects and the 32-bit link-editor is capable of generating 64-bit objects (however, in the latter case, the size of the generated object, not including the .bss, is restricted to 2 gigabytes).

There is no command line option required to distinguish 32-bit or 64-bit objects. The link-editor uses the ELF class of the first input relocatable file it sees to govern the mode in which it will operate. Intermixing of 32-bit and 64-bit objects is not permitted.

In general the operations of the link-editors on 32-bit and 64-bit objects is identical; however, this document typically uses 32-bit examples. Cases where 64-bit processing differs from the 32-bit processing are highlighted.

For more information regarding 64-bit applications refer to the Solaris 64-bit Developer's Guide.

Support Tools

Together with the objects mentioned in the previous sections come several support tools and libraries. These tools provide for the analysis and inspection of these objects and the linking processes. Among these tools are: elfdump(1), nm(1), dump(1), ldd(1), pvs(1), elf(3ELF), and a linker debugging support library. Throughout this document many discussions are augmented with examples of these tools.