summaryrefslogtreecommitdiffstats
path: root/compiler/image_writer.cc
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2016-03-15 12:41:27 +0000
committerVladimir Marko <vmarko@google.com>2016-03-15 13:24:11 +0000
commitd9813cb37254a72b08424359c7ef80f6a2136a74 (patch)
tree006621a324a56508f2792e722a7b901cfe474175 /compiler/image_writer.cc
parent5681b6638b0001c62d02795b0853e2e82787edf1 (diff)
downloadandroid_art-d9813cb37254a72b08424359c7ef80f6a2136a74.tar.gz
android_art-d9813cb37254a72b08424359c7ef80f6a2136a74.tar.bz2
android_art-d9813cb37254a72b08424359c7ef80f6a2136a74.zip
ART: Fix valgrind failure in image_test64.
Explicitly clear LengthPrefixedArray<ArtMethod> padding in ImageWriter. This also removes a potential source of non-deterministic data in compiled boot image. Bug: 26687569 Bug: 27552451 Change-Id: Icf4bf34c9ea5b3159462760fbf556d287841191d
Diffstat (limited to 'compiler/image_writer.cc')
-rw-r--r--compiler/image_writer.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc
index b1b971f6ba..0b6981016d 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -1542,15 +1542,16 @@ void ImageWriter::CopyAndFixupNativeData(size_t oat_index) {
}
case kNativeObjectRelocationTypeArtMethodArrayClean:
case kNativeObjectRelocationTypeArtMethodArrayDirty: {
- memcpy(dest, pair.first, LengthPrefixedArray<ArtMethod>::ComputeSize(
- 0,
- ArtMethod::Size(target_ptr_size_),
- ArtMethod::Alignment(target_ptr_size_)));
+ size_t size = ArtMethod::Size(target_ptr_size_);
+ size_t alignment = ArtMethod::Alignment(target_ptr_size_);
+ memcpy(dest, pair.first, LengthPrefixedArray<ArtMethod>::ComputeSize(0, size, alignment));
+ // Clear padding to avoid non-deterministic data in the image (and placate valgrind).
+ reinterpret_cast<LengthPrefixedArray<ArtMethod>*>(dest)->ClearPadding(size, alignment);
break;
+ }
case kNativeObjectRelocationTypeDexCacheArray:
// Nothing to copy here, everything is done in FixupDexCache().
break;
- }
}
}
// Fixup the image method roots.