Skip to content

Commit 8edaf51

Browse files
committed
Load embedded assembly store also in filesystem mode
1 parent 931f651 commit 8edaf51

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ EmbeddedAssemblies::zip_load_assembly_store_entries (std::span<uint8_t> const& b
258258
dynamic_local_string<SENSIBLE_PATH_MAX> entry_name;
259259
bool assembly_store_found = embedded_assembly_store_size != 0;
260260
if (assembly_store_found) {
261-
verify_assembly_store_and_set_info (embedded_assembly_store, "embedded");
261+
load_embedded_assembly_store ();
262262
log_debug (LOG_ASSEMBLY, "Looking for DSOs in APK");
263263
} else {
264264
log_debug (LOG_ASSEMBLY, "Looking for assembly store ('%s') and DSOs in APK", assembly_store_file_path.data ());

src/native/monodroid/embedded-assemblies.cc

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,13 +1310,21 @@ EmbeddedAssemblies::register_from_filesystem (const char *lib_dir_path,bool look
13101310
size_t
13111311
EmbeddedAssemblies::register_from_filesystem (monodroid_should_register should_register) noexcept
13121312
{
1313-
log_debug (LOG_ASSEMBLY, "Registering assemblies from the filesystem");
1314-
constexpr bool LookForMangledNames = true;
1315-
size_t assembly_count = register_from_filesystem (
1316-
AndroidSystem::app_lib_directories[0],
1317-
LookForMangledNames,
1318-
should_register
1319-
);
1313+
size_t assembly_count;
1314+
1315+
if (embedded_assembly_store_size > 0) {
1316+
log_debug (LOG_ASSEMBLY, "Filesystem mode, but registering assemblies from the embedded assembly store");
1317+
load_embedded_assembly_store ();
1318+
assembly_count = assembly_store.assembly_count;
1319+
} else {
1320+
log_debug (LOG_ASSEMBLY, "Registering assemblies from the filesystem");
1321+
constexpr bool LookForMangledNames = true;
1322+
assembly_count = register_from_filesystem (
1323+
AndroidSystem::app_lib_directories[0],
1324+
LookForMangledNames,
1325+
should_register
1326+
);
1327+
}
13201328

13211329
#if defined(DEBUG)
13221330
constexpr bool DoNotLookForMangledNames = false;
@@ -1328,6 +1336,6 @@ EmbeddedAssemblies::register_from_filesystem (monodroid_should_register should_r
13281336
);
13291337
#endif
13301338

1331-
log_debug (LOG_ASSEMBLY, "Found %zu assemblies on the filesystem", assembly_count);
1339+
log_debug (LOG_ASSEMBLY, "Found %zu assemblies", assembly_count);
13321340
return assembly_count;
13331341
}

src/native/monodroid/embedded-assemblies.hh

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

395395
void verify_assembly_store_and_set_info (void *data_start, const char *name) noexcept;
396+
397+
void load_embedded_assembly_store () noexcept
398+
{
399+
verify_assembly_store_and_set_info (embedded_assembly_store, "embedded");
400+
}
401+
396402
void map_assembly_store (dynamic_local_string<SENSIBLE_PATH_MAX> const& entry_name, ZipEntryLoadState &state) noexcept;
397403
const AssemblyStoreIndexEntry* find_assembly_store_entry (hash_t hash, const AssemblyStoreIndexEntry *entries, size_t entry_count) noexcept;
398404
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/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 0x%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 0x%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)