Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
grendello committed Nov 22, 2024
1 parent bc8b5d3 commit 88bc1b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
9 changes: 0 additions & 9 deletions src/native/monodroid/embedded-assemblies-zip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,27 @@ EmbeddedAssemblies::zip_load_entry_common (size_t entry_index, std::vector<uint8

log_debug (LOG_ASSEMBLY, " ZIP: local header offset: %u; data offset: %u; file size: %u", state.local_header_offset, state.data_offset, state.file_size);
if (state.compression_method != 0) {
log_debug (LOG_ASSEMBLY, " here #1");
return false;
}

if (entry_name.get ()[0] != state.prefix[0] || entry_name.length () < state.prefix_len || memcmp (state.prefix, entry_name.get (), state.prefix_len) != 0) {
// state.prefix and apk_lib_prefix can point to the same location, see get_assemblies_prefix_and_length()
// In such instance we short-circuit and avoid a couple of comparisons below.
if (state.prefix == apk_lib_prefix.data ()) {
log_debug (LOG_ASSEMBLY, " here #2");
return false;
}

if (entry_name.get ()[0] != apk_lib_prefix[0] || memcmp (apk_lib_prefix.data (), entry_name.get (), apk_lib_prefix.size () - 1) != 0) {
log_debug (LOG_ASSEMBLY, " here #3");
return false;
}
}

if (application_config.have_runtime_config_blob && !runtime_config_blob_found) {
log_debug (LOG_ASSEMBLY, " here #4 (blob name: '%s'; runtime_config_blob_name_size == %uz)",
SharedConstants::RUNTIME_CONFIG_BLOB_NAME.data (),
SharedConstants::runtime_config_blob_name_size
);
if (Util::ends_with (entry_name, SharedConstants::RUNTIME_CONFIG_BLOB_NAME)) {
log_debug (LOG_ASSEMBLY, " here #5");
runtime_config_blob_mmap = md_mmap_apk_file (state.file_fd, state.data_offset, state.file_size, entry_name.get ());
store_mapped_runtime_config_data (runtime_config_blob_mmap, entry_name.get ());
return false;
}
log_debug (LOG_ASSEMBLY, " here #6");
}

// assemblies must be 16-byte or 4-byte aligned, or Bad Things happen
Expand Down
11 changes: 8 additions & 3 deletions src/native/monodroid/embedded-assemblies.hh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ namespace xamarin::android::internal {

static constexpr size_t assemblies_prefix_size = calc_size(apk_lib_dir_name, zip_path_separator, SharedConstants::android_lib_abi, zip_path_separator);
static constexpr auto assemblies_prefix_array = concat_string_views<assemblies_prefix_size> (apk_lib_dir_name, zip_path_separator, SharedConstants::android_lib_abi, zip_path_separator);
static constexpr std::string_view assemblies_prefix { assemblies_prefix_array };

// .data() must be used otherwise string_view length will include the trailing \0 in the array
static constexpr std::string_view assemblies_prefix { assemblies_prefix_array.data () };

// We have two records for each assembly, for names with and without the extension
static constexpr uint32_t assembly_store_index_entries_per_assembly = 2;
Expand All @@ -104,11 +106,14 @@ namespace xamarin::android::internal {

static constexpr size_t assembly_store_file_name_size = calc_size (assembly_store_prefix, SharedConstants::android_lib_abi, assembly_store_extension, dso_suffix);
static constexpr auto assembly_store_file_name_array = concat_string_views<assembly_store_file_name_size> (assembly_store_prefix, SharedConstants::android_lib_abi, assembly_store_extension, dso_suffix);
static constexpr std::string_view assembly_store_file_name { assembly_store_file_name_array };

// .data() must be used otherwise string_view length will include the trailing \0 in the array
static constexpr std::string_view assembly_store_file_name { assembly_store_file_name_array.data () };

static constexpr size_t assembly_store_file_path_size = calc_size(apk_lib_dir_name, zip_path_separator, SharedConstants::android_lib_abi, zip_path_separator, assembly_store_prefix, SharedConstants::android_lib_abi, assembly_store_extension, dso_suffix);
static constexpr auto assembly_store_file_path_array = concat_string_views<assembly_store_file_path_size> (apk_lib_dir_name, zip_path_separator, SharedConstants::android_lib_abi, zip_path_separator, assembly_store_prefix, SharedConstants::android_lib_abi, assembly_store_extension, dso_suffix);
static constexpr std::string_view assembly_store_file_path { assembly_store_file_path_array };
// .data() must be used otherwise string_view length will include the trailing \0 in the array
static constexpr std::string_view assembly_store_file_path { assembly_store_file_path_array.data () };

static constexpr size_t dso_size_overhead = ArchiveDSOStubConfig::PayloadSectionOffset + (ArchiveDSOStubConfig::SectionHeaderEntryCount * ArchiveDSOStubConfig::SectionHeaderEntrySize);

Expand Down

0 comments on commit 88bc1b0

Please sign in to comment.