I’m trying to use the Clang UBSan Undefined Behavior Sanitizer on cortex-a53. I switched to using armclang as the linker instead of armlink as specified here. I use options: -fsanitize=undefined and -fsanitize-trap=all as described here. Linking fails and it looks like the linker cannot find a ubsan library. I see a lot of undefined symbol errors for symbols starting with __ubsan_... such as:
Error: L6218E: Undefined symbol __ubsan_handle_type_mismatch_v1.
Is UBSan available for ARM cortex-a53?
Hi there, thank you for asking a question. Please could you let me know where is best to moved your question to? Many thankshttps://community.arm.com/support-forums/
I think "ARM Development Studio Forum" would be a good fit. Thank you.
Thank you. I have moved this now.
Moving onto the Compiler and Libraries forum...
My name is Stephen and I work at Arm.Arm doesn't provide a UBSan handler function library, so if you use -fsanitize=minimal-runtime then it is up to you to define your own handler functions.However, if you use -fsanitize-trap=all then a runtime library shouldn't be necessary: any detectable UB violation leads to a trap instruction. There should be no function calls but instead just a direct insertion of halting / trapping instructions that cause an exception.It is possible that you've accidentally compiled a file without -fsanitize-trap=all ?There's an example in the open source LLVM For Embedded repo, which should translate to armclang:github.com/.../cpp-baremetal-semihosting-ubsanSee also github.com/.../ubsanHope this helpsStephen
I found that I had -fsanitize-trap=all as a linker option instead of a compiler option. changing it to a compiler option fixed the problem, the program compiles and links now with ubsan without any library being provided at link time, thanks!