[runtime] Remove all NACL support. It was unmaintained for a long time. (#4955)
[mono.git] / mono / metadata / assembly.c
index 93fbd89b7cb5c63ab770f96a9113bff6d831c129..16c22c8fd10e8923ba813eea59aece7e0507bb22 100644 (file)
@@ -89,7 +89,7 @@ static char **assemblies_path = NULL;
 /* Contains the list of directories that point to auxiliary GACs */
 static char **extra_gac_paths = NULL;
 
-#ifndef DISABLE_ASSEMBLY_REMAPPING
+#ifndef DISABLE_DESKTOP_LOADER
 
 #define FACADE_ASSEMBLY(str) {str, 0, NULL, FALSE, TRUE}
 
@@ -123,6 +123,9 @@ static const AssemblyVersionMap framework_assemblies [] = {
        {"Microsoft.Build.Utilities.v3.5", 2, "Microsoft.Build.Utilities.v4.0"},
        {"Microsoft.VisualBasic", 1},
        {"Microsoft.VisualC", 1},
+       FACADE_ASSEMBLY ("Microsoft.Win32.Primitives"),
+       FACADE_ASSEMBLY ("Microsoft.Win32.Registry"),
+       FACADE_ASSEMBLY ("Microsoft.Win32.Registry.AccessControl"),
        {"Mono.Cairo", 0},
        {"Mono.CompilerServices.SymbolWriter", 0},
        {"Mono.Data", 0},
@@ -209,7 +212,6 @@ static const AssemblyVersionMap framework_assemblies [] = {
        {"System.Net.Http", 4},
        {"System.Net.Http.Rtc", 0},
        FACADE_ASSEMBLY ("System.Net.HttpListener"),
-       {"System.Net.NetworkInformation", 0},
        FACADE_ASSEMBLY ("System.Net.Mail"),
        FACADE_ASSEMBLY ("System.Net.NameResolution"),
        FACADE_ASSEMBLY ("System.Net.NetworkInformation"),
@@ -226,6 +228,7 @@ static const AssemblyVersionMap framework_assemblies [] = {
        {"System.Numerics.Vectors", 3},
        FACADE_ASSEMBLY ("System.ObjectModel"),
        FACADE_ASSEMBLY ("System.Reflection"),
+       FACADE_ASSEMBLY ("System.Reflection.DispatchProxy"),
        FACADE_ASSEMBLY ("System.Reflection.Emit"),
        FACADE_ASSEMBLY ("System.Reflection.Emit.ILGeneration"),
        FACADE_ASSEMBLY ("System.Reflection.Emit.Lightweight"),
@@ -239,12 +242,13 @@ static const AssemblyVersionMap framework_assemblies [] = {
        FACADE_ASSEMBLY ("System.Runtime.Extensions"),
        FACADE_ASSEMBLY ("System.Runtime.Handles"),
        FACADE_ASSEMBLY ("System.Runtime.InteropServices"),
-       {"System.Runtime.InteropServices.RuntimeInformation", 2},
+       FACADE_ASSEMBLY ("System.Runtime.InteropServices.RuntimeInformation"),
        FACADE_ASSEMBLY ("System.Runtime.InteropServices.WindowsRuntime"),
+       FACADE_ASSEMBLY ("System.Runtime.Loader"),
        FACADE_ASSEMBLY ("System.Runtime.Numerics"),
        {"System.Runtime.Remoting", 0},
        {"System.Runtime.Serialization", 3},
-       {"System.Runtime.Serialization.Formatters", 3},
+       FACADE_ASSEMBLY ("System.Runtime.Serialization.Formatters"),
        {"System.Runtime.Serialization.Formatters.Soap", 0},
        FACADE_ASSEMBLY ("System.Runtime.Serialization.Json"),
        FACADE_ASSEMBLY ("System.Runtime.Serialization.Primitives"),
@@ -274,11 +278,11 @@ static const AssemblyVersionMap framework_assemblies [] = {
        FACADE_ASSEMBLY ("System.Security.Principal.Windows"),
        FACADE_ASSEMBLY ("System.Security.SecureString"),
        {"System.ServiceModel", 3},
-       {"System.ServiceModel.Duplex", 3},
-       {"System.ServiceModel.Http", 3},
-       {"System.ServiceModel.NetTcp", 3},
-       {"System.ServiceModel.Primitives", 3},
-       {"System.ServiceModel.Security", 3},
+       FACADE_ASSEMBLY ("System.ServiceModel.Duplex"),
+       FACADE_ASSEMBLY ("System.ServiceModel.Http"),
+       FACADE_ASSEMBLY ("System.ServiceModel.NetTcp"),
+       FACADE_ASSEMBLY ("System.ServiceModel.Primitives"),
+       FACADE_ASSEMBLY ("System.ServiceModel.Security"),
        {"System.ServiceModel.Web", 2},
        {"System.ServiceProcess", 0},
        FACADE_ASSEMBLY ("System.ServiceProcess.ServiceController"),
@@ -311,7 +315,7 @@ static const AssemblyVersionMap framework_assemblies [] = {
        {"System.Xml.Serialization", 0},
        FACADE_ASSEMBLY ("System.Xml.XDocument"),
        FACADE_ASSEMBLY ("System.Xml.XPath"),
-       {"System.Xml.XPath.XmlDocument", 3},
+       FACADE_ASSEMBLY ("System.Xml.XPath.XmlDocument"),
        FACADE_ASSEMBLY ("System.Xml.XPath.XDocument"),
        FACADE_ASSEMBLY ("System.Xml.XmlDocument"),
        FACADE_ASSEMBLY ("System.Xml.XmlSerializer"),
@@ -328,27 +332,6 @@ static const AssemblyVersionMap framework_assemblies [] = {
 static GList *loaded_assemblies = NULL;
 static MonoAssembly *corlib;
 
-#if defined(__native_client__)
-
-/* On Native Client, allow mscorlib to be loaded from memory  */
-/* instead of loaded off disk.  If these are not set, default */
-/* mscorlib loading will take place                           */
-
-/* NOTE: If mscorlib data is passed to mono in this way then */
-/* it needs to remain allocated during the use of mono.      */
-
-static void *corlibData = NULL;
-static size_t corlibSize = 0;
-
-void
-mono_set_corlib_data (void *data, size_t size)
-{
-  corlibData = data;
-  corlibSize = size;
-}
-
-#endif
-
 static char* unquote (const char *str);
 
 /* This protects loaded_assemblies and image->references */
@@ -458,12 +441,6 @@ mono_set_assemblies_path (const char* path)
        }
 }
 
-/* Native Client can't get this info from an environment variable so */
-/* it's passed in to the runtime, or set manually by embedding code. */
-#ifdef __native_client__
-char* nacl_mono_path = NULL;
-#endif
-
 static void
 check_path_env (void)
 {
@@ -471,10 +448,6 @@ check_path_env (void)
                return;
 
        char* path = g_getenv ("MONO_PATH");
-#ifdef __native_client__
-       if (!path)
-               path = strdup (nacl_mono_path);
-#endif
        if (!path)
                return;
 
@@ -967,7 +940,7 @@ mono_assemblies_init (void)
        mono_os_mutex_init_recursive (&assemblies_mutex);
        mono_os_mutex_init (&assembly_binding_mutex);
 
-#ifndef DISABLE_ASSEMBLY_REMAPPING
+#ifndef DISABLE_DESKTOP_LOADER
        assembly_remapping_table = g_hash_table_new (g_str_hash, g_str_equal);
 
        int i;
@@ -1257,7 +1230,7 @@ mono_assembly_remap_version (MonoAssemblyName *aname, MonoAssemblyName *dest_ana
                return dest_aname;
        }
        
-#ifndef DISABLE_ASSEMBLY_REMAPPING
+#ifndef DISABLE_DESKTOP_LOADER
        const AssemblyVersionMap *vmap = (AssemblyVersionMap *)g_hash_table_lookup (assembly_remapping_table, aname->name);
        if (vmap) {
                const AssemblyVersionSet* vset;
@@ -3488,23 +3461,6 @@ mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus *
                return corlib;
        }
 
-       // In native client, Corlib is embedded in the executable as static variable corlibData
-#if defined(__native_client__)
-       if (corlibData != NULL && corlibSize != 0) {
-               int status = 0;
-               /* First "FALSE" instructs mono not to make a copy. */
-               /* Second "FALSE" says this is not just a ref.      */
-               MonoImage* image = mono_image_open_from_data_full (corlibData, corlibSize, FALSE, &status, FALSE);
-               if (image == NULL || status != 0)
-                       g_print("mono_image_open_from_data_full failed: %d\n", status);
-               corlib = mono_assembly_load_from_full (image, "mscorlib", &status, FALSE);
-               if (corlib == NULL || status != 0)
-                       g_print ("mono_assembly_load_from_full failed: %d\n", status);
-               if (corlib)
-                       return corlib;
-       }
-#endif
-
        // A nonstandard preload hook may provide a special mscorlib assembly
        aname = mono_assembly_name_new ("mscorlib.dll");
        corlib = invoke_assembly_preload_hook (aname, assemblies_path);
@@ -3533,7 +3489,7 @@ mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus *
        g_free (corlib_file);
 
 return_corlib_and_facades:
-       if (corlib)
+       if (corlib && !strcmp (runtime->framework_version, "4.5"))  // FIXME: stop hardcoding 4.5 here
                default_path [1] = g_strdup_printf ("%s/Facades", corlib->basedir);
                
        return corlib;
@@ -3600,7 +3556,7 @@ exact_sn_match (MonoAssemblyName *wanted_name, MonoAssemblyName *candidate_name)
 gboolean
 framework_assembly_sn_match (MonoAssemblyName *wanted_name, MonoAssemblyName *candidate_name)
 {
-#ifndef DISABLE_ASSEMBLY_REMAPPING
+#ifndef DISABLE_DESKTOP_LOADER
        const AssemblyVersionMap *vmap = (AssemblyVersionMap *)g_hash_table_lookup (assembly_remapping_table, wanted_name->name);
        if (vmap) {
                if (!vmap->framework_facade_assembly) {
@@ -3657,6 +3613,15 @@ mono_assembly_load_full_nosearch (MonoAssemblyName *aname,
                return mono_assembly_load_corlib (mono_get_runtime_info (), status);
        }
 
+       MonoAssemblyCandidatePredicate predicate = NULL;
+       void* predicate_ud = NULL;
+#if !defined(DISABLE_DESKTOP_LOADER)
+       if (G_LIKELY (mono_loader_get_strict_strong_names ())) {
+               predicate = &mono_assembly_candidate_predicate_sn_same_name;
+               predicate_ud = aname;
+       }
+#endif
+
        len = strlen (aname->name);
        for (ext_index = 0; ext_index < 2; ext_index ++) {
                ext = ext_index == 0 ? ".dll" : ".exe";
@@ -3676,7 +3641,7 @@ mono_assembly_load_full_nosearch (MonoAssemblyName *aname,
 
                if (basedir) {
                        fullpath = g_build_filename (basedir, filename, NULL);
-                       result = mono_assembly_open_predicate (fullpath, refonly, FALSE, &mono_assembly_candidate_predicate_sn_same_name, aname, status);
+                       result = mono_assembly_open_predicate (fullpath, refonly, FALSE, predicate, predicate_ud, status);
                        g_free (fullpath);
                        if (result) {
                                result->in_gac = FALSE;
@@ -3685,7 +3650,7 @@ mono_assembly_load_full_nosearch (MonoAssemblyName *aname,
                        }
                }
 
-               result = load_in_path (filename, default_path, status, refonly, &mono_assembly_candidate_predicate_sn_same_name, aname);
+               result = load_in_path (filename, default_path, status, refonly, predicate, predicate_ud);
                if (result)
                        result->in_gac = FALSE;
                g_free (filename);