[compiler-rt] [sanitizer_common] mark __elf_aux_vector as weak on FreeBSD (PR #118110)
Dimitry Andric via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 29 08:48:42 PST 2024
https://github.com/DimitryAndric updated https://github.com/llvm/llvm-project/pull/118110
>From ac5218e39a35e201fe7de6bd4754b4b8517b98de Mon Sep 17 00:00:00 2001
From: Dimitry Andric <dimitry at andric.com>
Date: Fri, 29 Nov 2024 17:29:02 +0100
Subject: [PATCH] [sanitizer_common] mark __elf_aux_vector as weak on FreeBSD
At some point FreeBSD introduced libsys as a wrapper between syscalls
and libc, and then linking sanitized programs started failing with:
# c++ -fsanitize=address main.cc
ld: error: undefined symbol: __elf_aux_vector
>>> referenced by sanitizer_linux_libcdep.cpp:950 (/usr/src/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp:950)
>>> sanitizer_linux_libcdep.o:(__sanitizer::ReExec()) in archive /usr/lib/clang/17/lib/freebsd/libclang_rt.asan-x86_64.a
c++: error: linker command failed with exit code 1 (use -v to see invocation)
Mark __elf_aux_vector as weak in the internal sanitizer declaration, so
the linker will accept it at link time. The dynamic linker will then
take care of the symbol at run time.
---
compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 525bc1038619d8..62b1dc43dce136 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -57,7 +57,7 @@
// that, it was never implemented. So just define it to zero.
# undef MAP_NORESERVE
# define MAP_NORESERVE 0
-extern const Elf_Auxinfo *__elf_aux_vector;
+extern const Elf_Auxinfo *__elf_aux_vector __attribute__((weak));
extern "C" int __sys_sigaction(int signum, const struct sigaction *act,
struct sigaction *oldact);
# endif
More information about the llvm-commits
mailing list