| Issue |
60578
|
| Summary |
[UBSAN] Undefined references with `-Wl,--no-undefined`
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Lastique
|
When linking a shared library with `-Wl,--no-undefined` switch and UBSAN enabled, the linking fails with unresolved references to UBSAN symbols.
Here's a test case:
`ubsan_unresolved_test.cpp`:
```
int test(int n)
{
return n + 10;
}
```
Commands:
```
clang++ -stdlib=libc++ -fsanitize=undefined -fno-sanitize-recover=undefined -o ubsan_unresolved_test.o -c ubsan_unresolved_test.cpp
clang++ -stdlib=libc++ -fsanitize=undefined -fuse-ld=gold -Wl,--no-undefined -shared -o ubsan_unresolved_test.so ubsan_unresolved_test.o
```
Output:
```
ubsan_unresolved_test.o:ubsan_unresolved_test.cpp:function test(int): error: undefined reference to '__ubsan_handle_add_overflow_abort'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
clang version:
```
$ clang -v
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs