/* ltdl.c -- system independent dlopen wrapper
- Copyright (C) 1998, 1999, 2000, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
Originally by Thomas Tanner <tanner@ffii.org>
This file is part of GNU Libtool.
\f
/* --- WINDOWS SUPPORT --- */
-
-#ifdef DLL_EXPORT
-# define LT_GLOBAL_DATA __declspec(dllexport)
-#else
-# define LT_GLOBAL_DATA
+/* DLL building support on win32 hosts; mostly to workaround their
+ ridiculous implementation of data symbol exporting. */
+#ifndef LT_GLOBAL_DATA
+# if defined(__WINDOWS__) || defined(__CYGWIN__)
+# ifdef DLL_EXPORT /* defined by libtool (if required) */
+# define LT_GLOBAL_DATA __declspec(dllexport)
+# endif
+# endif
+# ifndef LT_GLOBAL_DATA /* static linking or !__WINDOWS__ */
+# define LT_GLOBAL_DATA
+# endif
#endif
/* fopen() mode flags for reading a text file */
#undef LT_READTEXT_MODE
-#ifdef __WINDOWS__
+#if defined(__WINDOWS__) || defined(__CYGWIN__)
# define LT_READTEXT_MODE "rt"
#else
# define LT_READTEXT_MODE "r"
lt_dlmutex_seterror *seterror;
lt_dlmutex_geterror *geterror;
{
- lt_dlmutex_unlock *old_unlock = unlock;
+ lt_dlmutex_unlock *old_unlock = lt_dlmutex_unlock_func;
int errors = 0;
/* Lock using the old lock() callback, if any. */
{
lt_dlmutex_lock_func = lock;
lt_dlmutex_unlock_func = unlock;
+ lt_dlmutex_seterror_func = seterror;
lt_dlmutex_geterror_func = geterror;
}
else
{
++errors;
}
+ /* Make sure that the handle pointed to by 'cur' still exists.
+ lt_dlclose recursively closes dependent libraries which removes
+ them from the linked list. One of these might be the one
+ pointed to by 'cur'. */
+ if (cur)
+ {
+ for (tmp = handles; tmp; tmp = tmp->next)
+ if (tmp == cur)
+ break;
+ if (! tmp)
+ cur = handles;
+ }
}
}
/* done if only resident modules are left */
handle->deplibs = (lt_dlhandle*) LT_EMALLOC (lt_dlhandle *, depcount);
if (!handle->deplibs)
- goto cleanup;
+ goto cleanup_names;
for (i = 0; i < depcount; ++i)
{
errors += lt_dlclose (handle->deplibs[i]);
}
}
+ LT_DLFREE (handle->deplibs);
}
return errors;
}
if (!file)
{
- file = fopen (filename, LT_READTEXT_MODE);
+ /* don't open .la files in current directory, root might get tricked to run a binary in a prepared directory */
+ if(!strncmp((filename + strlen(filename) - 3), LTDL_ARCHIVE_EXT,3) || strstr(filename,"/"))
+ file = fopen (filename, LT_READTEXT_MODE);
}
/* If we didn't find the file by now, it really isn't there. Set