Skip to content

Commit b796292

Browse files
committed
Runtime config binary blob is now fully embedded
1 parent 1c14cea commit b796292

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void ExecuteWithAbi (string [] supportedAbis, string apkInputPath, string apkOut
212212
apk.Flush ();
213213
}
214214

215-
AddRuntimeConfigBlob (apk);
215+
// AddRuntimeConfigBlob (apk);
216216
AddRuntimeLibraries (apk, supportedAbis);
217217
apk.Flush();
218218
AddNativeLibraries (files, supportedAbis);

src/Xamarin.Android.Build.Tasks/Utilities/ELFEmbeddingHelper.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,13 @@ static void DoEmbed (
144144
throw new NotSupportedException ($"Internal error: unsupported target arch '{arch}'");
145145
}
146146

147+
inputFile = Path.GetFullPath (inputFile);
148+
outputFile = Path.GetFullPath (outputFile);
149+
147150
var fi = new FileInfo (inputFile);
148151
long inputFileSize = fi.Length;
149152
string asmInputFile = Path.ChangeExtension (outputFile, ".s");
153+
string sanitizedInputFilePath = inputFile.Replace ("\\", "\\\\");
150154

151155
using var fs = File.Open (asmInputFile, FileMode.Create, FileAccess.Write, FileShare.Read);
152156
using var sw = new StreamWriter (fs, asmFileEncoding);
@@ -158,7 +162,7 @@ static void DoEmbed (
158162
sw.WriteLine ($".global {symbolName}");
159163
sw.WriteLine ($".type {symbolName},{cfg.AssemblerDirectivePrefix}object");
160164
sw.WriteLine ($"{symbolName}:");
161-
sw.WriteLine ($"\t.incbin \"{inputFile}\"");
165+
sw.WriteLine ($"\t.incbin \"{sanitizedInputFilePath}\"");
162166
sw.WriteLine ($"\t.size {symbolName}, {inputFileSize}");
163167
sw.WriteLine ();
164168

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ EmbeddedAssemblies::zip_load_entry_common (size_t entry_index, std::vector<uint8
6363
}
6464
}
6565

66-
if (application_config.have_runtime_config_blob && !runtime_config_blob_found) {
67-
if (Util::ends_with (entry_name, SharedConstants::RUNTIME_CONFIG_BLOB_NAME)) {
68-
runtime_config_blob_mmap = md_mmap_apk_file (state.file_fd, state.data_offset, state.file_size, entry_name.get ());
69-
store_mapped_runtime_config_data (runtime_config_blob_mmap, entry_name.get ());
70-
return false;
71-
}
72-
}
66+
// if (application_config.have_runtime_config_blob && !runtime_config_blob_found) {
67+
// if (Util::ends_with (entry_name, SharedConstants::RUNTIME_CONFIG_BLOB_NAME)) {
68+
// runtime_config_blob_mmap = md_mmap_apk_file (state.file_fd, state.data_offset, state.file_size, entry_name.get ());
69+
// store_mapped_runtime_config_data (runtime_config_blob_mmap, entry_name.get ());
70+
// return false;
71+
// }
72+
// }
7373

7474
// assemblies must be 16-byte or 4-byte aligned, or Bad Things happen
7575
if (((state.data_offset & 0xf) != 0) || ((state.data_offset & 0x3) != 0)) {

src/native/monodroid/monodroid-glue.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -714,14 +714,17 @@ MonodroidRuntime::create_domain (JNIEnv *env, jstring_array_wrapper &runtimeApks
714714

715715
gather_bundled_assemblies (runtimeApks, &user_assemblies_count, have_split_apks);
716716

717-
if (embeddedAssemblies.have_runtime_config_blob ()) {
717+
// if (embeddedAssemblies.have_runtime_config_blob ()) {
718+
if (embedded_runtime_config_size > 0) {
718719
size_t blob_time_index;
719720
if (FastTiming::enabled ()) [[unlikely]] {
720721
blob_time_index = internal_timing->start_event (TimingEventKind::RuntimeConfigBlob);
721722
}
722723

723724
runtime_config_args.kind = 1;
724-
embeddedAssemblies.get_runtime_config_blob (runtime_config_args.runtimeconfig.data.data, runtime_config_args.runtimeconfig.data.data_len);
725+
// embeddedAssemblies.get_runtime_config_blob (runtime_config_args.runtimeconfig.data.data, runtime_config_args.runtimeconfig.data.data_len);
726+
runtime_config_args.runtimeconfig.data.data = reinterpret_cast<const char*>(embedded_runtime_config);
727+
runtime_config_args.runtimeconfig.data.data_len = static_cast<uint32_t>(embedded_runtime_config_size);
725728
monovm_runtimeconfig_initialize (&runtime_config_args, cleanup_runtime_config, nullptr);
726729

727730
if (FastTiming::enabled ()) [[unlikely]] {
@@ -1381,10 +1384,10 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl
13811384

13821385
Logger::init_logging_categories (mono_log_mask_raw, mono_log_level_raw);
13831386

1384-
log_warn (LOG_DEFAULT, "Embedded runtime config size: %zu", embedded_runtime_config_size);
1385-
if (embedded_runtime_config_size > 0) {
1386-
log_warn (LOG_DEFAULT, "First byte of embedded runtime config: 0x%x", embedded_runtime_config[0]);
1387-
}
1387+
// log_warn (LOG_DEFAULT, "Embedded runtime config size: %zu", embedded_runtime_config_size);
1388+
// if (embedded_runtime_config_size > 0) {
1389+
// log_warn (LOG_DEFAULT, "First byte of embedded runtime config: 0x%x", embedded_runtime_config[0]);
1390+
// }
13881391

13891392
std::unique_ptr<char[]> mono_log_mask (mono_log_mask_raw);
13901393
std::unique_ptr<char[]> mono_log_level (mono_log_level_raw);

src/native/runtime-base/android-system.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,10 +741,12 @@ AndroidSystem::setup_apk_directories (unsigned short running_on_cpu, jstring_arr
741741

742742
if (have_split_apks) {
743743
if (Util::ends_with (apk, SharedConstants::split_config_abi_apk_name)) {
744+
log_warn (LOG_ASSEMBLY, "Here #1");
744745
add_apk_libdir (apk, number_of_added_directories, abi);
745746
break;
746747
}
747748
} else {
749+
log_warn (LOG_ASSEMBLY, "Here #2");
748750
add_apk_libdir (apk, number_of_added_directories, abi);
749751
}
750752
}

0 commit comments

Comments
 (0)