summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2014-03-14 10:41:49 +0000
committerAlexander Potapenko <glider@google.com>2014-03-14 10:41:49 +0000
commitb76ea32834762d0042c4b27b9394e91ed8c8c5ff (patch)
tree1c71671add459bc9661a584c241b74d1919df76c /llvm
parent4d97203add074ca5c4dd4b93241e6ddf57b1ce02 (diff)
downloadbcm5719-llvm-b76ea32834762d0042c4b27b9394e91ed8c8c5ff.tar.gz
bcm5719-llvm-b76ea32834762d0042c4b27b9394e91ed8c8c5ff.zip
[ASan] Fix https://code.google.com/p/address-sanitizer/issues/detail?id=274
by ignoring globals from __TEXT,__cstring,cstring_literals during instrumenation. Add a regression test. llvm-svn: 203916
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index e8d2e0a0085..5c35cc8faf8 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -895,7 +895,7 @@ bool AddressSanitizerModule::ShouldInstrumentGlobal(GlobalVariable *G) {
// our redzones get broken.
if ((G->getName().find("\01L_OBJC_") == 0) ||
(G->getName().find("\01l_OBJC_") == 0)) {
- DEBUG(dbgs() << "Ignoring \\01L_OBJC_* global: " << *G);
+ DEBUG(dbgs() << "Ignoring \\01L_OBJC_* global: " << *G << "\n");
return false;
}
@@ -906,7 +906,7 @@ bool AddressSanitizerModule::ShouldInstrumentGlobal(GlobalVariable *G) {
// them.
if ((Section.find("__OBJC,") == 0) ||
(Section.find("__DATA, __objc_") == 0)) {
- DEBUG(dbgs() << "Ignoring ObjC runtime global: " << *G);
+ DEBUG(dbgs() << "Ignoring ObjC runtime global: " << *G << "\n");
return false;
}
// See http://code.google.com/p/address-sanitizer/issues/detail?id=32
@@ -918,7 +918,13 @@ bool AddressSanitizerModule::ShouldInstrumentGlobal(GlobalVariable *G) {
// Therefore there's no point in placing redzones into __DATA,__cfstring.
// Moreover, it causes the linker to crash on OS X 10.7
if (Section.find("__DATA,__cfstring") == 0) {
- DEBUG(dbgs() << "Ignoring CFString: " << *G);
+ DEBUG(dbgs() << "Ignoring CFString: " << *G << "\n");
+ return false;
+ }
+ // The linker merges the contents of cstring_literals and removes the
+ // trailing zeroes.
+ if (Section.find("__TEXT,__cstring,cstring_literals") == 0) {
+ DEBUG(dbgs() << "Ignoring a cstring literal: " << *G << "\n");
return false;
}
}
OpenPOWER on IntegriCloud