问题描述
我一直在尝试为自定义Linux模块的功能指针找到所有可能的功能分配。但是,在某些情况下,LLVM IR显示结构包含{}*
类型作为元素。
问题是{}*
应该是上述结构中的函数指针:
%struct.file_operations = type {
%struct.module*,i64 (%struct.file*,i64,i32)*,i8*,i64*)*,i64 (%struct.kiocb*,%struct.iov_iter*)*,i32 (%struct.kiocb*,i1)*,i32 (%struct.file*,%struct.dir_context*)*,%struct.poll_table_struct*)*,i32,i64)*,%struct.vm_area_struct*)*,{}*,[...]
我碰巧通过索引14
访问该struct元素(摘录或LLVM IR格式化并缩短了相关性)。根据我为此使用的Linux内核版本,索引14
引用结构open
的{{1}}函数指针成员:
file_operations
通过查看LLVM IR(已为其分配我自己的struct file_operations {
[...]
int (*open) (struct inode *,struct file *);
[...]
}
函数)来确认它是open
函数指针:
lkm_open
为使我的LLVM分析正常工作,我需要此struct元素的正确类型,因为我认为这不是正确的类型...根据上面的store i32 (%struct.inode*,%struct.file*)* @lkm_open,i32 (%struct.inode*,%struct.file*)** bitcast ({}** getelementptr inbounds (%struct.lkm_state,%struct.lkm_state* @lkm_state,i64 0,i32 3,i32 14) to i32 (%struct.inode*,%struct.file*)**),align 8
指令,该类型不应为store
,但:
{}*
i32 (%struct.inode*,%struct.file*)*
在LLVM IR中是什么意思?为什么它是唯一用这种方式描述的struct成员(没有其他函数指针)?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)