diff options
author | 2019-03-13 10:52:39 +0000 | |
---|---|---|
committer | 2019-03-15 10:59:26 +0000 | |
commit | e37b7915908dba10e90c39a3a82cb0cd1dc05f5c (patch) | |
tree | 178e7fed04a9e93cb23cca83c276d6ea19e6caa4 | |
parent | 94b6c34aade019d6300c4b109885b3b6715d573e (diff) |
Fix ImageSpace relocation direction check.
The correct check whether `begin+diff` would overflow
uint32_t is `begin >= -diff` in unsigned arithmetic.
Note that with the current ranges of relocation diff and
ART_BASE_ADDRESS, the result of the check is the same as
before.
Test: m test-art-host-gtest
Bug: 77856493
Change-Id: Ic0ded458ad8fa327ea74e2e0ebdd4de18c4e5b04
-rw-r--r-- | runtime/gc/space/image_space.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index 173e879192..3d676ae93c 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -1625,7 +1625,7 @@ class ImageSpace::BootImageLoader { // First patch the image header. The `diff` is OK for patching 32-bit fields but // the 64-bit method fields in the ImageHeader may need a negative `delta`. reinterpret_cast<ImageHeader*>(space->Begin())->RelocateImage( - (reinterpret_cast32<uint32_t>(space->Begin()) < diff) + (reinterpret_cast32<uint32_t>(space->Begin()) >= -diff) // Would `begin+diff` overflow? ? -static_cast<int64_t>(-diff) : static_cast<int64_t>(diff)); // Patch fields and methods. |