[compiler-rt] r293959 - [sancov] Define delimiters for sanitizer coverage's binary section on Windows.
Marcos Pividori via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 2 15:02:16 PST 2017
Author: mpividori
Date: Thu Feb 2 17:02:15 2017
New Revision: 293959
URL: http://llvm.org/viewvc/llvm-project?rev=293959&view=rev
Log:
[sancov] Define delimiters for sanitizer coverage's binary section on Windows.
On Windows, the symbols "___stop___sancov_guards" and "___start___sancov_guards"
are not defined automatically. So, we need to take a different approach.
We define 3 sections: ".SCOV$A", ".SCOV$M" and ".SCOV$Z".
Section ".SCOV$A" will only hold a variable ___start___sancov_guard.
Section ".SCOV$M" will hold the main data.
Section ".SCOV$Z" will only hold a variable ___stop___sancov_guards.
When linking, they will be merged sorted by the characters after the $, so we
can use the pointers of the variables ___[start|stop]___sancov_guard to know the
actual range of addresses of that section.
___[start|stop]___sancov_guard should be defined only once per module. On
Windows, we have 2 different cases:
+ When considering a shared runtime:
All the modules, main executable and dlls, are linked to an auxiliary static
library dynamic_runtime_thunk.lib. Because of that, we include the delimiters
in `SancovDynamicRuntimeThunk`.
+ When considering a static runtime:
The main executable in linked to the static runtime library.
All the dlls are linked to an auxiliary static library dll_thunk.
Because of that, we include the delimiter to both `SancovDllThunk` and
`SANITIZER_LIBCDEP_SOURCES` (which is included in the static runtime lib).
Differential Revision: https://reviews.llvm.org/D28435
Added:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_win_sections.cc
Modified:
compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt
Modified: compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt?rev=293959&r1=293958&r2=293959&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt Thu Feb 2 17:02:15 2017
@@ -56,6 +56,7 @@ set(SANITIZER_LIBCDEP_SOURCES
sanitizer_coverage_libcdep.cc
sanitizer_coverage_libcdep_new.cc
sanitizer_coverage_mapping_libcdep.cc
+ sanitizer_coverage_win_sections.cc
sanitizer_linux_libcdep.cc
sanitizer_posix_libcdep.cc
sanitizer_stacktrace_libcdep.cc
@@ -211,6 +212,7 @@ if(MSVC)
${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES sanitizer_coverage_win_dll_thunk.cc
+ sanitizer_coverage_win_sections.cc
CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DLL_THUNK
DEFS ${SANITIZER_COMMON_DEFINITIONS})
@@ -230,6 +232,7 @@ if(MSVC)
${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
SOURCES sanitizer_coverage_win_dynamic_runtime_thunk.cc
+ sanitizer_coverage_win_sections.cc
CFLAGS ${SANITIZER_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS}
DEFS ${SANITIZER_COMMON_DEFINITIONS})
endif()
Added: compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_win_sections.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_win_sections.cc?rev=293959&view=auto
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_win_sections.cc (added)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_win_sections.cc Thu Feb 2 17:02:15 2017
@@ -0,0 +1,22 @@
+//===-- sanitizer_coverage_win_sections.cc --------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines delimiters for Sanitizer Coverage's section.
+//===----------------------------------------------------------------------===//
+
+#include "sanitizer_platform.h"
+#if SANITIZER_WINDOWS
+#include <stdint.h>
+#pragma section(".SCOV$A", read, write) // NOLINT
+#pragma section(".SCOV$Z", read, write) // NOLINT
+extern "C" {
+__declspec(allocate(".SCOV$A")) uint32_t __start___sancov_guards = 0;
+__declspec(allocate(".SCOV$Z")) uint32_t __stop___sancov_guards = 0;
+}
+#endif // SANITIZER_WINDOWS
More information about the llvm-commits
mailing list