musllvm

A pure LLVM/Clang cross compiler toolchain targeting musl C
git clone git://git.daat.foo/musllvm.git
Log | Files | Refs | README | LICENSE

0008-compiler-rt-lsan-basic-musl-fixes-on-various-archs.patch (1847B)


      1 From da1c921a45908cd05aed5bd44245d2b424a8580a Mon Sep 17 00:00:00 2001
      2 From: q66 <q66@chimera-linux.org>
      3 Date: Sun, 14 Apr 2024 14:41:14 +0200
      4 Subject: [PATCH 08/29] compiler-rt: lsan: basic musl fixes on various archs
      5 
      6 ---
      7  .../lib/sanitizer_common/sanitizer_linux_libcdep.cpp  | 11 +++++++++++
      8  1 file changed, 11 insertions(+)
      9 
     10 diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
     11 index e11eff13c..96e823ae7 100644
     12 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
     13 +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
     14 @@ -28,6 +28,14 @@
     15  #  include "sanitizer_procmaps.h"
     16  #  include "sanitizer_solaris.h"
     17  
     18 +#if defined(__powerpc__)
     19 +#define DTP_OFFSET 0x8000
     20 +#elif SANITIZER_RISCV64
     21 +#define DTP_OFFSET 0x800
     22 +#else
     23 +#define DTP_OFFSET 0
     24 +#endif
     25 +
     26  #  if SANITIZER_NETBSD
     27  #    define _RTLD_SOURCE  // for __lwp_gettcb_fast() / __lwp_getprivate_fast()
     28  #  endif
     29 @@ -467,6 +475,7 @@ static int CollectStaticTlsBlocks(struct dl_phdr_info *info, size_t size,
     30      begin = (uptr)__tls_get_addr(mod_and_off);
     31  #    endif
     32    }
     33 +  begin -= DTP_OFFSET;
     34    for (unsigned i = 0; i != info->dlpi_phnum; ++i)
     35      if (info->dlpi_phdr[i].p_type == PT_TLS) {
     36        static_cast<InternalMmapVector<TlsBlock> *>(data)->push_back(
     37 @@ -624,9 +624,11 @@
     38  #        elif SANITIZER_FREEBSD
     39    *size += 128;  // RTLD_STATIC_TLS_EXTRA
     40  #          if defined(__mips__) || defined(__powerpc64__) || SANITIZER_RISCV64
     41 +#          if SANITIZER_GLIBC
     42    const uptr pre_tcb_size = TlsPreTcbSize();
     43    *addr -= pre_tcb_size;
     44    *size += pre_tcb_size;
     45 +#          endif
     46  #          else
     47    // arm and aarch64 reserve two words at TP, so this underestimates the range.
     48    // However, this is sufficient for the purpose of finding the pointers to
     49 
     50 -- 
     51 2.49.0
     52