Remove PIC option from oat files.
dex2oat has been producing only PIC code for some time,
so there's no need to record it in the oat file anymore.
Also get rid of the now unnecessary relocation logic
that was using the flag.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Pixel 2 XL boots.
Test: m test-art-target-gtest
Test: testrunner.py --target --optimizing
Bug: 77856493
Change-Id: I070071ca5a808371f67883f4ae93d633a76231d0
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 9406c62..b4aa327 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -619,8 +619,6 @@
compiler_kind_(Compiler::kOptimizing),
// Take the default set of instruction features from the build.
image_file_location_oat_checksum_(0),
- image_file_location_oat_data_begin_(0),
- image_patch_delta_(0),
key_value_store_(nullptr),
verification_results_(nullptr),
runtime_(nullptr),
@@ -1105,9 +1103,6 @@
oss << kRuntimeISA;
key_value_store_->Put(OatHeader::kDex2OatHostKey, oss.str());
key_value_store_->Put(
- OatHeader::kPicKey,
- compiler_options_->compile_pic_ ? OatHeader::kTrueValue : OatHeader::kFalseValue);
- key_value_store_->Put(
OatHeader::kDebuggableKey,
compiler_options_->debuggable_ ? OatHeader::kTrueValue : OatHeader::kFalseValue);
key_value_store_->Put(
@@ -1563,9 +1558,6 @@
std::vector<gc::space::ImageSpace*> image_spaces =
Runtime::Current()->GetHeap()->GetBootImageSpaces();
image_file_location_oat_checksum_ = image_spaces[0]->GetImageHeader().GetOatChecksum();
- image_file_location_oat_data_begin_ =
- reinterpret_cast<uintptr_t>(image_spaces[0]->GetImageHeader().GetOatDataBegin());
- image_patch_delta_ = image_spaces[0]->GetImageHeader().GetPatchDelta();
// Store the boot image filename(s).
std::vector<std::string> image_filenames;
for (const gc::space::ImageSpace* image_space : image_spaces) {
@@ -1577,8 +1569,6 @@
}
} else {
image_file_location_oat_checksum_ = 0u;
- image_file_location_oat_data_begin_ = 0u;
- image_patch_delta_ = 0;
}
// Open dex files for class path.
@@ -2148,10 +2138,7 @@
elf_writer->EndDataBimgRelRo(data_bimg_rel_ro);
}
- if (!oat_writer->WriteHeader(elf_writer->GetStream(),
- image_file_location_oat_checksum_,
- image_file_location_oat_data_begin_,
- image_patch_delta_)) {
+ if (!oat_writer->WriteHeader(elf_writer->GetStream(), image_file_location_oat_checksum_)) {
LOG(ERROR) << "Failed to write oat header to the ELF file " << oat_file->GetPath();
return false;
}
@@ -2802,8 +2789,6 @@
Compiler::Kind compiler_kind_;
uint32_t image_file_location_oat_checksum_;
- uintptr_t image_file_location_oat_data_begin_;
- int32_t image_patch_delta_;
std::unique_ptr<SafeMap<std::string, std::string> > key_value_store_;
std::unique_ptr<VerificationResults> verification_results_;
diff --git a/dex2oat/linker/image_test.h b/dex2oat/linker/image_test.h
index d575420..2b6786d 100644
--- a/dex2oat/linker/image_test.h
+++ b/dex2oat/linker/image_test.h
@@ -340,7 +340,8 @@
elf_writer->EndDataBimgRelRo(data_bimg_rel_ro);
}
- bool header_ok = oat_writer->WriteHeader(elf_writer->GetStream(), 0u, 0u, 0u);
+ bool header_ok = oat_writer->WriteHeader(elf_writer->GetStream(),
+ /* image_file_location_oat_checksum */ 0u);
ASSERT_TRUE(header_ok);
writer->UpdateOatFileHeader(i, oat_writer->GetOatHeader());
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index e8f57f5..f88d8d4 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -2815,21 +2815,10 @@
return true;
}
-bool OatWriter::WriteHeader(OutputStream* out,
- uint32_t image_file_location_oat_checksum,
- uintptr_t image_file_location_oat_begin,
- int32_t image_patch_delta) {
+bool OatWriter::WriteHeader(OutputStream* out, uint32_t image_file_location_oat_checksum) {
CHECK(write_state_ == WriteState::kWriteHeader);
oat_header_->SetImageFileLocationOatChecksum(image_file_location_oat_checksum);
- oat_header_->SetImageFileLocationOatDataBegin(image_file_location_oat_begin);
- if (GetCompilerOptions().IsBootImage()) {
- CHECK_EQ(image_patch_delta, 0);
- CHECK_EQ(oat_header_->GetImagePatchDelta(), 0);
- } else {
- CHECK_ALIGNED(image_patch_delta, kPageSize);
- oat_header_->SetImagePatchDelta(image_patch_delta);
- }
oat_header_->UpdateChecksumWithHeaderData();
const size_t file_offset = oat_data_offset_;
diff --git a/dex2oat/linker/oat_writer.h b/dex2oat/linker/oat_writer.h
index 5202d39..c049518 100644
--- a/dex2oat/linker/oat_writer.h
+++ b/dex2oat/linker/oat_writer.h
@@ -198,10 +198,7 @@
// Check the size of the written oat file.
bool CheckOatSize(OutputStream* out, size_t file_offset, size_t relative_offset);
// Write the oat header. This finalizes the oat file.
- bool WriteHeader(OutputStream* out,
- uint32_t image_file_location_oat_checksum,
- uintptr_t image_file_location_oat_begin,
- int32_t image_patch_delta);
+ bool WriteHeader(OutputStream* out, uint32_t image_file_location_oat_checksum);
// Returns whether the oat file has an associated image.
bool HasImage() const {
diff --git a/dex2oat/linker/oat_writer_test.cc b/dex2oat/linker/oat_writer_test.cc
index bd09f23..f764b42 100644
--- a/dex2oat/linker/oat_writer_test.cc
+++ b/dex2oat/linker/oat_writer_test.cc
@@ -235,7 +235,8 @@
elf_writer->EndDataBimgRelRo(data_bimg_rel_ro);
}
- if (!oat_writer.WriteHeader(elf_writer->GetStream(), 42U, 4096U, 0)) {
+ if (!oat_writer.WriteHeader(elf_writer->GetStream(),
+ /* image_file_location_oat_checksum */ 42U)) {
return false;
}
@@ -417,7 +418,6 @@
ASSERT_TRUE(oat_header.IsValid());
ASSERT_EQ(class_linker->GetBootClassPath().size(), oat_header.GetDexFileCount()); // core
ASSERT_EQ(42U, oat_header.GetImageFileLocationOatChecksum());
- ASSERT_EQ(4096U, oat_header.GetImageFileLocationOatDataBegin());
ASSERT_EQ("lue.art", std::string(oat_header.GetStoreValueByKey(OatHeader::kImageLocationKey)));
ASSERT_TRUE(java_lang_dex_file_ != nullptr);
@@ -464,7 +464,7 @@
TEST_F(OatTest, OatHeaderSizeCheck) {
// If this test is failing and you have to update these constants,
// it is time to update OatHeader::kOatVersion
- EXPECT_EQ(76U, sizeof(OatHeader));
+ EXPECT_EQ(68U, sizeof(OatHeader));
EXPECT_EQ(4U, sizeof(OatMethodOffsets));
EXPECT_EQ(8U, sizeof(OatQuickMethodHeader));
EXPECT_EQ(166 * static_cast<size_t>(GetInstructionSetPointerSize(kRuntimeISA)),
diff --git a/dexoptanalyzer/dexoptanalyzer.cc b/dexoptanalyzer/dexoptanalyzer.cc
index 00b8ef2..10bb673 100644
--- a/dexoptanalyzer/dexoptanalyzer.cc
+++ b/dexoptanalyzer/dexoptanalyzer.cc
@@ -39,10 +39,8 @@
kDex2OatFromScratch = 1,
kDex2OatForBootImageOat = 2,
kDex2OatForFilterOat = 3,
- kDex2OatForRelocationOat = 4,
- kDex2OatForBootImageOdex = 5,
- kDex2OatForFilterOdex = 6,
- kDex2OatForRelocationOdex = 7,
+ kDex2OatForBootImageOdex = 4,
+ kDex2OatForFilterOdex = 5,
kErrorInvalidArguments = 101,
kErrorCannotCreateRuntime = 102,
@@ -119,10 +117,8 @@
UsageError(" kDex2OatFromScratch = 1");
UsageError(" kDex2OatForBootImageOat = 2");
UsageError(" kDex2OatForFilterOat = 3");
- UsageError(" kDex2OatForRelocationOat = 4");
- UsageError(" kDex2OatForBootImageOdex = 5");
- UsageError(" kDex2OatForFilterOdex = 6");
- UsageError(" kDex2OatForRelocationOdex = 7");
+ UsageError(" kDex2OatForBootImageOdex = 4");
+ UsageError(" kDex2OatForFilterOdex = 5");
UsageError(" kErrorInvalidArguments = 101");
UsageError(" kErrorCannotCreateRuntime = 102");
@@ -275,11 +271,9 @@
case OatFileAssistant::kDex2OatFromScratch: return kDex2OatFromScratch;
case OatFileAssistant::kDex2OatForBootImage: return kDex2OatForBootImageOat;
case OatFileAssistant::kDex2OatForFilter: return kDex2OatForFilterOat;
- case OatFileAssistant::kDex2OatForRelocation: return kDex2OatForRelocationOat;
case -OatFileAssistant::kDex2OatForBootImage: return kDex2OatForBootImageOdex;
case -OatFileAssistant::kDex2OatForFilter: return kDex2OatForFilterOdex;
- case -OatFileAssistant::kDex2OatForRelocation: return kDex2OatForRelocationOdex;
default:
LOG(ERROR) << "Unknown dexoptNeeded " << dexoptNeeded;
return kErrorUnknownDexOptNeeded;
diff --git a/dexoptanalyzer/dexoptanalyzer_test.cc b/dexoptanalyzer/dexoptanalyzer_test.cc
index 1cbf546..93ebf2b 100644
--- a/dexoptanalyzer/dexoptanalyzer_test.cc
+++ b/dexoptanalyzer/dexoptanalyzer_test.cc
@@ -59,10 +59,8 @@
case 1: return OatFileAssistant::kDex2OatFromScratch;
case 2: return OatFileAssistant::kDex2OatForBootImage;
case 3: return OatFileAssistant::kDex2OatForFilter;
- case 4: return OatFileAssistant::kDex2OatForRelocation;
- case 5: return -OatFileAssistant::kDex2OatForBootImage;
- case 6: return -OatFileAssistant::kDex2OatForFilter;
- case 7: return -OatFileAssistant::kDex2OatForRelocation;
+ case 4: return -OatFileAssistant::kDex2OatForBootImage;
+ case 5: return -OatFileAssistant::kDex2OatForFilter;
default: return dexoptanalyzerResult;
}
}
@@ -177,8 +175,6 @@
Copy(GetDexSrc1(), dex_location);
GenerateOatForTest(dex_location.c_str(),
CompilerFilter::kSpeed,
- /*relocate*/true,
- /*pic*/false,
/*with_alternate_image*/true);
Verify(dex_location, CompilerFilter::kExtract);
@@ -196,8 +192,6 @@
Copy(GetDexSrc1(), dex_location);
GenerateOatForTest(dex_location.c_str(),
CompilerFilter::kExtract,
- /*relocate*/true,
- /*pic*/false,
/*with_alternate_image*/true);
Verify(dex_location, CompilerFilter::kExtract);
@@ -222,7 +216,7 @@
std::string odex_location = GetOdexDir() + "/StrippedDexOdexNoOat.odex";
Copy(GetDexSrc1(), dex_location);
- GeneratePicOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
+ GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
// Strip the dex file
Copy(GetStrippedDexSrc1(), dex_location);
@@ -241,7 +235,7 @@
// Create the odex file
Copy(GetDexSrc1(), dex_location);
- GeneratePicOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
+ GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
// Strip the dex file.
Copy(GetStrippedDexSrc1(), dex_location);
@@ -263,8 +257,7 @@
Verify(dex_location, CompilerFilter::kQuicken);
}
-// Case: We have a DEX file, an ODEX file and an OAT file, where the ODEX and
-// OAT files both have patch delta of 0.
+// Case: We have a DEX file, an ODEX file and an OAT file.
TEST_F(DexoptAnalyzerTest, OdexOatOverlap) {
std::string dex_location = GetScratchDir() + "/OdexOatOverlap.jar";
std::string odex_location = GetOdexDir() + "/OdexOatOverlap.odex";
@@ -280,18 +273,6 @@
Verify(dex_location, CompilerFilter::kSpeed);
}
-// Case: We have a DEX file and a PIC ODEX file, but no OAT file.
-TEST_F(DexoptAnalyzerTest, DexPicOdexNoOat) {
- std::string dex_location = GetScratchDir() + "/DexPicOdexNoOat.jar";
- std::string odex_location = GetOdexDir() + "/DexPicOdexNoOat.odex";
-
- Copy(GetDexSrc1(), dex_location);
- GeneratePicOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
-
- Verify(dex_location, CompilerFilter::kSpeed);
- Verify(dex_location, CompilerFilter::kEverything);
-}
-
// Case: We have a DEX file and a VerifyAtRuntime ODEX file, but no OAT file..
TEST_F(DexoptAnalyzerTest, DexVerifyAtRuntimeOdexNoOat) {
std::string dex_location = GetScratchDir() + "/DexVerifyAtRuntimeOdexNoOat.jar";
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index d9be750..fc7f5b7 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -470,17 +470,9 @@
GetQuickToInterpreterBridgeOffset);
#undef DUMP_OAT_HEADER_OFFSET
- os << "IMAGE PATCH DELTA:\n";
- os << StringPrintf("%d (0x%08x)\n\n",
- oat_header.GetImagePatchDelta(),
- oat_header.GetImagePatchDelta());
-
os << "IMAGE FILE LOCATION OAT CHECKSUM:\n";
os << StringPrintf("0x%08x\n\n", oat_header.GetImageFileLocationOatChecksum());
- os << "IMAGE FILE LOCATION OAT BEGIN:\n";
- os << StringPrintf("0x%08x\n\n", oat_header.GetImageFileLocationOatDataBegin());
-
// Print the key-value store.
{
os << "KEY VALUE STORE:\n";
diff --git a/oatdump/oatdump_app_test.cc b/oatdump/oatdump_app_test.cc
index a344286..2b04a0d 100644
--- a/oatdump/oatdump_app_test.cc
+++ b/oatdump/oatdump_app_test.cc
@@ -28,14 +28,4 @@
ASSERT_TRUE(Exec(kStatic, kModeOatWithBootImage, {}, kListAndCode));
}
-TEST_F(OatDumpTest, TestPicAppWithBootImage) {
- ASSERT_TRUE(GenerateAppOdexFile(kDynamic, {"--runtime-arg", "-Xmx64M", "--compile-pic"}));
- ASSERT_TRUE(Exec(kDynamic, kModeOatWithBootImage, {}, kListAndCode));
-}
-TEST_F(OatDumpTest, TestPicAppWithBootImageStatic) {
- TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
- ASSERT_TRUE(GenerateAppOdexFile(kStatic, {"--runtime-arg", "-Xmx64M", "--compile-pic"}));
- ASSERT_TRUE(Exec(kStatic, kModeOatWithBootImage, {}, kListAndCode));
-}
-
} // namespace art
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc
index 02fc925..aaa3e83 100644
--- a/patchoat/patchoat.cc
+++ b/patchoat/patchoat.cc
@@ -475,21 +475,21 @@
PROT_READ | PROT_WRITE,
MAP_PRIVATE,
&error_msg));
- if (elf.get() == nullptr) {
+ if (elf == nullptr) {
LOG(ERROR) << "Unable to open oat file " << input_oat_filename << " : " << error_msg;
return false;
}
- MaybePic is_oat_pic = IsOatPic(elf.get());
- if (is_oat_pic >= ERROR_FIRST) {
- // Error logged by IsOatPic
- return false;
- } else if (is_oat_pic == NOT_PIC) {
- LOG(ERROR) << "patchoat cannot be used on non-PIC oat file: " << input_oat_filename;
+ const OatHeader* oat_header = GetOatHeader(elf.get());
+ if (oat_header == nullptr) {
+ LOG(ERROR) << "Failed to find oat header in oat file " << input_oat_filename;
return false;
}
- CHECK(is_oat_pic == PIC);
+ if (!oat_header->IsValid()) {
+ LOG(ERROR) << "Elf file " << input_oat_filename << " has an invalid oat header";
+ return false;
+ }
std::string output_vdex_filename =
ImageHeader::GetVdexLocationFromImageLocation(output_image_filename);
@@ -784,33 +784,6 @@
return true;
}
-PatchOat::MaybePic PatchOat::IsOatPic(const ElfFile* oat_in) {
- if (oat_in == nullptr) {
- LOG(ERROR) << "No ELF input oat fie available";
- return ERROR_OAT_FILE;
- }
-
- const std::string& file_path = oat_in->GetFilePath();
-
- const OatHeader* oat_header = GetOatHeader(oat_in);
- if (oat_header == nullptr) {
- LOG(ERROR) << "Failed to find oat header in oat file " << file_path;
- return ERROR_OAT_FILE;
- }
-
- if (!oat_header->IsValid()) {
- LOG(ERROR) << "Elf file " << file_path << " has an invalid oat header";
- return ERROR_OAT_FILE;
- }
-
- bool is_pic = oat_header->IsPic();
- if (kIsDebugBuild) {
- LOG(INFO) << "Oat file at " << file_path << " is " << (is_pic ? "PIC" : "not pic");
- }
-
- return is_pic ? PIC : NOT_PIC;
-}
-
class PatchOat::PatchOatArtFieldVisitor : public ArtFieldVisitor {
public:
explicit PatchOatArtFieldVisitor(PatchOat* patch_oat) : patch_oat_(patch_oat) {}
diff --git a/patchoat/patchoat.h b/patchoat/patchoat.h
index ac2fdf5..237ef50 100644
--- a/patchoat/patchoat.h
+++ b/patchoat/patchoat.h
@@ -81,16 +81,6 @@
// Was the .art image at image_path made with --compile-pic ?
static bool IsImagePic(const ImageHeader& image_header, const std::string& image_path);
- enum MaybePic {
- NOT_PIC, // Code not pic. Patch as usual.
- PIC, // Code was pic. Create symlink; skip OAT patching.
- ERROR_OAT_FILE, // Failed to symlink oat file
- ERROR_FIRST = ERROR_OAT_FILE,
- };
-
- // Was the .oat image at oat_in made with --compile-pic ?
- static MaybePic IsOatPic(const ElfFile* oat_in);
-
static bool CreateVdexAndOatSymlinks(const std::string& input_image_filename,
const std::string& output_image_filename);
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index ccb42c4..e19dedc 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -940,7 +940,6 @@
runtime->GetOatFileManager().RegisterImageOatFiles(spaces);
DCHECK(!oat_files.empty());
const OatHeader& default_oat_header = oat_files[0]->GetOatHeader();
- CHECK_EQ(default_oat_header.GetImageFileLocationOatDataBegin(), 0U);
const char* image_file_location = oat_files[0]->GetOatHeader().
GetStoreValueByKey(OatHeader::kImageLocationKey);
CHECK(image_file_location == nullptr || *image_file_location == 0);
diff --git a/runtime/dexopt_test.cc b/runtime/dexopt_test.cc
index 93af77f..556ff69 100644
--- a/runtime/dexopt_test.cc
+++ b/runtime/dexopt_test.cc
@@ -89,25 +89,12 @@
}
void DexoptTest::GenerateOatForTest(const std::string& dex_location,
- const std::string& oat_location_in,
+ const std::string& oat_location,
CompilerFilter::Filter filter,
- bool relocate,
- bool pic,
bool with_alternate_image,
const char* compilation_reason) {
std::string dalvik_cache = GetDalvikCache(GetInstructionSetString(kRuntimeISA));
std::string dalvik_cache_tmp = dalvik_cache + ".redirected";
- std::string oat_location = oat_location_in;
- if (!relocate) {
- // Temporarily redirect the dalvik cache so dex2oat doesn't find the
- // relocated image file.
- ASSERT_EQ(0, rename(dalvik_cache.c_str(), dalvik_cache_tmp.c_str())) << strerror(errno);
- // If the oat location is in dalvik cache, replace the cache path with the temporary one.
- size_t pos = oat_location.find(dalvik_cache);
- if (pos != std::string::npos) {
- oat_location = oat_location.replace(pos, dalvik_cache.length(), dalvik_cache_tmp);
- }
- }
std::vector<std::string> args;
args.push_back("--dex-file=" + dex_location);
@@ -125,10 +112,6 @@
args.push_back("--profile-file=" + profile_file.GetFilename());
}
- if (pic) {
- args.push_back("--compile-pic");
- }
-
std::string image_location = GetImageLocation();
if (with_alternate_image) {
args.push_back("--boot-image=" + GetImageLocation2());
@@ -141,12 +124,6 @@
std::string error_msg;
ASSERT_TRUE(Dex2Oat(args, &error_msg)) << error_msg;
- if (!relocate) {
- // Restore the dalvik cache if needed.
- ASSERT_EQ(0, rename(dalvik_cache_tmp.c_str(), dalvik_cache.c_str())) << strerror(errno);
- oat_location = oat_location_in;
- }
-
// Verify the odex file was generated as expected.
std::unique_ptr<OatFile> odex_file(OatFile::Open(/* zip_fd */ -1,
oat_location.c_str(),
@@ -158,7 +135,6 @@
/* reservation */ nullptr,
&error_msg));
ASSERT_TRUE(odex_file.get() != nullptr) << error_msg;
- EXPECT_EQ(pic, odex_file->IsPic());
EXPECT_EQ(filter, odex_file->GetCompilerFilter());
std::unique_ptr<ImageHeader> image_header(
@@ -176,51 +152,22 @@
EXPECT_EQ(combined_checksum, oat_header.GetImageFileLocationOatChecksum());
}
}
-
- if (!with_alternate_image) {
- if (CompilerFilter::IsAotCompilationEnabled(filter)) {
- if (relocate) {
- EXPECT_EQ(reinterpret_cast<uintptr_t>(image_header->GetOatDataBegin()),
- oat_header.GetImageFileLocationOatDataBegin());
- EXPECT_EQ(image_header->GetPatchDelta(), oat_header.GetImagePatchDelta());
- } else {
- EXPECT_NE(reinterpret_cast<uintptr_t>(image_header->GetOatDataBegin()),
- oat_header.GetImageFileLocationOatDataBegin());
- EXPECT_NE(image_header->GetPatchDelta(), oat_header.GetImagePatchDelta());
- }
- }
- }
}
void DexoptTest::GenerateOdexForTest(const std::string& dex_location,
- const std::string& odex_location,
- CompilerFilter::Filter filter) {
+ const std::string& odex_location,
+ CompilerFilter::Filter filter,
+ const char* compilation_reason) {
GenerateOatForTest(dex_location,
odex_location,
filter,
- /*relocate*/false,
- /*pic*/false,
- /*with_alternate_image*/false);
-}
-
-void DexoptTest::GeneratePicOdexForTest(const std::string& dex_location,
- const std::string& odex_location,
- CompilerFilter::Filter filter,
- const char* compilation_reason) {
- GenerateOatForTest(dex_location,
- odex_location,
- filter,
- /*relocate*/false,
- /*pic*/true,
- /*with_alternate_image*/false,
+ /* with_alternate_image */ false,
compilation_reason);
}
void DexoptTest::GenerateOatForTest(const char* dex_location,
- CompilerFilter::Filter filter,
- bool relocate,
- bool pic,
- bool with_alternate_image) {
+ CompilerFilter::Filter filter,
+ bool with_alternate_image) {
std::string oat_location;
std::string error_msg;
ASSERT_TRUE(OatFileAssistant::DexLocationToOatFilename(
@@ -228,17 +175,11 @@
GenerateOatForTest(dex_location,
oat_location,
filter,
- relocate,
- pic,
with_alternate_image);
}
void DexoptTest::GenerateOatForTest(const char* dex_location, CompilerFilter::Filter filter) {
- GenerateOatForTest(dex_location,
- filter,
- /*relocate*/true,
- /*pic*/false,
- /*with_alternate_image*/false);
+ GenerateOatForTest(dex_location, filter, /* with_alternate_image */ false);
}
bool DexoptTest::PreRelocateImage(const std::string& image_location, std::string* error_msg) {
@@ -247,7 +188,7 @@
bool dalvik_cache_exists;
bool is_global_cache;
GetDalvikCache(GetInstructionSetString(kRuntimeISA),
- true,
+ /* create_if_absent */ true,
&dalvik_cache,
&have_android_data,
&dalvik_cache_exists,
diff --git a/runtime/dexopt_test.h b/runtime/dexopt_test.h
index 5dff379..067b67a 100644
--- a/runtime/dexopt_test.h
+++ b/runtime/dexopt_test.h
@@ -36,36 +36,24 @@
// The oat file will be generated for dex_location in the given oat_location
// with the following configuration:
// filter - controls the compilation filter
- // pic - whether or not the code will be PIC
- // relocate - if true, the oat file will be relocated with respect to the
- // boot image. Otherwise the oat file will not be relocated.
// with_alternate_image - if true, the oat file will be generated with an
// image checksum different than the current image checksum.
void GenerateOatForTest(const std::string& dex_location,
const std::string& oat_location,
CompilerFilter::Filter filter,
- bool relocate,
- bool pic,
bool with_alternate_image,
const char* compilation_reason = nullptr);
- // Generate a non-PIC odex file for the purposes of test.
- // The generated odex file will be un-relocated.
+ // Generate an odex file for the purposes of test.
void GenerateOdexForTest(const std::string& dex_location,
const std::string& odex_location,
- CompilerFilter::Filter filter);
-
- void GeneratePicOdexForTest(const std::string& dex_location,
- const std::string& odex_location,
- CompilerFilter::Filter filter,
- const char* compilation_reason = nullptr);
+ CompilerFilter::Filter filter,
+ const char* compilation_reason = nullptr);
// Generate an oat file for the given dex location in its oat location (under
// the dalvik cache).
void GenerateOatForTest(const char* dex_location,
CompilerFilter::Filter filter,
- bool relocate,
- bool pic,
bool with_alternate_image);
// Generate a standard oat file in the oat location.
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index f308f63..3999e27 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -1400,17 +1400,6 @@
image.GetName());
return nullptr;
}
- int32_t image_patch_delta = image_header.GetPatchDelta();
- int32_t oat_patch_delta = oat_file->GetOatHeader().GetImagePatchDelta();
- if (oat_patch_delta != image_patch_delta && !image_header.CompilePic()) {
- // We should have already relocated by this point. Bail out.
- *error_msg = StringPrintf("Failed to match oat file patch delta %d to expected patch delta %d "
- "in image %s",
- oat_patch_delta,
- image_patch_delta,
- image.GetName());
- return nullptr;
- }
return oat_file;
}
diff --git a/runtime/oat.cc b/runtime/oat.cc
index 39dc8da..519eed7 100644
--- a/runtime/oat.cc
+++ b/runtime/oat.cc
@@ -81,9 +81,7 @@
quick_imt_conflict_trampoline_offset_(0),
quick_resolution_trampoline_offset_(0),
quick_to_interpreter_bridge_offset_(0),
- image_patch_delta_(0),
- image_file_location_oat_checksum_(0),
- image_file_location_oat_data_begin_(0) {
+ image_file_location_oat_checksum_(0) {
// Don't want asserts in header as they would be checked in each file that includes it. But the
// fields are private, so we check inside a method.
static_assert(sizeof(magic_) == sizeof(kOatMagic),
@@ -110,9 +108,6 @@
if (!IsAligned<kPageSize>(executable_offset_)) {
return false;
}
- if (!IsAligned<kPageSize>(image_patch_delta_)) {
- return false;
- }
if (!IsValidInstructionSet(instruction_set_)) {
return false;
}
@@ -135,9 +130,6 @@
if (!IsAligned<kPageSize>(executable_offset_)) {
return "Executable offset not page-aligned.";
}
- if (!IsAligned<kPageSize>(image_patch_delta_)) {
- return "Image patch delta not page-aligned.";
- }
if (!IsValidInstructionSet(instruction_set_)) {
return StringPrintf("Invalid instruction set, %d.", static_cast<int>(instruction_set_));
}
@@ -159,7 +151,6 @@
UpdateChecksum(&instruction_set_features_bitmap_, sizeof(instruction_set_features_bitmap_));
UpdateChecksum(&dex_file_count_, sizeof(dex_file_count_));
UpdateChecksum(&image_file_location_oat_checksum_, sizeof(image_file_location_oat_checksum_));
- UpdateChecksum(&image_file_location_oat_data_begin_, sizeof(image_file_location_oat_data_begin_));
// Update checksum for variable data size.
UpdateChecksum(&key_value_store_size_, sizeof(key_value_store_size_));
@@ -362,26 +353,6 @@
quick_to_interpreter_bridge_offset_ = offset;
}
-int32_t OatHeader::GetImagePatchDelta() const {
- CHECK(IsValid());
- return image_patch_delta_;
-}
-
-void OatHeader::RelocateOat(off_t delta) {
- CHECK(IsValid());
- CHECK_ALIGNED(delta, kPageSize);
- image_patch_delta_ += delta;
- if (image_file_location_oat_data_begin_ != 0) {
- image_file_location_oat_data_begin_ += delta;
- }
-}
-
-void OatHeader::SetImagePatchDelta(int32_t off) {
- CHECK(IsValid());
- CHECK_ALIGNED(off, kPageSize);
- image_patch_delta_ = off;
-}
-
uint32_t OatHeader::GetImageFileLocationOatChecksum() const {
CHECK(IsValid());
return image_file_location_oat_checksum_;
@@ -392,17 +363,6 @@
image_file_location_oat_checksum_ = image_file_location_oat_checksum;
}
-uint32_t OatHeader::GetImageFileLocationOatDataBegin() const {
- CHECK(IsValid());
- return image_file_location_oat_data_begin_;
-}
-
-void OatHeader::SetImageFileLocationOatDataBegin(uint32_t image_file_location_oat_data_begin) {
- CHECK(IsValid());
- CHECK_ALIGNED(image_file_location_oat_data_begin, kPageSize);
- image_file_location_oat_data_begin_ = image_file_location_oat_data_begin;
-}
-
uint32_t OatHeader::GetKeyValueStoreSize() const {
CHECK(IsValid());
return key_value_store_size_;
@@ -481,10 +441,6 @@
return sizeof(OatHeader) + key_value_store_size_;
}
-bool OatHeader::IsPic() const {
- return IsKeyEnabled(OatHeader::kPicKey);
-}
-
bool OatHeader::IsDebuggable() const {
return IsKeyEnabled(OatHeader::kDebuggableKey);
}
diff --git a/runtime/oat.h b/runtime/oat.h
index 037c8f9..963725a 100644
--- a/runtime/oat.h
+++ b/runtime/oat.h
@@ -32,13 +32,12 @@
class PACKED(4) OatHeader {
public:
static constexpr uint8_t kOatMagic[] = { 'o', 'a', 't', '\n' };
- // Last oat version changed reason: Add stack map fast path for GC.
- static constexpr uint8_t kOatVersion[] = { '1', '6', '1', '\0' };
+ // Last oat version changed reason: Remove PIC option from oat files.
+ static constexpr uint8_t kOatVersion[] = { '1', '6', '2', '\0' };
static constexpr const char* kImageLocationKey = "image-location";
static constexpr const char* kDex2OatCmdLineKey = "dex2oat-cmdline";
static constexpr const char* kDex2OatHostKey = "dex2oat-host";
- static constexpr const char* kPicKey = "pic";
static constexpr const char* kDebuggableKey = "debuggable";
static constexpr const char* kNativeDebuggableKey = "native-debuggable";
static constexpr const char* kCompilerFilter = "compiler-filter";
@@ -95,17 +94,11 @@
uint32_t GetQuickToInterpreterBridgeOffset() const;
void SetQuickToInterpreterBridgeOffset(uint32_t offset);
- int32_t GetImagePatchDelta() const;
- void RelocateOat(off_t delta);
- void SetImagePatchDelta(int32_t off);
-
InstructionSet GetInstructionSet() const;
uint32_t GetInstructionSetFeaturesBitmap() const;
uint32_t GetImageFileLocationOatChecksum() const;
void SetImageFileLocationOatChecksum(uint32_t image_file_location_oat_checksum);
- uint32_t GetImageFileLocationOatDataBegin() const;
- void SetImageFileLocationOatDataBegin(uint32_t image_file_location_oat_data_begin);
uint32_t GetKeyValueStoreSize() const;
const uint8_t* GetKeyValueStore() const;
@@ -113,7 +106,6 @@
bool GetStoreKeyValuePairByIndex(size_t index, const char** key, const char** value) const;
size_t GetHeaderSize() const;
- bool IsPic() const;
bool IsDebuggable() const;
bool IsNativeDebuggable() const;
CompilerFilter::Filter GetCompilerFilter() const;
@@ -149,11 +141,7 @@
uint32_t quick_resolution_trampoline_offset_;
uint32_t quick_to_interpreter_bridge_offset_;
- // The amount that the image this oat is associated with has been patched.
- int32_t image_patch_delta_;
-
uint32_t image_file_location_oat_checksum_;
- uint32_t image_file_location_oat_data_begin_;
uint32_t key_value_store_size_;
uint8_t key_value_store_[0]; // note variable width data at end
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 8f84a4b..0579b6e 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -1995,11 +1995,6 @@
method->SetEntryPointFromQuickCompiledCode(GetQuickCode());
}
-bool OatFile::IsPic() const {
- return GetOatHeader().IsPic();
- // TODO: Check against oat_patches. b/18144996
-}
-
bool OatFile::IsDebuggable() const {
return GetOatHeader().IsDebuggable();
}
diff --git a/runtime/oat_file.h b/runtime/oat_file.h
index f20c603..b3736e6 100644
--- a/runtime/oat_file.h
+++ b/runtime/oat_file.h
@@ -129,8 +129,6 @@
return is_executable_;
}
- bool IsPic() const;
-
// Indicates whether the oat file was compiled with full debugging capability.
bool IsDebuggable() const;
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index 4ed7e35..009abdb 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -58,9 +58,6 @@
case OatFileAssistant::kOatBootImageOutOfDate:
stream << "kOatBootImageOutOfDate";
break;
- case OatFileAssistant::kOatRelocationOutOfDate:
- stream << "kOatRelocationOutOfDate";
- break;
case OatFileAssistant::kOatUpToDate:
stream << "kOatUpToDate";
break;
@@ -442,43 +439,6 @@
return kOatDexOutOfDate;
}
- if (CompilerFilter::IsAotCompilationEnabled(current_compiler_filter)) {
- if (!file.IsPic()) {
- const ImageInfo* image_info = GetImageInfo();
- if (image_info == nullptr) {
- VLOG(oat) << "No image to check oat relocation against.";
- return kOatRelocationOutOfDate;
- }
-
- // Verify the oat_data_begin recorded for the image in the oat file matches
- // the actual oat_data_begin for boot.oat in the image.
- const OatHeader& oat_header = file.GetOatHeader();
- uintptr_t oat_data_begin = oat_header.GetImageFileLocationOatDataBegin();
- if (oat_data_begin != image_info->oat_data_begin) {
- VLOG(oat) << file.GetLocation() <<
- ": Oat file image oat_data_begin (" << oat_data_begin << ")"
- << " does not match actual image oat_data_begin ("
- << image_info->oat_data_begin << ")";
- return kOatRelocationOutOfDate;
- }
-
- // Verify the oat_patch_delta recorded for the image in the oat file matches
- // the actual oat_patch_delta for the image.
- int32_t oat_patch_delta = oat_header.GetImagePatchDelta();
- if (oat_patch_delta != image_info->patch_delta) {
- VLOG(oat) << file.GetLocation() <<
- ": Oat file image patch delta (" << oat_patch_delta << ")"
- << " does not match actual image patch delta ("
- << image_info->patch_delta << ")";
- return kOatRelocationOutOfDate;
- }
- } else {
- // Oat files compiled in PIC mode do not require relocation.
- VLOG(oat) << "Oat relocation test skipped for PIC oat file";
- }
- } else {
- VLOG(oat) << "Oat relocation test skipped for compiler filter " << current_compiler_filter;
- }
return kOatUpToDate;
}
@@ -709,7 +669,6 @@
case kOatDexOutOfDate:
case kOatBootImageOutOfDate: return false;
- case kOatRelocationOutOfDate:
case kOatUpToDate: return true;
}
UNREACHABLE();
@@ -776,7 +735,6 @@
bool downgrade,
ClassLoaderContext* context) {
- bool compilation_desired = CompilerFilter::IsAotCompilationEnabled(target);
bool filter_okay = CompilerFilterIsOkay(target, profile_changed, downgrade);
bool class_loader_context_okay = ClassLoaderContextIsOkay(context);
@@ -788,16 +746,6 @@
return kNoDexOptNeeded;
}
- if (filter_okay && !compilation_desired && Status() == kOatRelocationOutOfDate) {
- // If no compilation is desired, then it doesn't matter if the oat
- // file needs relocation. It's in good shape as is.
- return kNoDexOptNeeded;
- }
-
- if (filter_okay && Status() == kOatRelocationOutOfDate) {
- return kDex2OatForRelocation;
- }
-
if (IsUseable()) {
return kDex2OatForFilter;
}
@@ -945,10 +893,6 @@
VLOG(oat) << "Oat File Assistant: No relocated oat file found,"
<< " attempting to fall back to interpreting oat file instead.";
- if (Status() == kOatRelocationOutOfDate && !IsExecutable()) {
- return ReleaseFile();
- }
-
switch (Status()) {
case kOatBootImageOutOfDate:
// OutOfDate may be either a mismatched image, or a missing image.
@@ -961,19 +905,6 @@
// go forward.
FALLTHROUGH_INTENDED;
- case kOatRelocationOutOfDate:
- // We are loading an oat file for runtime use that needs relocation.
- // Reload the file non-executable to ensure that we interpret out of the
- // dex code in the oat file rather than trying to execute the unrelocated
- // compiled code.
- oat_file_assistant_->load_executable_ = false;
- Reset();
- if (IsUseable()) {
- CHECK(!IsExecutable());
- return ReleaseFile();
- }
- break;
-
case kOatUpToDate:
case kOatCannotOpen:
case kOatDexOutOfDate:
@@ -1026,11 +957,6 @@
*out_compilation_filter = "run-from-vdex-fallback";
}
return;
-
- case kOatRelocationOutOfDate:
- // On relocation-out-of-date, we'd run the dex code.
- *out_compilation_filter = "run-from-vdex-fallback";
- return;
}
LOG(FATAL) << "Unreachable";
UNREACHABLE();
diff --git a/runtime/oat_file_assistant.h b/runtime/oat_file_assistant.h
index dbfbdf9..3da1a22 100644
--- a/runtime/oat_file_assistant.h
+++ b/runtime/oat_file_assistant.h
@@ -66,11 +66,6 @@
// is out of date with respect to the target compiler filter.
// Matches Java: dalvik.system.DexFile.DEX2OAT_FOR_FILTER
kDex2OatForFilter = 3,
-
- // dex2oat should be run to update the apk/jar because the existing code
- // is not relocated to match the boot image.
- // Matches Java: dalvik.system.DexFile.DEX2OAT_FOR_RELOCATION
- kDex2OatForRelocation = 4,
};
enum OatStatus {
@@ -85,13 +80,6 @@
// dex file, but is out of date with respect to the boot image.
kOatBootImageOutOfDate,
- // kOatRelocationOutOfDate - The oat file is up to date with respect to
- // the dex file and boot image, but contains compiled code that has the
- // wrong patch delta with respect to the boot image. Patchoat should be
- // run on the oat file to update the patch delta of the compiled code to
- // match the boot image.
- kOatRelocationOutOfDate,
-
// kOatUpToDate - The oat file is completely up to date with respect to
// the dex file and boot image.
kOatUpToDate,
diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc
index 6ee3bdb..efdefb1 100644
--- a/runtime/oat_file_assistant_test.cc
+++ b/runtime/oat_file_assistant_test.cc
@@ -228,13 +228,13 @@
EXPECT_EQ(nullptr, oat_file.get());
}
-// Case: We have a DEX file and a PIC ODEX file, but no OAT file.
-// Expect: The status is kNoDexOptNeeded, because PIC needs no relocation.
+// Case: We have a DEX file and an ODEX file, but no OAT file.
+// Expect: The status is kNoDexOptNeeded.
TEST_F(OatFileAssistantTest, OdexUpToDate) {
std::string dex_location = GetScratchDir() + "/OdexUpToDate.jar";
std::string odex_location = GetOdexDir() + "/OdexUpToDate.odex";
Copy(GetDexSrc1(), dex_location);
- GeneratePicOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed, "install");
+ GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed, "install");
// For the use of oat location by making the dex parent not writable.
OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false);
@@ -258,14 +258,14 @@
// Case: We have a DEX file and a PIC ODEX file, but no OAT file. We load the dex
// file via a symlink.
-// Expect: The status is kNoDexOptNeeded, because PIC needs no relocation.
+// Expect: The status is kNoDexOptNeeded.
TEST_F(OatFileAssistantTest, OdexUpToDateSymLink) {
std::string scratch_dir = GetScratchDir();
std::string dex_location = GetScratchDir() + "/OdexUpToDate.jar";
std::string odex_location = GetOdexDir() + "/OdexUpToDate.odex";
Copy(GetDexSrc1(), dex_location);
- GeneratePicOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
+ GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
// Now replace the dex location with a symlink.
std::string link = scratch_dir + "/link";
@@ -325,8 +325,7 @@
VerifyOptimizationStatus(dex_location, CompilerFilter::kSpeed, "unknown");
}
-// Case: Passing valid file descriptors of updated odex/vdex filesalong with
-// the dex file.
+// Case: Passing valid file descriptors of updated odex/vdex files along with the dex file.
// Expect: The status is kNoDexOptNeeded.
TEST_F(OatFileAssistantTest, GetDexOptNeededWithFd) {
std::string dex_location = GetScratchDir() + "/OatUpToDate.jar";
@@ -337,9 +336,7 @@
GenerateOatForTest(dex_location.c_str(),
odex_location.c_str(),
CompilerFilter::kSpeed,
- true,
- false,
- false);
+ /* with_alternate_image */ false);
android::base::unique_fd odex_fd(open(odex_location.c_str(), O_RDONLY));
android::base::unique_fd vdex_fd(open(vdex_location.c_str(), O_RDONLY));
@@ -378,9 +375,7 @@
GenerateOatForTest(dex_location.c_str(),
odex_location.c_str(),
CompilerFilter::kSpeed,
- true,
- false,
- false);
+ /* with_alternate_image */ false);
android::base::unique_fd vdex_fd(open(vdex_location.c_str(), O_RDONLY));
android::base::unique_fd zip_fd(open(dex_location.c_str(), O_RDONLY));
@@ -413,9 +408,7 @@
GenerateOatForTest(dex_location.c_str(),
odex_location.c_str(),
CompilerFilter::kSpeed,
- true,
- false,
- false);
+ /* with_alternate_image */ false);
android::base::unique_fd odex_fd(open(odex_location.c_str(), O_RDONLY));
android::base::unique_fd zip_fd(open(dex_location.c_str(), O_RDONLY));
@@ -737,9 +730,7 @@
Copy(GetDexSrc1(), dex_location);
GenerateOatForTest(dex_location.c_str(),
CompilerFilter::kSpeed,
- /*relocate*/true,
- /*pic*/false,
- /*with_alternate_image*/true);
+ /* with_alternate_image */ true);
ScopedNonWritable scoped_non_writable(dex_location);
ASSERT_TRUE(scoped_non_writable.IsSuccessful());
@@ -774,9 +765,7 @@
Copy(GetDexSrc1(), dex_location);
GenerateOatForTest(dex_location.c_str(),
CompilerFilter::kExtract,
- /*relocate*/true,
- /*pic*/false,
- /*with_alternate_image*/true);
+ /* with_alternate_image */ true);
ScopedNonWritable scoped_non_writable(dex_location);
ASSERT_TRUE(scoped_non_writable.IsSuccessful());
@@ -807,11 +796,11 @@
EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
oat_file_assistant.GetDexOptNeeded(CompilerFilter::kExtract));
- EXPECT_EQ(-OatFileAssistant::kDex2OatForRelocation,
+ EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
- EXPECT_EQ(OatFileAssistant::kOatRelocationOutOfDate, oat_file_assistant.OdexFileStatus());
+ EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OdexFileStatus());
EXPECT_EQ(OatFileAssistant::kOatCannotOpen, oat_file_assistant.OatFileStatus());
EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
@@ -827,7 +816,7 @@
// Create the dex and odex files
Copy(GetDexSrc1(), dex_location);
- GeneratePicOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
+ GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
// Strip the dex file
Copy(GetStrippedDexSrc1(), dex_location);
@@ -863,7 +852,7 @@
// Create the odex file
Copy(GetDexSrc1(), dex_location);
- GeneratePicOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
+ GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
// Strip the dex file.
Copy(GetStrippedDexSrc1(), dex_location);
@@ -923,9 +912,8 @@
EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
}
-// Case: We have a DEX file, an ODEX file and an OAT file, where the ODEX and
-// OAT files both have patch delta of 0.
-// Expect: It shouldn't crash.
+// Case: We have a DEX file, an ODEX file and an OAT file.
+// Expect: It shouldn't crash. We should load the odex file executable.
TEST_F(OatFileAssistantTest, OdexOatOverlap) {
std::string dex_location = GetScratchDir() + "/OdexOatOverlap.jar";
std::string odex_location = GetOdexDir() + "/OdexOatOverlap.odex";
@@ -933,31 +921,23 @@
// Create the dex, the odex and the oat files.
Copy(GetDexSrc1(), dex_location);
GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
- GenerateOatForTest(dex_location.c_str(),
- CompilerFilter::kSpeed,
- /*relocate*/false,
- /*pic*/false,
- /*with_alternate_image*/false);
+ GenerateOatForTest(dex_location.c_str(), CompilerFilter::kSpeed);
// Verify things don't go bad.
OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
- // -kDex2OatForRelocation is expected rather than kDex2OatForRelocation
- // based on the assumption that the odex location is more up-to-date than the oat
- // location, even if they both need relocation.
- EXPECT_EQ(-OatFileAssistant::kDex2OatForRelocation,
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
+ EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
+ oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
- EXPECT_EQ(OatFileAssistant::kOatRelocationOutOfDate, oat_file_assistant.OdexFileStatus());
- EXPECT_EQ(OatFileAssistant::kOatRelocationOutOfDate, oat_file_assistant.OatFileStatus());
+ EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OdexFileStatus());
+ EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OatFileStatus());
EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
- // Things aren't relocated, so it should fall back to interpreted.
std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
ASSERT_TRUE(oat_file.get() != nullptr);
- EXPECT_FALSE(oat_file->IsExecutable());
+ EXPECT_TRUE(oat_file->IsExecutable());
std::vector<std::unique_ptr<const DexFile>> dex_files;
dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
EXPECT_EQ(1u, dex_files.size());
@@ -1247,7 +1227,7 @@
}
// Case: We have a DEX file and an ODEX file, and no OAT file,
-// Expect: We should load the odex file non-executable.
+// Expect: We should load the odex file executable.
TEST_F(DexoptTest, LoadDexOdexNoOat) {
std::string dex_location = GetScratchDir() + "/LoadDexOdexNoOat.jar";
std::string odex_location = GetOdexDir() + "/LoadDexOdexNoOat.odex";
@@ -1261,14 +1241,14 @@
std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
ASSERT_TRUE(oat_file.get() != nullptr);
- EXPECT_FALSE(oat_file->IsExecutable());
+ EXPECT_TRUE(oat_file->IsExecutable());
std::vector<std::unique_ptr<const DexFile>> dex_files;
dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
EXPECT_EQ(1u, dex_files.size());
}
// Case: We have a MultiDEX file and an ODEX file, and no OAT file.
-// Expect: We should load the odex file non-executable.
+// Expect: We should load the odex file executable.
TEST_F(DexoptTest, LoadMultiDexOdexNoOat) {
std::string dex_location = GetScratchDir() + "/LoadMultiDexOdexNoOat.jar";
std::string odex_location = GetOdexDir() + "/LoadMultiDexOdexNoOat.odex";
@@ -1282,7 +1262,7 @@
std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
ASSERT_TRUE(oat_file.get() != nullptr);
- EXPECT_FALSE(oat_file->IsExecutable());
+ EXPECT_TRUE(oat_file->IsExecutable());
std::vector<std::unique_ptr<const DexFile>> dex_files;
dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
EXPECT_EQ(2u, dex_files.size());
@@ -1314,7 +1294,6 @@
{OatFileAssistant::kDex2OatFromScratch, "DEX2OAT_FROM_SCRATCH"},
{OatFileAssistant::kDex2OatForBootImage, "DEX2OAT_FOR_BOOT_IMAGE"},
{OatFileAssistant::kDex2OatForFilter, "DEX2OAT_FOR_FILTER"},
- {OatFileAssistant::kDex2OatForRelocation, "DEX2OAT_FOR_RELOCATION"},
};
ScopedObjectAccess soa(Thread::Current());
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index bcad4a3..1f0b265 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -72,7 +72,6 @@
CHECK_NE(oat_file->Begin(), existing->Begin()) << "Oat file already mapped at that location";
}
}
- have_non_pic_oat_file_ = have_non_pic_oat_file_ || !oat_file->IsPic();
const OatFile* ret = oat_file.get();
oat_files_.insert(std::move(oat_file));
return ret;
@@ -143,7 +142,7 @@
}
OatFileManager::OatFileManager()
- : have_non_pic_oat_file_(false), only_use_system_oat_files_(false) {}
+ : only_use_system_oat_files_(false) {}
OatFileManager::~OatFileManager() {
// Explicitly clear oat_files_ since the OatFile destructor calls back into OatFileManager for
diff --git a/runtime/oat_file_manager.h b/runtime/oat_file_manager.h
index 80456e9..4132b25 100644
--- a/runtime/oat_file_manager.h
+++ b/runtime/oat_file_manager.h
@@ -65,11 +65,6 @@
const OatFile* FindOpenedOatFileFromDexLocation(const std::string& dex_base_location) const
REQUIRES(!Locks::oat_file_manager_lock_);
- // Returns true if we have a non pic oat file.
- bool HaveNonPicOatFile() const {
- return have_non_pic_oat_file_;
- }
-
// Returns the boot image oat files.
std::vector<const OatFile*> GetBootOatFiles() const;
@@ -142,7 +137,6 @@
std::string* error_msg);
std::set<std::unique_ptr<const OatFile>> oat_files_ GUARDED_BY(Locks::oat_file_manager_lock_);
- bool have_non_pic_oat_file_;
// Only use the compiled code in an OAT file when the file is on /system. If the OAT file
// is not on /system, don't load it "executable".
diff --git a/test/117-nopatchoat/nopatchoat.cc b/test/117-nopatchoat/nopatchoat.cc
index a8a895a..c673dd7 100644
--- a/test/117-nopatchoat/nopatchoat.cc
+++ b/test/117-nopatchoat/nopatchoat.cc
@@ -46,18 +46,6 @@
return oat_dex_file != nullptr && oat_dex_file->GetOatFile()->IsExecutable();
}
-
- static bool needsRelocation(jclass cls) {
- const OatDexFile* oat_dex_file = getOatDexFile(cls);
-
- if (oat_dex_file == nullptr) {
- return false;
- }
-
- const OatFile* oat_file = oat_dex_file->GetOatFile();
- return !oat_file->IsPic()
- && CompilerFilter::IsAotCompilationEnabled(oat_file->GetCompilerFilter());
- }
};
extern "C" JNIEXPORT jboolean JNICALL Java_Main_isRelocationDeltaZero(JNIEnv*, jclass) {
@@ -68,8 +56,4 @@
return NoPatchoatTest::hasExecutableOat(cls);
}
-extern "C" JNIEXPORT jboolean JNICALL Java_Main_needsRelocation(JNIEnv*, jclass cls) {
- return NoPatchoatTest::needsRelocation(cls);
-}
-
} // namespace art
diff --git a/test/117-nopatchoat/src/Main.java b/test/117-nopatchoat/src/Main.java
index ef47ab9..dfb98b0 100644
--- a/test/117-nopatchoat/src/Main.java
+++ b/test/117-nopatchoat/src/Main.java
@@ -18,13 +18,7 @@
public static void main(String[] args) {
System.loadLibrary(args[0]);
- // With a relocationDelta of 0, the runtime has no way to determine if the oat file in
- // ANDROID_DATA has been relocated, since a non-relocated oat file always has a 0 delta.
- // Hitting this condition should be rare and ideally we would prevent it from happening but
- // there is no way to do so without major changes to the run-test framework.
- boolean executable_correct = (needsRelocation() ?
- hasExecutableOat() == isRelocationDeltaZero() :
- hasExecutableOat() == true);
+ boolean executable_correct = hasExecutableOat();
System.out.println(
"Has oat is " + hasOatFile() + ", has executable oat is " + (
@@ -42,8 +36,6 @@
return ret.substring(0, ret.length() - 1);
}
- private native static boolean needsRelocation();
-
private native static boolean hasOatFile();
private native static boolean hasExecutableOat();