[RFC,3/5] xtensa: support dynconfig on windows

Message ID 1495487553-19078-4-git-send-email-jcmvbkbc@gmail.com
State New, archived
Headers

Commit Message

Max Filippov May 22, 2017, 9:12 p.m. UTC
  2017-05-22  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* xtensa-config.c (windows.h): New #include'd header.
	(RTLD_LAZY): New macro definition.
	(dlopen, dlsym, dlclose, dlerror): New functions.
---
 bfd/xtensa-config.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
  

Comments

Nick Clifton June 12, 2017, 3:45 p.m. UTC | #1
Hi Max,

> 2017-05-22  Max Filippov  <jcmvbkbc@gmail.com>
> bfd/
> 	* xtensa-config.c (windows.h): New #include'd header.
> 	(RTLD_LAZY): New macro definition.
> 	(dlopen, dlsym, dlclose, dlerror): New functions.

Approved - please apply.

Cheers
  Nick
  

Patch

diff --git a/bfd/xtensa-config.c b/bfd/xtensa-config.c
index fdbcca4..3e12e26 100644
--- a/bfd/xtensa-config.c
+++ b/bfd/xtensa-config.c
@@ -3,6 +3,8 @@ 
 
 #if defined (HAVE_DLFCN_H)
 #include <dlfcn.h>
+#elif defined (HAVE_WINDOWS_H)
+#include <windows.h>
 #endif
 #include <stdio.h>
 #include <stdlib.h>
@@ -12,6 +14,37 @@ 
 
 static struct xtensa_config xtensa_defconfig = XTENSA_CONFIG_INITIALIZER;
 
+#if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)
+
+#define RTLD_LAZY 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)  */
+
 void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED, void *def)
 {
   static int init;