ART: Move .bss mappings check before .bss init.
Previously the check was done before we compared the dex
file checksums, so an out of date oat file could have
failed the check. Now we're doing the check only if we're
initializing the .bss section for use by an executable oat
file, i.e. after matching the dex file checksums.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 119601889
Change-Id: Ib79d84c5bc2cf0674fc1f76071c589d49663e13c
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index d29a6b7..ae6ac9b 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -3727,32 +3727,7 @@
}
}
if (initialize_oat_file_data) {
- // Initialize the .data.bimg.rel.ro section.
- if (!oat_file->GetBootImageRelocations().empty()) {
- uint8_t* reloc_begin = const_cast<uint8_t*>(oat_file->DataBimgRelRoBegin());
- CheckedCall(mprotect,
- "un-protect boot image relocations",
- reloc_begin,
- oat_file->DataBimgRelRoSize(),
- PROT_READ | PROT_WRITE);
- uint32_t boot_image_begin = dchecked_integral_cast<uint32_t>(reinterpret_cast<uintptr_t>(
- Runtime::Current()->GetHeap()->GetBootImageSpaces().front()->Begin()));
- for (const uint32_t& relocation : oat_file->GetBootImageRelocations()) {
- const_cast<uint32_t&>(relocation) += boot_image_begin;
- }
- CheckedCall(mprotect,
- "protect boot image relocations",
- reloc_begin,
- oat_file->DataBimgRelRoSize(),
- PROT_READ);
- }
-
- // Initialize the .bss section.
- // TODO: Pre-initialize from boot/app image?
- ArtMethod* resolution_method = Runtime::Current()->GetResolutionMethod();
- for (ArtMethod*& entry : oat_file->GetBssMethods()) {
- entry = resolution_method;
- }
+ oat_file->InitializeRelocations();
}
jweak dex_cache_jweak = vm->AddWeakGlobalRef(self, dex_cache);
dex_cache->SetDexFile(&dex_file);