In case somebody hits this, here's a resolved issue: -fno-wrapv is
matters for UBSan coverage.

Confusion starts with:

$ uname -srm; cat a.c && clang -fsanitize=undefined a.c -c -o a.o && nm a.o
OpenBSD 7.0 amd64
int main(int argc, char **argv) {
  int k = 0x7fffffff;
  k += argc;
  return 0;
}
00000000 W __llvm_retpoline_r11
00000000 W __retguard_2371
00000000 F a.c
00000000 T main

Notice the lack of `__ubsan` symbols. Adding -fno-wrav (which I found in
kernel Makefile.amd64) restores the desired instrumentation:

% clang -fsanitize=undefined -fno-wrapv a.c -c -o a.o && nm a.o
00000000 W __llvm_retpoline_r11
00000000 W __retguard_2371
         U __ubsan_handle_add_overflow
00000000 F a.c
00000000 T main

Reply via email to