[llvm-dev] Where does the LLVM implement the Ubsan's instrumentations?

Shi, Steven via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 21 06:04:31 PDT 2017


> > I think your best bet for controlling code bloat is to compile with
> > -fsanitize=undefined -fsanitize-trap=undefined.
> 
> Also you may not need all of UBSan's checks at the same time -- so pick
> and choose among its checks using the finer-grained flags.
> 
> If you're really stuck against a hard limit on code size, try applying
> UBSan to a subset of files in your project at a time.

Hi John,
Thank your suggestion. I like the trap-funcion way. With the compile options "-fsanitize=undefined -fsanitize-trap=undefined -ftrap-function=__my_trap_function", my firmware can save +40% code size. It is great! 

But I have another question about the trap-function. I hope to print the wrong code running IP address in my trap function (then, I can use llvm-symbolizer to know its code location), and I also hope to print undefined behavior specific type info, e.g. add_overflow, type_mismatch_v1, etc., which are defined in compiler-rt\lib\ubsan\ubsan_interface.inc. How should I correctly define the __my_sanitizer_trap() and let clang/llvm input relative info into my trap function?

Thanks
Steven



More information about the llvm-dev mailing list