Merge "Windows LTO: bfd: Search plugin dir for dependencies"
diff --git a/binutils-2.27/ld/plugin.c b/binutils-2.27/ld/plugin.c
index 4c161d1..adc8b52 100644
--- a/binutils-2.27/ld/plugin.c
+++ b/binutils-2.27/ld/plugin.c
@@ -184,7 +184,11 @@
static void *
dlopen (const char *file, int mode ATTRIBUTE_UNUSED)
{
- return LoadLibrary (file);
+ // Use LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR to search the loaded library's
+ // directory to satisfy dependencies.
+ return LoadLibraryEx(file, NULL,
+ LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR |
+ LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
}
static void *
@@ -200,9 +204,20 @@
return 0;
}
+static const char *
+dlerror (void)
+{
+ DWORD error = GetLastError();
+ static char error_buf[512];
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), error_buf,
+ sizeof(error_buf), NULL);
+ return error_buf;
+}
+
#endif /* !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) */
-#ifndef HAVE_DLFCN_H
+#if !defined (HAVE_DLFCN_H) && !defined (HAVE_WINDOWS_H)
static const char *
dlerror (void)
{