Run LLVM skip with option

I have just started working with LLVM. I wrote my own Hello pass that worked great.

Now I want to run the pass pass pass option, from StackProtector.cpp, but I am having problems with that. When I look at the source code, it looks like I should be using the -stack-protector flag:

INITIALIZE_PASS(StackProtector, "stack-protector", "Insert stack protectors", false, false)

      

But this flag is not recognized by the option.

I'm not sure which file to download as it is not as easy as downloading my own LLVMHello.so file and I couldn't find the StackProtector.so file; I believe this could be a problem.

Edit:

I finally got a response from LLVMDev. In fact, the pass I wanted to run is done by llc, not opt. I couldn't find a -stack-protector option though, with

llc --help

      

because this parameter is hidden. If instead I do

llc --help-hidden

      

shown that there is a pass and I just need to run

llc -print-before=stack-protector <input>

      

+3


source to share


1 answer


First you add to your pass:

static RegisterPass<StackProtector> X("StackProtector", "Insert stack protectors", false, false);

      

Secondly, in the terminal, when you run a pass on the target file, after running make, you have something like:



//home/YOURNAME/llvm/Release+Asserts/bin/opt -load //home/YOURNAME/llvm/Release+Asserts/lib/StackProtector.so -StackProtector //home/YOURNAME/llvm/tools/clang/woRKSPACE/Test.bc

      

where Test.bc is your target code. Also, remember: in your Makefile, don't forget to add LIBRARYNAME = StackProtector

.

Also, keep in mind if the pass has not been registered yet (if so, you will get a segfault error)

+2


source







All Articles