Pointers LLVM IR显示结构元素的{}*
我一直在尝试为自定义Linux模块找到所有可能的函数到函数指针的赋值。然而,有一种情况是LLVM IR显示一个结构包含一个Pointers LLVM IR显示结构元素的{}*,pointers,struct,clang,llvm,llvm-ir,Pointers,Struct,Clang,Llvm,Llvm Ir,我一直在尝试为自定义Linux模块找到所有可能的函数到函数指针的赋值。然而,有一种情况是LLVM IR显示一个结构包含一个{}*类型作为元素 问题在于,{}*应该是所述结构中的函数指针: %struct.file_operations = type { %struct.module*, i64 (%struct.file*, i64, i32)*, i64 (%struct.file*, i8*, i64, i64*)*, i64 (%struct.file*,
{}*
类型作为元素
问题在于,{}*
应该是所述结构中的函数指针:
%struct.file_operations = type {
%struct.module*,
i64 (%struct.file*, i64, i32)*,
i64 (%struct.file*, i8*, i64, i64*)*,
i64 (%struct.file*, i8*, i64, i64*)*,
i64 (%struct.kiocb*, %struct.iov_iter*)*,
i64 (%struct.kiocb*, %struct.iov_iter*)*,
i32 (%struct.kiocb*, i1)*,
i32 (%struct.file*, %struct.dir_context*)*,
i32 (%struct.file*, %struct.dir_context*)*,
i32 (%struct.file*, %struct.poll_table_struct*)*,
i64 (%struct.file*, i32, i64)*,
i64 (%struct.file*, i32, i64)*,
i32 (%struct.file*, %struct.vm_area_struct*)*,
i64,
{}*,
[...]
我碰巧通过索引14
访问了这个struct元素(摘录或LLVM IR格式,并因相关性而缩短)。根据我用于此操作的Linux内核版本,索引14
指的是结构文件\u操作的open
函数指针成员:
struct file_operations {
[...]
int (*open) (struct inode *, struct file *);
[...]
}
通过查看分配给我自己的lkm_open
函数的LLVM IR,确认它是open
函数指针:
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
为了让我的LLVM分析工作,我需要这个struct元素的正确类型,因为我认为这不是正确的类型。。。根据上面的存储
指令,类型不应为{}*
,而是:
i32 (%struct.inode*, %struct.file*)*
在LLVM IR中,{}*
是什么意思?为什么它是唯一以这种方式描述的结构成员(没有其他函数指针)