---
name: "ld.so"
section: "1"
platform: "openbsd"
package: "man"
version: "8.0-current-20261101"
release: "OpenBSD 8.0-current (2026-11-01)"
platforms: ["freebsd", "openbsd"]
url: "https://new.carta.tech/ld.so"
---

# ld.so(1)

run-time link-editor

## NAME

**ld.so** – run-time link-editor

## DESCRIPTION

**ld.so** is a self-contained, position independent program image providing run-time support for loading and link-editing shared objects into a process's address space. It uses the data structures( see [elf(5)](/elf/5.md)) contained within dynamically linked programs to determine which shared libraries are needed and loads them at a convenient virtual address using the [mmap(2)](/mmap/2.md) system call.

After all shared libraries have been successfully loaded, **ld.so** proceeds to resolve external references from both the main program and all objects loaded. A mechanism is provided for initialization routines to be called, on a per-object basis, giving a shared object an opportunity to perform any extra set-up, before execution of the program proper begins.

**ld.so** is itself a shared object that is initially loaded by the kernel.

To quickly locate the required shared objects in the filesystem, **ld.so** may use a “hints” file, prepared by the [ldconfig(8)](/ldconfig/8.md) utility, in which the full path specification of the shared objects can be looked up by hashing on the 3-tuple ⟨library-name, major-version-number, minor-version-number⟩.

**ld.so** searches for shared objects in the following lists of paths:

1. LD\_LIBRARY\_PATH environment variable if set

2. DT\_RUNPATH of the calling object if set, otherwise:

   1. DT\_RPATH of the calling object if set

   2. DT\_RPATH of the program if set

      (The use of DT\_RPATH is deprecated as its behaviour varies across operating systems.)

3. default search path set by [ldconfig(8)](/ldconfig/8.md)

4. */usr/lib*

**ld.so** recognises a number of environment variables that can be used to modify its behaviour as follows:

- LD\_LIBRARY\_PATH

  A colon separated list of directories, prepending the default search path for shared libraries.

- LD\_PRELOAD

  A colon separated list of library names to load before any of the regular libraries are loaded.

- LD\_BIND\_NOW

  Specifies that the dynamic linker should process all relocations before transferring control to the program. Normally, the procedure linkage table entries are handled lazily, avoiding symbol lookup and relocation for unused functions.

- LD\_TRACE\_LOADED\_OBJECTS

  When set, causes **ld.so** to exit after loading the shared objects and printing a summary which includes the absolute pathnames of all objects, to standard output.

- LD\_TRACE\_LOADED\_OBJECTS\_FMT1

  - LD\_TRACE\_LOADED\_OBJECTS\_FMT2

  When set, these variables are interpreted as format strings a la [printf(3)](/printf/3.md) to customize the trace output and are used by [ldd(1)](/ldd/1.md)'s **-f** option and allows [ldd(1)](/ldd/1.md) to be operated as a filter more conveniently. LD\_TRACE\_LOADED\_OBJECTS\_FMT1 is used for tracing shared libraries; LD\_TRACE\_LOADED\_OBJECTS\_FMT2 for dynamically loaded objects, the dynamic linker, and the main executable. The following conversions can be used:

  - %a

    The main program's name (also known as “\_\_progname”).

  - %A

    The value of the environment variable LD\_TRACE\_LOADED\_OBJECTS\_PROGNAME.

  - %e

    The end address of the object.

  - %g

    The object's group reference count.

  - %m

    The object's major version number.

  - %n

    The object's minor version number.

  - %O

    The object's open count.

  - %o

    The object name.

  - %p

    The full pathname as determined by **ld.so**'s library search rules.

  - %r

    The object's reference count.

  - %x

    The object's load address.

    Additionally, **\\n** and **\\t** are recognised and have their usual meaning.

- LD\_DEBUG

  When set, be verbose about what **ld.so** does.

Many of these environment variables are ignored for executables with set-user-ID, set-group-ID, or which are not readable.

## FILES

- */var/run/ld.so.hints*

  library location hints built by [ldconfig(8)](/ldconfig/8.md)

## SEE ALSO

[ld(1)](/ld/1.md), [ldd(1)](/ldd/1.md), [elf(5)](/elf/5.md), [ldconfig(8)](/ldconfig/8.md)

## HISTORY

The shared library model employed first appeared in SunOS 4.0.
