[compiler-rt] [asan][win][msvc] override new and delete and seperate TUs (PR #68754)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 20 20:52:13 PST 2023


================
@@ -0,0 +1,99 @@
+//===-- asan_win_new_delete_thunk_common.h ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// Windows-specific user-provided new/delete operator detection and fallback.
+//
+// In order to provide correct fallback behavior for operator new and delete, we
+// need to honor partially hooked new and delete operators. For example, if
+// plain operator new is provided by the user, then array operator new should
+// fallback to use that operator new. This is slighly complicated in that ASAN
+// must know which operator new/delete was used to correctly track allocations.
+// The solution here is to only pass the allocation/deallocation request
+// directly to ASAN with full metadata when we know all fallbacks for the given
+// overload are provided by ASAN. This requires us to detect which overloads are
+// provided by ASAN. We can accomplish this by seperating the definitions into
+// multiple TUs so each can be selected individually, and adding a dynamic
+// initializer to those TUs to mark whether that overload is included.
+//===----------------------------------------------------------------------===//
+
+#include <sanitizer_common/sanitizer_internal_defs.h>
----------------
vitalybuka wrote:

`#include "sanitizer_common/sanitizer_internal_defs.h"`


https://github.com/llvm/llvm-project/pull/68754


More information about the llvm-commits mailing list