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