2 .\" Copyright (c) 1998 John D. Polstra
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" $FreeBSD: head/lib/libc/gen/dladdr.3 206622 2010-04-14 19:08:06Z uqs $
33 .Nd find the shared object containing a given address
35 This function is not in a library.
36 It is included in every dynamically linked program automatically.
40 .Fn dladdr "const void * __restrict addr" "Dl_info * __restrict dlip"
45 queries the dynamic linker for information about the shared object
46 containing the address
48 The information is returned in the structure specified by
50 The structure contains at least the following members:
51 .Bl -tag -width "XXXconst char *dli_fname"
52 .It Li "const char *dli_fname"
53 The pathname of the shared object containing the address.
54 .It Li "void *dli_fbase"
55 The base address at which the shared object is mapped into the
56 address space of the calling process.
57 .It Li "const char *dli_sname"
58 The name of the nearest run-time symbol with a value less than or
61 When possible, the symbol name is returned as it would appear in C
64 If no symbol with a suitable value is found, both this field and
68 .It Li "void *dli_saddr"
69 The value of the symbol returned in
76 is available only in dynamically linked programs.
78 If a mapped shared object containing
83 In that case, a message detailing the failure can be retrieved by
87 On success, a non-zero value is returned.
94 function first appeared in the Solaris operating system.
96 This implementation is bug-compatible with the Solaris
98 In particular, the following bugs are present:
103 lies in the main executable rather than in a shared library, the
107 The pathname is taken directly from
109 of the calling process.
110 When executing a program specified by its
111 full pathname, most shells set
114 But this is not required of shells or guaranteed
115 by the operating system.
123 is a global function, its value may be an unpleasant surprise.
125 dynamically linked programs, the address of a global function is
126 considered to point to its program linkage table entry, rather than to
127 the entry point of the function itself.
128 This causes most global
129 functions to appear to be defined within the main executable, rather
130 than in the shared libraries where the actual code resides.
132 Returning 0 as an indication of failure goes against long-standing