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

mono-runtime-relocation.patch « patches « packages - github.com/mono/bockbuild.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3261bbd95c393fb593151843b0ff86488f691463 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
From ae4ba92baf2ef554abbb5c31295068e68c7ae087 Mon Sep 17 00:00:00 2001
From: Aaron Bockover <abockover@novell.com>
Date: Mon, 11 Jan 2010 01:15:43 -0500
Subject: [PATCH] Support Mono runtime relocation on OS X

assembly.c (mono_set_rootdir): support finding the Mono paths on OS X
at runtime in the same way as on Windows, which yields a relocatable
Mono. Uses dyld's _NSGetExecutablePath to resolve the path of the
running mono process.

On TARGET_ARM, fallback () will always be executed.
---
 mono/metadata/assembly.c |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/mono/metadata/assembly.c b/mono/metadata/assembly.c
index 1e7f733..ce37e8e 100644
--- a/mono/metadata/assembly.c
+++ b/mono/metadata/assembly.c
@@ -38,6 +38,10 @@
 #include <sys/stat.h>
 #endif
 
+#ifdef PLATFORM_MACOSX
+#include <mach-o/dyld.h>
+#endif
+
 /* AssemblyVersionMap: an assembly name and the assembly version set on which it is based */
 typedef struct  {
 	const char* assembly_name;
@@ -549,10 +553,35 @@ set_dirs (char *exe)
 void
 mono_set_rootdir (void)
 {
-#ifdef PLATFORM_WIN32
+#if defined(PLATFORM_WIN32) || (defined(PLATFORM_MACOSX) && !defined(TARGET_ARM))
 	gchar *bindir, *installdir, *root, *name, *config;
 
+#ifdef PLATFORM_WIN32
 	name = mono_get_module_file_name ((HMODULE) &__ImageBase);
+#else
+	{
+		/*
+		 * _NSGetExecutablePath may return -1 to indicate buf is not large
+		 *  enough, but we ignore that case to avoid having to do extra dynamic
+		 *  allocation for the path and hope that 4096 is enough - this is
+		 *  ok in the Linux/Solaris case below at least...
+		 */
+
+		gchar buf[4096];
+		guint buf_size = sizeof (buf);
+
+		name = NULL;
+		if (_NSGetExecutablePath (buf, &buf_size) == 0) {
+			name = g_strdup (buf);
+		}
+
+		if (name == NULL) {
+			fallback ();
+			return;
+		}
+	}
+#endif
+
 	bindir = g_path_get_dirname (name);
 	installdir = g_path_get_dirname (bindir);
 	root = g_build_path (G_DIR_SEPARATOR_S, installdir, "lib", NULL);
-- 
1.6.5.5