Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoltan Varga <vargaz@gmail.com>2015-06-10 23:29:51 +0300
committerRolf Bjarne Kvinge <rolf@xamarin.com>2015-07-15 18:31:56 +0300
commit782fd5375e387f1d55808ca19e30e2cb2a1c49b1 (patch)
tree74fd61f0f9fddc7d229ae5bba3e3e66a1c074f9a
parent50ff184118c969215d501644530ef2f840b7ae0f (diff)
[runtime] Work around an ios9 problem where dlopen() cant' find system libraries specified without paths.monotouch-8.9.0-ios9-branch
-rw-r--r--mono/metadata/loader.c10
-rw-r--r--mono/utils/mono-dl-darwin.c64
-rw-r--r--mono/utils/mono-dl.c12
-rw-r--r--mono/utils/mono-dl.h2
4 files changed, 87 insertions, 1 deletions
diff --git a/mono/metadata/loader.c b/mono/metadata/loader.c
index ea521d5520e..5c3e938e890 100644
--- a/mono/metadata/loader.c
+++ b/mono/metadata/loader.c
@@ -1413,7 +1413,7 @@ mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char
/*
* Try loading the module using a variety of names
*/
- for (i = 0; i < 4; ++i) {
+ for (i = 0; i < 5; ++i) {
char *base_name = NULL, *dir_name = NULL;
gboolean is_absolute = is_absolute_path (new_scope);
@@ -1447,6 +1447,14 @@ mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char
break;
}
continue;
+ case 3:
+ if (!is_absolute && mono_dl_get_system_dir ()) {
+ dir_name = mono_dl_get_system_dir ();
+ file_name = g_path_get_basename (new_scope);
+ base_name = NULL;
+ } else
+ continue;
+ break;
default:
#ifndef TARGET_WIN32
if (!g_ascii_strcasecmp ("user32.dll", new_scope) ||
diff --git a/mono/utils/mono-dl-darwin.c b/mono/utils/mono-dl-darwin.c
new file mode 100644
index 00000000000..ff7028555c1
--- /dev/null
+++ b/mono/utils/mono-dl-darwin.c
@@ -0,0 +1,64 @@
+/*
+ * mono-dl.c: Interface to the dynamic linker
+ *
+ * Author:
+ * Mono Team (http://www.mono-project.com)
+ *
+ * Copyright 2001-2004 Ximian, Inc.
+ * Copyright 2004-2009 Novell, Inc.
+ */
+#include <config.h>
+
+#if defined (TARGET_MACH)
+
+#include "mono/utils/mono-dl.h"
+#include "mono/utils/mono-embed.h"
+#include "mono/utils/mono-path.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <glib.h>
+#include <dlfcn.h>
+#include <unistd.h>
+#include <mach-o/dyld.h>
+
+const char *
+mono_dl_get_so_prefix (void)
+{
+ return "lib";
+}
+const char **
+mono_dl_get_so_suffixes (void)
+{
+ static const char *suffixes[] = {
+ ".dylib",
+ ".so",
+ ".bundle",
+ "",
+ };
+ return suffixes;
+}
+
+int
+mono_dl_get_executable_path (char *buf, int buflen)
+{
+ uint32_t bsize = buflen;
+ if (_NSGetExecutablePath (buf, &bsize) == 0)
+ return strlen (buf);
+ return -1;
+}
+
+const char*
+mono_dl_get_system_dir (void)
+{
+#ifdef TARGET_IOS
+ /* IOS9 can't load system libraries using relative paths, i.e. 'libc' doesn't work, but '/usr/lib/libc' does. */
+ return "/usr/lib";
+#else
+ return NULL;
+#endif
+}
+
+#endif
diff --git a/mono/utils/mono-dl.c b/mono/utils/mono-dl.c
index 04e9165b7c0..7fc0e694d9c 100644
--- a/mono/utils/mono-dl.c
+++ b/mono/utils/mono-dl.c
@@ -638,3 +638,15 @@ mono_dl_open_runtime_lib (const char* lib_name, int flags, char **error_msg)
}
#endif
+
+
+const char*
+mono_dl_get_system_dir (void)
+{
+#ifdef TARGET_IOS
+ /* IOS9 can't load system libraries using relative paths, i.e. 'libc' doesn't work, but '/usr/lib/libc' does. */
+ return "/usr/lib";
+#else
+ return NULL;
+#endif
+}
diff --git a/mono/utils/mono-dl.h b/mono/utils/mono-dl.h
index 869495cb5c5..f6a760ee2ef 100644
--- a/mono/utils/mono-dl.h
+++ b/mono/utils/mono-dl.h
@@ -14,5 +14,7 @@ char* mono_dl_build_path (const char *directory, const char *name, void **
MonoDl* mono_dl_open_runtime_lib (const char *lib_name, int flags, char **error_msg) MONO_INTERNAL;
+const char* mono_dl_get_system_dir (void);
+
#endif /* __MONO_UTILS_DL_H__ */