<div><div dir="auto">when might we not want this? Can you add a comment, even if only on phabricator?</div></div><div dir="auto"><br></div><div dir="auto">Thank you,</div><div dir="auto"> Filipe</div><div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 27 Aug 2019 at 20:55, Julian Lettner via Phabricator <<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">yln created this revision.<br>
Herald added subscribers: llvm-commits, hiraditya.<br>
Herald added a project: LLVM.<br>
yln added reviewers: kubamracek, dcoughlin, delcypher, eugenis.<br>
<br>
By default ASan calls a versioned function<br>
`__asan_version_mismatch_check_vXXX` to ensure that the compiler ABI<br>
version and runtime ABI version are compatible. This ensures that we get<br>
a predictable linker error instead of hard-to-debug runtime errors.<br>
<br>
Sometimes, however, we want to skip this safety guard. This new command<br>
line option allows us to do just that.<br>
<br>
rdar://47891956<br>
<br>
<br>
Repository:<br>
rG LLVM Github Monorepo<br>
<br>
<a href="https://reviews.llvm.org/D66826" rel="noreferrer" target="_blank">https://reviews.llvm.org/D66826</a><br>
<br>
Files:<br>
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp<br>
llvm/test/Instrumentation/AddressSanitizer/version-mismatch-check.ll<br>
<br>
<br>
Index: llvm/test/Instrumentation/AddressSanitizer/version-mismatch-check.ll<br>
===================================================================<br>
--- /dev/null<br>
+++ llvm/test/Instrumentation/AddressSanitizer/version-mismatch-check.ll<br>
@@ -0,0 +1,12 @@<br>
+; Check that the ASan module constructor guards against compiler/runtime version<br>
+; mismatch.<br>
+<br>
+; RUN: opt < %s -asan-module -S | FileCheck %s<br>
+; RUN: opt < %s -asan-module -asan-guard-against-version-mismatch=0 -S | FileCheck %s --check-prefix=NOGUARD<br>
+<br>
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"<br>
+target triple = "x86_64-unknown-linux-gnu"<br>
+<br>
+; CHECK-LABEL: define internal void @asan.module_ctor()<br>
+; CHECK: call void @__asan_version_mismatch_check_v<br>
+; NOGUARD-NOT: call void @__asan_version_mismatch_check_v<br>
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp<br>
===================================================================<br>
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp<br>
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp<br>
@@ -193,6 +193,11 @@<br>
cl::desc("Enable recovery mode (continue-after-error)."),<br>
cl::Hidden, cl::init(false));<br>
<br>
+static cl::opt<bool> ClInsertVersionCheck(<br>
+ "asan-guard-against-version-mismatch",<br>
+ cl::desc("Guard against compiler/runtime version mismatch."),<br>
+ cl::Hidden, cl::init(true));<br>
+<br>
// This flag may need to be replaced with -f[no-]asan-reads.<br>
static cl::opt<bool> ClInstrumentReads("asan-instrument-reads",<br>
cl::desc("instrument read instructions"),<br>
@@ -2426,8 +2431,9 @@<br>
<br>
// Create a module constructor. A destructor is created lazily because not all<br>
// platforms, and not all modules need it.<br>
+ std::string AsanVersion = std::to_string(GetAsanVersion(M));<br>
std::string VersionCheckName =<br>
- kAsanVersionCheckNamePrefix + std::to_string(GetAsanVersion(M));<br>
+ ClInsertVersionCheck ? (kAsanVersionCheckNamePrefix + AsanVersion) : "";<br>
std::tie(AsanCtorFunction, std::ignore) = createSanitizerCtorAndInitFunctions(<br>
M, kAsanModuleCtorName, kAsanInitName, /*InitArgTypes=*/{},<br>
/*InitArgs=*/{}, VersionCheckName);<br>
<br>
<br>
</blockquote></div></div>
</div>