From a6e225f62810c1c35550b8de369e8720e6ec8a16 Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Thu, 4 Jun 2020 11:54:26 +0100 Subject: Explicitly track global variables in getDirectCallTarget Global variables can't be a direct call target. Their values are read and treated as indirect call targets. --- lib/Module/ModuleUtil.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/Module') diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index bce6de97..974667e3 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -263,7 +263,14 @@ Function *klee::getDirectCallTarget( // Walk through aliases and bitcasts to try to find // the function being called. do { - if (Function *f = dyn_cast(v)) { + if (isa(v)) { + // We don't care how we got this GlobalVariable + viaConstantExpr = false; + + // Global variables won't be a direct call target. Instead, their + // value need to be read and is handled as indirect call target. + v = nullptr; + } else if (Function *f = dyn_cast(v)) { return f; } else if (llvm::GlobalAlias *ga = dyn_cast(v)) { #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) -- cgit 1.4.1