summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2018-12-13 09:47:39 +0000
committerVitaly Buka <vitalybuka@google.com>2018-12-13 09:47:39 +0000
commita257639a6935a2c63377784c5c9c3b73864a2582 (patch)
treefb08dfa65a4ad2e8bb9720ef15b0d172e892fe18 /llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
parent577b9fc54370b51262b11f5fee7474e9c71f4507 (diff)
downloadbcm5719-llvm-a257639a6935a2c63377784c5c9c3b73864a2582.tar.gz
bcm5719-llvm-a257639a6935a2c63377784c5c9c3b73864a2582.zip
[asan] Don't check ODR violations for particular types of globals
Summary: private and internal: should not trigger ODR at all. unnamed_addr: current ODR checking approach fail and rereport false violation if a linker merges such globals linkonce_odr, weak_odr: could cause similar problems and they are already not instrumented for ELF. Reviewers: eugenis, kcc Subscribers: kubamracek, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D55621 llvm-svn: 349015
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp')
-rw-r--r--llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index cd7652d3c3a..87288388853 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -2190,7 +2190,13 @@ bool AddressSanitizerModule::InstrumentGlobals(IRBuilder<> &IRB, Module &M, bool
GlobalAlias::create(GlobalValue::PrivateLinkage, "", NewGlobal);
}
- if (UseOdrIndicator) {
+ // ODR check is not useful for the following, but we see false reports
+ // caused by linker optimizations.
+ if (NewGlobal->hasLocalLinkage() || NewGlobal->hasGlobalUnnamedAddr() ||
+ NewGlobal->hasLinkOnceODRLinkage() || NewGlobal->hasWeakODRLinkage()) {
+ ODRIndicator = ConstantExpr::getIntToPtr(ConstantInt::get(IntptrTy, -1),
+ IRB.getInt8PtrTy());
+ } else if (UseOdrIndicator) {
// With local aliases, we need to provide another externally visible
// symbol __odr_asan_XXX to detect ODR violation.
auto *ODRIndicatorSym =
OpenPOWER on IntegriCloud