diff options
author | Zoltan Varga <vargaz@gmail.com> | 2015-06-10 23:29:51 +0300 |
---|---|---|
committer | Zoltan Varga <vargaz@gmail.com> | 2015-07-09 21:46:47 +0300 |
commit | bc72da1ee322e94aad28fc89e1ded346c46b1724 (patch) | |
tree | 869649ee06095717947fd46ed7f3cbeb4f08074a | |
parent | 62dcda3c66c8346a2050e985469607b1798dce4a (diff) |
[runtime] Work around an ios9 problem where dlopen() cant' find system libraries specified without paths.
-rw-r--r-- | mono/metadata/loader.c | 10 | ||||
-rw-r--r-- | mono/utils/mono-dl-darwin.c | 11 | ||||
-rw-r--r-- | mono/utils/mono-dl-posix.c | 7 | ||||
-rw-r--r-- | mono/utils/mono-dl-windows.c | 6 | ||||
-rw-r--r-- | mono/utils/mono-dl.h | 2 |
5 files changed, 34 insertions, 2 deletions
diff --git a/mono/metadata/loader.c b/mono/metadata/loader.c index 233efef8aaa..33cd384f434 100644 --- a/mono/metadata/loader.c +++ b/mono/metadata/loader.c @@ -1491,7 +1491,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); @@ -1525,6 +1525,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 index b1cd30f9045..ff7028555c1 100644 --- a/mono/utils/mono-dl-darwin.c +++ b/mono/utils/mono-dl-darwin.c @@ -50,4 +50,15 @@ mono_dl_get_executable_path (char *buf, int buflen) 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-posix.c b/mono/utils/mono-dl-posix.c index be52a3e6e4c..09eed6222e2 100644 --- a/mono/utils/mono-dl-posix.c +++ b/mono/utils/mono-dl-posix.c @@ -47,6 +47,13 @@ mono_dl_get_executable_path (char *buf, int buflen) { return readlink ("/proc/self/exe", buf, buflen - 1); } + +const char* +mono_dl_get_system_dir (void) +{ + return NULL; +} + #endif void * diff --git a/mono/utils/mono-dl-windows.c b/mono/utils/mono-dl-windows.c index 5dabce44835..19ff818f733 100644 --- a/mono/utils/mono-dl-windows.c +++ b/mono/utils/mono-dl-windows.c @@ -159,4 +159,10 @@ mono_dl_get_executable_path (char *buf, int buflen) return -1; //TODO } +const char* +mono_dl_get_system_dir (void) +{ + return NULL; +} + #endif diff --git a/mono/utils/mono-dl.h b/mono/utils/mono-dl.h index 4b972ef62f0..c87823208ab 100644 --- a/mono/utils/mono-dl.h +++ b/mono/utils/mono-dl.h @@ -34,7 +34,6 @@ 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; -//Platform API for mono_dl const char* mono_dl_get_so_prefix (void) MONO_INTERNAL; const char** mono_dl_get_so_suffixes (void) MONO_INTERNAL; void* mono_dl_open_file (const char *file, int flags) MONO_INTERNAL; @@ -43,6 +42,7 @@ void* mono_dl_lookup_symbol (MonoDl *module, const char *name) MONO_INTERNAL; int mono_dl_convert_flags (int flags) MONO_INTERNAL; char* mono_dl_current_error_string (void) MONO_INTERNAL; int mono_dl_get_executable_path (char *buf, int buflen) MONO_INTERNAL; +const char* mono_dl_get_system_dir (void); #endif /* __MONO_UTILS_DL_H__ */ |