From 46774767fcf7780d1455e755729198648d08742e Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Wed, 22 Oct 2014 11:37:02 -0700 Subject: ART: Add support for patching and loading OAT files compiled with PIC * Images (.art) compiled with pic now have a new field added. * isDexOptNeeded will now skip patch-ing for apps compiled PIC * First-boot patching now only copies boot.art, boot.oat is linked As a result, all system preopted dex files (with --compile-pic) no longer take up any space in /data/dalvik-cache/. Bug: 18035729 Change-Id: Ie1acad81a0fd8b2f24e1f3f07a06e6fdb548be62 --- dex2oat/dex2oat.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'dex2oat') diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 1eb5718d69..bdb2b513b0 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -157,6 +157,9 @@ static void UsageError(const char* fmt, ...) { UsageError(" Example: --instruction-set-features=div"); UsageError(" Default: default"); UsageError(""); + UsageError(" --compile-pic: Force indirect use of code, methods, and classes"); + UsageError(" Default: disabled"); + UsageError(""); UsageError(" --compiler-backend=(Quick|Optimizing|Portable): select compiler backend"); UsageError(" set."); UsageError(" Example: --compiler-backend=Portable"); @@ -401,7 +404,7 @@ class Dex2Oat { } void PrepareImageWriter(uintptr_t image_base) { - image_writer_.reset(new ImageWriter(*driver_, image_base)); + image_writer_.reset(new ImageWriter(*driver_, image_base, compiler_options_->GetCompilePic())); } bool CreateOatFile(const std::vector& dex_files, @@ -485,10 +488,15 @@ class Dex2Oat { PLOG(ERROR) << "Failed to open ELF file: " << oat_filename; return false; } - if (!ElfWriter::Fixup(oat_file.get(), oat_data_begin)) { - LOG(ERROR) << "Failed to fixup ELF file " << oat_file->GetPath(); - return false; + + // Do not fix up the ELF file if we are --compile-pic + if (!compiler_options_->GetCompilePic()) { + if (!ElfWriter::Fixup(oat_file.get(), oat_data_begin)) { + LOG(ERROR) << "Failed to fixup ELF file " << oat_file->GetPath(); + return false; + } } + return true; } -- cgit v1.2.3