1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20: #include <dlfcn.h>
21: #include <stddef.h>
22: #include <unistd.h>
23: #include <ldsodefs.h>
24:
25:
26:
27: #include <shlib-compat.h>
28: #if SHLIB_COMPAT (libdl, GLIBC_2_0, GLIBC_2_1)
29:
30: struct dlopen_args
31: {
32:
33: const char *file;
34: int mode;
35:
36: void *new;
37:
38: const void *caller;
39: };
40:
41:
42:
43: #ifdef SHARED
44: # define NS __LM_ID_CALLER
45: #else
46: # define NS LM_ID_BASE
47: #endif
48:
49:
50: static void
51: dlopen_doit (void *a)
52: {
53: struct dlopen_args *args = (struct dlopen_args *) a;
54:
55: args->new = GLRO(dl_open) (args->file ?: "", args->mode | __RTLD_DLOPEN,
56: args->caller,
57: args->file == NULL ? LM_ID_BASE : NS,
58: __dlfcn_argc, __dlfcn_argv, __environ);
59: }
60:
61: extern void *__dlopen_nocheck (const char *file, int mode);
62: void *
63: __dlopen_nocheck (const char *file, int mode)
64: {
65: struct dlopen_args args;
66: args.file = file;
67: args.caller = RETURN_ADDRESS (0);
68:
69: if ((mode & RTLD_BINDING_MASK) == 0)
70:
71: mode |= RTLD_LAZY;
72: args.mode = mode;
73:
74: if (__builtin_expect (_dlfcn_hook != NULL, 0))
75: return _dlfcn_hook->dlopen (file, mode, RETURN_ADDRESS (0));
76:
77: return _dlerror_run (dlopen_doit, &args) ? NULL : args.new;
78: }
79: compat_symbol (libdl, __dlopen_nocheck, dlopen, GLIBC_2_0);
80: #endif