[PATCH] Fix ASan issue 305 -- don't instrument .CRT initializer/terminator callbacks
Timur Iskhodzhanov
timurrrr at google.com
Mon May 5 06:52:55 PDT 2014
Hi glider,
See http://code.google.com/p/address-sanitizer/issues/detail?id=305 for more details
http://reviews.llvm.org/D3607
Files:
lib/Transforms/Instrumentation/AddressSanitizer.cpp
Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -906,8 +906,8 @@
// Ignore the globals from the __OBJC section. The ObjC runtime assumes
// those conform to /usr/lib/objc/runtime.h, so we can't add redzones to
// them.
- if ((Section.find("__OBJC,") == 0) ||
- (Section.find("__DATA, __objc_") == 0)) {
+ if (Section.startswith("__OBJC,") ||
+ Section.startswith("__DATA, __objc_")) {
DEBUG(dbgs() << "Ignoring ObjC runtime global: " << *G << "\n");
return false;
}
@@ -919,16 +919,25 @@
// is placed into __DATA,__cfstring
// 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) {
+ if (Section.startswith("__DATA,__cfstring")) {
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) {
+ if (Section.startswith("__TEXT,__cstring,cstring_literals")) {
DEBUG(dbgs() << "Ignoring a cstring literal: " << *G << "\n");
return false;
}
+
+ // See https://code.google.com/p/address-sanitizer/issues/detail?id=305
+ // Callbacks put into the CRT initializer/terminator sections
+ // should not be instrumented.
+ if (Section.startswith(".CRT") && Section.find("$") != StringRef::npos) {
+ DEBUG(dbgs() << "Ignoring a global initializer callback: " << *G << "\n");
+ return false;
+ }
+
// Globals from llvm.metadata aren't emitted, do not instrument them.
if (Section == "llvm.metadata") return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3607.9071.patch
Type: text/x-patch
Size: 1950 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140505/3fd4524d/attachment.bin>
More information about the llvm-commits
mailing list