sslab-gatech / unisan

UniSan: Proactive Kernel Memory Initialization to Eliminate Data Leakages
MIT License
42 stars 20 forks source link

How to use clang to complie linux kernel into LLVM IR? #5

Closed daydayup40 closed 6 years ago

daydayup40 commented 6 years ago

How to use clang to complie linux kernel into LLVM IR?

meng-xu commented 6 years ago

(Copied from the email I sent to you)

As of now, most part of the Linux kernel has built-in support for being compiled with LLVM by just adding CC=clang before make.

For details, check https://lkml.org/lkml/2017/11/22/943 and https://lwn.net/Articles/734071/ for the latest progress.

There are also wrappers that help you with the process, for example, https://github.com/ramosian-glider/clang-kernel-build (There are many on GitHub).

The very old schooled way (not sure whether it is still working now) is via the LLVMLinux proeject (https://wiki.linuxfoundation.org/llvmlinux).

daydayup40 commented 6 years ago

Thanks for your detail and early reply. I have follwed a tutorial to build a linux kernel like https://github.com/ramosian-glider/clang-kernel-build, but I cannot find any IR files(.bc and .ll) for analyze. I used make CC=$CLANG_PATH/clang CFLAG="-emit-llvm -c" command, but still not generate IR files. Could you tell me how did you generate the IR files(.bc and .ll) for analyze?