[Tizen] Add coreclr_preload_assembly to CoreCLR host API
This API allows to preload ni.dll (both simple and composite)
Restrictions:
- single file bundle can't be preloaded using this API
- images with huge pages (i.e. images with alignment > os page size) can't be preloaded using this API
!This patch should be rebased with caution, see comment for MAPApplyBaseRelocationsPreloadedPEFile!
Co-authored by k.baladurin@samsung.com
----
Simple change to tests coreclr preloading api on corerun (note the extra / for non-SPC dlls, it is needed because TPA list in corerun is created with extra / after dir name, i.e. "/home/user/Dev/runtime2/overlay_x64//System.Runtime.ni.dll" will be in tpa list, and argument of coreclr_preload_assembly must match it exactly). TPA list in dotnet/launcher is created without extra /.
How to test:
0. build runtime in debug
1. generate R2R ni.dll
2. run some app under gdb and stop on coreclr_preload_assembly_func
3. check that coreclr_preload_assembly_func correctly mmaps all files loaded in below patch (both using gdb in code and /proc/<pid>/smaps)
4. stop on PAL_LOADLoadPEFile and check that all ni.dll are found in preloaded cache instead of new load (also check that loaded base address doesn't change both in code and in /proc/<pid>/smaps)
diff --git a/src/coreclr/hosts/corerun/corerun.cpp b/src/coreclr/hosts/corerun/corerun.cpp
index
b3f2c867c30..
33d446d1a32 100644
--- a/src/coreclr/hosts/corerun/corerun.cpp
+++ b/src/coreclr/hosts/corerun/corerun.cpp
@@ -288,6 +288,17 @@ static int run(const configuration& config)
return -1;
}
+ coreclr_preload_assembly_ptr coreclr_preload_assembly_func = nullptr;
+ if (!try_get_export(coreclr_mod, "coreclr_preload_assembly", (void**)&coreclr_preload_assembly_func))
+ {
+ return -1;
+ }
+
+
+ coreclr_preload_assembly_func("/home/user/Dev/runtime2/overlay_x64/System.Private.CoreLib.dll");
+ coreclr_preload_assembly_func("/home/user/Dev/runtime2/overlay_x64//System.Runtime.ni.dll");
+ coreclr_preload_assembly_func("/home/user/Dev/runtime2/overlay_x64//System.IO.ni.dll");
+
// Construct CoreCLR properties.
pal::string_utf8_t tpa_list_utf8 = pal::convert_to_utf8(std::move(tpa_list));
pal::string_utf8_t app_path_utf8 = pal::convert_to_utf8(std::move(app_path));