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