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) \
16 __libc_dlopen_mode (name, RTLD_LAZY | __RTLD_DLOPEN)
17 extern void *__libc_dlopen_mode (__const
char *__name
, int __mode
);
18 extern void *__libc_dlsym (void *__map
, __const
char *__name
);
19 extern int __libc_dlclose (void *__map
);
20 libc_hidden_proto (__libc_dlopen_mode
)
21 libc_hidden_proto (__libc_dlsym
)
22 libc_hidden_proto (__libc_dlclose
)
24 /* Locate shared object containing the given address. */
26 extern int _dl_addr (const void *address
, Dl_info
*info
,
27 struct link_map
**mapp
, const ElfW(Sym
) **symbolp
)
29 libc_hidden_proto (_dl_addr
)
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. */
35 extern void *_dl_open (const char *name
, int mode
, const void *caller
,
38 libc_hidden_proto (_dl_open
)
40 /* Close an object previously opened by _dl_open. */
41 extern void _dl_close (void *map
)
43 libc_hidden_proto (_dl_close
)
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. */
48 extern void *_dl_sym (void *handle
, const char *name
, void *who
)
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
55 extern void *_dl_vsym (void *handle
, const char *name
, const char *version
,
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,
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
64 points to a malloc'ed string which the caller has to free after use.
65 ARGS is passed as argument to OPERATE. */
66 extern int _dl_catch_error (const char **objname
, const char **errstring
,
67 void (*operate
) (void *),
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. */
75 extern int _dlerror_run (void (*operate
) (void *), void *args
)
79 # define DL_CALLER_DECL /* Nothing */
80 # define DL_CALLER RETURN_ADDRESS (0)
82 # define DL_CALLER_DECL , void *dl_caller
83 # define DL_CALLER dl_caller
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
,
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
);
102 extern struct dlfcn_hook
*_dlfcn_hook
;
103 libdl_hidden_proto (_dlfcn_hook
)
105 extern void *__dlopen (const char *file
, int mode DL_CALLER_DECL
)
107 extern void *__dlmopen (Lmid_t nsid
, const char *file
, int mode DL_CALLER_DECL
)
109 extern int __dlclose (void *handle
)
111 extern void *__dlsym (void *handle
, const char *name DL_CALLER_DECL
)
113 extern void *__dlvsym (void *handle
, const char *name
, const char *version
116 extern char *__dlerror (void)
118 extern int __dladdr (const void *address
, Dl_info
*info
)
120 extern int __dladdr1 (const void *address
, Dl_info
*info
,
121 void **extra_info
, int flags
)
123 extern int __dlinfo (void *handle
, int request
, void *arg DL_CALLER_DECL
)
128 extern void * __libc_dlsym_private (struct link_map
*map
, const char *name
)
130 extern void __libc_register_dl_open_hook (struct link_map
*map
)
132 extern void __libc_register_dlfcn_hook (struct link_map
*map
)