1 /* Load a shared object at run time.
2 Copyright (C) 1995-2015 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
25 #if !defined SHARED && IS_IN (libdl)
28 dlopen (const char *file
, int mode
)
30 return __dlopen (file
, mode
, RETURN_ADDRESS (0));
32 static_link_warning (dlopen
)
38 /* The arguments for dlopen_doit. */
41 /* The return value of dlopen_doit. */
43 /* Address of the caller. */
48 /* Non-shared code has no support for multiple namespaces. */
50 # define NS __LM_ID_CALLER
52 # define NS LM_ID_BASE
59 struct dlopen_args
*args
= (struct dlopen_args
*) a
;
61 if (args
->mode
& ~(RTLD_BINDING_MASK
| RTLD_NOLOAD
| RTLD_DEEPBIND
62 | RTLD_GLOBAL
| RTLD_LOCAL
| RTLD_NODELETE
64 GLRO(dl_signal_error
) (0, NULL
, NULL
, _("invalid mode parameter"));
66 args
->new = GLRO(dl_open
) (args
->file
?: "", args
->mode
| __RTLD_DLOPEN
,
68 args
->file
== NULL
? LM_ID_BASE
: NS
,
69 __dlfcn_argc
, __dlfcn_argv
, __environ
);
74 __dlopen (const char *file
, int mode DL_CALLER_DECL
)
77 if (__glibc_unlikely (_dlfcn_hook
!= NULL
))
78 return _dlfcn_hook
->dlopen (file
, mode
, DL_CALLER
);
81 struct dlopen_args args
;
84 args
.caller
= DL_CALLER
;
87 return _dlerror_run (dlopen_doit
, &args
) ? NULL
: args
.new;
89 if (_dlerror_run (dlopen_doit
, &args
))
92 __libc_register_dl_open_hook ((struct link_map
*) args
.new);
93 __libc_register_dlfcn_hook ((struct link_map
*) args
.new);
99 # include <shlib-compat.h>
100 strong_alias (__dlopen
, __dlopen_check
)
101 versioned_symbol (libdl
, __dlopen_check
, dlopen
, GLIBC_2_1
);