From 17d5dae239c8e8cca84afffd3672981379536491 Mon Sep 17 00:00:00 2001 From: Kai Tietz Date: Tue, 20 Mar 2012 19:24:32 +0000 Subject: [PATCH] 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. --- bfd/ChangeLog | 14 ++++++++++++++ bfd/config.in | 3 +++ bfd/configure | 16 ++++++++++++++++ bfd/configure.in | 3 +++ bfd/plugin.c | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 735a0ba51d5..762633dfa65 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,17 @@ +2012-03-20 Kai Tietz + + 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. + 2012-03-20 H.J. Lu PR ld/13880 diff --git a/bfd/config.in b/bfd/config.in index 98157e13e0b..cb53b147413 100644 --- a/bfd/config.in +++ b/bfd/config.in @@ -245,6 +245,9 @@ /* Define if has win32_pstatus_t. */ #undef HAVE_WIN32_PSTATUS_T +/* Define to 1 if you have the header file. */ +#undef HAVE_WINDOWS_H + /* Define to 1 if you have the header file. */ #undef HAVE_ZLIB_H diff --git a/bfd/configure b/bfd/configure index cff9b265f1d..58a57baa59d 100755 --- a/bfd/configure +++ b/bfd/configure @@ -13508,6 +13508,22 @@ fi fi + +for ac_header in windows.h dlfcn.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether string.h and strings.h may both be included" >&5 $as_echo_n "checking whether string.h and strings.h may both be included... " >&6; } if test "${gcc_cv_header_string+set}" = set; then : diff --git a/bfd/configure.in b/bfd/configure.in index c40c825438b..f4439157603 100644 --- a/bfd/configure.in +++ b/bfd/configure.in @@ -190,6 +190,9 @@ AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h sys/stat.h) GCC_HEADER_STDINT(bfd_stdint.h) AC_HEADER_TIME AC_HEADER_DIRENT + +AC_CHECK_HEADERS(windows.h dlfcn.h) + ACX_HEADER_STRING AC_CHECK_FUNCS(fcntl getpagesize setitimer sysconf fdopen getuid getgid fileno) AC_CHECK_FUNCS(strtoull) diff --git a/bfd/plugin.c b/bfd/plugin.c index 064e2731282..0a29e378d50 100644 --- a/bfd/plugin.c +++ b/bfd/plugin.c @@ -25,7 +25,13 @@ #if BFD_SUPPORTS_PLUGINS #include +#ifdef HAVE_DLFCN_H #include +#elif defined (HAVE_WINDOWS_H) +#include +#else +#error Unknown how to handle dynamic-load-libraries. +#endif #include #include "plugin-api.h" #include "sysdep.h" @@ -34,6 +40,37 @@ #include "libiberty.h" #include +#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 -- 2.30.2