diff options
author | Ian Rogers <irogers@google.com> | 2014-10-16 20:31:53 -0700 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2014-10-16 21:30:37 -0700 |
commit | d4c4d953035d4418126d36517e402f411d6a87f3 (patch) | |
tree | 735aacf812bbac7c1ae7c0788c1ca6f58cfa82ee /patchoat | |
parent | 6f3dbbadf4ce66982eb3d400e0a74cb73eb034f3 (diff) | |
download | art-d4c4d953035d4418126d36517e402f411d6a87f3.zip art-d4c4d953035d4418126d36517e402f411d6a87f3.tar.gz art-d4c4d953035d4418126d36517e402f411d6a87f3.tar.bz2 |
Some code clean-up.
Change-Id: I4b745fd5298cd61c793e3b57514b48347bd66c0e
Diffstat (limited to 'patchoat')
-rw-r--r-- | patchoat/patchoat.cc | 14 | ||||
-rw-r--r-- | patchoat/patchoat.h | 20 |
2 files changed, 18 insertions, 16 deletions
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc index 504addc..c0c96e5 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -27,6 +27,7 @@ #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 +514,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 +532,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 +801,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 7dd95f5..fd36ad5 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); }; |