如何检查LLVM StoreInst的目标是否是函数指针
How to check if a target of an LLVM StoreInst is a function pointer
如何检查LLVM StoreInst
的存储目标是否是函数指针?
给定一个LLVM加载/存储指令,有两个独立的部分需要计算。首先,是什么类型的位置。第二,该类型是否满足某些属性,等等。
if (StoreInst *si = dyn_cast<StoreInst>(&*I))
{
Value* v = si->getPointerOperand();
Type* ptrType = v->getType()->getPointerElementType();
指针类型就是存储数据的类型。但我们想知道底层类型是否实际上是一个函数,从而使其成为函数指针(或指针指针,等等)。
if (PointerType* pt = dyn_cast<PointerType>(ptrType))
{
do {
// The call to getTypeAtIndex has to be made on a composite type
// And needs explicitly an unsigned int, otherwise 0
// can ambiguously be NULL.
Type* pointedType = pt->getTypeAtIndex((unsigned int)0);
if (pointedType->isFunctionTy())
{
errs() << "Found the underlying function typen";
break;
}
// This may be a pointer to a pointer to ...
ptrType = pointedType;
} while (pt = dyn_cast<PointerType>(ptrType));
这段代码检测到下面的store - store i8* (i8*)* @tFunc, i8* (i8*)** %8, align 8
,它将指向函数tFunc的指针存储到另一个位置。
相关文章:
- C++LDAP检查用户是否是特定组的成员
- 检查某些类型是否是模板类 std::optional 的实例化
- 将错误返回给调用方而不是立即在 C++ 中抛出错误是否是一种好的做法
- 如何检查模板专用化是否是基本模板的子类?
- 如何检查变量是否是C++中的地图?
- C++ Chrono 确定一天是否是周末?
- 将相同共享指针的副本存储在不同的向量中是否是一种好的做法?
- 使用类在C++中存储和列出变量/方法是否是一种好的做法
- 代码在 CodeSignal 中工作不正确。不确定这是否是我的代码缺陷
- 如果 C 函数仍然可以间接执行(通过回调函数),那么将它声明为静态函数是否是一种不好的做法?
- MFC 中的窗口消息管理:添加基类调用是否是强制性的?
- 检查 n2 是否是 n1 的倍数后结果错误,但根本没有错误
- C ++:检查它是否是类中的数字
- 传递给放置 new 的指针是否是指向其对象表示形式的非 UB 指针?
- 使用 SET(C++) 检查两个给定字符串是否是字谜时出现运行时错误
- 从 std::string 到 std::array<char,size> 的 memcopy 额外数据是否是一种未定义的行为?
- 有没有办法检查发送到变量的值是否是正确的类型,而它已经在该变量下?
- 如何检查一个模板是否是另一个模板的类成员
- 有没有办法检查用户输入是否是数字?
- 如何检查LLVM StoreInst的目标是否是函数指针