My Summer with LLVM [under construction]



I will talk about a few products from LLVM here which I had to use in my project. There are a zillion more of them.

Basically, the concept of taking a program written in a hig-level language and compiling it to an intermediate representation (bitcode) is what we can achieve using LLVM. This helps in having the ability to transfer/delegate work (compiled code) across heterogenous devices. For example, we can compile a program using LLVM on device1 and share that bitcode to other devices such that they can recompile that bitcode according to their architecture and run that same program. Because LLVM has a bunch of optimizations it can impose on this bitcode, the amount of work in achieving cross-compatability decreases tremendously.

So what are some of the tools we can use to do this?

Example 1: Finding Memory Corruptions


Now lets look at a simple example that involves these tools and see if we can prevent some vulnerabilities from happening. We will make a slight modification to asan, build compiler-rt and clang with that modification and compile a C program using clang and asan. Then we will debug that program using lldb and see how asan works and how our change affects the way these tools work.

Example 2: Finding Programmer Errors


Now lets look at another way of improving security. Instrument the code with rich metadata that can be useful in preventing programmer errors.

Code base


Here is a link to the codebase. There are 2 parts to it.

Future Work


Going forward, the biggest goal is to complete the metadata part.