I compile my code with -fsanitize=address switch. I have my own llvm pass that I want to execute. By the time the pass starts, I can see that the ASAN pass was made. Is it possible to run my pass before the ASAN pass?
Asked
Active
Viewed 115 times
1 Answers
0
I‘ve also tried to run my pass before the ASAN pass in different ways to instrument my program at BasicBlock-level.
And this seems to be available for me:
Register a "StandardPasses" with EP_EarlyAsPossible
flag which makes your pass works earlier than ASAN.
static RegisterStandardPasses Y(PassManagerBuilder::EP_EarlyAsPossible,
[](const PassManagerBuilder &Builder,
legacy::PassManagerBase &PM) {
PM.add(new MyPass());
});
Compile your pass as a ".so" file.
Then use clang -Xclang -load -Xclang xxYourPassxx.so -fsanitize=address main.c -o main
to compile your code.
I also compiled the main.bc & main.ll for checking. And the results show me that my instrumentation doesn't appear in ASAN's block (Because my pass runs before ASAN).

Coldshield
- 1
- 2