diff options
Diffstat (limited to 'patchoat/patchoat.h')
-rw-r--r-- | patchoat/patchoat.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/patchoat/patchoat.h b/patchoat/patchoat.h index 61ec695d83..64efea9d68 100644 --- a/patchoat/patchoat.h +++ b/patchoat/patchoat.h @@ -18,6 +18,7 @@ #define ART_PATCHOAT_PATCHOAT_H_ #include "arch/instruction_set.h" +#include "base/enums.h" #include "base/macros.h" #include "base/mutex.h" #include "elf_file.h" @@ -168,7 +169,7 @@ class PatchOat { } auto ret = reinterpret_cast<uintptr_t>(obj) + delta_; // Trim off high bits in case negative relocation with 64 bit patchoat. - if (InstructionSetPointerSize(isa_) == sizeof(uint32_t)) { + if (Is32BitISA()) { ret = static_cast<uintptr_t>(static_cast<uint32_t>(ret)); } return reinterpret_cast<T*>(ret); @@ -181,12 +182,16 @@ class PatchOat { } T ret = obj + delta_; // Trim off high bits in case negative relocation with 64 bit patchoat. - if (InstructionSetPointerSize(isa_) == 4) { + if (Is32BitISA()) { ret = static_cast<T>(static_cast<uint32_t>(ret)); } return ret; } + bool Is32BitISA() const { + return InstructionSetPointerSize(isa_) == PointerSize::k32; + } + // Walks through the old image and patches the mmap'd copy of it to the new offset. It does not // change the heap. class PatchVisitor { |