[interp] Remove unreachable code (#12411)
[mono-project.git] / mono / utils / mono-dl-posix.c
blobf8e71e1356e8153401b742be38a047ce3027763e
1 /**
2 * \file
3 * Interface to the dynamic linker
5 * Author:
6 * Mono Team (http://www.mono-project.com)
8 * Copyright 2001-2004 Ximian, Inc.
9 * Copyright 2004-2009 Novell, Inc.
10 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
12 #include <config.h>
14 #ifdef HAVE_UNISTD_H
15 #include <unistd.h>
16 #endif
18 #if defined(_POSIX_VERSION) && !defined (HOST_WASM)
20 #include "mono/utils/mono-dl.h"
21 #include "mono/utils/mono-embed.h"
22 #include "mono/utils/mono-path.h"
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <ctype.h>
27 #include <string.h>
28 #include <glib.h>
29 #include <dlfcn.h>
31 #if !defined (TARGET_MACH)
32 const char *
33 mono_dl_get_so_prefix (void)
35 return "lib";
37 const char **
38 mono_dl_get_so_suffixes (void)
40 static const char *suffixes[] = {
41 ".so",
42 "",
44 return suffixes;
47 int
48 mono_dl_get_executable_path (char *buf, int buflen)
50 return readlink ("/proc/self/exe", buf, buflen - 1);
53 const char*
54 mono_dl_get_system_dir (void)
56 return NULL;
59 #endif
61 void *
62 mono_dl_open_file (const char *file, int flags)
64 #ifdef HOST_ANDROID
65 /* Bionic doesn't support NULL filenames */
66 if (!file)
67 return NULL;
68 #endif
69 #if defined(_AIX)
71 * dlopen is /weird/ on AIX
72 * shared libraries (really, all oobjects are, since PPC is PIC)
73 * can cohabitate with not just SOs of the other arch, but also
74 * with regular objects in an archive used for static linking
76 * we have to pass RTLD_MEMBER, otherwise lib.a(lib.o) doesn't work
78 return dlopen (file, flags | RTLD_MEMBER);
79 #else
80 return dlopen (file, flags);
81 #endif
84 void
85 mono_dl_close_handle (MonoDl *module)
87 dlclose (module->handle);
90 void*
91 mono_dl_lookup_symbol (MonoDl *module, const char *name)
93 return dlsym (module->handle, name);
96 int
97 mono_dl_convert_flags (int flags)
99 int lflags = flags & MONO_DL_LOCAL? 0: RTLD_GLOBAL;
101 if (flags & MONO_DL_LAZY)
102 lflags |= RTLD_LAZY;
103 else
104 lflags |= RTLD_NOW;
105 return lflags;
108 char*
109 mono_dl_current_error_string (void)
111 return g_strdup (dlerror ());
114 #endif