[compiler-rt] r337170 - [cfi] Don't pass a uint16_t to memset. Make sure the 16-bit constant is appropriate for us.
Filipe Cabecinhas via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 16 06:41:54 PDT 2018
Author: filcab
Date: Mon Jul 16 06:41:54 2018
New Revision: 337170
URL: http://llvm.org/viewvc/llvm-project?rev=337170&view=rev
Log:
[cfi] Don't pass a uint16_t to memset. Make sure the 16-bit constant is appropriate for us.
Reviewers: eugenis, pcc, kcc
Subscribers: delcypher, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D49252
Modified:
compiler-rt/trunk/lib/cfi/cfi.cc
Modified: compiler-rt/trunk/lib/cfi/cfi.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/cfi/cfi.cc?rev=337170&r1=337169&r2=337170&view=diff
==============================================================================
--- compiler-rt/trunk/lib/cfi/cfi.cc (original)
+++ compiler-rt/trunk/lib/cfi/cfi.cc Mon Jul 16 06:41:54 2018
@@ -132,7 +132,10 @@ void ShadowBuilder::Start() {
void ShadowBuilder::AddUnchecked(uptr begin, uptr end) {
uint16_t *shadow_begin = MemToShadow(begin, shadow_);
uint16_t *shadow_end = MemToShadow(end - 1, shadow_) + 1;
- memset(shadow_begin, kUncheckedShadow,
+ // memset takes a byte, so our unchecked shadow value requires both bytes to
+ // be the same. Make sure we're ok during compilation.
+ static_assert(kUncheckedShadow & 0xff == ((kUncheckedShadow >> 8) & 0xff));
+ memset(shadow_begin, kUncheckedShadow & 0xff,
(shadow_end - shadow_begin) * sizeof(*shadow_begin));
}
More information about the llvm-commits
mailing list