Provide win32-based dlapi replacements on windows platforms without dlfcn.h.
authorDave Korn <dave.korn@artimi.com>
Fri, 15 Oct 2010 16:21:41 +0000 (16:21 +0000)
committerDave Korn <dave.korn@artimi.com>
Fri, 15 Oct 2010 16:21:41 +0000 (16:21 +0000)
ld/ChangeLog:

* configure.in: If <dlfcn.h> can't be found, try for <Windows.h>
* configure: Regenerate.
* config.in: Likewise.
* plugin.c [!HAVE_DLFCN_H && HAVE_WINDOWS_H] (dlopen): Provide
trival LoadLibrary-based replacement for Windows systems.
[!HAVE_DLFCN_H && HAVE_WINDOWS_H] (dlsym): Likewise trivial
replacement based on GetProcAddress.
[!HAVE_DLFCN_H && HAVE_WINDOWS_H] (dlsym): Likewise FreeLibrary.
* sysdep.h: Don't infer presence of <dlfcn.h> from ENABLE_PLUGINS
anymore, use its own guard.

ld/ChangeLog
ld/config.in
ld/configure
ld/configure.in
ld/plugin.c
ld/sysdep.h

index 85c784af459087ebb2bbeedb2ce69fd10bc25b59..e0a3e6106a3e28a0a5598d59990102fb6236ce91 100644 (file)
@@ -1,3 +1,16 @@
+2010-10-15  Dave Korn  <dave.korn.cygwin@gmail.com>
+
+       * configure.in: If <dlfcn.h> can't be found, try for <Windows.h>
+       * configure: Regenerate.
+       * config.in: Likewise.
+       * plugin.c [!HAVE_DLFCN_H && HAVE_WINDOWS_H] (dlopen): Provide
+       trival LoadLibrary-based replacement for Windows systems.
+       [!HAVE_DLFCN_H && HAVE_WINDOWS_H] (dlsym): Likewise trivial
+       replacement based on GetProcAddress.
+       [!HAVE_DLFCN_H && HAVE_WINDOWS_H] (dlsym): Likewise FreeLibrary.
+       * sysdep.h: Don't infer presence of <dlfcn.h> from ENABLE_PLUGINS
+       anymore, use its own guard.
+
 2010-10-15  Dave Korn  <dave.korn.cygwin@gmail.com>
 
        * plugin.c (add_input_file): Take copy of input string.
index 9e6e97bb8181a9c04484313e3e0aab81ced12115..f49327c11a7c23455d7ca14af0d57cc37dbe1b7a 100644 (file)
 /* Define to 1 if you have the `waitpid' function. */
 #undef HAVE_WAITPID
 
+/* Define to 1 if you have the <Windows.h> header file. */
+#undef HAVE_WINDOWS_H
+
 /* Define to 1 if you have the <zlib.h> header file. */
 #undef HAVE_ZLIB_H
 
index 9ff8529c98a0e913b36afb7331b0d08aab9ea78c..3367a88a3289ba370dbe891baff58e8f73923792 100755 (executable)
@@ -12919,6 +12919,22 @@ else
 fi
 done
 
+# We also support plugins on Windows (MinGW).
+if test x$enable_plugins = xno ; then
+  for ac_header in Windows.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "Windows.h" "ac_cv_header_Windows_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_Windows_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_WINDOWS_H 1
+_ACEOF
+ enable_plugins=yes
+fi
+
+done
+
+fi
  if test x$enable_plugins = xyes; then
   ENABLE_PLUGINS_TRUE=
   ENABLE_PLUGINS_FALSE='#'
index 29d01ccaa39e27e33f2088eaed4cc69e2d1df448..122f65e13bafec5daad3a67a11657cc91f4dfe9c 100644 (file)
@@ -169,6 +169,10 @@ enable_plugins=yes
 AC_CHECK_HEADER([dlfcn.h],[],[enable_plugins=no],[AC_INCLUDES_DEFAULT])
 AC_SEARCH_LIBS([dlopen],[dl],[],[enable_plugins=no],[])
 AC_CHECK_FUNCS([dlopen dlsym dlclose],[],[enable_plugins=no])
+# We also support plugins on Windows (MinGW).
+if test x$enable_plugins = xno ; then
+  AC_CHECK_HEADERS([Windows.h],[enable_plugins=yes],[],[AC_INCLUDES_DEFAULT])
+fi
 AM_CONDITIONAL([ENABLE_PLUGINS], [test x$enable_plugins = xyes])
 
 AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
index 0c88ef8beafedb9576cf868180cb8fa70a6101b3..c1961c54f4fb9a8ddd8e1bf755a34cfab2e65226 100644 (file)
@@ -32,6 +32,9 @@
 #include "plugin.h"
 #include "plugin-api.h"
 #include "elf-bfd.h"
+#if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)
+#include <Windows.h>
+#endif
 
 /* The suffix to append to the name of the real (claimed) object file
    when generating a dummy BFD to hold the IR symbols sent from the
@@ -128,6 +131,31 @@ static const enum ld_plugin_tag tv_header_tags[] =
 /* How many entries in the constant leading part of the tv array.  */
 static const size_t tv_header_size = ARRAY_SIZE (tv_header_tags);
 
+#if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)
+
+#define RTLD_NOW 0     /* Dummy value.  */
+
+static void *
+dlopen (const char *file, int mode ATTRIBUTE_UNUSED)
+{
+  return LoadLibrary (file);
+}
+
+static void *
+dlsym (void *handle, const char *name)
+{
+  return GetProcAddress (handle, name);
+}
+
+static int
+dlclose (void *handle)
+{
+  FreeLibrary (handle);
+  return 0;
+}
+
+#endif /* !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)  */
+
 /* Helper function for exiting with error status.  */
 static int
 set_plugin_error (const char *plugin)
index 9dfae105d55c399e7455e7802c08f42b9b62c722..b7d5b88a857bf3053127053c5a3dc0898fcf452d 100644 (file)
@@ -90,8 +90,7 @@ extern char *strrchr ();
 #endif
 #endif
 
-/* This is both more precise than and includes HAVE_DLFCN_H.  */
-#ifdef ENABLE_PLUGINS
+#ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
 #endif
 
This page took 0.034827 seconds and 4 git commands to generate.