Skip to content

Commit 552bdae

Browse files
author
anoopkg6
committed
Resolve Endianess issue with getting shadow 4 bytes corresponding to the first origin pointer
1 parent 424fa83 commit 552bdae

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,8 +2187,14 @@ std::pair<Value *, Value *> DFSanFunction::loadShadowFast(
21872187
// and then the entire shadow for the second origin pointer (which will be
21882188
// chosen by combineOrigins() iff the least-significant half of the wide
21892189
// shadow was empty but the other half was not).
2190-
Value *WideShadowLo = IRB.CreateShl(
2191-
WideShadow, ConstantInt::get(WideShadowTy, WideShadowBitWidth / 2));
2190+
Value *WideShadowLo =
2191+
F->getParent()->getDataLayout().isLittleEndian()
2192+
? IRB.CreateShl(
2193+
WideShadow,
2194+
ConstantInt::get(WideShadowTy, WideShadowBitWidth / 2))
2195+
: IRB.CreateAnd(
2196+
WideShadow,
2197+
ConstantInt::get(WideShadowTy, 0xFFFFFFFF00000000ULL));
21922198
Shadows.push_back(WideShadow);
21932199
Origins.push_back(DFS.loadNextOrigin(Pos, OriginAlign, &OriginAddr));
21942200

0 commit comments

Comments
 (0)