mirror of
https://git.proxmox.com/git/llvm-toolchain
synced 2025-07-31 04:49:33 +00:00
fix the patches
This commit is contained in:
parent
7edcbc81fc
commit
42d0ccfc40
5
debian/patches/series
vendored
5
debian/patches/series
vendored
@ -49,8 +49,7 @@ asan-glibc-2.24.diff
|
||||
lldb-dont-assume-64bit-systems-are-all-x86-64.patch
|
||||
lldb-arm64.diff
|
||||
clang-tidy-run-bin.diff
|
||||
|
||||
silent-llvm-symbolizer.diff
|
||||
upstream-asan-msan-fix-reallocation-logic.diff
|
||||
upstream-fix-asan-initialization.diff
|
||||
upstream-msan-prevent-initialization-failure.diff
|
||||
upstream-asan-msan-fix-reallocation-logic.diff
|
||||
|
||||
|
102
debian/patches/upstream-fix-asan-initialization.diff
vendored
102
debian/patches/upstream-fix-asan-initialization.diff
vendored
@ -1,102 +0,0 @@
|
||||
From 570ee9dd7a6f90b0370a86535cbde6738d0ccf67 Mon Sep 17 00:00:00 2001
|
||||
From: Maxim Ostapenko <m.ostapenko@partner.samsung.com>
|
||||
Date: Mon, 16 May 2016 07:20:53 +0000
|
||||
Subject: [PATCH] [asan] Fix asan initialization failure with newer (2.23+)
|
||||
glibc in use.
|
||||
|
||||
This patch tries to fix https://llvm.org/bugs/show_bug.cgi?id=27310 by using the same hack for malloc as we use for calloc: allocate corresponding memory from internal buffer when ASan is not initialized.
|
||||
This way we could avoid nasty '==6987==AddressSanitizer CHECK failed: ../../../../libsanitizer/asan/asan_rtl.cc:556 "((!asan_init_is_running && "ASan init calls itself!")) != (0)" (0x0, 0x0)' errors in
|
||||
environments with glibc 2.23+ in use, where _dl_signal_error, called from dlsym for undefined symbols calls malloc in order to get a buffer for error message.
|
||||
|
||||
Differential Revision: http://reviews.llvm.org/D20235
|
||||
|
||||
|
||||
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269633 91177308-0d34-0410-b5e6-96231b3b80d8
|
||||
---
|
||||
lib/asan/asan_malloc_linux.cc | 42 ++++++++++++++++++++++++------------------
|
||||
1 file changed, 24 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/compiler-rt/lib/asan/asan_malloc_linux.cc b/compiler-rt/lib/asan/asan_malloc_linux.cc
|
||||
index a81f19f..162abd2 100644
|
||||
--- a/compiler-rt/lib/asan/asan_malloc_linux.cc
|
||||
+++ b/compiler-rt/lib/asan/asan_malloc_linux.cc
|
||||
@@ -26,52 +26,58 @@
|
||||
// ---------------------- Replacement functions ---------------- {{{1
|
||||
using namespace __asan; // NOLINT
|
||||
|
||||
-static const uptr kCallocPoolSize = 1024;
|
||||
-static uptr calloc_memory_for_dlsym[kCallocPoolSize];
|
||||
+static uptr allocated_for_dlsym;
|
||||
+static const uptr kDlsymAllocPoolSize = 1024;
|
||||
+static uptr alloc_memory_for_dlsym[kDlsymAllocPoolSize];
|
||||
|
||||
-static bool IsInCallocPool(const void *ptr) {
|
||||
- sptr off = (sptr)ptr - (sptr)calloc_memory_for_dlsym;
|
||||
- return 0 <= off && off < (sptr)kCallocPoolSize;
|
||||
+static bool IsInDlsymAllocPool(const void *ptr) {
|
||||
+ uptr off = (uptr)ptr - (uptr)alloc_memory_for_dlsym;
|
||||
+ return off < sizeof(alloc_memory_for_dlsym);
|
||||
+}
|
||||
+
|
||||
+static void *AllocateFromLocalPool(uptr size_in_bytes) {
|
||||
+ uptr size_in_words = RoundUpTo(size_in_bytes, kWordSize) / kWordSize;
|
||||
+ void *mem = (void*)&alloc_memory_for_dlsym[allocated_for_dlsym];
|
||||
+ allocated_for_dlsym += size_in_words;
|
||||
+ CHECK_LT(allocated_for_dlsym, kDlsymAllocPoolSize);
|
||||
+ return mem;
|
||||
}
|
||||
|
||||
INTERCEPTOR(void, free, void *ptr) {
|
||||
GET_STACK_TRACE_FREE;
|
||||
- if (UNLIKELY(IsInCallocPool(ptr)))
|
||||
+ if (UNLIKELY(IsInDlsymAllocPool(ptr)))
|
||||
return;
|
||||
asan_free(ptr, &stack, FROM_MALLOC);
|
||||
}
|
||||
|
||||
INTERCEPTOR(void, cfree, void *ptr) {
|
||||
GET_STACK_TRACE_FREE;
|
||||
- if (UNLIKELY(IsInCallocPool(ptr)))
|
||||
+ if (UNLIKELY(IsInDlsymAllocPool(ptr)))
|
||||
return;
|
||||
asan_free(ptr, &stack, FROM_MALLOC);
|
||||
}
|
||||
|
||||
INTERCEPTOR(void*, malloc, uptr size) {
|
||||
+ if (UNLIKELY(!asan_inited))
|
||||
+ // Hack: dlsym calls malloc before REAL(malloc) is retrieved from dlsym.
|
||||
+ return AllocateFromLocalPool(size);
|
||||
GET_STACK_TRACE_MALLOC;
|
||||
return asan_malloc(size, &stack);
|
||||
}
|
||||
|
||||
INTERCEPTOR(void*, calloc, uptr nmemb, uptr size) {
|
||||
- if (UNLIKELY(!asan_inited)) {
|
||||
+ if (UNLIKELY(!asan_inited))
|
||||
// Hack: dlsym calls calloc before REAL(calloc) is retrieved from dlsym.
|
||||
- static uptr allocated;
|
||||
- uptr size_in_words = ((nmemb * size) + kWordSize - 1) / kWordSize;
|
||||
- void *mem = (void*)&calloc_memory_for_dlsym[allocated];
|
||||
- allocated += size_in_words;
|
||||
- CHECK(allocated < kCallocPoolSize);
|
||||
- return mem;
|
||||
- }
|
||||
+ return AllocateFromLocalPool(nmemb * size);
|
||||
GET_STACK_TRACE_MALLOC;
|
||||
return asan_calloc(nmemb, size, &stack);
|
||||
}
|
||||
|
||||
INTERCEPTOR(void*, realloc, void *ptr, uptr size) {
|
||||
GET_STACK_TRACE_MALLOC;
|
||||
- if (UNLIKELY(IsInCallocPool(ptr))) {
|
||||
- uptr offset = (uptr)ptr - (uptr)calloc_memory_for_dlsym;
|
||||
- uptr copy_size = Min(size, kCallocPoolSize - offset);
|
||||
+ if (UNLIKELY(IsInDlsymAllocPool(ptr))) {
|
||||
+ uptr offset = (uptr)ptr - (uptr)alloc_memory_for_dlsym;
|
||||
+ uptr copy_size = Min(size, kDlsymAllocPoolSize - offset);
|
||||
void *new_ptr = asan_malloc(size, &stack);
|
||||
internal_memcpy(new_ptr, ptr, copy_size);
|
||||
return new_ptr;
|
||||
--
|
||||
2.10.2
|
||||
|
Loading…
Reference in New Issue
Block a user