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
path: root/tools
diff options
context:
space:
mode:
authorAleksey Kliger (λgeek) <alklig@microsoft.com>2019-07-18 00:35:15 +0300
committerGitHub <noreply@github.com>2019-07-18 00:35:15 +0300
commitd5b374bb51a07bf3525d63b4cef6ad6979c27d07 (patch)
tree1a6aa96bd8ab3545b4792b3a88e9ec3986e0bdde /tools
parente2ce0a16a61a02511728d217d92156691dc42289 (diff)
[loader] Add MonoAssemblyLoadContext; stop sharing MonoImages on netcore (#15527)
Implement a couple of things: 1. Add a `MonoAssemblyLoadContext` opaque struct 2. On netcore Mono, use it to keep track of which `MonoImage`s are loaded. (Addresses part of #13891) In a bit more detail: - Add a `MonoLoadedImages` struct to hold the hash tables that we use for checking if a `MonoImage` is already loaded - Add an opaque `MonoAssemblyLoadContext` typedef - (Framework Mono) Add a `get_global_loaded_images()` function to get the shared `MonoLoadedImages` - (netcore Mono) Add a `MonoAssemblyLoadContext` struct that owns a `MonoLoadedImages` and add a `default_alc` member to `MonoDomain - Pass a `MonoAssemblyLoadContext*` to most `MonoImage`-loading functions - on Framework Mono its usually NULL and we fall back to the global loaded images, on netcore Mono it's usually `domain->default_alc->loaded_images` - (netcore Mono) Create a default Assembly Load Context when a `MonoDomain` is created - Add a `MonoAssemblyLoadContext*` field to `MonoAssemblyLoadRequest` and pass an ALC in a few places. --- Remaining work: (netcore Mono) There are still places where a `MonoAssemblyLoadRequest` or a `MonoAssemblyOpenRequest` has a `NULL` ALC - those will need to be tracked down and fixed. (netcore Mono) Eventually `MonoAssemblyLoadContext` should keep track of the loaded `MonoAssembly`s, not just images. One goal on netcore Mono is to ifdef out `MonoDomain:domain_assemblies`. --- * [loader] Add a MonoLoadedImages struct to own the MonoImage sharing Initially, there's just a single global set of loaded images. Once we have AssemblyLoadContext support, each ALC will have a separate set. NOTE: - Some of the existing Mono API is difficult to support with this design since it assumes each MonoImage is loaded at most once. * [loader] Add a MonoAssemblyLoadContext member to MonoImage for netcore * [loader] Unregister image from its owner when closing * [loader] Pass MonoLoadedImages to register_image * [domain] Add mono_domain_default_alc and mono_alc_get_loaded_images * [loader] Add an AssemblyLoadContext argument to mono_image_loaded_internal * [metadata] Add mono_image_get_alc () * [loader] Pass MonoAssemblyLoadContext to mono_image_open_from_data_internal * [loader] Pass MonoAssemblyLoadContext to mono_image_open_from_module_handle * [loaded] Pass MonoLoadedImages to mono_image_open_a_lot_parameterized * [loader] Pass MonoAssemblyLoadContext to mono_image_open_a_lot * [runtime] Mark mono_image_open_full external only Runtime should use mono_image_open_a_lot. * [runtime] Mark mono_image_loaded_by_guid external only Also mark mono_image_loaded_by_guid_full external only Runtime will need some (as yet unwritten) mechanism that takes a MonoAssemblyLoadContext as an argument. * [domain] Create a default ALC for each MonoDomain * [netcore] Pass default ALC in mono_core_preload_hook If the assembly name matches a trusted platform assembly, open it in the default ALC of the root domain * [mini] Open main assembly in default ALC in the root domain * [netcore] Don't define get_global_loaded_images() Every assembly load request should come from an assembly load context. Each ALC has a set of loaded images. So we should never need a global list. With this PR, we no longer share MonoImages across distinct ALCs. So in principle, each ALC can open the same assembly but resolve its references in different ways. Fixes part of https://github.com/mono/mono/issues/13891 * [runtime] Mark mono_pe_file_open external only * [loader] Pass MonoAssemblyLoadContext to mono_image_open_raw and mono_image_open_metadata_only * [loader] Pass MonoAssemblyLoadContext to do_mono_image_open and set MonoImage:alc * [loader] Add version 2 of assembly preload hook Pass MonoAssemblyLoadContext through the preload hook. This is used in mono_assembly_request_byname_nosearch which, in turn, is called by load_reference_by_aname_default_asmctx which is used to resolve references from one assembly to another. * [netcore] Pass native ALC ptr to AssemblyLoadContext.InternalLoadFile * [netcore] Implement AssemblyLoadContext.InternalInitializeNativeALC also implement mono_domain_create_individual_alc () * [netcore] Pass ALC to System.Reflection.Assembly.InternalLoad Pass the domain default ALC to mono_assembly_load () Also pass MonoAssemblyLoadContext to mono_assembly_load_full_gac_base_default () * [loader] Implement MONO_LOADED_IMAGES_ASSEMBLY properly Store the MonoLoadedImages for netmodules in the MonoImage for the main image of an assembly. This is also used by SRE - the dummy module of the AssemblyBuilder has the loaded_images that contains the ModuleBuilders. * [loader] Use global_loaded_images for netmodules with framework Mono The new stuff is only for ALC support in netcore * [loader] Drop netmodule support in MonoAssemblyLoadContext netmodules are not supported in netcore * [loader] Spin out image hashing out of image.c Move MonoLoadedImages support code to loaded-images.c loaded-images-global.c and loaded-images-netcore.c Also spin out assembly-load-context.c for MonoAssemblyLoadContext functions * Move ALC icall to assembly-load-context.c * formatting fix * [msvc] Add new files to .filters * update comments * [image] Change mono_loaded_images_remove_image to decrement the refcount Decrement the refcount and remove the image from the loaded images hashes in one place. Change mono_loaded_images_remove_image to return TRUE if the rest of image unloading should proceed or not. * [loader] Drop unused argument to mono_alc_init
Diffstat (limited to 'tools')
-rw-r--r--tools/pedump/pedump.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/pedump/pedump.c b/tools/pedump/pedump.c
index c87ae85cd39..e86be797292 100644
--- a/tools/pedump/pedump.c
+++ b/tools/pedump/pedump.c
@@ -432,7 +432,7 @@ verify_image_file (const char *fname)
int i, count = 0;
if (!strstr (fname, "mscorlib.dll")) {
- image = mono_image_open_raw (fname, &status);
+ image = mono_image_open_raw (mono_domain_default_alc (mono_get_root_domain ()), fname, &status);
if (!image) {
printf ("Could not open %s\n", fname);
return 1;