Link Editing With the Link-Editor

The link-editor, ld(1), takes a variety of input files, typically generated from compilers, assemblers, or previous invocations of the link-editor. The link-editor concatenates and interprets the data within these input files to form an output file. The output file that is produced is one of the following basic types.

  • Dynamic Executable - A concatenation of relocatable objects that can be executed by exec(2). A dynamic executable is loaded at a fixed virtual address space and is executed under control of the runtime linker, ld.so.1(1), to produce a runtime process. Dynamic executables typically have one or more dependencies in the form of shared objects.

    A dynamic executable is created when the -z type=exec option is used, or is the default when no other options that control the output file type are provided.

  • Kernel Module - A special case of a relocatable object, containing dynamic linking information, that can be loaded by the operating system kernel. Kernel modules can have dependencies on other kernel modules.

    A kernel module is created when the -z type=kmod option is used.

  • Position-independent Executable (PIE) - A position independent form of a dynamic executable that can be executed by exec(2). A position-independent executable is loaded at an arbitrary virtual address space and is executed under control of the runtime linker, ld.so.1(1), to produce a runtime process. Position-independent executables typically have one or more dependencies in the form of shared objects.

    A position-independent executable is created when the -z type=pie option is used.

  • Relocatable Object - A concatenation of relocatable objects that can be used in subsequent link-edit phases.

    A relocatable object is created when the -z type=reloc option, or -r option are used.

  • Shared Object - A concatenation of relocatable objects that provide services for other dynamic objects. A shared object is loaded at an arbitrary virtual address space under the control of the runtime linker, ld.so.1(1), and is bound to executables, or other shared objects, at runtime. Shared objects can have dependencies on other shared objects.

    A shared object is created when the -z type=shared option, or -G option are used.

  • Static Executable - A concatenation of relocatable objects that can be executed directly by exec(2), without assistance from the runtime linker, ld.so.1(1).

    A static executable is created when the -z type=static option, or -a option are used. However, modern versions of the Oracle Solaris operating system do not support the creation of static executables. See Static Executables.

Dynamic executables and position-independent executables are collectively referred to as executables. These executables, together with shared objects, are collectively referred to as dynamic objects.

Shared objects and relocatable archives, created with ar(1), are collectively referred to as libraries.

To provide for efficient arbitrary virtual address space mapping, position-independent executables and shared objects should be created from position-independent code (PIC).