* sysdeps/i386/dl-trampoline.S (_dl_runtime_profile): Use register
[glibc.git] / include / dlfcn.h
blob79c8f7d31bbd24801aab735c5e35e71e4068d2ba
1 #ifndef _DLFCN_H
2 #include <dlfcn/dlfcn.h>
3 #include <link.h> /* For ElfW. */
4 #include <stdbool.h>
6 /* Internally used flag. */
7 #define __RTLD_DLOPEN 0x80000000
8 #define __RTLD_SPROF 0x40000000
9 #define __RTLD_OPENEXEC 0x20000000
10 #define __RTLD_CALLMAP 0x10000000
11 #define __RTLD_AUDIT 0x08000000
13 #define __LM_ID_CALLER -2
15 #ifdef SHARED
16 /* Locally stored program arguments. */
17 extern int __dlfcn_argc attribute_hidden;
18 extern char **__dlfcn_argv attribute_hidden;
19 #else
20 /* These variables are defined and initialized in the startup code. */
21 extern int __libc_argc attribute_hidden;
22 extern char **__libc_argv attribute_hidden;
24 # define __dlfcn_argc __libc_argc
25 # define __dlfcn_argv __libc_argv
26 #endif
29 /* Now define the internal interfaces. */
31 #define __libc_dlopen(name) \
32 __libc_dlopen_mode (name, RTLD_LAZY | __RTLD_DLOPEN)
33 extern void *__libc_dlopen_mode (__const char *__name, int __mode);
34 extern void *__libc_dlsym (void *__map, __const char *__name);
35 extern int __libc_dlclose (void *__map);
36 libc_hidden_proto (__libc_dlopen_mode)
37 libc_hidden_proto (__libc_dlsym)
38 libc_hidden_proto (__libc_dlclose)
40 /* Locate shared object containing the given address. */
41 #ifdef ElfW
42 extern int _dl_addr (const void *address, Dl_info *info,
43 struct link_map **mapp, const ElfW(Sym) **symbolp)
44 internal_function;
45 libc_hidden_proto (_dl_addr)
46 #endif
48 /* Close an object previously opened by _dl_open. */
49 extern void _dl_close (void *map) attribute_hidden;
50 /* Same as above, but without locking and safety checks for user
51 provided map arguments. */
52 extern void _dl_close_worker (struct link_map *map) attribute_hidden;
54 /* Look up NAME in shared object HANDLE (which may be RTLD_DEFAULT or
55 RTLD_NEXT). WHO is the calling function, for RTLD_NEXT. Returns
56 the symbol value, which may be NULL. */
57 extern void *_dl_sym (void *handle, const char *name, void *who)
58 internal_function;
60 /* Look up version VERSION of symbol NAME in shared object HANDLE
61 (which may be RTLD_DEFAULT or RTLD_NEXT). WHO is the calling
62 function, for RTLD_NEXT. Returns the symbol value, which may be
63 NULL. */
64 extern void *_dl_vsym (void *handle, const char *name, const char *version,
65 void *who)
66 internal_function;
68 /* Call OPERATE, catching errors from `dl_signal_error'. If there is no
69 error, *ERRSTRING is set to null. If there is an error, *ERRSTRING is
70 set to a string constructed from the strings passed to _dl_signal_error,
71 and the error code passed is the return value and *OBJNAME is set to
72 the object name which experienced the problems. ERRSTRING if nonzero
73 points to a malloc'ed string which the caller has to free after use.
74 ARGS is passed as argument to OPERATE. MALLOCEDP is set to true only
75 if the returned string is allocated using the libc's malloc. */
76 extern int _dl_catch_error (const char **objname, const char **errstring,
77 bool *mallocedp, void (*operate) (void *),
78 void *args)
79 internal_function;
81 /* Helper function for <dlfcn.h> functions. Runs the OPERATE function via
82 _dl_catch_error. Returns zero for success, nonzero for failure; and
83 arranges for `dlerror' to return the error details.
84 ARGS is passed as argument to OPERATE. */
85 extern int _dlerror_run (void (*operate) (void *), void *args)
86 internal_function;
88 #ifdef SHARED
89 # define DL_CALLER_DECL /* Nothing */
90 # define DL_CALLER RETURN_ADDRESS (0)
91 #else
92 # define DL_CALLER_DECL , void *dl_caller
93 # define DL_CALLER dl_caller
94 #endif
96 struct dlfcn_hook
98 void *(*dlopen) (const char *file, int mode, void *dl_caller);
99 int (*dlclose) (void *handle);
100 void *(*dlsym) (void *handle, const char *name, void *dl_caller);
101 void *(*dlvsym) (void *handle, const char *name, const char *version,
102 void *dl_caller);
103 char *(*dlerror) (void);
104 int (*dladdr) (const void *address, Dl_info *info);
105 int (*dladdr1) (const void *address, Dl_info *info,
106 void **extra_info, int flags);
107 int (*dlinfo) (void *handle, int request, void *arg, void *dl_caller);
108 void *(*dlmopen) (Lmid_t nsid, const char *file, int mode, void *dl_caller);
109 void *pad[4];
112 extern struct dlfcn_hook *_dlfcn_hook;
113 libdl_hidden_proto (_dlfcn_hook)
115 extern void *__dlopen (const char *file, int mode DL_CALLER_DECL)
116 attribute_hidden;
117 extern void *__dlmopen (Lmid_t nsid, const char *file, int mode DL_CALLER_DECL)
118 attribute_hidden;
119 extern int __dlclose (void *handle)
120 attribute_hidden;
121 extern void *__dlsym (void *handle, const char *name DL_CALLER_DECL)
122 attribute_hidden;
123 extern void *__dlvsym (void *handle, const char *name, const char *version
124 DL_CALLER_DECL)
125 attribute_hidden;
126 extern char *__dlerror (void)
127 attribute_hidden;
128 extern int __dladdr (const void *address, Dl_info *info)
129 attribute_hidden;
130 extern int __dladdr1 (const void *address, Dl_info *info,
131 void **extra_info, int flags)
132 attribute_hidden;
133 extern int __dlinfo (void *handle, int request, void *arg DL_CALLER_DECL)
134 attribute_hidden;
136 #ifndef SHARED
137 struct link_map;
138 extern void * __libc_dlsym_private (struct link_map *map, const char *name)
139 attribute_hidden;
140 extern void __libc_register_dl_open_hook (struct link_map *map)
141 attribute_hidden;
142 extern void __libc_register_dlfcn_hook (struct link_map *map)
143 attribute_hidden;
144 #endif
146 #endif