This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Undefined Behavior Sanitizer UBSan

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?

Parents
  • 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-ubsan

    See also github.com/.../ubsan

    Hope this helps

    Stephen

Reply
  • 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-ubsan

    See also github.com/.../ubsan

    Hope this helps

    Stephen

Children