我正在尝试编译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操作的详细输出,更改gcc为clang,并运行它来创建.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 传递?
我需要使用两个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)