image_space.cc revision 1a762136398ffa4ed2c366d344b45ca4244d6c6c
1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include "image_space.h" 18 19#include <random> 20 21#include "base/stl_util.h" 22#include "base/unix_file/fd_file.h" 23#include "base/scoped_flock.h" 24#include "gc/accounting/space_bitmap-inl.h" 25#include "mirror/art_method.h" 26#include "mirror/class-inl.h" 27#include "mirror/object-inl.h" 28#include "oat_file.h" 29#include "os.h" 30#include "space-inl.h" 31#include "utils.h" 32 33namespace art { 34namespace gc { 35namespace space { 36 37Atomic<uint32_t> ImageSpace::bitmap_index_(0); 38 39ImageSpace::ImageSpace(const std::string& image_filename, const char* image_location, 40 MemMap* mem_map, accounting::ContinuousSpaceBitmap* live_bitmap) 41 : MemMapSpace(image_filename, mem_map, mem_map->Begin(), mem_map->End(), mem_map->End(), 42 kGcRetentionPolicyNeverCollect), 43 image_location_(image_location) { 44 DCHECK(live_bitmap != nullptr); 45 live_bitmap_.reset(live_bitmap); 46} 47 48static int32_t ChooseRelocationOffsetDelta(int32_t min_delta, int32_t max_delta) { 49 CHECK_ALIGNED(min_delta, kPageSize); 50 CHECK_ALIGNED(max_delta, kPageSize); 51 CHECK_LT(min_delta, max_delta); 52 53 std::default_random_engine generator; 54 generator.seed(NanoTime() * getpid()); 55 std::uniform_int_distribution<int32_t> distribution(min_delta, max_delta); 56 int32_t r = distribution(generator); 57 if (r % 2 == 0) { 58 r = RoundUp(r, kPageSize); 59 } else { 60 r = RoundDown(r, kPageSize); 61 } 62 CHECK_LE(min_delta, r); 63 CHECK_GE(max_delta, r); 64 CHECK_ALIGNED(r, kPageSize); 65 return r; 66} 67 68static bool GenerateImage(const std::string& image_filename, std::string* error_msg) { 69 const std::string boot_class_path_string(Runtime::Current()->GetBootClassPathString()); 70 std::vector<std::string> boot_class_path; 71 Split(boot_class_path_string, ':', boot_class_path); 72 if (boot_class_path.empty()) { 73 *error_msg = "Failed to generate image because no boot class path specified"; 74 return false; 75 } 76 77 std::vector<std::string> arg_vector; 78 79 std::string dex2oat(Runtime::Current()->GetCompilerExecutable()); 80 arg_vector.push_back(dex2oat); 81 82 std::string image_option_string("--image="); 83 image_option_string += image_filename; 84 arg_vector.push_back(image_option_string); 85 86 for (size_t i = 0; i < boot_class_path.size(); i++) { 87 arg_vector.push_back(std::string("--dex-file=") + boot_class_path[i]); 88 } 89 90 std::string oat_file_option_string("--oat-file="); 91 oat_file_option_string += image_filename; 92 oat_file_option_string.erase(oat_file_option_string.size() - 3); 93 oat_file_option_string += "oat"; 94 arg_vector.push_back(oat_file_option_string); 95 96 Runtime::Current()->AddCurrentRuntimeFeaturesAsDex2OatArguments(&arg_vector); 97 98 int32_t base_offset = ChooseRelocationOffsetDelta(ART_BASE_ADDRESS_MIN_DELTA, 99 ART_BASE_ADDRESS_MAX_DELTA); 100 LOG(INFO) << "Using an offset of 0x" << std::hex << base_offset << " from default " 101 << "art base address of 0x" << std::hex << ART_BASE_ADDRESS; 102 arg_vector.push_back(StringPrintf("--base=0x%x", ART_BASE_ADDRESS + base_offset)); 103 104 if (kIsTargetBuild) { 105 arg_vector.push_back("--image-classes-zip=/system/framework/framework.jar"); 106 arg_vector.push_back("--image-classes=preloaded-classes"); 107 } else { 108 arg_vector.push_back("--host"); 109 } 110 111 const std::vector<std::string>& compiler_options = Runtime::Current()->GetImageCompilerOptions(); 112 for (size_t i = 0; i < compiler_options.size(); ++i) { 113 arg_vector.push_back(compiler_options[i].c_str()); 114 } 115 116 std::string command_line(Join(arg_vector, ' ')); 117 LOG(INFO) << "GenerateImage: " << command_line; 118 return Exec(arg_vector, error_msg); 119} 120 121bool ImageSpace::FindImageFilename(const char* image_location, 122 const InstructionSet image_isa, 123 std::string* system_filename, 124 bool* has_system, 125 std::string* cache_filename, 126 bool* dalvik_cache_exists, 127 bool* has_cache) { 128 *has_system = false; 129 *has_cache = false; 130 // image_location = /system/framework/boot.art 131 // system_image_location = /system/framework/<image_isa>/boot.art 132 std::string system_image_filename(GetSystemImageFilename(image_location, image_isa)); 133 if (OS::FileExists(system_image_filename.c_str())) { 134 *system_filename = system_image_filename; 135 *has_system = true; 136 } 137 138 bool have_android_data = false; 139 *dalvik_cache_exists = false; 140 std::string dalvik_cache; 141 GetDalvikCache(GetInstructionSetString(image_isa), true, &dalvik_cache, 142 &have_android_data, dalvik_cache_exists); 143 144 if (have_android_data && *dalvik_cache_exists) { 145 // Always set output location even if it does not exist, 146 // so that the caller knows where to create the image. 147 // 148 // image_location = /system/framework/boot.art 149 // *image_filename = /data/dalvik-cache/<image_isa>/boot.art 150 std::string error_msg; 151 if (!GetDalvikCacheFilename(image_location, dalvik_cache.c_str(), cache_filename, &error_msg)) { 152 LOG(WARNING) << error_msg; 153 return *has_system; 154 } 155 *has_cache = OS::FileExists(cache_filename->c_str()); 156 } 157 return *has_system || *has_cache; 158} 159 160static bool ReadSpecificImageHeader(const char* filename, ImageHeader* image_header) { 161 std::unique_ptr<File> image_file(OS::OpenFileForReading(filename)); 162 if (image_file.get() == nullptr) { 163 return false; 164 } 165 const bool success = image_file->ReadFully(image_header, sizeof(ImageHeader)); 166 if (!success || !image_header->IsValid()) { 167 return false; 168 } 169 return true; 170} 171 172bool ImageSpace::RelocateImage(const char* image_location, const char* dest_filename, 173 InstructionSet isa, std::string* error_msg) { 174 std::string patchoat(Runtime::Current()->GetPatchoatExecutable()); 175 176 std::string input_image_location_arg("--input-image-location="); 177 input_image_location_arg += image_location; 178 179 std::string output_image_filename_arg("--output-image-file="); 180 output_image_filename_arg += dest_filename; 181 182 std::string input_oat_location_arg("--input-oat-location="); 183 input_oat_location_arg += ImageHeader::GetOatLocationFromImageLocation(image_location); 184 185 std::string output_oat_filename_arg("--output-oat-file="); 186 output_oat_filename_arg += ImageHeader::GetOatLocationFromImageLocation(dest_filename); 187 188 std::string instruction_set_arg("--instruction-set="); 189 instruction_set_arg += GetInstructionSetString(isa); 190 191 std::string base_offset_arg("--base-offset-delta="); 192 StringAppendF(&base_offset_arg, "%d", ChooseRelocationOffsetDelta(ART_BASE_ADDRESS_MIN_DELTA, 193 ART_BASE_ADDRESS_MAX_DELTA)); 194 195 std::vector<std::string> argv; 196 argv.push_back(patchoat); 197 198 argv.push_back(input_image_location_arg); 199 argv.push_back(output_image_filename_arg); 200 201 argv.push_back(input_oat_location_arg); 202 argv.push_back(output_oat_filename_arg); 203 204 argv.push_back(instruction_set_arg); 205 argv.push_back(base_offset_arg); 206 207 std::string command_line(Join(argv, ' ')); 208 LOG(INFO) << "RelocateImage: " << command_line; 209 return Exec(argv, error_msg); 210} 211 212static ImageHeader* ReadSpecificImageHeaderOrDie(const char* filename) { 213 std::unique_ptr<ImageHeader> hdr(new ImageHeader); 214 if (!ReadSpecificImageHeader(filename, hdr.get())) { 215 LOG(FATAL) << "Unable to read image header for " << filename; 216 return nullptr; 217 } 218 return hdr.release(); 219} 220 221ImageHeader* ImageSpace::ReadImageHeaderOrDie(const char* image_location, 222 const InstructionSet image_isa) { 223 std::string system_filename; 224 bool has_system = false; 225 std::string cache_filename; 226 bool has_cache = false; 227 bool dalvik_cache_exists = false; 228 if (FindImageFilename(image_location, image_isa, &system_filename, &has_system, 229 &cache_filename, &dalvik_cache_exists, &has_cache)) { 230 if (Runtime::Current()->ShouldRelocate()) { 231 if (has_system && has_cache) { 232 std::unique_ptr<ImageHeader> sys_hdr(new ImageHeader); 233 std::unique_ptr<ImageHeader> cache_hdr(new ImageHeader); 234 if (!ReadSpecificImageHeader(system_filename.c_str(), sys_hdr.get())) { 235 LOG(FATAL) << "Unable to read image header for " << image_location << " at " 236 << system_filename; 237 return nullptr; 238 } 239 if (!ReadSpecificImageHeader(cache_filename.c_str(), cache_hdr.get())) { 240 LOG(FATAL) << "Unable to read image header for " << image_location << " at " 241 << cache_filename; 242 return nullptr; 243 } 244 if (sys_hdr->GetOatChecksum() != cache_hdr->GetOatChecksum()) { 245 LOG(FATAL) << "Unable to find a relocated version of image file " << image_location; 246 return nullptr; 247 } 248 return cache_hdr.release(); 249 } else if (!has_cache) { 250 LOG(FATAL) << "Unable to find a relocated version of image file " << image_location; 251 return nullptr; 252 } else if (!has_system && has_cache) { 253 // This can probably just use the cache one. 254 return ReadSpecificImageHeaderOrDie(cache_filename.c_str()); 255 } 256 } else { 257 // We don't want to relocate, Just pick the appropriate one if we have it and return. 258 if (has_system && has_cache) { 259 // We want the cache if the checksum matches, otherwise the system. 260 std::unique_ptr<ImageHeader> system(ReadSpecificImageHeaderOrDie(system_filename.c_str())); 261 std::unique_ptr<ImageHeader> cache(ReadSpecificImageHeaderOrDie(cache_filename.c_str())); 262 if (system.get() == nullptr || 263 (cache.get() != nullptr && cache->GetOatChecksum() == system->GetOatChecksum())) { 264 return cache.release(); 265 } else { 266 return system.release(); 267 } 268 } else if (has_system) { 269 return ReadSpecificImageHeaderOrDie(system_filename.c_str()); 270 } else if (has_cache) { 271 return ReadSpecificImageHeaderOrDie(cache_filename.c_str()); 272 } 273 } 274 } 275 276 LOG(FATAL) << "Unable to find image file for: " << image_location; 277 return nullptr; 278} 279 280static bool ChecksumsMatch(const char* image_a, const char* image_b) { 281 ImageHeader hdr_a; 282 ImageHeader hdr_b; 283 return ReadSpecificImageHeader(image_a, &hdr_a) && ReadSpecificImageHeader(image_b, &hdr_b) 284 && hdr_a.GetOatChecksum() == hdr_b.GetOatChecksum(); 285} 286 287ImageSpace* ImageSpace::Create(const char* image_location, 288 const InstructionSet image_isa) { 289 std::string error_msg; 290 std::string system_filename; 291 bool has_system = false; 292 std::string cache_filename; 293 bool has_cache = false; 294 bool dalvik_cache_exists = false; 295 const bool found_image = FindImageFilename(image_location, image_isa, &system_filename, 296 &has_system, &cache_filename, &dalvik_cache_exists, 297 &has_cache); 298 299 ImageSpace* space; 300 bool relocate = Runtime::Current()->ShouldRelocate(); 301 if (found_image) { 302 const std::string* image_filename; 303 bool is_system = false; 304 bool relocated_version_used = false; 305 if (relocate) { 306 CHECK(dalvik_cache_exists) << "Requiring relocation for image " << image_location << " " 307 << "at " << system_filename << " but we do not have any " 308 << "dalvik_cache to find/place it in."; 309 if (has_system) { 310 if (has_cache && ChecksumsMatch(system_filename.c_str(), cache_filename.c_str())) { 311 // We already have a relocated version 312 image_filename = &cache_filename; 313 relocated_version_used = true; 314 } else { 315 // We cannot have a relocated version, Relocate the system one and use it. 316 if (RelocateImage(image_location, cache_filename.c_str(), image_isa, 317 &error_msg)) { 318 relocated_version_used = true; 319 image_filename = &cache_filename; 320 } else { 321 LOG(FATAL) << "Unable to relocate image " << image_location << " " 322 << "from " << system_filename << " to " << cache_filename << ": " 323 << error_msg; 324 return nullptr; 325 } 326 } 327 } else { 328 CHECK(has_cache); 329 // We can just use cache's since it should be fine. This might or might not be relocated. 330 image_filename = &cache_filename; 331 } 332 } else { 333 if (has_system && has_cache) { 334 // Check they have the same cksum. If they do use the cache. Otherwise system. 335 if (ChecksumsMatch(system_filename.c_str(), cache_filename.c_str())) { 336 image_filename = &cache_filename; 337 relocated_version_used = true; 338 } else { 339 image_filename = &system_filename; 340 is_system = true; 341 } 342 } else if (has_system) { 343 image_filename = &system_filename; 344 is_system = true; 345 } else { 346 CHECK(has_cache); 347 image_filename = &cache_filename; 348 } 349 } 350 { 351 // Note that we must not use the file descriptor associated with 352 // ScopedFlock::GetFile to Init the image file. We want the file 353 // descriptor (and the associated exclusive lock) to be released when 354 // we leave Create. 355 ScopedFlock image_lock; 356 image_lock.Init(image_filename->c_str(), &error_msg); 357 LOG(INFO) << "Using image file " << image_filename->c_str() << " for image location " 358 << image_location; 359 space = ImageSpace::Init(image_filename->c_str(), image_location, 360 !is_system, &error_msg); 361 } 362 if (space != nullptr) { 363 return space; 364 } 365 366 // If the /system file exists, it should be up-to-date, don't try to generate it. Same if it is 367 // a relocated copy from something in /system (i.e. checksum's match). 368 // Otherwise, log a warning and fall through to GenerateImage. 369 if (relocated_version_used) { 370 LOG(FATAL) << "Attempted to use relocated version of " << image_location << " " 371 << "at " << cache_filename << " generated from " << system_filename << " " 372 << "but image failed to load: " << error_msg; 373 return nullptr; 374 } else if (is_system) { 375 LOG(FATAL) << "Failed to load /system image '" << *image_filename << "': " << error_msg; 376 return nullptr; 377 } else { 378 LOG(WARNING) << error_msg; 379 } 380 } 381 382 CHECK(dalvik_cache_exists) << "No place to put generated image."; 383 CHECK(GenerateImage(cache_filename, &error_msg)) 384 << "Failed to generate image '" << cache_filename << "': " << error_msg; 385 { 386 // Note that we must not use the file descriptor associated with 387 // ScopedFlock::GetFile to Init the image file. We want the file 388 // descriptor (and the associated exclusive lock) to be released when 389 // we leave Create. 390 ScopedFlock image_lock; 391 image_lock.Init(cache_filename.c_str(), &error_msg); 392 space = ImageSpace::Init(cache_filename.c_str(), image_location, true, &error_msg); 393 } 394 if (space == nullptr) { 395 LOG(FATAL) << "Failed to load generated image '" << cache_filename << "': " << error_msg; 396 } 397 return space; 398} 399 400void ImageSpace::VerifyImageAllocations() { 401 byte* current = Begin() + RoundUp(sizeof(ImageHeader), kObjectAlignment); 402 while (current < End()) { 403 DCHECK_ALIGNED(current, kObjectAlignment); 404 mirror::Object* obj = reinterpret_cast<mirror::Object*>(current); 405 CHECK(live_bitmap_->Test(obj)); 406 CHECK(obj->GetClass() != nullptr) << "Image object at address " << obj << " has null class"; 407 if (kUseBakerOrBrooksReadBarrier) { 408 obj->AssertReadBarrierPointer(); 409 } 410 current += RoundUp(obj->SizeOf(), kObjectAlignment); 411 } 412} 413 414ImageSpace* ImageSpace::Init(const char* image_filename, const char* image_location, 415 bool validate_oat_file, std::string* error_msg) { 416 CHECK(image_filename != nullptr); 417 CHECK(image_location != nullptr); 418 419 uint64_t start_time = 0; 420 if (VLOG_IS_ON(heap) || VLOG_IS_ON(startup)) { 421 start_time = NanoTime(); 422 LOG(INFO) << "ImageSpace::Init entering image_filename=" << image_filename; 423 } 424 425 std::unique_ptr<File> file(OS::OpenFileForReading(image_filename)); 426 if (file.get() == NULL) { 427 *error_msg = StringPrintf("Failed to open '%s'", image_filename); 428 return nullptr; 429 } 430 ImageHeader image_header; 431 bool success = file->ReadFully(&image_header, sizeof(image_header)); 432 if (!success || !image_header.IsValid()) { 433 *error_msg = StringPrintf("Invalid image header in '%s'", image_filename); 434 return nullptr; 435 } 436 437 // Note: The image header is part of the image due to mmap page alignment required of offset. 438 std::unique_ptr<MemMap> map(MemMap::MapFileAtAddress(image_header.GetImageBegin(), 439 image_header.GetImageSize(), 440 PROT_READ | PROT_WRITE, 441 MAP_PRIVATE, 442 file->Fd(), 443 0, 444 false, 445 image_filename, 446 error_msg)); 447 if (map.get() == NULL) { 448 DCHECK(!error_msg->empty()); 449 return nullptr; 450 } 451 CHECK_EQ(image_header.GetImageBegin(), map->Begin()); 452 DCHECK_EQ(0, memcmp(&image_header, map->Begin(), sizeof(ImageHeader))); 453 454 std::unique_ptr<MemMap> image_map(MemMap::MapFileAtAddress(nullptr, image_header.GetImageBitmapSize(), 455 PROT_READ, MAP_PRIVATE, 456 file->Fd(), image_header.GetBitmapOffset(), 457 false, 458 image_filename, 459 error_msg)); 460 if (image_map.get() == nullptr) { 461 *error_msg = StringPrintf("Failed to map image bitmap: %s", error_msg->c_str()); 462 return nullptr; 463 } 464 uint32_t bitmap_index = bitmap_index_.FetchAndAddSequentiallyConsistent(1); 465 std::string bitmap_name(StringPrintf("imagespace %s live-bitmap %u", image_filename, 466 bitmap_index)); 467 std::unique_ptr<accounting::ContinuousSpaceBitmap> bitmap( 468 accounting::ContinuousSpaceBitmap::CreateFromMemMap(bitmap_name, image_map.release(), 469 reinterpret_cast<byte*>(map->Begin()), 470 map->Size())); 471 if (bitmap.get() == nullptr) { 472 *error_msg = StringPrintf("Could not create bitmap '%s'", bitmap_name.c_str()); 473 return nullptr; 474 } 475 476 std::unique_ptr<ImageSpace> space(new ImageSpace(image_filename, image_location, 477 map.release(), bitmap.release())); 478 479 // VerifyImageAllocations() will be called later in Runtime::Init() 480 // as some class roots like ArtMethod::java_lang_reflect_ArtMethod_ 481 // and ArtField::java_lang_reflect_ArtField_, which are used from 482 // Object::SizeOf() which VerifyImageAllocations() calls, are not 483 // set yet at this point. 484 485 space->oat_file_.reset(space->OpenOatFile(image_filename, error_msg)); 486 if (space->oat_file_.get() == nullptr) { 487 DCHECK(!error_msg->empty()); 488 return nullptr; 489 } 490 491 if (validate_oat_file && !space->ValidateOatFile(error_msg)) { 492 DCHECK(!error_msg->empty()); 493 return nullptr; 494 } 495 496 Runtime* runtime = Runtime::Current(); 497 runtime->SetInstructionSet(space->oat_file_->GetOatHeader().GetInstructionSet()); 498 499 mirror::Object* resolution_method = image_header.GetImageRoot(ImageHeader::kResolutionMethod); 500 runtime->SetResolutionMethod(down_cast<mirror::ArtMethod*>(resolution_method)); 501 mirror::Object* imt_conflict_method = image_header.GetImageRoot(ImageHeader::kImtConflictMethod); 502 runtime->SetImtConflictMethod(down_cast<mirror::ArtMethod*>(imt_conflict_method)); 503 mirror::Object* default_imt = image_header.GetImageRoot(ImageHeader::kDefaultImt); 504 runtime->SetDefaultImt(down_cast<mirror::ObjectArray<mirror::ArtMethod>*>(default_imt)); 505 506 mirror::Object* callee_save_method = image_header.GetImageRoot(ImageHeader::kCalleeSaveMethod); 507 runtime->SetCalleeSaveMethod(down_cast<mirror::ArtMethod*>(callee_save_method), Runtime::kSaveAll); 508 callee_save_method = image_header.GetImageRoot(ImageHeader::kRefsOnlySaveMethod); 509 runtime->SetCalleeSaveMethod(down_cast<mirror::ArtMethod*>(callee_save_method), Runtime::kRefsOnly); 510 callee_save_method = image_header.GetImageRoot(ImageHeader::kRefsAndArgsSaveMethod); 511 runtime->SetCalleeSaveMethod(down_cast<mirror::ArtMethod*>(callee_save_method), Runtime::kRefsAndArgs); 512 513 if (VLOG_IS_ON(heap) || VLOG_IS_ON(startup)) { 514 LOG(INFO) << "ImageSpace::Init exiting (" << PrettyDuration(NanoTime() - start_time) 515 << ") " << *space.get(); 516 } 517 return space.release(); 518} 519 520OatFile* ImageSpace::OpenOatFile(const char* image_path, std::string* error_msg) const { 521 const ImageHeader& image_header = GetImageHeader(); 522 std::string oat_filename = ImageHeader::GetOatLocationFromImageLocation(image_path); 523 524 OatFile* oat_file = OatFile::Open(oat_filename, oat_filename, image_header.GetOatDataBegin(), 525 !Runtime::Current()->IsCompiler(), error_msg); 526 if (oat_file == NULL) { 527 *error_msg = StringPrintf("Failed to open oat file '%s' referenced from image %s: %s", 528 oat_filename.c_str(), GetName(), error_msg->c_str()); 529 return nullptr; 530 } 531 uint32_t oat_checksum = oat_file->GetOatHeader().GetChecksum(); 532 uint32_t image_oat_checksum = image_header.GetOatChecksum(); 533 if (oat_checksum != image_oat_checksum) { 534 *error_msg = StringPrintf("Failed to match oat file checksum 0x%x to expected oat checksum 0x%x" 535 " in image %s", oat_checksum, image_oat_checksum, GetName()); 536 return nullptr; 537 } 538 int32_t image_patch_delta = image_header.GetPatchDelta(); 539 int32_t oat_patch_delta = oat_file->GetOatHeader().GetImagePatchDelta(); 540 if (oat_patch_delta != image_patch_delta) { 541 // We should have already relocated by this point. Bail out. 542 *error_msg = StringPrintf("Failed to match oat file patch delta %d to expected patch delta %d " 543 "in image %s", oat_patch_delta, image_patch_delta, GetName()); 544 return nullptr; 545 } 546 547 return oat_file; 548} 549 550bool ImageSpace::ValidateOatFile(std::string* error_msg) const { 551 CHECK(oat_file_.get() != NULL); 552 for (const OatFile::OatDexFile* oat_dex_file : oat_file_->GetOatDexFiles()) { 553 const std::string& dex_file_location = oat_dex_file->GetDexFileLocation(); 554 uint32_t dex_file_location_checksum; 555 if (!DexFile::GetChecksum(dex_file_location.c_str(), &dex_file_location_checksum, error_msg)) { 556 *error_msg = StringPrintf("Failed to get checksum of dex file '%s' referenced by image %s: " 557 "%s", dex_file_location.c_str(), GetName(), error_msg->c_str()); 558 return false; 559 } 560 if (dex_file_location_checksum != oat_dex_file->GetDexFileLocationChecksum()) { 561 *error_msg = StringPrintf("ValidateOatFile found checksum mismatch between oat file '%s' and " 562 "dex file '%s' (0x%x != 0x%x)", 563 oat_file_->GetLocation().c_str(), dex_file_location.c_str(), 564 oat_dex_file->GetDexFileLocationChecksum(), 565 dex_file_location_checksum); 566 return false; 567 } 568 } 569 return true; 570} 571 572const OatFile* ImageSpace::GetOatFile() const { 573 return oat_file_.get(); 574} 575 576OatFile* ImageSpace::ReleaseOatFile() { 577 CHECK(oat_file_.get() != NULL); 578 return oat_file_.release(); 579} 580 581void ImageSpace::Dump(std::ostream& os) const { 582 os << GetType() 583 << " begin=" << reinterpret_cast<void*>(Begin()) 584 << ",end=" << reinterpret_cast<void*>(End()) 585 << ",size=" << PrettySize(Size()) 586 << ",name=\"" << GetName() << "\"]"; 587} 588 589} // namespace space 590} // namespace gc 591} // namespace art 592