Chromium Code Reviews| Index: src/IceASanInstrumentation.cpp |
| diff --git a/src/IceASanInstrumentation.cpp b/src/IceASanInstrumentation.cpp |
| index e7c531bdec2030f062926a6246affa827c8a5d0b..e245e299bc4606484eac82ab51d83ff8839c1398 100644 |
| --- a/src/IceASanInstrumentation.cpp |
| +++ b/src/IceASanInstrumentation.cpp |
| @@ -363,6 +363,26 @@ void ASanInstrumentation::instrumentCall(LoweringContext &Context, |
| void ASanInstrumentation::instrumentLoad(LoweringContext &Context, |
| InstLoad *Instr) { |
| + Operand *Src = Instr->getSourceAddress(); |
| + auto *Reloc = llvm::dyn_cast<ConstantRelocatable>(Src); |
| + if (Reloc != nullptr) { |
|
Jim Stichnoth
2016/08/16 21:36:46
if (auto *Reloc = llvm::dyn_cast<ConstantRelocatab
tlively
2016/08/16 21:55:38
Done.
|
| + std::string SrcName = Reloc->getName().toStringOrEmpty(); |
| + assert(!SrcName.empty()); |
| + StringMap::const_iterator SrcSub = FuncSubstitutions.find(SrcName); |
| + if (SrcSub != FuncSubstitutions.end()) { |
| + auto *NewSrc = ConstantRelocatable::create( |
| + Ctx, Reloc->getType(), |
| + RelocatableTuple(Reloc->getOffset(), RelocOffsetArray(0), |
| + Ctx->getGlobalString(SrcSub->second), |
| + Reloc->getEmitString())); |
| + auto *NewLoad = InstLoad::create(Context.getNode()->getCfg(), |
| + Instr->getDest(), NewSrc); |
| + Instr->setDeleted(); |
| + Context.insert(NewLoad); |
| + instrumentLoad(Context, NewLoad); |
|
Karl
2016/08/16 21:38:43
Do you need to recurse here? It looks like you jus
tlively
2016/08/16 21:55:38
Done.
|
| + return; |
| + } |
| + } |
| Constant *Func = |
| Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_check_load")); |
| instrumentAccess(Context, Instr->getSourceAddress(), |
| @@ -417,7 +437,8 @@ void ASanInstrumentation::instrumentAccess(LoweringContext &Context, |
| Context.setNext(Next); |
| } |
| -// TODO(tlively): Trace back load and store addresses to find their real offsets |
| +// TODO(tlively): Trace back load and store addresses to find their real |
|
Jim Stichnoth
2016/08/16 21:36:46
Why did this line change?
tlively
2016/08/16 21:55:38
Done.
|
| +// offsets |
| bool ASanInstrumentation::isOkGlobalAccess(Operand *Op, SizeT Size) { |
| auto *Reloc = llvm::dyn_cast<ConstantRelocatable>(Op); |
| if (Reloc == nullptr) |