aboutsummaryrefslogtreecommitdiff
path: root/bfd/plugin.c
diff options
context:
space:
mode:
authorKai Tietz <kai.tietz@onevision.com>2012-03-20 19:24:32 +0000
committerKai Tietz <kai.tietz@onevision.com>2012-03-20 19:24:32 +0000
commit17d5dae239c8e8cca84afffd3672981379536491 (patch)
tree85066d21a90e83a70d4903caa8424f01984001f9 /bfd/plugin.c
parentbdb892b99584bfd481ed23c90ad7ceafb31ca791 (diff)
downloadfsf-binutils-gdb-17d5dae239c8e8cca84afffd3672981379536491.zip
fsf-binutils-gdb-17d5dae239c8e8cca84afffd3672981379536491.tar.gz
fsf-binutils-gdb-17d5dae239c8e8cca84afffd3672981379536491.tar.bz2
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 064e273..0a29e37 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