Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get bitcode llvm after linking?

I am trying to get LLVM IR for a file which is linked with some static libararies.

I tried to link using llvm-link . It just copy the .bc files in one file ( not like native linking).

clang -L$(T_LIB_PATH) -lpthread -emit-llvm gives an error: emit-llvm can not be used with linking. When passing -c option, it gives warning that the linking options were not used.

My main goal is to get .bc file with all resolved symbols and references. How can I achieve that with clang version 3.4.?

like image 979
Hazem Abaza Avatar asked Oct 12 '20 22:10

Hazem Abaza


1 Answers

You may have a look at wllvm. It is a wrapper on the compiler, which enable to build a project and extract the LLVM bitcode of the whole program.

You need to use wllvm and wllvm++ for C and C++, respectively (after setting some environment variables).

like image 177
Thierry Titcheu Avatar answered Nov 03 '22 20:11

Thierry Titcheu