File: dladdr.3

package info (click to toggle)
audacity 1.2.4b-2.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 24,136 kB
  • ctags: 20,445
  • sloc: ansic: 139,567; cpp: 55,998; sh: 24,963; lisp: 3,772; makefile: 1,683; python: 272
file content (129 lines) | stat: -rw-r--r-- 4,083 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
.\"
.\" Copyright (c) 1998 John D. Polstra
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/dladdr.3,v 1.3.2.4 2003/03/15 15:11:05 trhodes Exp $
.\"
.Dd June 8, 2003
.Os
.Dt DLADDR 3
.Sh NAME
.Nm dladdr
.Nd find the shared object containing a given address
.Sh SYNOPSIS
.In dlfcn.h
.Ft int
.Fn dladdr "const void *addr" "Dl_info *info"
.Sh DESCRIPTION
The
.Fn dladdr
function
queries the dynamic linker for information about the shared object
containing the address
.Fa addr .
The information is returned in the structure specified by
.Fa info .
The structure contains at least the following members:
.Bl -tag -width "XXXconst char *dli_fname"
.It Li "const char *dli_fname"
The pathname of the shared object containing the address.
.It Li "void *dli_fbase"
The base address at which the shared object is mapped into the
address space of the calling process.
.It Li "const char *dli_sname"
The name of the nearest run-time symbol with a value less than or
equal to
.Fa addr .
.Pp
If no symbol with a suitable value is found, both this field and
.Va dli_saddr
are set to
.Dv NULL .
.It Li "void *dli_saddr"
The value of the symbol returned in
.Li dli_sname .
.El
.Pp
The
.Fn dladdr
function
is available only in dynamically linked programs.
.Sh ERRORS
If a mapped shared object containing
.Fa addr
cannot be found,
.Fn dladdr
returns 0.
.Pp
On success, a non-zero value is returned.
.Sh SEE ALSO
.Xr dyld 3 ,
.Xr dlopen 3
.Sh HISTORY
The
.Fn dladdr
function first appeared in the Solaris operating system.
.Sh AUTHORS
The dlcompat package was written by Jorge Acereda 
<jacereda@users.sourceforge.net> and
Peter O'Gorman <ogorman@users.sourceforge.net>
.Pp
Some of the code for this particular function was borrowed from
a post to the darwin development list by Douglas Davidson.
.Pp
This man page was borrowed from FreeBSD and modified.
.Sh BUGS
This implementation is almost bug-compatible with the Solaris
implementation.  The following bugs are present:
.Bl -bullet
.It
If
.Fa addr
lies in the main executable rather than in a shared library, the
pathname returned in
.Va dli_fname
may not be correct.  The pathname is taken directly from
.Va argv[0]
of the calling process.  When executing a program specified by its
full pathname, most shells set
.Va argv[0]
to the pathname.  But this is not required of shells or guaranteed
by the operating system.
.It
.Fn dlerror
can not be used to get the error string if 
.Fn dladdr
fails.
.It
The symbol returned has an underscore if it is a C symbol, and can
not be used as input to 
.Fn dlsym
as
.Fn dlsym 
in a default dlcompat installation takes symbol names as they appear
in C source code (no underscore).
.It
Returning 0 as an indication of failure goes against long-standing
Unix tradition.
.El