Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang: -shared -fsanitize=undefined doesn't link with libubsan #134504

Open
stsp opened this issue Apr 5, 2025 · 1 comment
Open

clang: -shared -fsanitize=undefined doesn't link with libubsan #134504

stsp opened this issue Apr 5, 2025 · 1 comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

Comments

@stsp
Copy link

stsp commented Apr 5, 2025

$ gcc -shared -o libex.so example.c -fsanitize=undefined
$ ldd libex.so
	linux-vdso.so.1 (0x000079ecce133000)
	libubsan.so.1 => /lib/x86_64-linux-gnu/libubsan.so.1 (0x000079eccda00000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x000079eccd600000)
	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x000079eccd200000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x000079ecce0df000)
	/lib64/ld-linux-x86-64.so.2 (0x000079ecce135000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x000079eccd913000)

$ clang -shared -fsanitize=undefined -o libex.so example.c
$ ldd libex.so
	linux-vdso.so.1 (0x000077ad748b4000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x000077ad74600000)
	/lib64/ld-linux-x86-64.so.2 (0x000077ad748b6000)

As the result, when used with
-Wl,--no-undefined this breaks
on clang, but works properly with
gcc.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Apr 5, 2025
stsp added a commit to dosemu2/dosemu2 that referenced this issue Apr 5, 2025
That breaks with ubsan+solib.
Filled the upstream bug:
llvm/llvm-project#134504
@EugeneZelenko EugeneZelenko added clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' and removed clang Clang issues not falling into any other category labels Apr 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 5, 2025

@llvm/issue-subscribers-clang-driver

Author: Stas Sergeev (stsp)

``` $ gcc -shared -o libex.so example.c -fsanitize=undefined $ ldd libex.so linux-vdso.so.1 (0x000079ecce133000) libubsan.so.1 => /lib/x86_64-linux-gnu/libubsan.so.1 (0x000079eccda00000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x000079eccd600000) libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x000079eccd200000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x000079ecce0df000) /lib64/ld-linux-x86-64.so.2 (0x000079ecce135000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x000079eccd913000)

$ clang -shared -fsanitize=undefined -o libex.so example.c
$ ldd libex.so
linux-vdso.so.1 (0x000077ad748b4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x000077ad74600000)
/lib64/ld-linux-x86-64.so.2 (0x000077ad748b6000)


As the result, when used with
`-Wl,--no-undefined` this breaks
on clang, but works properly with
gcc.
</details>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
Projects
None yet
Development

No branches or pull requests

3 participants