diff options
author | Ray Donnelly <mingw.android@gmail.com> | 2013-02-03 21:55:43 +0000 |
---|---|---|
committer | Ray Donnelly <mingw.android@gmail.com> | 2013-02-03 22:20:47 +0000 |
commit | a1562c183b55e6766b4a3ba5148f742b7be0f276 (patch) | |
tree | 028349a19b05dcbdf6208f1d96bcaeb6808fd9aa | |
parent | dbb331ef919ae846a3983b7be1e5ffbb1ee1a839 (diff) | |
download | toolchain_binutils-a1562c183b55e6766b4a3ba5148f742b7be0f276.zip toolchain_binutils-a1562c183b55e6766b4a3ba5148f742b7be0f276.tar.gz toolchain_binutils-a1562c183b55e6766b4a3ba5148f742b7be0f276.tar.bz2 |
Backport Pavel Chupin's fixes for mingw gold plugins
Changelog modified to reflect minor changes, for
original patch and changelog, see the links.
Thread starts in December:
http://sourceware.org/ml/binutils/2012-12/msg00255.html
..continues into January:
http://sourceware.org/ml/binutils/2013-01/msg00061.html
..and ends with the final version by Ian Lance Taylor:
http://sourceware.org/ml/binutils/2013-01/msg00167.html
ChangeLog:
2012-12-25 Pavel Chupin <[hidden email]>
Fix mingw gold build with plugins enabled.
* gold/Makefile.am: Replace -ldl with @DLOPEN_LIBS@.
* gold/configure.ac: Export DLOPEN_LIBS, add headers check.
* gold/plugin.cc: Handle non-dlfcn case.
* gold/Makefile.in: Regenerate.
* gold/config.in: Regenerate.
* gold/configure: Regenerate.
* gold/testsuite/Makefile.in: Regenerate.
-rw-r--r-- | binutils-2.21/gold/Makefile.am | 2 | ||||
-rw-r--r-- | binutils-2.21/gold/Makefile.in | 3 | ||||
-rw-r--r-- | binutils-2.21/gold/config.in | 6 | ||||
-rwxr-xr-x | binutils-2.21/gold/configure | 30 | ||||
-rw-r--r-- | binutils-2.21/gold/configure.ac | 7 | ||||
-rw-r--r-- | binutils-2.21/gold/plugin.cc | 30 | ||||
-rw-r--r-- | binutils-2.21/gold/testsuite/Makefile.in | 3 |
7 files changed, 79 insertions, 2 deletions
diff --git a/binutils-2.21/gold/Makefile.am b/binutils-2.21/gold/Makefile.am index c1c3588..a8daef6 100644 --- a/binutils-2.21/gold/Makefile.am +++ b/binutils-2.21/gold/Makefile.am @@ -20,7 +20,7 @@ AM_CPPFLAGS = \ LIBIBERTY = ../libiberty/libiberty.a if PLUGINS -LIBDL = -ldl +LIBDL = @DLOPEN_LIBS@ endif if THREADS diff --git a/binutils-2.21/gold/Makefile.in b/binutils-2.21/gold/Makefile.in index aad0f3a..63369ea 100644 --- a/binutils-2.21/gold/Makefile.in +++ b/binutils-2.21/gold/Makefile.in @@ -246,6 +246,7 @@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ +DLOPEN_LIBS = @DLOPEN_LIBS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -371,7 +372,7 @@ AM_CPPFLAGS = \ @INCINTL@ LIBIBERTY = ../libiberty/libiberty.a -@PLUGINS_TRUE@LIBDL = -ldl +@PLUGINS_TRUE@LIBDL = @DLOPEN_LIBS@ @THREADS_TRUE@THREADSLIB = -lpthread AM_YFLAGS = -d diff --git a/binutils-2.21/gold/config.in b/binutils-2.21/gold/config.in index 8611376..c96189d 100644 --- a/binutils-2.21/gold/config.in +++ b/binutils-2.21/gold/config.in @@ -66,6 +66,9 @@ don't. */ #undef HAVE_DECL_VSNPRINTF +/* Define to 1 if you have the <dlfcn.h> header file. */ +#undef HAVE_DLFCN_H + /* Define to 1 if you have the <ext/hash_map> header file. */ #undef HAVE_EXT_HASH_MAP @@ -162,6 +165,9 @@ /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the <windows.h> header file. */ +#undef HAVE_WINDOWS_H + /* Define to 1 if you have the <zlib.h> header file. */ #undef HAVE_ZLIB_H diff --git a/binutils-2.21/gold/configure b/binutils-2.21/gold/configure index 56a6116..ec510d2 100755 --- a/binutils-2.21/gold/configure +++ b/binutils-2.21/gold/configure @@ -594,6 +594,7 @@ LTLIBOBJS MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE +DLOPEN_LIBS CXXCPP HAVE_ZLIB_FALSE HAVE_ZLIB_TRUE @@ -6941,6 +6942,35 @@ fi done + +for ac_header in windows.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default" +if test "x$ac_cv_header_windows_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_WINDOWS_H 1 +_ACEOF + +fi + +done + +for ac_header in dlfcn.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default" +if test "x$ac_cv_header_dlfcn_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_DLFCN_H 1 +_ACEOF + DLOPEN_LIBS="-ldl" +else + DLOPEN_LIBS="" +fi + +done + + + for ac_func in mallinfo posix_fallocate readv sysconf times do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/binutils-2.21/gold/configure.ac b/binutils-2.21/gold/configure.ac index 1bceb1e..41d3552 100644 --- a/binutils-2.21/gold/configure.ac +++ b/binutils-2.21/gold/configure.ac @@ -445,6 +445,13 @@ AC_LANG_PUSH(C++) AC_CHECK_HEADERS(tr1/unordered_set tr1/unordered_map) AC_CHECK_HEADERS(ext/hash_map ext/hash_set) AC_CHECK_HEADERS(byteswap.h) + +dnl When plugins enabled dynamic loader interface is required. Check headers +dnl which may provide this interface. In case of dlfcn.h add libdl to link. +AC_CHECK_HEADERS(windows.h) +AC_CHECK_HEADERS(dlfcn.h, [DLOPEN_LIBS="-ldl"], [DLOPEN_LIBS=""]) +AC_SUBST(DLOPEN_LIBS) + AC_CHECK_FUNCS(mallinfo posix_fallocate readv sysconf times) AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp, strndup, memmem]) diff --git a/binutils-2.21/gold/plugin.cc b/binutils-2.21/gold/plugin.cc index 8ce152c..aab0410 100644 --- a/binutils-2.21/gold/plugin.cc +++ b/binutils-2.21/gold/plugin.cc @@ -29,9 +29,39 @@ #include <vector> #ifdef ENABLE_PLUGINS +#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 +#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 reinterpret_cast<void *>( + GetProcAddress(static_cast<HMODULE>(handle),name)); +} + +static const char * +dlerror(void) +{ + return "unable to load dll"; +} + +#endif /* !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) */ +#endif /* ENABLE_PLUGINS */ + #include "parameters.h" #include "errors.h" #include "fileread.h" diff --git a/binutils-2.21/gold/testsuite/Makefile.in b/binutils-2.21/gold/testsuite/Makefile.in index 4b1cd54..77d4351 100644 --- a/binutils-2.21/gold/testsuite/Makefile.in +++ b/binutils-2.21/gold/testsuite/Makefile.in @@ -1750,6 +1750,7 @@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ +DLOPEN_LIBS = @DLOPEN_LIBS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -1757,6 +1758,8 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GENCAT = @GENCAT@ GMSGFMT = @GMSGFMT@ +GOLD_LDADD = @GOLD_LDADD@ +GOLD_LDFLAGS = @GOLD_LDFLAGS@ GREP = @GREP@ INCINTL = @INCINTL@ INSTALL = @INSTALL@ |