oat_file.cc revision 0a112bbbcd761c749c346bfec0ec39c1ef37a590
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 "oat_file.h" 18 19#include <dlfcn.h> 20#include <sstream> 21#include <string.h> 22 23#include "base/bit_vector.h" 24#include "base/stl_util.h" 25#include "base/unix_file/fd_file.h" 26#include "elf_file.h" 27#include "oat.h" 28#include "mirror/art_method.h" 29#include "mirror/art_method-inl.h" 30#include "mirror/class.h" 31#include "mirror/object-inl.h" 32#include "os.h" 33#include "runtime.h" 34#include "utils.h" 35#include "vmap_table.h" 36 37namespace art { 38 39void OatFile::CheckLocation(const std::string& location) { 40 CHECK(!location.empty()); 41} 42 43OatFile* OatFile::OpenMemory(std::vector<uint8_t>& oat_contents, 44 const std::string& location, 45 std::string* error_msg) { 46 CHECK(!oat_contents.empty()) << location; 47 CheckLocation(location); 48 std::unique_ptr<OatFile> oat_file(new OatFile(location, false)); 49 oat_file->begin_ = &oat_contents[0]; 50 oat_file->end_ = &oat_contents[oat_contents.size()]; 51 return oat_file->Setup(error_msg) ? oat_file.release() : nullptr; 52} 53 54OatFile* OatFile::Open(const std::string& filename, 55 const std::string& location, 56 byte* requested_base, 57 bool executable, 58 std::string* error_msg) { 59 CHECK(!filename.empty()) << location; 60 CheckLocation(filename); 61 std::unique_ptr<OatFile> ret; 62 if (kUsePortableCompiler && executable) { 63 // If we are using PORTABLE, use dlopen to deal with relocations. 64 // 65 // We use our own ELF loader for Quick to deal with legacy apps that 66 // open a generated dex file by name, remove the file, then open 67 // another generated dex file with the same name. http://b/10614658 68 ret.reset(OpenDlopen(filename, location, requested_base, error_msg)); 69 } else { 70 // If we aren't trying to execute, we just use our own ElfFile loader for a couple reasons: 71 // 72 // On target, dlopen may fail when compiling due to selinux restrictions on installd. 73 // 74 // On host, dlopen is expected to fail when cross compiling, so fall back to OpenElfFile. 75 // This won't work for portable runtime execution because it doesn't process relocations. 76 std::unique_ptr<File> file(OS::OpenFileForReading(filename.c_str())); 77 if (file.get() == NULL) { 78 *error_msg = StringPrintf("Failed to open oat filename for reading: %s", strerror(errno)); 79 return nullptr; 80 } 81 ret.reset(OpenElfFile(file.get(), location, requested_base, false, executable, error_msg)); 82 } 83 return ret.release(); 84} 85 86OatFile* OatFile::OpenWritable(File* file, const std::string& location, std::string* error_msg) { 87 CheckLocation(location); 88 return OpenElfFile(file, location, NULL, true, false, error_msg); 89} 90 91OatFile* OatFile::OpenReadable(File* file, const std::string& location, std::string* error_msg) { 92 CheckLocation(location); 93 return OpenElfFile(file, location, NULL, false, false, error_msg); 94} 95 96OatFile* OatFile::OpenDlopen(const std::string& elf_filename, 97 const std::string& location, 98 byte* requested_base, 99 std::string* error_msg) { 100 std::unique_ptr<OatFile> oat_file(new OatFile(location, true)); 101 bool success = oat_file->Dlopen(elf_filename, requested_base, error_msg); 102 if (!success) { 103 return nullptr; 104 } 105 return oat_file.release(); 106} 107 108OatFile* OatFile::OpenElfFile(File* file, 109 const std::string& location, 110 byte* requested_base, 111 bool writable, 112 bool executable, 113 std::string* error_msg) { 114 std::unique_ptr<OatFile> oat_file(new OatFile(location, executable)); 115 bool success = oat_file->ElfFileOpen(file, requested_base, writable, executable, error_msg); 116 if (!success) { 117 CHECK(!error_msg->empty()); 118 return nullptr; 119 } 120 return oat_file.release(); 121} 122 123OatFile::OatFile(const std::string& location, bool is_executable) 124 : location_(location), begin_(NULL), end_(NULL), is_executable_(is_executable), 125 dlopen_handle_(NULL), 126 secondary_lookup_lock_("OatFile secondary lookup lock", kOatFileSecondaryLookupLock) { 127 CHECK(!location_.empty()); 128} 129 130OatFile::~OatFile() { 131 STLDeleteValues(&oat_dex_files_); 132 if (dlopen_handle_ != NULL) { 133 dlclose(dlopen_handle_); 134 } 135} 136 137bool OatFile::Dlopen(const std::string& elf_filename, byte* requested_base, 138 std::string* error_msg) { 139 char* absolute_path = realpath(elf_filename.c_str(), NULL); 140 if (absolute_path == NULL) { 141 *error_msg = StringPrintf("Failed to find absolute path for '%s'", elf_filename.c_str()); 142 return false; 143 } 144 dlopen_handle_ = dlopen(absolute_path, RTLD_NOW); 145 free(absolute_path); 146 if (dlopen_handle_ == NULL) { 147 *error_msg = StringPrintf("Failed to dlopen '%s': %s", elf_filename.c_str(), dlerror()); 148 return false; 149 } 150 begin_ = reinterpret_cast<byte*>(dlsym(dlopen_handle_, "oatdata")); 151 if (begin_ == NULL) { 152 *error_msg = StringPrintf("Failed to find oatdata symbol in '%s': %s", elf_filename.c_str(), 153 dlerror()); 154 return false; 155 } 156 if (requested_base != NULL && begin_ != requested_base) { 157 *error_msg = StringPrintf("Failed to find oatdata symbol at expected address: " 158 "oatdata=%p != expected=%p /proc/self/maps:\n", 159 begin_, requested_base); 160 ReadFileToString("/proc/self/maps", error_msg); 161 return false; 162 } 163 end_ = reinterpret_cast<byte*>(dlsym(dlopen_handle_, "oatlastword")); 164 if (end_ == NULL) { 165 *error_msg = StringPrintf("Failed to find oatlastword symbol in '%s': %s", elf_filename.c_str(), 166 dlerror()); 167 return false; 168 } 169 // Readjust to be non-inclusive upper bound. 170 end_ += sizeof(uint32_t); 171 return Setup(error_msg); 172} 173 174bool OatFile::ElfFileOpen(File* file, byte* requested_base, bool writable, bool executable, 175 std::string* error_msg) { 176 elf_file_.reset(ElfFile::Open(file, writable, true, error_msg)); 177 if (elf_file_.get() == nullptr) { 178 DCHECK(!error_msg->empty()); 179 return false; 180 } 181 bool loaded = elf_file_->Load(executable, error_msg); 182 if (!loaded) { 183 DCHECK(!error_msg->empty()); 184 return false; 185 } 186 begin_ = elf_file_->FindDynamicSymbolAddress("oatdata"); 187 if (begin_ == NULL) { 188 *error_msg = StringPrintf("Failed to find oatdata symbol in '%s'", file->GetPath().c_str()); 189 return false; 190 } 191 if (requested_base != NULL && begin_ != requested_base) { 192 *error_msg = StringPrintf("Failed to find oatdata symbol at expected address: " 193 "oatdata=%p != expected=%p /proc/self/maps:\n", 194 begin_, requested_base); 195 ReadFileToString("/proc/self/maps", error_msg); 196 return false; 197 } 198 end_ = elf_file_->FindDynamicSymbolAddress("oatlastword"); 199 if (end_ == NULL) { 200 *error_msg = StringPrintf("Failed to find oatlastword symbol in '%s'", file->GetPath().c_str()); 201 return false; 202 } 203 // Readjust to be non-inclusive upper bound. 204 end_ += sizeof(uint32_t); 205 return Setup(error_msg); 206} 207 208bool OatFile::Setup(std::string* error_msg) { 209 if (!GetOatHeader().IsValid()) { 210 *error_msg = StringPrintf("Invalid oat magic for '%s'", GetLocation().c_str()); 211 return false; 212 } 213 const byte* oat = Begin(); 214 oat += sizeof(OatHeader); 215 if (oat > End()) { 216 *error_msg = StringPrintf("In oat file '%s' found truncated OatHeader", GetLocation().c_str()); 217 return false; 218 } 219 220 oat += GetOatHeader().GetKeyValueStoreSize(); 221 if (oat > End()) { 222 *error_msg = StringPrintf("In oat file '%s' found truncated variable-size data: " 223 "%p + %zd + %ud <= %p", GetLocation().c_str(), 224 Begin(), sizeof(OatHeader), GetOatHeader().GetKeyValueStoreSize(), 225 End()); 226 return false; 227 } 228 229 for (size_t i = 0; i < GetOatHeader().GetDexFileCount(); i++) { 230 uint32_t dex_file_location_size = *reinterpret_cast<const uint32_t*>(oat); 231 if (UNLIKELY(dex_file_location_size == 0U)) { 232 *error_msg = StringPrintf("In oat file '%s' found OatDexFile #%zd with empty location name", 233 GetLocation().c_str(), i); 234 return false; 235 } 236 oat += sizeof(dex_file_location_size); 237 if (UNLIKELY(oat > End())) { 238 *error_msg = StringPrintf("In oat file '%s' found OatDexFile #%zd truncated after dex file " 239 "location size", GetLocation().c_str(), i); 240 return false; 241 } 242 243 const char* dex_file_location_data = reinterpret_cast<const char*>(oat); 244 oat += dex_file_location_size; 245 if (UNLIKELY(oat > End())) { 246 *error_msg = StringPrintf("In oat file '%s' found OatDexFile #%zd with truncated dex file " 247 "location", GetLocation().c_str(), i); 248 return false; 249 } 250 251 std::string dex_file_location(dex_file_location_data, dex_file_location_size); 252 253 uint32_t dex_file_checksum = *reinterpret_cast<const uint32_t*>(oat); 254 oat += sizeof(dex_file_checksum); 255 if (UNLIKELY(oat > End())) { 256 *error_msg = StringPrintf("In oat file '%s' found OatDexFile #%zd for '%s' truncated after " 257 "dex file checksum", GetLocation().c_str(), i, 258 dex_file_location.c_str()); 259 return false; 260 } 261 262 uint32_t dex_file_offset = *reinterpret_cast<const uint32_t*>(oat); 263 if (UNLIKELY(dex_file_offset == 0U)) { 264 *error_msg = StringPrintf("In oat file '%s' found OatDexFile #%zd for '%s' with zero dex " 265 "file offset", GetLocation().c_str(), i, dex_file_location.c_str()); 266 return false; 267 } 268 if (UNLIKELY(dex_file_offset > Size())) { 269 *error_msg = StringPrintf("In oat file '%s' found OatDexFile #%zd for '%s' with dex file " 270 "offset %ud > %zd", GetLocation().c_str(), i, 271 dex_file_location.c_str(), dex_file_offset, Size()); 272 return false; 273 } 274 oat += sizeof(dex_file_offset); 275 if (UNLIKELY(oat > End())) { 276 *error_msg = StringPrintf("In oat file '%s' found OatDexFile #%zd for '%s' truncated " 277 " after dex file offsets", GetLocation().c_str(), i, 278 dex_file_location.c_str()); 279 return false; 280 } 281 282 const uint8_t* dex_file_pointer = Begin() + dex_file_offset; 283 if (UNLIKELY(!DexFile::IsMagicValid(dex_file_pointer))) { 284 *error_msg = StringPrintf("In oat file '%s' found OatDexFile #%zd for '%s' with invalid " 285 " dex file magic '%s'", GetLocation().c_str(), i, 286 dex_file_location.c_str(), dex_file_pointer); 287 return false; 288 } 289 if (UNLIKELY(!DexFile::IsVersionValid(dex_file_pointer))) { 290 *error_msg = StringPrintf("In oat file '%s' found OatDexFile #%zd for '%s' with invalid " 291 " dex file version '%s'", GetLocation().c_str(), i, 292 dex_file_location.c_str(), dex_file_pointer); 293 return false; 294 } 295 const DexFile::Header* header = reinterpret_cast<const DexFile::Header*>(dex_file_pointer); 296 const uint32_t* methods_offsets_pointer = reinterpret_cast<const uint32_t*>(oat); 297 298 oat += (sizeof(*methods_offsets_pointer) * header->class_defs_size_); 299 if (UNLIKELY(oat > End())) { 300 *error_msg = StringPrintf("In oat file '%s' found OatDexFile #%zd for '%s' with truncated " 301 " method offsets", GetLocation().c_str(), i, 302 dex_file_location.c_str()); 303 return false; 304 } 305 306 // Create the OatDexFile and add it to the owning map indexed by the dex file location. 307 OatDexFile* oat_dex_file = new OatDexFile(this, 308 dex_file_location, 309 dex_file_checksum, 310 dex_file_pointer, 311 methods_offsets_pointer); 312 StringPiece key(oat_dex_file->GetDexFileLocation()); 313 oat_dex_files_.Put(key, oat_dex_file); 314 } 315 return true; 316} 317 318const OatHeader& OatFile::GetOatHeader() const { 319 return *reinterpret_cast<const OatHeader*>(Begin()); 320} 321 322const byte* OatFile::Begin() const { 323 CHECK(begin_ != NULL); 324 return begin_; 325} 326 327const byte* OatFile::End() const { 328 CHECK(end_ != NULL); 329 return end_; 330} 331 332const OatFile::OatDexFile* OatFile::GetOatDexFile(const char* dex_location, 333 const uint32_t* dex_location_checksum, 334 bool warn_if_not_found) const { 335 // NOTE: We assume here that the canonical location for a given dex_location never 336 // changes. If it does (i.e. some symlink used by the filename changes) we may return 337 // an incorrect OatDexFile. As long as we have a checksum to check, we shall return 338 // an identical file or fail; otherwise we may see some unpredictable failures. 339 340 // TODO: Additional analysis of usage patterns to see if this can be simplified 341 // without any performance loss, for example by not doing the first lock-free lookup. 342 343 const OatFile::OatDexFile* oat_dex_file = nullptr; 344 StringPiece key(dex_location); 345 // Try to find the key cheaply in the oat_dex_files_ map which holds dex locations 346 // directly mentioned in the oat file and doesn't require locking. 347 auto primary_it = oat_dex_files_.find(key); 348 if (primary_it != oat_dex_files_.end()) { 349 oat_dex_file = primary_it->second; 350 DCHECK(oat_dex_file != nullptr); 351 } else { 352 // This dex_location is not one of the dex locations directly mentioned in the 353 // oat file. The correct lookup is via the canonical location but first see in 354 // the secondary_oat_dex_files_ whether we've looked up this location before. 355 MutexLock mu(Thread::Current(), secondary_lookup_lock_); 356 auto secondary_lb = secondary_oat_dex_files_.lower_bound(key); 357 if (secondary_lb != secondary_oat_dex_files_.end() && key == secondary_lb->first) { 358 oat_dex_file = secondary_lb->second; // May be nullptr. 359 } else { 360 // We haven't seen this dex_location before, we must check the canonical location. 361 if (UNLIKELY(oat_dex_files_by_canonical_location_.empty())) { 362 // Lazily fill in the oat_dex_files_by_canonical_location_. 363 for (const auto& entry : oat_dex_files_) { 364 const std::string& dex_location = entry.second->GetDexFileLocation(); 365 string_cache_.emplace_back(DexFile::GetDexCanonicalLocation(dex_location.c_str())); 366 StringPiece canonical_location_key(string_cache_.back()); 367 oat_dex_files_by_canonical_location_.Put(canonical_location_key, entry.second); 368 } 369 } 370 std::string dex_canonical_location = DexFile::GetDexCanonicalLocation(dex_location); 371 StringPiece canonical_key(dex_canonical_location); 372 auto canonical_it = oat_dex_files_by_canonical_location_.find(canonical_key); 373 if (canonical_it != oat_dex_files_by_canonical_location_.end()) { 374 oat_dex_file = canonical_it->second; 375 } // else keep nullptr. 376 377 // Copy the key to the string_cache_ and store the result in secondary map. 378 string_cache_.emplace_back(key.data(), key.length()); 379 StringPiece key_copy(string_cache_.back()); 380 secondary_oat_dex_files_.PutBefore(secondary_lb, key_copy, oat_dex_file); 381 } 382 } 383 if (oat_dex_file != nullptr && 384 (dex_location_checksum == nullptr || 385 oat_dex_file->GetDexFileLocationChecksum() == *dex_location_checksum)) { 386 return oat_dex_file; 387 } 388 389 if (warn_if_not_found) { 390 std::string dex_canonical_location = DexFile::GetDexCanonicalLocation(dex_location); 391 std::string checksum("<unspecified>"); 392 if (dex_location_checksum != NULL) { 393 checksum = StringPrintf("0x%08x", *dex_location_checksum); 394 } 395 LOG(WARNING) << "Failed to find OatDexFile for DexFile " << dex_location 396 << " ( canonical path " << dex_canonical_location << ")" 397 << " with checksum " << checksum << " in OatFile " << GetLocation(); 398 if (kIsDebugBuild) { 399 for (Table::const_iterator it = oat_dex_files_.begin(); it != oat_dex_files_.end(); ++it) { 400 LOG(WARNING) << "OatFile " << GetLocation() 401 << " contains OatDexFile " << it->second->GetDexFileLocation() 402 << " (canonical path " << it->first << ")" 403 << " with checksum 0x" << std::hex << it->second->GetDexFileLocationChecksum(); 404 } 405 } 406 } 407 408 return NULL; 409} 410 411std::vector<const OatFile::OatDexFile*> OatFile::GetOatDexFiles() const { 412 std::vector<const OatFile::OatDexFile*> result; 413 for (Table::const_iterator it = oat_dex_files_.begin(); it != oat_dex_files_.end(); ++it) { 414 result.push_back(it->second); 415 } 416 return result; 417} 418 419OatFile::OatDexFile::OatDexFile(const OatFile* oat_file, 420 const std::string& dex_file_location, 421 uint32_t dex_file_location_checksum, 422 const byte* dex_file_pointer, 423 const uint32_t* oat_class_offsets_pointer) 424 : oat_file_(oat_file), 425 dex_file_location_(dex_file_location), 426 dex_file_location_checksum_(dex_file_location_checksum), 427 dex_file_pointer_(dex_file_pointer), 428 oat_class_offsets_pointer_(oat_class_offsets_pointer) {} 429 430OatFile::OatDexFile::~OatDexFile() {} 431 432size_t OatFile::OatDexFile::FileSize() const { 433 return reinterpret_cast<const DexFile::Header*>(dex_file_pointer_)->file_size_; 434} 435 436const DexFile* OatFile::OatDexFile::OpenDexFile(std::string* error_msg) const { 437 return DexFile::Open(dex_file_pointer_, FileSize(), dex_file_location_, 438 dex_file_location_checksum_, error_msg); 439} 440 441OatFile::OatClass OatFile::OatDexFile::GetOatClass(uint16_t class_def_index) const { 442 uint32_t oat_class_offset = oat_class_offsets_pointer_[class_def_index]; 443 444 const byte* oat_class_pointer = oat_file_->Begin() + oat_class_offset; 445 CHECK_LT(oat_class_pointer, oat_file_->End()) << oat_file_->GetLocation(); 446 447 const byte* status_pointer = oat_class_pointer; 448 CHECK_LT(status_pointer, oat_file_->End()) << oat_file_->GetLocation(); 449 mirror::Class::Status status = 450 static_cast<mirror::Class::Status>(*reinterpret_cast<const int16_t*>(status_pointer)); 451 CHECK_LT(status, mirror::Class::kStatusMax); 452 453 const byte* type_pointer = status_pointer + sizeof(uint16_t); 454 CHECK_LT(type_pointer, oat_file_->End()) << oat_file_->GetLocation(); 455 OatClassType type = static_cast<OatClassType>(*reinterpret_cast<const uint16_t*>(type_pointer)); 456 CHECK_LT(type, kOatClassMax); 457 458 const byte* after_type_pointer = type_pointer + sizeof(int16_t); 459 CHECK_LE(after_type_pointer, oat_file_->End()) << oat_file_->GetLocation(); 460 461 uint32_t bitmap_size = 0; 462 const byte* bitmap_pointer = nullptr; 463 const byte* methods_pointer = nullptr; 464 if (type == kOatClassSomeCompiled) { 465 bitmap_size = static_cast<uint32_t>(*reinterpret_cast<const uint32_t*>(after_type_pointer)); 466 bitmap_pointer = after_type_pointer + sizeof(bitmap_size); 467 CHECK_LE(bitmap_pointer, oat_file_->End()) << oat_file_->GetLocation(); 468 methods_pointer = bitmap_pointer + bitmap_size; 469 } else { 470 methods_pointer = after_type_pointer; 471 } 472 CHECK_LE(methods_pointer, oat_file_->End()) << oat_file_->GetLocation(); 473 474 return OatClass(oat_file_, 475 status, 476 type, 477 bitmap_size, 478 reinterpret_cast<const uint32_t*>(bitmap_pointer), 479 reinterpret_cast<const OatMethodOffsets*>(methods_pointer)); 480} 481 482OatFile::OatClass::OatClass(const OatFile* oat_file, 483 mirror::Class::Status status, 484 OatClassType type, 485 uint32_t bitmap_size, 486 const uint32_t* bitmap_pointer, 487 const OatMethodOffsets* methods_pointer) 488 : oat_file_(oat_file), status_(status), type_(type), 489 bitmap_(bitmap_pointer), methods_pointer_(methods_pointer) { 490 CHECK(methods_pointer != nullptr); 491 switch (type_) { 492 case kOatClassAllCompiled: { 493 CHECK_EQ(0U, bitmap_size); 494 CHECK(bitmap_pointer == nullptr); 495 break; 496 } 497 case kOatClassSomeCompiled: { 498 CHECK_NE(0U, bitmap_size); 499 CHECK(bitmap_pointer != nullptr); 500 break; 501 } 502 case kOatClassNoneCompiled: { 503 CHECK_EQ(0U, bitmap_size); 504 CHECK(bitmap_pointer == nullptr); 505 methods_pointer_ = nullptr; 506 break; 507 } 508 case kOatClassMax: { 509 LOG(FATAL) << "Invalid OatClassType " << type_; 510 break; 511 } 512 } 513} 514 515const OatFile::OatMethod OatFile::OatClass::GetOatMethod(uint32_t method_index) const { 516 // NOTE: We don't keep the number of methods and cannot do a bounds check for method_index. 517 if (methods_pointer_ == NULL) { 518 CHECK_EQ(kOatClassNoneCompiled, type_); 519 return OatMethod(NULL, 0, 0); 520 } 521 size_t methods_pointer_index; 522 if (bitmap_ == NULL) { 523 CHECK_EQ(kOatClassAllCompiled, type_); 524 methods_pointer_index = method_index; 525 } else { 526 CHECK_EQ(kOatClassSomeCompiled, type_); 527 if (!BitVector::IsBitSet(bitmap_, method_index)) { 528 return OatMethod(NULL, 0, 0); 529 } 530 size_t num_set_bits = BitVector::NumSetBits(bitmap_, method_index); 531 methods_pointer_index = num_set_bits; 532 } 533 const OatMethodOffsets& oat_method_offsets = methods_pointer_[methods_pointer_index]; 534 if (oat_file_->IsExecutable() || Runtime::Current()->IsCompiler()) { 535 return OatMethod( 536 oat_file_->Begin(), 537 oat_method_offsets.code_offset_, 538 oat_method_offsets.gc_map_offset_); 539 } else { 540 // We aren't allowed to use the compiled code. We just force it down the interpreted version. 541 return OatMethod(oat_file_->Begin(), 0, 0); 542 } 543} 544 545OatFile::OatMethod::OatMethod(const byte* base, 546 const uint32_t code_offset, 547 const uint32_t gc_map_offset) 548 : begin_(base), 549 code_offset_(code_offset), 550 native_gc_map_offset_(gc_map_offset) { 551} 552 553OatFile::OatMethod::~OatMethod() {} 554 555 556uint32_t OatFile::OatMethod::GetQuickCodeSize() const { 557 uintptr_t code = reinterpret_cast<uintptr_t>(GetQuickCode()); 558 if (code == 0) { 559 return 0; 560 } 561 // TODO: make this Thumb2 specific 562 code &= ~0x1; 563 return reinterpret_cast<uint32_t*>(code)[-1]; 564} 565 566void OatFile::OatMethod::LinkMethod(mirror::ArtMethod* method) const { 567 CHECK(method != NULL); 568 method->SetEntryPointFromPortableCompiledCode(GetPortableCode()); 569 method->SetEntryPointFromQuickCompiledCode(GetQuickCode()); 570 method->SetNativeGcMap(GetNativeGcMap()); // Used by native methods in work around JNI mode. 571} 572 573} // namespace art 574