[compiler-rt] 867a1d6 - [sanitizer_common] mark __elf_aux_vector as weak on FreeBSD (#118110)

via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 2 15:31:22 PST 2024


Author: Dimitry Andric
Date: 2024-12-03T00:31:19+01:00
New Revision: 867a1d621d1c6146dc29fa6b471407327d8f1bff

URL: https://github.com/llvm/llvm-project/commit/867a1d621d1c6146dc29fa6b471407327d8f1bff
DIFF: https://github.com/llvm/llvm-project/commit/867a1d621d1c6146dc29fa6b471407327d8f1bff.diff

LOG: [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.

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

Removed: 
    


################################################################################
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