summaryrefslogtreecommitdiffstats
path: root/compiler/compiled_method.h
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2016-02-04 20:01:32 +0000
committerVladimir Marko <vmarko@google.com>2016-02-04 20:19:58 +0000
commit34ed3afc41820c72a3c0ab9770be66b6668aa029 (patch)
tree6d22fb81b21cff59e21320dd91bb6b66da97acbd /compiler/compiled_method.h
parente99d23aba15f540b52d69d58bd7aee710dfc0610 (diff)
downloadart-34ed3afc41820c72a3c0ab9770be66b6668aa029.tar.gz
art-34ed3afc41820c72a3c0ab9770be66b6668aa029.tar.bz2
art-34ed3afc41820c72a3c0ab9770be66b6668aa029.zip
ART: Avoid uninitialized padding in LinkerPatch.
Bug: 26956807 Change-Id: I0cb54a4443109de9bc95728d96bd1f80810e68a3
Diffstat (limited to 'compiler/compiled_method.h')
-rw-r--r--compiler/compiled_method.h6
1 files changed, 4 insertions, 2 deletions
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);