@@ -89,14 +89,14 @@ MockBuilder::MockBuilder(
8989 std::vector<std::pair<std::string, std::string>> &redefinitions,
9090 InterpreterHandler *interpreterHandler,
9191 std::set<std::string> &mainModuleFunctions,
92- std::set<std::string> &mainModuleGlobals)
92+ std::set<std::string> &mainModuleGlobals,
93+ const AnnotationsData &annotationsData)
9394 : userModule(initModule), ctx(initModule->getContext ()), opts(opts),
9495 interpreterOptions(interpreterOptions),
9596 ignoredExternals(ignoredExternals), redefinitions(redefinitions),
9697 interpreterHandler(interpreterHandler),
9798 mainModuleFunctions(mainModuleFunctions),
98- mainModuleGlobals(mainModuleGlobals),
99- annotationsData(opts.AnnotationsFile, opts.TaintAnnotationsFile) {}
99+ mainModuleGlobals(mainModuleGlobals), annotationsData(annotationsData) {}
100100
101101std::unique_ptr<llvm::Module> MockBuilder::build () {
102102 initMockModule ();
@@ -535,7 +535,7 @@ MockBuilder::buildCallKleeTaintFunction(const std::string &functionName,
535535 {llvm::Type::getInt8PtrTy (mockModule->getContext ()),
536536 llvm::Type::getInt64Ty (mockModule->getContext ())},
537537 false );
538- auto kleeAddTaintCallee =
538+ auto kleeTaintFunctionCallee =
539539 mockModule->getOrInsertFunction (functionName, kleeTaintFunctionType);
540540
541541 // //TODO: that's not all:
@@ -579,13 +579,15 @@ MockBuilder::buildCallKleeTaintFunction(const std::string &functionName,
579579 if (!source->getType ()->isPointerTy () && !source->getType ()->isArrayTy ()) {
580580 beginPtr = builder->CreateAlloca (source->getType ());
581581 builder->CreateStore (source, beginPtr);
582+ beginPtr = builder->CreateBitCast (
583+ beginPtr, llvm::Type::getInt8PtrTy (mockModule->getContext ()));
582584 } else {
583585 beginPtr = builder->CreateBitCast (
584586 source, llvm::Type::getInt8PtrTy (mockModule->getContext ()));
585587 }
586588
587589 return builder->CreateCall (
588- kleeAddTaintCallee ,
590+ kleeTaintFunctionCallee ,
589591 {beginPtr, llvm::ConstantInt::get (mockModule->getContext (),
590592 llvm::APInt (64 , taint, false ))});
591593}
@@ -847,6 +849,14 @@ void MockBuilder::buildAnnotationForExternalFunctionReturn(
847849 std::string retName = " ret_" + func->getName ().str ();
848850 llvm::Value *retValuePtr = builder->CreateAlloca (returnType, nullptr );
849851
852+ // TODO: fix strange type ("fopen" mock, store instruction)
853+ // if (func->getName() == "fopen") {
854+ // buildCallKleeMakeSymbolic("klee_make_mock", retValuePtr, returnType,
855+ // func->getName().str());
856+ // llvm::Value *retValue = builder->CreateLoad(returnType, retValuePtr,
857+ // retName); builder->CreateRet(retValue); return;
858+ // }
859+
850860 if (returnType->isPointerTy () && (allocSourcePtr || mustInitNull)) {
851861 processingValue (retValuePtr, returnType, allocSourcePtr,
852862 mustInitNull || maybeInitNull);
0 commit comments