summaryrefslogtreecommitdiff
path: root/ld/plugin.c
diff options
context:
space:
mode:
authorDave Korn <dave.korn@artimi.com>2010-10-15 16:21:40 +0000
committerDave Korn <dave.korn@artimi.com>2010-10-15 16:21:40 +0000
commitaebd3a7c76a81e3c88d497f94bf0616545abdf5f (patch)
tree487d999456d8f309a0f553e358185df212bf27b4 /ld/plugin.c
parentdc814f0f09ac2da6273b77183fbc66ceb3c9218f (diff)
downloadbinutils-redhat-aebd3a7c76a81e3c88d497f94bf0616545abdf5f.tar.gz
Provide win32-based dlapi replacements on windows platforms without dlfcn.h.
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.
Diffstat (limited to 'ld/plugin.c')
-rw-r--r--ld/plugin.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/ld/plugin.c b/ld/plugin.c
index 0c88ef8bea..c1961c54f4 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -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)