diff options
Diffstat (limited to 'patchoat')
| -rw-r--r-- | patchoat/patchoat.cc | 15 | ||||
| -rw-r--r-- | patchoat/patchoat.h | 20 |
2 files changed, 19 insertions, 16 deletions
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc index 504addc054..8e5af53e66 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -24,9 +24,11 @@ #include <string> #include <vector> +#include "base/dumpable.h" #include "base/scoped_flock.h" #include "base/stringpiece.h" #include "base/stringprintf.h" +#include "base/unix_file/fd_file.h" #include "elf_utils.h" #include "elf_file.h" #include "elf_file_impl.h" @@ -513,7 +515,7 @@ bool PatchOat::PatchOatHeader(ElfFileImpl* oat_file) { } bool PatchOat::PatchElf() { - if (oat_file_->is_elf64_) + if (oat_file_->Is64Bit()) return PatchElf<ElfFileImpl64>(oat_file_->GetImpl64()); else return PatchElf<ElfFileImpl32>(oat_file_->GetImpl32()); @@ -531,13 +533,12 @@ bool PatchOat::PatchElf(ElfFileImpl* oat_file) { } bool need_fixup = false; - for (unsigned int i = 0; i < oat_file->GetProgramHeaderNum(); i++) { + for (unsigned int i = 0; i < oat_file->GetProgramHeaderNum(); ++i) { auto hdr = oat_file->GetProgramHeader(i); - if (hdr->p_vaddr != 0 && hdr->p_vaddr != hdr->p_offset) { - need_fixup = true; - } - if (hdr->p_paddr != 0 && hdr->p_paddr != hdr->p_offset) { + if ((hdr->p_vaddr != 0 && hdr->p_vaddr != hdr->p_offset) || + (hdr->p_paddr != 0 && hdr->p_paddr != hdr->p_offset)) { need_fixup = true; + break; } } if (!need_fixup) { @@ -801,7 +802,7 @@ static int patchoat(int argc, char **argv) { bool dump_timings = kIsDebugBuild; bool lock_output = true; - for (int i = 0; i < argc; i++) { + for (int i = 0; i < argc; ++i) { const StringPiece option(argv[i]); const bool log_options = false; if (log_options) { diff --git a/patchoat/patchoat.h b/patchoat/patchoat.h index 7dd95f5d6b..fd36ad59a3 100644 --- a/patchoat/patchoat.h +++ b/patchoat/patchoat.h @@ -52,7 +52,8 @@ class PatchOat { private: // Takes ownership only of the ElfFile. All other pointers are only borrowed. PatchOat(ElfFile* oat_file, off_t delta, TimingLogger* timings) - : oat_file_(oat_file), delta_(delta), timings_(timings) {} + : oat_file_(oat_file), image_(nullptr), bitmap_(nullptr), heap_(nullptr), delta_(delta), + timings_(timings) {} PatchOat(MemMap* image, gc::accounting::ContinuousSpaceBitmap* bitmap, MemMap* heap, off_t delta, TimingLogger* timings) : image_(image), bitmap_(bitmap), heap_(heap), @@ -106,21 +107,22 @@ class PatchOat { void operator() (mirror::Class* cls, mirror::Reference* ref) const EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_, Locks::heap_bitmap_lock_); private: - PatchOat* patcher_; - mirror::Object* copy_; + PatchOat* const patcher_; + mirror::Object* const copy_; }; // The elf file we are patching. std::unique_ptr<ElfFile> oat_file_; // A mmap of the image we are patching. This is modified. - const MemMap* image_; + const MemMap* const image_; + // The bitmap over the image within the heap we are patching. This is not modified. + gc::accounting::ContinuousSpaceBitmap* const bitmap_; // The heap we are patching. This is not modified. - gc::accounting::ContinuousSpaceBitmap* bitmap_; - // The heap we are patching. This is not modified. - const MemMap* heap_; + const MemMap* const heap_; // The amount we are changing the offset by. - off_t delta_; - TimingLogger* timings_; + const off_t delta_; + // Timing splits. + TimingLogger* const timings_; DISALLOW_IMPLICIT_CONSTRUCTORS(PatchOat); }; |