]> git.ipfire.org Git - thirdparty/glibc.git/blame - include/dlfcn.h
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[thirdparty/glibc.git] / include / dlfcn.h
CommitLineData
6796bc80 1#ifndef _DLFCN_H
94e365c6 2#include <dlfcn/dlfcn.h>
8dd56993 3#include <link.h> /* For ElfW. */
bdbf022d 4
2f54c82d
UD
5/* Internally used flag. */
6#define __RTLD_DLOPEN 0x80000000
9d0881aa 7#define __RTLD_SPROF 0x40000000
5a4b5076 8#define __RTLD_OPENEXEC 0x20000000
c14e9135 9#define __RTLD_CALLMAP 0x10000000
2f54c82d 10
c0f62c56
UD
11#define __LM_ID_CALLER -2
12
bdbf022d 13/* Now define the internal interfaces. */
b3fc5f84 14
102070bc
UD
15#define __libc_dlopen(name) \
16 __libc_dlopen_mode (name, RTLD_LAZY | __RTLD_DLOPEN)
00a9b51d 17extern void *__libc_dlopen_mode (__const char *__name, int __mode);
aaa8d85c
UD
18extern void *__libc_dlsym (void *__map, __const char *__name);
19extern int __libc_dlclose (void *__map);
9d79e037
UD
20libc_hidden_proto (__libc_dlopen_mode)
21libc_hidden_proto (__libc_dlsym)
22libc_hidden_proto (__libc_dlclose)
94e365c6
UD
23
24/* Locate shared object containing the given address. */
8dd56993
RM
25#ifdef ElfW
26extern int _dl_addr (const void *address, Dl_info *info,
27 struct link_map **mapp, const ElfW(Sym) **symbolp)
94e365c6 28 internal_function;
a20d8dbe 29libc_hidden_proto (_dl_addr)
8dd56993 30#endif
94e365c6 31
a334319f
UD
32/* Open the shared object NAME, relocate it, and run its initializer if it
33 hasn't already been run. MODE is as for `dlopen' (see <dlfcn.h>). If
34 the object is already opened, returns its existing map. */
35extern void *_dl_open (const char *name, int mode, const void *caller,
36 Lmid_t nsid)
37 internal_function;
38libc_hidden_proto (_dl_open)
39
94e365c6 40/* Close an object previously opened by _dl_open. */
a334319f
UD
41extern void _dl_close (void *map)
42 internal_function;
43libc_hidden_proto (_dl_close)
94e365c6
UD
44
45/* Look up NAME in shared object HANDLE (which may be RTLD_DEFAULT or
46 RTLD_NEXT). WHO is the calling function, for RTLD_NEXT. Returns
47 the symbol value, which may be NULL. */
48extern void *_dl_sym (void *handle, const char *name, void *who)
b3fc5f84
UD
49 internal_function;
50
94e365c6
UD
51/* Look up version VERSION of symbol NAME in shared object HANDLE
52 (which may be RTLD_DEFAULT or RTLD_NEXT). WHO is the calling
53 function, for RTLD_NEXT. Returns the symbol value, which may be
54 NULL. */
55extern void *_dl_vsym (void *handle, const char *name, const char *version,
56 void *who)
57 internal_function;
8e17ea58 58
94e365c6
UD
59/* Call OPERATE, catching errors from `dl_signal_error'. If there is no
60 error, *ERRSTRING is set to null. If there is an error, *ERRSTRING is
61 set to a string constructed from the strings passed to _dl_signal_error,
8e17ea58
UD
62 and the error code passed is the return value and *OBJNAME is set to
63 the object name which experienced the problems. ERRSTRING if nonzero
94e365c6 64 points to a malloc'ed string which the caller has to free after use.
a334319f 65 ARGS is passed as argument to OPERATE. */
8e17ea58 66extern int _dl_catch_error (const char **objname, const char **errstring,
a334319f 67 void (*operate) (void *),
94e365c6
UD
68 void *args)
69 internal_function;
70
71/* Helper function for <dlfcn.h> functions. Runs the OPERATE function via
72 _dl_catch_error. Returns zero for success, nonzero for failure; and
73 arranges for `dlerror' to return the error details.
74 ARGS is passed as argument to OPERATE. */
75extern int _dlerror_run (void (*operate) (void *), void *args)
76 internal_function;
77
5f21997b
UD
78#ifdef SHARED
79# define DL_CALLER_DECL /* Nothing */
80# define DL_CALLER RETURN_ADDRESS (0)
81#else
82# define DL_CALLER_DECL , void *dl_caller
83# define DL_CALLER dl_caller
84#endif
85
86struct dlfcn_hook
87{
88 void *(*dlopen) (const char *file, int mode, void *dl_caller);
89 int (*dlclose) (void *handle);
90 void *(*dlsym) (void *handle, const char *name, void *dl_caller);
91 void *(*dlvsym) (void *handle, const char *name, const char *version,
92 void *dl_caller);
93 char *(*dlerror) (void);
94 int (*dladdr) (const void *address, Dl_info *info);
95 int (*dladdr1) (const void *address, Dl_info *info,
96 void **extra_info, int flags);
97 int (*dlinfo) (void *handle, int request, void *arg, void *dl_caller);
98 void *(*dlmopen) (Lmid_t nsid, const char *file, int mode, void *dl_caller);
99 void *pad[4];
100};
101
102extern struct dlfcn_hook *_dlfcn_hook;
103libdl_hidden_proto (_dlfcn_hook)
104
105extern void *__dlopen (const char *file, int mode DL_CALLER_DECL)
106 attribute_hidden;
107extern void *__dlmopen (Lmid_t nsid, const char *file, int mode DL_CALLER_DECL)
108 attribute_hidden;
109extern int __dlclose (void *handle)
110 attribute_hidden;
111extern void *__dlsym (void *handle, const char *name DL_CALLER_DECL)
112 attribute_hidden;
113extern void *__dlvsym (void *handle, const char *name, const char *version
114 DL_CALLER_DECL)
115 attribute_hidden;
116extern char *__dlerror (void)
117 attribute_hidden;
118extern int __dladdr (const void *address, Dl_info *info)
119 attribute_hidden;
120extern int __dladdr1 (const void *address, Dl_info *info,
121 void **extra_info, int flags)
122 attribute_hidden;
123extern int __dlinfo (void *handle, int request, void *arg DL_CALLER_DECL)
124 attribute_hidden;
125
126#ifndef SHARED
127struct link_map;
128extern void * __libc_dlsym_private (struct link_map *map, const char *name)
129 attribute_hidden;
130extern void __libc_register_dl_open_hook (struct link_map *map)
131 attribute_hidden;
132extern void __libc_register_dlfcn_hook (struct link_map *map)
133 attribute_hidden;
134#endif
135
6796bc80 136#endif