1*c81f5875SBen Grasdiff --git a/bfd/Makefile.am b/bfd/Makefile.am 2*c81f5875SBen Grasindex 49f9662..2ac03e9 100644 3*c81f5875SBen Gras--- a/bfd/Makefile.am 4*c81f5875SBen Gras+++ b/bfd/Makefile.am 5*c81f5875SBen Gras@@ -35,7 +35,7 @@ AM_CFLAGS = $(WARN_CFLAGS) 6*c81f5875SBen Gras AM_CPPFLAGS = -DBINDIR='"$(bindir)"' 7*c81f5875SBen Gras if PLUGINS 8*c81f5875SBen Gras bfdinclude_HEADERS += $(INCDIR)/plugin-api.h 9*c81f5875SBen Gras-LIBDL = -ldl 10*c81f5875SBen Gras+LIBDL = @lt_cv_dlopen_libs@ 11*c81f5875SBen Gras endif 12*c81f5875SBen Gras 13*c81f5875SBen Gras # bfd.h goes here, for now 14*c81f5875SBen Grasdiff --git a/bfd/Makefile.in b/bfd/Makefile.in 15*c81f5875SBen Grasindex 5718fab..7b0f863 100644 16*c81f5875SBen Gras--- a/bfd/Makefile.in 17*c81f5875SBen Gras+++ b/bfd/Makefile.in 18*c81f5875SBen Gras@@ -293,6 +293,7 @@ libdir = @libdir@ 19*c81f5875SBen Gras libexecdir = @libexecdir@ 20*c81f5875SBen Gras localedir = @localedir@ 21*c81f5875SBen Gras localstatedir = @localstatedir@ 22*c81f5875SBen Gras+lt_cv_dlopen_libs = @lt_cv_dlopen_libs@ 23*c81f5875SBen Gras mandir = @mandir@ 24*c81f5875SBen Gras mkdir_p = @mkdir_p@ 25*c81f5875SBen Gras oldincludedir = @oldincludedir@ 26*c81f5875SBen Gras@@ -336,7 +337,7 @@ libbfd_la_LDFLAGS = $(am__append_1) -release `cat libtool-soversion` \ 27*c81f5875SBen Gras @INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la 28*c81f5875SBen Gras AM_CFLAGS = $(WARN_CFLAGS) 29*c81f5875SBen Gras AM_CPPFLAGS = -DBINDIR='"$(bindir)"' 30*c81f5875SBen Gras-@PLUGINS_TRUE@LIBDL = -ldl 31*c81f5875SBen Gras+@PLUGINS_TRUE@LIBDL = @lt_cv_dlopen_libs@ 32*c81f5875SBen Gras 33*c81f5875SBen Gras # bfd.h goes here, for now 34*c81f5875SBen Gras BFD_H = bfd.h 35*c81f5875SBen Grasdiff --git a/bfd/configure b/bfd/configure 36*c81f5875SBen Grasindex d81719d..fdf5356 100755 37*c81f5875SBen Gras--- a/bfd/configure 38*c81f5875SBen Gras+++ b/bfd/configure 39*c81f5875SBen Gras@@ -606,6 +606,7 @@ havevecs 40*c81f5875SBen Gras tdefaults 41*c81f5875SBen Gras bfd_ufile_ptr 42*c81f5875SBen Gras bfd_file_ptr 43*c81f5875SBen Gras+lt_cv_dlopen_libs 44*c81f5875SBen Gras supports_plugins 45*c81f5875SBen Gras bfd_default_target_size 46*c81f5875SBen Gras bfd_machines 47*c81f5875SBen Grasdiff --git a/bfd/configure.in b/bfd/configure.in 48*c81f5875SBen Grasindex 612d032..530bbcb 100644 49*c81f5875SBen Gras--- a/bfd/configure.in 50*c81f5875SBen Gras+++ b/bfd/configure.in 51*c81f5875SBen Gras@@ -1100,6 +1100,7 @@ else 52*c81f5875SBen Gras supports_plugins=0 53*c81f5875SBen Gras fi 54*c81f5875SBen Gras AC_SUBST(supports_plugins) 55*c81f5875SBen Gras+AC_SUBST(lt_cv_dlopen_libs) 56*c81f5875SBen Gras 57*c81f5875SBen Gras # Determine the host dependant file_ptr a.k.a. off_t type. In order 58*c81f5875SBen Gras # prefer: off64_t - if ftello64 and fseeko64, off_t - if ftello and 59*c81f5875SBen Grasdiff --git a/gold/Makefile.am b/gold/Makefile.am 60*c81f5875SBen Grasindex df8dcb5..f6ced44 100644 61*c81f5875SBen Gras--- a/gold/Makefile.am 62*c81f5875SBen Gras+++ b/gold/Makefile.am 63*c81f5875SBen Gras@@ -37,7 +38,7 @@ AM_CPPFLAGS = \ 64*c81f5875SBen Gras LIBIBERTY = ../libiberty/libiberty.a 65*c81f5875SBen Gras 66*c81f5875SBen Gras if PLUGINS 67*c81f5875SBen Gras-LIBDL = -ldl 68*c81f5875SBen Gras+LIBDL = @DLOPEN_LIBS@ 69*c81f5875SBen Gras endif 70*c81f5875SBen Gras 71*c81f5875SBen Gras if THREADS 72*c81f5875SBen Grasdiff --git a/gold/Makefile.in b/gold/Makefile.in 73*c81f5875SBen Grasindex 216532a..f12832b 100644 74*c81f5875SBen Gras--- a/gold/Makefile.in 75*c81f5875SBen Gras+++ b/gold/Makefile.in 76*c81f5875SBen Gras@@ -272,6 +273,7 @@ CYGPATH_W = @CYGPATH_W@ 77*c81f5875SBen Gras DATADIRNAME = @DATADIRNAME@ 78*c81f5875SBen Gras DEFS = @DEFS@ 79*c81f5875SBen Gras DEPDIR = @DEPDIR@ 80*c81f5875SBen Gras+DLOPEN_LIBS = @DLOPEN_LIBS@ 81*c81f5875SBen Gras ECHO_C = @ECHO_C@ 82*c81f5875SBen Gras ECHO_N = @ECHO_N@ 83*c81f5875SBen Gras ECHO_T = @ECHO_T@ 84*c81f5875SBen Gras@@ -398,7 +400,7 @@ AM_CPPFLAGS = \ 85*c81f5875SBen Gras -DTOOLLIBDIR="\"$(tooldir)/lib\"" @INCINTL@ 86*c81f5875SBen Gras 87*c81f5875SBen Gras LIBIBERTY = ../libiberty/libiberty.a 88*c81f5875SBen Gras-@PLUGINS_TRUE@LIBDL = -ldl 89*c81f5875SBen Gras+@PLUGINS_TRUE@LIBDL = @DLOPEN_LIBS@ 90*c81f5875SBen Gras @THREADS_TRUE@THREADSLIB = -lpthread 91*c81f5875SBen Gras AM_YFLAGS = -d 92*c81f5875SBen Gras 93*c81f5875SBen Grasdiff --git a/gold/config.in b/gold/config.in 94*c81f5875SBen Grasindex 42252bf..d46fd75 100644 95*c81f5875SBen Gras--- a/gold/config.in 96*c81f5875SBen Gras+++ b/gold/config.in 97*c81f5875SBen Gras@@ -73,6 +73,9 @@ 98*c81f5875SBen Gras don't. */ 99*c81f5875SBen Gras #undef HAVE_DECL_VSNPRINTF 100*c81f5875SBen Gras 101*c81f5875SBen Gras+/* Define to 1 if you have the <dlfcn.h> header file. */ 102*c81f5875SBen Gras+#undef HAVE_DLFCN_H 103*c81f5875SBen Gras+ 104*c81f5875SBen Gras /* Define to 1 if you have the <ext/hash_map> header file. */ 105*c81f5875SBen Gras #undef HAVE_EXT_HASH_MAP 106*c81f5875SBen Gras 107*c81f5875SBen Gras@@ -184,6 +187,9 @@ 108*c81f5875SBen Gras /* Define to 1 if you have the <unistd.h> header file. */ 109*c81f5875SBen Gras #undef HAVE_UNISTD_H 110*c81f5875SBen Gras 111*c81f5875SBen Gras+/* Define to 1 if you have the <windows.h> header file. */ 112*c81f5875SBen Gras+#undef HAVE_WINDOWS_H 113*c81f5875SBen Gras+ 114*c81f5875SBen Gras /* Define to 1 if you have the <zlib.h> header file. */ 115*c81f5875SBen Gras #undef HAVE_ZLIB_H 116*c81f5875SBen Gras 117*c81f5875SBen Grasdiff --git a/gold/configure b/gold/configure 118*c81f5875SBen Grasindex 9e1ee27..7e58cdf 100755 119*c81f5875SBen Gras--- a/gold/configure 120*c81f5875SBen Gras+++ b/gold/configure 121*c81f5875SBen Gras@@ -596,6 +596,7 @@ MAINTAINER_MODE_FALSE 122*c81f5875SBen Gras MAINTAINER_MODE_TRUE 123*c81f5875SBen Gras HAVE_PUBNAMES_FALSE 124*c81f5875SBen Gras HAVE_PUBNAMES_TRUE 125*c81f5875SBen Gras+DLOPEN_LIBS 126*c81f5875SBen Gras CXXCPP 127*c81f5875SBen Gras HAVE_ZLIB_FALSE 128*c81f5875SBen Gras HAVE_ZLIB_TRUE 129*c81f5875SBen Gras@@ -7139,6 +7140,35 @@ fi 130*c81f5875SBen Gras 131*c81f5875SBen Gras done 132*c81f5875SBen Gras 133*c81f5875SBen Gras+ 134*c81f5875SBen Gras+for ac_header in windows.h 135*c81f5875SBen Gras+do : 136*c81f5875SBen Gras+ ac_fn_cxx_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default" 137*c81f5875SBen Gras+if test "x$ac_cv_header_windows_h" = x""yes; then : 138*c81f5875SBen Gras+ cat >>confdefs.h <<_ACEOF 139*c81f5875SBen Gras+#define HAVE_WINDOWS_H 1 140*c81f5875SBen Gras+_ACEOF 141*c81f5875SBen Gras+ 142*c81f5875SBen Gras+fi 143*c81f5875SBen Gras+ 144*c81f5875SBen Gras+done 145*c81f5875SBen Gras+ 146*c81f5875SBen Gras+for ac_header in dlfcn.h 147*c81f5875SBen Gras+do : 148*c81f5875SBen Gras+ ac_fn_cxx_check_header_mongrel "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default" 149*c81f5875SBen Gras+if test "x$ac_cv_header_dlfcn_h" = x""yes; then : 150*c81f5875SBen Gras+ cat >>confdefs.h <<_ACEOF 151*c81f5875SBen Gras+#define HAVE_DLFCN_H 1 152*c81f5875SBen Gras+_ACEOF 153*c81f5875SBen Gras+ DLOPEN_LIBS="-ldl" 154*c81f5875SBen Gras+else 155*c81f5875SBen Gras+ DLOPEN_LIBS="" 156*c81f5875SBen Gras+fi 157*c81f5875SBen Gras+ 158*c81f5875SBen Gras+done 159*c81f5875SBen Gras+ 160*c81f5875SBen Gras+ 161*c81f5875SBen Gras+ 162*c81f5875SBen Gras for ac_func in mallinfo posix_fallocate fallocate readv sysconf times 163*c81f5875SBen Gras do : 164*c81f5875SBen Gras as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` 165*c81f5875SBen Grasdiff --git a/gold/configure.ac b/gold/configure.ac 166*c81f5875SBen Grasindex 804a474..b03c09d 100644 167*c81f5875SBen Gras--- a/gold/configure.ac 168*c81f5875SBen Gras+++ b/gold/configure.ac 169*c81f5875SBen Gras@@ -505,6 +506,13 @@ AC_LANG_PUSH(C++) 170*c81f5875SBen Gras AC_CHECK_HEADERS(tr1/unordered_set tr1/unordered_map) 171*c81f5875SBen Gras AC_CHECK_HEADERS(ext/hash_map ext/hash_set) 172*c81f5875SBen Gras AC_CHECK_HEADERS(byteswap.h) 173*c81f5875SBen Gras+ 174*c81f5875SBen Gras+dnl When plugins enabled dynamic loader interface is required. Check headers 175*c81f5875SBen Gras+dnl which may provide this interface. In case of dlfcn.h add libdl to link. 176*c81f5875SBen Gras+AC_CHECK_HEADERS(windows.h) 177*c81f5875SBen Gras+AC_CHECK_HEADERS(dlfcn.h, [DLOPEN_LIBS="-ldl"], [DLOPEN_LIBS=""]) 178*c81f5875SBen Gras+AC_SUBST(DLOPEN_LIBS) 179*c81f5875SBen Gras+ 180*c81f5875SBen Gras AC_CHECK_FUNCS(mallinfo posix_fallocate fallocate readv sysconf times) 181*c81f5875SBen Gras AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp, strndup, memmem]) 182*c81f5875SBen Gras 183*c81f5875SBen Grasdiff --git a/gold/plugin.cc b/gold/plugin.cc 184*c81f5875SBen Grasindex c39e11ec..9176e06 100644 185*c81f5875SBen Gras--- a/gold/plugin.cc 186*c81f5875SBen Gras+++ b/gold/plugin.cc 187*c81f5875SBen Gras@@ -29,9 +29,39 @@ 188*c81f5875SBen Gras #include <vector> 189*c81f5875SBen Gras 190*c81f5875SBen Gras #ifdef ENABLE_PLUGINS 191*c81f5875SBen Gras+#ifdef HAVE_DLFCN_H 192*c81f5875SBen Gras #include <dlfcn.h> 193*c81f5875SBen Gras+#elif defined (HAVE_WINDOWS_H) 194*c81f5875SBen Gras+#include <windows.h> 195*c81f5875SBen Gras+#else 196*c81f5875SBen Gras+#error Unknown how to handle dynamic-load-libraries. 197*c81f5875SBen Gras #endif 198*c81f5875SBen Gras 199*c81f5875SBen Gras+#if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) 200*c81f5875SBen Gras+ 201*c81f5875SBen Gras+#define RTLD_NOW 0 /* Dummy value. */ 202*c81f5875SBen Gras+static void * 203*c81f5875SBen Gras+dlopen(const char *file, int mode ATTRIBUTE_UNUSED) 204*c81f5875SBen Gras+{ 205*c81f5875SBen Gras+ return LoadLibrary(file); 206*c81f5875SBen Gras+} 207*c81f5875SBen Gras+ 208*c81f5875SBen Gras+static void * 209*c81f5875SBen Gras+dlsym(void *handle, const char *name) 210*c81f5875SBen Gras+{ 211*c81f5875SBen Gras+ return reinterpret_cast<void *>( 212*c81f5875SBen Gras+ GetProcAddress(static_cast<HMODULE>(handle),name)); 213*c81f5875SBen Gras+} 214*c81f5875SBen Gras+ 215*c81f5875SBen Gras+static const char * 216*c81f5875SBen Gras+dlerror(void) 217*c81f5875SBen Gras+{ 218*c81f5875SBen Gras+ return "unable to load dll"; 219*c81f5875SBen Gras+} 220*c81f5875SBen Gras+ 221*c81f5875SBen Gras+#endif /* !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) */ 222*c81f5875SBen Gras+#endif /* ENABLE_PLUGINS */ 223*c81f5875SBen Gras+ 224*c81f5875SBen Gras #include "parameters.h" 225*c81f5875SBen Gras #include "errors.h" 226*c81f5875SBen Gras #include "fileread.h" 227*c81f5875SBen Grasdiff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in 228*c81f5875SBen Grasindex 6e22934..b2eb352 100644 229*c81f5875SBen Gras--- a/gold/testsuite/Makefile.in 230*c81f5875SBen Gras+++ b/gold/testsuite/Makefile.in 231*c81f5875SBen Gras@@ -1878,6 +1878,7 @@ CYGPATH_W = @CYGPATH_W@ 232*c81f5875SBen Gras DATADIRNAME = @DATADIRNAME@ 233*c81f5875SBen Gras DEFS = @DEFS@ 234*c81f5875SBen Gras DEPDIR = @DEPDIR@ 235*c81f5875SBen Gras+DLOPEN_LIBS = @DLOPEN_LIBS@ 236*c81f5875SBen Gras ECHO_C = @ECHO_C@ 237*c81f5875SBen Gras ECHO_N = @ECHO_N@ 238*c81f5875SBen Gras ECHO_T = @ECHO_T@ 239