diff options
author | Vladimir Marko <vmarko@google.com> | 2015-05-13 19:06:30 +0100 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2015-05-14 13:41:41 +0100 |
commit | a36098b3717e14baf6a173e72082f6ef3b7bcefd (patch) | |
tree | f52b4be71f2d9182bbf751a6949ef2d74c380c57 /compiler | |
parent | 3beb245da9392818e3154d47593f82cf0ef69aac (diff) | |
download | art-a36098b3717e14baf6a173e72082f6ef3b7bcefd.zip art-a36098b3717e14baf6a173e72082f6ef3b7bcefd.tar.gz art-a36098b3717e14baf6a173e72082f6ef3b7bcefd.tar.bz2 |
ART: Do not relocate app program headers in patchoat.
Change the check whether to relocate program headers in
patchoat to simply look whether there is a PT_LOAD section
with p_vaddr == 0. If there is, don't relocate the headers,
it should be an app. Otherwise, it's a boot image and needs
to be relocated.
Add overflow checking to ElfFileImpl<>::GetLoadedSize().
Bug: 21047854
(cherry picked from commit 3fc9903407c6e89ffbbc92ded9e272d9de58e9b6)
Change-Id: Ib3e1295fc06993bcfbaadd8f253ee4f5498f52e9
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/elf_writer.cc | 13 | ||||
-rw-r--r-- | compiler/elf_writer.h | 4 | ||||
-rw-r--r-- | compiler/image_writer.cc | 2 |
3 files changed, 10 insertions, 9 deletions
diff --git a/compiler/elf_writer.cc b/compiler/elf_writer.cc index 47402f3..f75638d 100644 --- a/compiler/elf_writer.cc +++ b/compiler/elf_writer.cc @@ -39,16 +39,17 @@ uintptr_t ElfWriter::GetOatDataAddress(ElfFile* elf_file) { } void ElfWriter::GetOatElfInformation(File* file, - size_t& oat_loaded_size, - size_t& oat_data_offset) { + size_t* oat_loaded_size, + size_t* oat_data_offset) { std::string error_msg; std::unique_ptr<ElfFile> elf_file(ElfFile::Open(file, false, false, &error_msg)); CHECK(elf_file.get() != nullptr) << error_msg; - oat_loaded_size = elf_file->GetLoadedSize(); - CHECK_NE(0U, oat_loaded_size); - oat_data_offset = GetOatDataAddress(elf_file.get()); - CHECK_NE(0U, oat_data_offset); + bool success = elf_file->GetLoadedSize(oat_loaded_size, &error_msg); + CHECK(success) << error_msg; + CHECK_NE(0U, *oat_loaded_size); + *oat_data_offset = GetOatDataAddress(elf_file.get()); + CHECK_NE(0U, *oat_data_offset); } bool ElfWriter::Fixup(File* file, uintptr_t oat_data_begin) { diff --git a/compiler/elf_writer.h b/compiler/elf_writer.h index 033c1f8..8e13b51 100644 --- a/compiler/elf_writer.h +++ b/compiler/elf_writer.h @@ -38,8 +38,8 @@ class ElfWriter { // Looks up information about location of oat file in elf file container. // Used for ImageWriter to perform memory layout. static void GetOatElfInformation(File* file, - size_t& oat_loaded_size, - size_t& oat_data_offset); + size_t* oat_loaded_size, + size_t* oat_data_offset); // Returns runtime oat_data runtime address for an opened ElfFile. static uintptr_t GetOatDataAddress(ElfFile* elf_file); diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index 4dc7509..195949b 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -166,7 +166,7 @@ bool ImageWriter::Write(const std::string& image_filename, size_t oat_loaded_size = 0; size_t oat_data_offset = 0; - ElfWriter::GetOatElfInformation(oat_file.get(), oat_loaded_size, oat_data_offset); + ElfWriter::GetOatElfInformation(oat_file.get(), &oat_loaded_size, &oat_data_offset); Thread::Current()->TransitionFromSuspendedToRunnable(); CreateHeader(oat_loaded_size, oat_data_offset); |