Use RTLD_NOLOAD, if it's supported.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33131 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Chisnall 2011-05-26 18:29:43 +00:00
parent f6496702aa
commit 928551c80a

View file

@ -62,6 +62,18 @@ __objc_dynamic_init(const char* exec_path)
static dl_handle_t
__objc_dynamic_link(const char* module, int mode, const char* debug_file)
{
#ifdef RTLD_NOLOAD
/*
* If we've got RTLD_NOLOAD, then ask the dynamic linker first to check if
* the library is already loaded. If it is, then just return a handle to
* it. If not, then load it again.
*/
void *handle = dlopen(module, RTLD_LAZY | RTLD_GLOBAL | RTLD_NOLOAD);
if (NULL != handle)
{
return handle;
}
#endif
return (dl_handle_t)dlopen(module, RTLD_LAZY | RTLD_GLOBAL);
}