summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib
diff options
context:
space:
mode:
authorWalter Lee <waltl@google.com>2017-11-13 14:02:27 +0000
committerWalter Lee <waltl@google.com>2017-11-13 14:02:27 +0000
commit52b2bd7845497c36e45b87a42f737c5cc925b537 (patch)
tree5ee32686a8e54c0ff16e451afa325b32d046587b /compiler-rt/lib
parentd6b0ecb79514e4c188e725e33b4bc92f5213f602 (diff)
downloadbcm5719-llvm-52b2bd7845497c36e45b87a42f737c5cc925b537.tar.gz
bcm5719-llvm-52b2bd7845497c36e45b87a42f737c5cc925b537.zip
[asan] Add CMake hook to override shadow scale in compiler_rt
Allow user to override shadow scale in compiler_rt by passing -DCOMPILER_RT_ASAN_SHADOW_SCALE=n to CMake. Propagate the override shadow scale value via a compiler define to compiler-rt and asan tests. Tests will use the define to partially disable unsupported tests. Set "-mllvm -asan-mapping-scale=<n>" for compiler_rt tests. Differential Revision: https://reviews.llvm.org/D39469 llvm-svn: 318038
Diffstat (limited to 'compiler-rt/lib')
-rw-r--r--compiler-rt/lib/asan/CMakeLists.txt1
-rw-r--r--compiler-rt/lib/asan/asan_mapping.h4
-rw-r--r--compiler-rt/lib/asan/tests/CMakeLists.txt2
3 files changed, 7 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index 9291e71099f..da82e485b58 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -40,6 +40,7 @@ set(ASAN_PREINIT_SOURCES
include_directories(..)
set(ASAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
+set(ASAN_COMMON_DEFINITIONS ${COMPILER_RT_ASAN_SHADOW_SCALE_DEFINITION})
append_rtti_flag(OFF ASAN_CFLAGS)
diff --git a/compiler-rt/lib/asan/asan_mapping.h b/compiler-rt/lib/asan/asan_mapping.h
index febe090e2ea..c1e965c7a01 100644
--- a/compiler-rt/lib/asan/asan_mapping.h
+++ b/compiler-rt/lib/asan/asan_mapping.h
@@ -131,7 +131,11 @@
// || `[0x30000000, 0x35ffffff]` || LowShadow ||
// || `[0x00000000, 0x2fffffff]` || LowMem ||
+#if defined(ASAN_SHADOW_SCALE)
+static const u64 kDefaultShadowScale = ASAN_SHADOW_SCALE;
+#else
static const u64 kDefaultShadowScale = 3;
+#endif
static const u64 kDefaultShadowSentinel = ~(uptr)0;
static const u64 kDefaultShadowOffset32 = 1ULL << 29; // 0x20000000
static const u64 kDefaultShadowOffset64 = 1ULL << 44;
diff --git a/compiler-rt/lib/asan/tests/CMakeLists.txt b/compiler-rt/lib/asan/tests/CMakeLists.txt
index 40732080fdd..67a8fafaba3 100644
--- a/compiler-rt/lib/asan/tests/CMakeLists.txt
+++ b/compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -23,6 +23,7 @@ set(ASAN_UNITTEST_HEADERS
set(ASAN_UNITTEST_COMMON_CFLAGS
${COMPILER_RT_UNITTEST_CFLAGS}
${COMPILER_RT_GTEST_CFLAGS}
+ ${COMPILER_RT_ASAN_SHADOW_SCALE_LLVM_FLAG}
-I${COMPILER_RT_SOURCE_DIR}/include
-I${COMPILER_RT_SOURCE_DIR}/lib
-I${COMPILER_RT_SOURCE_DIR}/lib/asan
@@ -52,6 +53,7 @@ list(APPEND ASAN_UNITTEST_COMMON_LINK_FLAGS -g)
# Use -D instead of definitions to please custom compile command.
list(APPEND ASAN_UNITTEST_COMMON_CFLAGS
+ ${COMPILER_RT_ASAN_SHADOW_SCALE_FLAG}
-DASAN_HAS_BLACKLIST=1
-DASAN_HAS_EXCEPTIONS=1
-DASAN_UAR=0)
OpenPOWER on IntegriCloud