- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在位代码级别检测对程序每个函数的调用。假设有一个函数 void f(int a)
,我需要在 main 函数的开头检测以下代码。
int a;
klee_make_symbolic(&a, sizeof(a), "a");
f(a);
我写了一个通行证来实现这一点。
for (Module::iterator f = M.begin(), fe = M.end(); f != fe; ++f) {
std::vector<llvm::Value*> args;
for(Function::arg_iterator ai = f->arg_begin(), ae = f->arg_end(); ai != ae; ++ai){
Type* tp = ai->getType();
AllocaInst* arg = new AllocaInst(tp, "name", firstInst);
args.push_back(arg);
LLVM_TYPE_Q llvm::Type *i8Ty = Type::getInt8Ty(getGlobalContext());
Constant *fc = M.getOrInsertFunction("klee_make_symbolic",
PointerType::getUnqual(i8Ty),
Type::getInt64Ty(getGlobalContext()),
PointerType::getUnqual(i8Ty),
NULL);
Function* kleeMakeSymbolic = cast<Function>(fc);
std::vector<Value* > klee_args;
klee_args.push_back(arg);
klee_args.push_back(ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
dl->getTypeAllocSizeInBits(tp)));// dl is DataLayout
klee_args.push_back(arg);//I dont't know how to pass a argument of "const char *"
// Inject a call to klee_make_symbolic
CallInst::Create(kleeMakeSymbolic, klee_args, "", firstInst);
}
// Inject a call to the function
CallInst::Create(f, args, "", firstInst);
}
但是我得到了一个断言失败:
llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, const llvm::Twine&): Assertion `(Args.size() == FTy->getNumParams() || (FTy->isVarArg() && Args.size() > FTy->getNumParams())) && "Calling a function with bad signature!"' failed.
我是 LLVm 的新手,有人能告诉我我的实现有什么问题吗?
最佳答案
您正在将 a
的指针传递给函数 f
。那是您的实现的问题。
在你的代码中:
for (Module::iterator f = M.begin(), fe = M.end(); f != fe; ++f) {
std::vector<llvm::Value*> args;
for(Function::arg_iterator ai = f->arg_begin(), ae = f->arg_end(); ai != ae; ++ai){
Type* tp = ai->getType();
AllocaInst* arg = new AllocaInst(tp, "name", firstInst);
args.push_back(arg);
...
}
// Inject a call to the function
CallInst::Create(f, args, "", firstInst);
}
您正在将 arg
推送到您的 args
向量中。 arg
是AllocaInst
的值,因此它是一个指针。您需要适合您的函数签名的值。您需要发出从 AllocaInst
加载的 LoadInst
并将 LoadInst
推送到您的向量中。
针对您的问题:
klee_args.push_back(arg);//I dont't know how to pass a argument of "const char *"
查看 IRBuilder
中的 CreateGlobalStringPtr
函数。文档 here . IRBuilder
是一个很好的辅助类,它使 LLVM IR 的使用变得更容易一些。
关于llvm - 在 LLVM IR 中检测函数调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27663178/
我已经设置了自定义 SSIS IR,但是从 IR 节点上的当前工作目录或临时文件夹读取文件时遇到问题 https://learn.microsoft.com/en-us/sql/integration
我已经编写了一个修改中间表示 (IR) 代码的 LLVM pass。为了增加可移植性,我还希望它与 gcc 编译器一起工作。所以我想知道是否有任何工具可以将 gcc 的某些中间表示 (IR) 转换为
我已经下载了 Sony Android Add-on IR SDK ( http://developer.sonymobile.com/knowledge-base/sdks/sony-add-on-
我在手机中使用其他应用程序,使用它的 IR。但是当我尝试在任何项目中使用 IREmitter 时,它会触发该错误! mCIR = (ConsumerIrManager)getSystemService
我想找到一些 Clang/LLVM 的调试选项,其工作方式类似于 GCC -fdump-tree-all-all , -fdump-rtl-all ,和 -fdump-ipa-all-all . 基本
我使用 LLVM opt 来运行一个传递,例如,opt -load libMyPass.so my-pass foo.ll > foo1.ll。 foo.ll 是一个 IR 文件,我希望 foo1.l
我在 Raspian jessie(无像素)(所有更新和升级)上安装了当前的 lirc 包(0.9.0~pre1-1.2)并连接到(lirc 默认)GPIO 端口: 到 gpio 端口 17 - 通过
在学习 Antlr4 时,我使用 Golang 作为目标语言,所以我的玩具语言中的语句如下: $myVar = 10 $myVar + 5 将转换为一些生成结果“15”的 Golang 代码 但是,据
我正在尝试使用 SSIS 脚本任务连接到本地 REST Web 服务,并在 Azure 数据工厂的 SSIS-IR 上运行它,该 SSIS-IR 具有自托管 IR 的代理,最终连接到本地服务器。可行吗
我正在尝试关注 this链接以便为 c 代码生成 IR 表示。我使用的c代码如下 void main() { int c1 = 17; int c2 = 25; int c3 = c1 + c2
在为 lto 链接后,有没有办法获得 llvm IR?例如,我有以下行: $ clang -flto -O2 a.c main.c -fuse-ld=gold -v -save-temps 所以我想获
我正在通过这个学习 LLVM IR LangRef . 如本引用所述: LLVM programs are composed of Modules, each of which is a transl
如果这个问题听起来很愚蠢,我很抱歉。 为什么inverse document frequency使用日志?日志在 tf/idf 中有何帮助? 最佳答案 AFAIK,使用日志有助于使用几何分布对数字进行
我建立了一个LLVM定位前端,该前端会产生一些IR。随后并且完全可以预期,在某些情况下,IR输出是不正确的(例如,它看起来正确,但是执行时结果程序崩溃)。但是,我还没有找到很多有用的工具来解决这一问题
我想将C#编译为LLVM IR。因此,我认为将编译的CIL转换为LLVM IR是我可以尝试的一种方法。 我可以使用一些工具,例如vmkit和mono-llvm。 有人在使用此工具吗?或者如何将CIL转
如何创建图像以及如何使用十六进制颜色代码逐像素为其着色? 例如。我想创建一个 100x100 像素的图像,并且我想要 1x1 区域的颜色为“$002125”,2x2 区域的颜色为“$125487”..
我正在测试一个 main 函数,它只返回 void 并且在使用 lli 运行位码时出现核心转储错误(信号 65 或 73)。 : define void @main() { entry: ret
我收到一个要求,其中我有一个 c 文件,并且我正在为其生成 LLVM IR。从为每条指令生成的 LLVM IR 中,我正在计算执行需要多少个周期,现在我的问题是如何追溯到 C 代码并显示特定的 C 代
我目前正在尝试运行其他人留下的 sql 命令/脚本来建立数据库。他们有这个脚本 BEGIN; \ir file.sql \ir file.sql END; 它在第一个反斜杠处给出错误。我正在使用 Po
我特别需要在我的 C++ 代码运行期间逐行解析 LLVM IR 代码,我需要知道每行的哪些操作数发生了什么操作。 例如,如果 IR 代码是: %0 = load i32* %a, align 4 我想
我是一名优秀的程序员,十分优秀!