Compiling and running LLVM IR code on your machine

Moderator: Applied Static Analysis

bhermann
Moderator
Moderator
Beiträge: 15
Registriert: 17. Aug 2012 19:51

Compiling and running LLVM IR code on your machine

Beitrag von bhermann » 19. Mai 2016 15:55

Since I've been caught a little bit off-guard on this issue in the lecture, here are some pointers to actually make something meaningful with (transformed) programs in LLVM IR bitcode.

If you want to compile down an executable ELF file:

Code: Alles auswählen

llvm@68e3b3fbd8a7:~/examples$ clang -c -emit-llvm test.c
llvm@68e3b3fbd8a7:~/examples$ llc-3.6 test.bc
llvm@68e3b3fbd8a7:~/examples$ gcc test.s -o test
llvm@68e3b3fbd8a7:~/examples$ ./test 2 2
2
You can also interpret the LLVM bitcode on the fly:

Code: Alles auswählen

llvm@68e3b3fbd8a7:~/examples$ clang -c -emit-llvm test.c
llvm@68e3b3fbd8a7:~/examples$ llc-3.6 test.bc
llvm@68e3b3fbd8a7:~/examples$ lli-3.6 test.bc 2 2
2
Have fun with your (transformed) programs. :)

Zurück zu „Applied Static Analysis“