Skip to content

Commit 867a1d6

Browse files
[sanitizer_common] mark __elf_aux_vector as weak on FreeBSD (#118110)
At some point FreeBSD introduced libsys as a wrapper between syscalls and libc, and then linking sanitized programs started failing with: ```text # 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.
1 parent 5f881b7 commit 867a1d6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
// that, it was never implemented. So just define it to zero.
5858
# undef MAP_NORESERVE
5959
# define MAP_NORESERVE 0
60-
extern const Elf_Auxinfo *__elf_aux_vector;
60+
extern const Elf_Auxinfo *__elf_aux_vector __attribute__((weak));
6161
extern "C" int __sys_sigaction(int signum, const struct sigaction *act,
6262
struct sigaction *oldact);
6363
# endif

0 commit comments

Comments
 (0)