From 34ed3afc41820c72a3c0ab9770be66b6668aa029 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 4 Feb 2016 20:01:32 +0000 Subject: ART: Avoid uninitialized padding in LinkerPatch. Bug: 26956807 Change-Id: I0cb54a4443109de9bc95728d96bd1f80810e68a3 --- compiler/compiled_method.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'compiler/compiled_method.h') diff --git a/compiler/compiled_method.h b/compiler/compiled_method.h index 7a93613481..58876200ca 100644 --- a/compiler/compiled_method.h +++ b/compiler/compiled_method.h @@ -283,11 +283,13 @@ class LinkerPatch { static_assert(sizeof(element_offset_) == sizeof(cmp1_), "needed by relational operators"); }; union { - uint32_t cmp2_; // Used for relational operators. + // Note: To avoid uninitialized padding on 64-bit systems, we use `size_t` for `cmp2_`. + // This allows a hashing function to treat an array of linker patches as raw memory. + size_t cmp2_; // Used for relational operators. // Literal offset of the insn loading PC (same as literal_offset if it's the same insn, // may be different if the PC-relative addressing needs multiple insns). uint32_t pc_insn_offset_; - static_assert(sizeof(pc_insn_offset_) == sizeof(cmp2_), "needed by relational operators"); + static_assert(sizeof(pc_insn_offset_) <= sizeof(cmp2_), "needed by relational operators"); }; friend bool operator==(const LinkerPatch& lhs, const LinkerPatch& rhs); -- cgit v1.2.3-59-g8ed1b