Skip to content

Commit 2d196a3

Browse files
committed
Load embedded assembly store also in filesystem mode
1 parent a67f936 commit 2d196a3

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

src/native/mono/monodroid/embedded-assemblies-zip.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ EmbeddedAssemblies::zip_load_assembly_store_entries (std::span<uint8_t> const& b
266266
dynamic_local_string<SENSIBLE_PATH_MAX> entry_name;
267267
bool assembly_store_found = embedded_assembly_store_size != 0;
268268
if (assembly_store_found) {
269-
verify_assembly_store_and_set_info (embedded_assembly_store, "embedded");
269+
load_embedded_assembly_store ();
270270
log_debug (LOG_ASSEMBLY, "Looking for DSOs in APK");
271271
} else {
272272
log_debug (LOG_ASSEMBLY, "Looking for assembly store ('%s') and DSOs in APK", assembly_store_file_path.data ());

src/native/mono/monodroid/embedded-assemblies.cc

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,13 +1405,21 @@ EmbeddedAssemblies::register_from_filesystem (const char *lib_dir_path,bool look
14051405
size_t
14061406
EmbeddedAssemblies::register_from_filesystem (monodroid_should_register should_register) noexcept
14071407
{
1408-
log_debug (LOG_ASSEMBLY, "Registering assemblies from the filesystem"sv);
1409-
constexpr bool LookForMangledNames = true;
1410-
size_t assembly_count = register_from_filesystem (
1411-
AndroidSystem::app_lib_directories[0],
1412-
LookForMangledNames,
1413-
should_register
1414-
);
1408+
size_t assembly_count;
1409+
1410+
if (embedded_assembly_store_size > 0) {
1411+
log_debug (LOG_ASSEMBLY, "Filesystem mode, but registering assemblies from the embedded assembly store");
1412+
load_embedded_assembly_store ();
1413+
assembly_count = assembly_store.assembly_count;
1414+
} else {
1415+
log_debug (LOG_ASSEMBLY, "Registering assemblies from the filesystem");
1416+
constexpr bool LookForMangledNames = true;
1417+
assembly_count = register_from_filesystem (
1418+
AndroidSystem::app_lib_directories[0],
1419+
LookForMangledNames,
1420+
should_register
1421+
);
1422+
}
14151423

14161424
#if defined(DEBUG)
14171425
constexpr bool DoNotLookForMangledNames = false;
@@ -1423,6 +1431,6 @@ EmbeddedAssemblies::register_from_filesystem (monodroid_should_register should_r
14231431
);
14241432
#endif
14251433

1426-
log_debug (LOG_ASSEMBLY, "Found {} assemblies on the filesystem", assembly_count);
1434+
log_debug (LOG_ASSEMBLY, "Found %zu assemblies", assembly_count);
14271435
return assembly_count;
14281436
}

src/native/mono/monodroid/embedded-assemblies.hh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,12 @@ namespace xamarin::android::internal {
417417
void set_debug_entry_data (XamarinAndroidBundledAssembly &entry, ZipEntryLoadState const& state, dynamic_local_string<SENSIBLE_PATH_MAX> const& entry_name) noexcept;
418418

419419
void verify_assembly_store_and_set_info (void *data_start, const char *name) noexcept;
420+
421+
void load_embedded_assembly_store () noexcept
422+
{
423+
verify_assembly_store_and_set_info (embedded_assembly_store, "embedded");
424+
}
425+
420426
void map_assembly_store (dynamic_local_string<SENSIBLE_PATH_MAX> const& entry_name, ZipEntryLoadState &state) noexcept;
421427
const AssemblyStoreIndexEntry* find_assembly_store_entry (hash_t hash, const AssemblyStoreIndexEntry *entries, size_t entry_count) noexcept;
422428
void store_individual_assembly_data (dynamic_local_string<SENSIBLE_PATH_MAX> const& entry_name, ZipEntryLoadState const& state, monodroid_should_register should_register) noexcept;

src/native/mono/runtime-base/monodroid-dl.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ namespace xamarin::android::internal
4848
size_t arr_size;
4949

5050
if constexpr (WhichCache == CacheKind::AOT) {
51-
log_debug (LOG_ASSEMBLY, "Looking for hash {:x} in AOT cache", hash);
51+
log_debug (LOG_ASSEMBLY, "Looking for hash 0x%zx in AOT cache", hash);
5252
arr = aot_dso_cache;
5353
arr_size = application_config.number_of_aot_cache_entries;
5454
} else if constexpr (WhichCache == CacheKind::DSO) {
55-
log_debug (LOG_ASSEMBLY, "Looking for hash {:x} in DSO cache", hash);
55+
log_debug (LOG_ASSEMBLY, "Looking for hash 0x%zx in DSO cache", hash);
5656
arr = dso_cache;
5757
arr_size = application_config.number_of_dso_cache_entries;
5858
}

0 commit comments

Comments
 (0)