Skip to content

Commit ce071c8

Browse files
anoopkg6anoopkg6
authored andcommitted
[dfsan] Fix getShadowAddress computation (llvm#162864)
Fix getShadowAddress computation by adding ShadowBase if it is not zero. Co-authored-by: anoopkg6 <[email protected]>
1 parent 982ca1e commit ce071c8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,8 +1957,12 @@ Value *DataFlowSanitizer::getShadowAddress(Value *Addr,
19571957
Value *DataFlowSanitizer::getShadowAddress(Value *Addr,
19581958
BasicBlock::iterator Pos) {
19591959
IRBuilder<> IRB(Pos->getParent(), Pos);
1960-
Value *ShadowOffset = getShadowOffset(Addr, IRB);
1961-
return getShadowAddress(Addr, Pos, ShadowOffset);
1960+
Value *ShadowAddr = getShadowOffset(Addr, IRB);
1961+
uint64_t ShadowBase = MapParams->ShadowBase;
1962+
if (ShadowBase != 0)
1963+
ShadowAddr =
1964+
IRB.CreateAdd(ShadowAddr, ConstantInt::get(IntptrTy, ShadowBase));
1965+
return getShadowAddress(Addr, Pos, ShadowAddr);
19621966
}
19631967

19641968
Value *DFSanFunction::combineShadowsThenConvert(Type *T, Value *V1, Value *V2,

0 commit comments

Comments
 (0)