summaryrefslogtreecommitdiff
path: root/bfd/plugin.c
diff options
context:
space:
mode:
authorKai Tietz <kai.tietz@onevision.com>2012-03-20 19:24:27 +0000
committerKai Tietz <kai.tietz@onevision.com>2012-03-20 19:24:27 +0000
commitdef6a63671f32867a35ba5c200cd7ba1b3227096 (patch)
treeae59ae7d3c8c41bb1d043c776880568c4a63920a /bfd/plugin.c
parent81eb727e537b076d28fadee710bed6bf49bdc2da (diff)
downloadbinutils-redhat-def6a63671f32867a35ba5c200cd7ba1b3227096.tar.gz
PR ld/12742
* configure.in (AC_CHECK_HEADERS): Test for windows.h and dlfcn.h. * plugin.c: Guard include of dlfcn.h if HAVE_DLFCN_H is defined. Add windows.h header include if HAVE_WINDOWS_H is defined. (dlerror): New static function if windows variant is used instead of dlfcn.h. (dlclose): Likewise. (dlopen): Likewise. (dlsym): Likewise. * configure: Regenerated. * config.in: Regenerated.
Diffstat (limited to 'bfd/plugin.c')
-rw-r--r--bfd/plugin.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 064e273128..0a29e378d5 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -25,7 +25,13 @@
#if BFD_SUPPORTS_PLUGINS
#include <assert.h>
+#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
+#elif defined (HAVE_WINDOWS_H)
+#include <windows.h>
+#else
+#error Unknown how to handle dynamic-load-libraries.
+#endif
#include <stdarg.h>
#include "plugin-api.h"
#include "sysdep.h"
@@ -34,6 +40,37 @@
#include "libiberty.h"
#include <dirent.h>
+#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 ATTRIBUTE_UNUSED
+dlclose (void *handle)
+{
+ FreeLibrary (handle);
+ return 0;
+}
+
+static const char *
+dlerror (void)
+{
+ return "Unable to load DLL.";
+}
+
+#endif /* !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) */
+
#define bfd_plugin_close_and_cleanup _bfd_generic_close_and_cleanup
#define bfd_plugin_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
#define bfd_plugin_new_section_hook _bfd_generic_new_section_hook