小编Kev*_*oos的帖子

将Linux内核模块编译为LLVM .bc bitcode

背景

我正在尝试编译Linux内核中的某些驱动程序:drm(drivers/gpu/drm/drm_drv.o)和radeon(drivers/gpu/drm/radeon/)gpu驱动程序.我正在使用LLVM进行静态分析(跟踪copy_to/from_user()调用中使用的参数).

到目前为止,我能够使用Makefile编译实际模块,如下所示:

make CC=clang CFLAGS=-emit-llvm drivers/gpu/drm/radeon/ 

但这实际上并没有发出任何llvm bitcode - 我需要.bc文件来运行我的传递opt.

我只知道如何.bc直接使用clang(如下所示)生成文件,但不能使用Makefile ...

clang -emit-llvm hello.c -c -o hello.bc 

由于这个工作,我抓住了GNU make操作的详细输出,更改gccclang,并运行它来创建.bc文件,这也起作用:

 clang -emit-llvm  [[tons of CFLAGS]]  -c -o drm_drv.bc drivers/gpu/drm/drm_drv.c 

唯一的问题是我一次只能处理内核模块中的单个C文件.这种做法也非常繁琐......

主要问题

这让我.bc想到了我的主要问题:如何使用内核的Makefile发布llvm bitcode文件?

或者,如果.bc必须在每个文件的基础上创建bitcode,那么我将如何将它们全部链接在一起,以便我可以在内核模块中opt的所有.bc文件的聚合上运行LLVM 传递?

makefile llvm clang linux-kernel

10
推荐指数
1
解决办法
2037
查看次数

ARM Linux页表项格式 - 未使用的位?

我需要使用两个PTE位来存储我的内核模块在拦截页面保护错误时将使用的自定义"状态"值.

我正在开发Galaxy Nexus,它有一个ARM Cortex A9(我相信ARM v7).Linux内核版本3.0.31.Linux PTE定义如下(来自arch/arm/include/asm/pgtable.h:

/*
 * "Linux" PTE definitions.
 *
 * We keep two sets of PTEs - the hardware and the linux version.
 * This allows greater flexibility in the way we map the Linux bits
 * onto the hardware tables, and allows us to have YOUNG and DIRTY
 * bits.
 *
 * The PTE table pointer refers to the hardware entries; the "Linux"
 * entries are stored 1024 bytes below.
 */
#define L_PTE_PRESENT …
Run Code Online (Sandbox Code Playgroud)

arm virtual-memory linux-kernel

7
推荐指数
1
解决办法
2110
查看次数

标签 统计

linux-kernel ×2

arm ×1

clang ×1

llvm ×1

makefile ×1

virtual-memory ×1