summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Drobyshev <a.drobyshev@samsung.com>2019-05-30 16:53:19 (GMT)
committerAndrey Drobyshev <a.drobyshev@samsung.com>2019-05-30 16:53:19 (GMT)
commita98905ed52b5d082718efd334106754f3e278739 (patch)
treeadb87a5d386899088101647ae840c49d9b75a236
parent9f310807bd994bf4d6bdba560b43411d20e579f5 (diff)
downloadcoreclr-a98905ed52b5d082718efd334106754f3e278739.zip
coreclr-a98905ed52b5d082718efd334106754f3e278739.tar.gz
coreclr-a98905ed52b5d082718efd334106754f3e278739.tar.bz2
[Tizen] introduce integration with libasan.
Signed-off-by: Andrey Drobyshev <a.drobyshev@samsung.com>
-rw-r--r--src/inc/corinfo.h3
-rw-r--r--src/inc/jithelpers.h9
-rw-r--r--src/jit/gentree.h9
-rw-r--r--src/jit/lower.cpp25
-rw-r--r--src/jit/target.h8
-rw-r--r--src/jit/utils.cpp3
-rw-r--r--src/vm/jithelpers.cpp25
7 files changed, 82 insertions, 0 deletions
diff --git a/src/inc/corinfo.h b/src/inc/corinfo.h
index 852bf31..a73f377 100644
--- a/src/inc/corinfo.h
+++ b/src/inc/corinfo.h
@@ -656,6 +656,9 @@ enum CorInfoHelpFunc
CORINFO_HELP_GVMLOOKUP_FOR_SLOT, // Resolve a generic virtual method target from this pointer and runtime method handle
+ CORINFO_HELP_ENABLE_ASAN,
+ CORINFO_HELP_DISABLE_ASAN,
+
CORINFO_HELP_COUNT,
};
diff --git a/src/inc/jithelpers.h b/src/inc/jithelpers.h
index f305a4d..269027b 100644
--- a/src/inc/jithelpers.h
+++ b/src/inc/jithelpers.h
@@ -362,6 +362,15 @@
JITHELPER(CORINFO_HELP_GVMLOOKUP_FOR_SLOT, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB)
+#if FEATURE_ASAN_INTEGRATION
+ JITHELPER(CORINFO_HELP_ENABLE_ASAN, JIT_DisableAsanCallsForwarding, CORINFO_HELP_SIG_UNDEF)
+ JITHELPER(CORINFO_HELP_DISABLE_ASAN, JIT_EnableAsanCallsForwarding, CORINFO_HELP_SIG_UNDEF)
+#else
+ JITHELPER(CORINFO_HELP_ENABLE_ASAN, NULL, CORINFO_HELP_SIG_UNDEF)
+ JITHELPER(CORINFO_HELP_DISABLE_ASAN, NULL, CORINFO_HELP_SIG_UNDEF)
+#endif
+
+
#undef JITHELPER
#undef DYNAMICJITHELPER
#undef JITHELPER
diff --git a/src/jit/gentree.h b/src/jit/gentree.h
index e639d54..ab8888d 100644
--- a/src/jit/gentree.h
+++ b/src/jit/gentree.h
@@ -3460,6 +3460,8 @@ struct GenTreeCall final : public GenTree
#define GTF_CALL_M_GUARDED 0x00200000 // GT_CALL -- this call was transformed by guarded devirtualization
#define GTF_CALL_M_ALLOC_SIDE_EFFECTS 0x00400000 // GT_CALL -- this is a call to an allocator with side effects
+#define GTF_CALL_M_ASAN 0x00800000 // GT_CALL -- an external call to libasan
+
// clang-format on
bool IsUnmanaged() const
@@ -3685,6 +3687,13 @@ struct GenTreeCall final : public GenTree
return (gtCallMoreFlags & GTF_CALL_M_UNBOXED) != 0;
}
+#if FEATURE_ASAN_INTEGRATION
+ bool IsAsanCall() const
+ {
+ return (gtCallMoreFlags & GTF_CALL_M_ASAN) != 0;
+ }
+#endif
+
void ClearGuardedDevirtualizationCandidate()
{
gtCallMoreFlags &= ~GTF_CALL_M_GUARDED_DEVIRT;
diff --git a/src/jit/lower.cpp b/src/jit/lower.cpp
index 55f44a7..fbecd0e 100644
--- a/src/jit/lower.cpp
+++ b/src/jit/lower.cpp
@@ -1597,6 +1597,13 @@ void Lowering::LowerCall(GenTree* node)
break;
case GTF_CALL_NONVIRT:
+#if FEATURE_ASAN_INTEGRATION
+ if (call->IsAsanCall())
+ {
+ return;
+ }
+ else
+#endif
if (call->IsUnmanaged())
{
controlExpr = LowerNonvirtPinvokeCall(call);
@@ -3696,6 +3703,15 @@ void Lowering::InsertPInvokeCallProlog(GenTreeCall* call)
GenTree* storeGCState = SetGCState(0);
BlockRange().InsertBefore(insertBefore, LIR::SeqTree(comp, storeGCState));
ContainCheckStoreIndir(storeGCState->AsIndir());
+
+#if FEATURE_ASAN_INTEGRATION
+ GenTreeCall* asanCall = comp->gtNewHelperCallNode(CORINFO_HELP_ENABLE_ASAN,
+ TYP_VOID);
+ asanCall->gtFlags |= GTF_CALL_UNMANAGED;
+ asanCall->gtCallMoreFlags |= GTF_CALL_M_ASAN;
+ asanCall->fgArgInfo = new fgArgInfo(comp, asanCall, 0);
+ BlockRange().InsertBefore(insertBefore, asanCall);
+#endif // FEATURE_ASAN_INTEGRATION
}
//------------------------------------------------------------------------
@@ -3733,6 +3749,15 @@ void Lowering::InsertPInvokeCallEpilog(GenTreeCall* call)
// gcstate = 1
GenTree* insertionPoint = call->gtNext;
+#if FEATURE_ASAN_INTEGRATION
+ GenTreeCall* asanCall = comp->gtNewHelperCallNode(CORINFO_HELP_DISABLE_ASAN,
+ TYP_VOID);
+ asanCall->gtFlags |= GTF_CALL_UNMANAGED;
+ asanCall->gtCallMoreFlags |= GTF_CALL_M_ASAN;
+ asanCall->fgArgInfo = new fgArgInfo(comp, asanCall, 0);
+ BlockRange().InsertBefore(insertionPoint, asanCall);
+#endif // FEATURE_ASAN_INTEGRATION
+
GenTree* tree = SetGCState(1);
BlockRange().InsertBefore(insertionPoint, LIR::SeqTree(comp, tree));
ContainCheckStoreIndir(tree->AsIndir());
diff --git a/src/jit/target.h b/src/jit/target.h
index 561db79..038ac69 100644
--- a/src/jit/target.h
+++ b/src/jit/target.h
@@ -196,6 +196,14 @@ typedef unsigned char regNumberSmall;
/*****************************************************************************/
+#ifdef LIBASAN
+#define FEATURE_ASAN_INTEGRATION 1
+#else
+#define FEATURE_ASAN_INTEGRATION 0
+#endif
+
+/*****************************************************************************/
+
// The pseudorandom nop insertion is not necessary for current CoreCLR scenarios
// #if defined(FEATURE_CORECLR) && !defined(_TARGET_ARM_)
// #define PSEUDORANDOM_NOP_INSERTION
diff --git a/src/jit/utils.cpp b/src/jit/utils.cpp
index ae7dd60..c0b1e26 100644
--- a/src/jit/utils.cpp
+++ b/src/jit/utils.cpp
@@ -1443,6 +1443,9 @@ void HelperCallProperties::init()
case CORINFO_HELP_JIT_PINVOKE_END:
case CORINFO_HELP_GETCURRENTMANAGEDTHREADID:
+ case CORINFO_HELP_ENABLE_ASAN:
+ case CORINFO_HELP_DISABLE_ASAN:
+
noThrow = true;
break;
diff --git a/src/vm/jithelpers.cpp b/src/vm/jithelpers.cpp
index d0e0b44..88421bd 100644
--- a/src/vm/jithelpers.cpp
+++ b/src/vm/jithelpers.cpp
@@ -5700,6 +5700,31 @@ HCIMPL0(void, JIT_DebugLogLoopCloning)
}
HCIMPLEND
+#if FEATURE_ASAN_INTEGRATION
+extern "C" void __sanitizer_enable_calls_forwarding();
+extern "C" void __sanitizer_disable_calls_forwarding();
+
+HCIMPL0(void, JIT_EnableAsanCallsForwarding)
+{
+ CONTRACTL {
+ FCALL_CHECK;
+ } CONTRACTL_END;
+
+ __sanitizer_enable_calls_forwarding();
+}
+HCIMPLEND
+
+HCIMPL0(void, JIT_DisableAsanCallsForwarding)
+{
+ CONTRACTL {
+ FCALL_CHECK;
+ } CONTRACTL_END;
+
+ __sanitizer_disable_calls_forwarding();
+}
+HCIMPLEND
+#endif // FEATURE_ASAN_INTEGRATION
+
//========================================================================
//
// INTEROP HELPERS