1dladdr(3C) Standard C Library Functions dladdr(3C)
2
3
4
6 dladdr, dladdr1 - translate address to symbolic information
7
9 #include <dlfcn.h>
10
11 int dladdr(void *address, Dl_info_t *dlip);
12
13
14 int dladdr1(void *address, Dl_info_t *dlip, void **info, int flags);
15
16
18 The dladdr() and dladdr1() functions determine if the specified address
19 is located within one of the mapped objects that make up the current
20 applications address space. An address is deemed to fall within a
21 mapped object when it is between the base address, and the _end address
22 of that object. See NOTES. If a mapped object fits this criteria, the
23 symbol table made available to the runtime linker is searched to locate
24 the nearest symbol to the specified address. The nearest symbol is one
25 that has a value less than or equal to the required address.
26
27
28 The Dl_info_t structure must be preallocated by the user. The structure
29 members are filled in by dladdr(), based on the specified address. The
30 Dl_info_t structure includes the following members:
31
32 const char *dli_fname;
33 void *dli_fbase;
34 const char *dli_sname;
35 void *dli_saddr;
36
37
38
39 The Dl_info_t members provide the following information.
40
41 dli_fname Contains a pointer to the filename of the containing
42 object.
43
44
45 dli_fbase Contains the base address of the containing object.
46
47
48 dli_sname Contains a pointer to the symbol name that is nearest to
49 the specified address. This symbol either represents the
50 exact address that was specified, or is the nearest symbol
51 with a lower address.
52
53
54 dli_saddr Contains the actual address of the symbol pointed to by
55 dli_sname.
56
57
58
59 The dladdr1() function provides for addition information to be returned
60 as specified by the flags argument:
61
62 RTLD_DL_SYMENT Obtain the ELF symbol table entry for the matched
63 symbol. The info argument points to a symbol pointer
64 as defined in <sys/elf.h> (Elf32_Sym **info or
65 Elf64_Sym **info). Most of the information found in
66 an ELF symbol can only be properly interpreted by
67 the runtime linker. However, there are two fields
68 that contain information useful to the caller of
69 dladdr1(): The st_size field contains the size of
70 the referenced item. The st_info field provides sym‐
71 bol type and binding attributes. See the Linker and
72 Libraries Guild for more information.
73
74
75 RTLD_DL_LINKMAP Obtain the Link_map for the matched file. The info
76 argument points to a Link_map pointer as defined in
77 <sys/link.h> (Link_map **info).
78
79
81 If the specified address cannot be matched to a mapped object, a 0 is
82 returned. Otherwise, a non-zero return is made and the associated
83 Dl_info_t elements are filled.
84
86 The dladdr() and dladdr1() functions are one of a family of functions
87 that give the user direct access to the dynamic linking facilities.
88 These facilities are available to dynamically-linked processes only.
89 See Linker and Libraries Guide.
90
92 See attributes(5) for descriptions of the following attributes:
93
94
95
96
97 ┌─────────────────────────────┬─────────────────────────────┐
98 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
99 ├─────────────────────────────┼─────────────────────────────┤
100 │MT-Level │MT-Safe │
101 └─────────────────────────────┴─────────────────────────────┘
102
104 ld(1), dlclose(3C), dldump(3C), dlerror(3C), dlopen(3C), dlsym(3C),
105 attributes(5)
106
107
108 Linker and Libraries Guide
109
111 The Dl_info_t pointer elements point to addresses within the mapped
112 objects. These pointers can become invalid if objects are removed prior
113 to these elements use. See dlclose(3C).
114
115
116 If no symbol is found to describe the specified address, both the
117 dli_sname and dli_saddr members are set to 0.
118
119
120 If the address specified exists within a mapped object in the range
121 between the base address and the address of the first global symbol in
122 the object, the reserved local symbol _START_ is returned. This symbol
123 acts as a label representing the start of the mapped object. As a
124 label, this symbol has no size. The dli_saddr member is set to the base
125 address of the associated object. The dli_sname member is set to the
126 symbol name _START_. If the flag argument is set to RTLD_DL_SYMENT,
127 symbol information for _START_ is returned.
128
129
130 If an object is acting as a filter, care should be taken when inter‐
131 preting the address of any symbol obtained using a handle to this
132 object. For example, using dlsym(3C) to obtain the symbol _end for this
133 object, results in returning the address of the symbol _end within the
134 filtee, not the filter. For more information on filters see the Linker
135 and Libraries Guide.
136
137
138
139SunOS 5.11 4 Feb 2009 dladdr(3C)