This repository was archived by the owner on Feb 5, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed
lib/Transforms/Instrumentation Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -544,6 +544,7 @@ bool AddressSanitizer::ShouldInstrumentGlobal(GlobalVariable *G) {
544
544
Type *Ty = cast<PointerType>(G->getType ())->getElementType ();
545
545
DEBUG (dbgs () << " GLOBAL: " << *G);
546
546
547
+ if (BL->isIn (*G)) return false ;
547
548
if (!Ty->isSized ()) return false ;
548
549
if (!G->hasInitializer ()) return false ;
549
550
// Touch only those globals that will not be defined in other modules.
@@ -643,6 +644,8 @@ bool AddressSanitizer::insertGlobalRedzones(Module &M) {
643
644
Type *RightRedZoneTy = ArrayType::get (IRB.getInt8Ty (), RightRedzoneSize);
644
645
// Determine whether this global should be poisoned in initialization.
645
646
bool GlobalHasDynamicInitializer = HasDynamicInitializer (G);
647
+ // Don't check initialization order if this global is blacklisted.
648
+ GlobalHasDynamicInitializer &= ! BL->isInInit (*G);
646
649
647
650
StructType *NewTy = StructType::get (Ty, RightRedZoneTy, NULL );
648
651
Constant *NewInitializer = ConstantStruct::get (
Original file line number Diff line number Diff line change @@ -89,6 +89,10 @@ bool BlackList::isIn(const Module &M) {
89
89
return inSection (" src" , M.getModuleIdentifier ());
90
90
}
91
91
92
+ bool BlackList::isInInit (const GlobalVariable &G) {
93
+ return isIn (*G.getParent ()) || inSection (" global-init" , G.getName ());
94
+ }
95
+
92
96
bool BlackList::inSection (const StringRef Section,
93
97
const StringRef Query) {
94
98
Regex *FunctionRegex = Entries[Section];
Original file line number Diff line number Diff line change 14
14
// variables. Each line contains a prefix, followed by a wild card expression.
15
15
// ---
16
16
// fun:*_ZN4base6subtle*
17
- // global:*global_with_initialization_problems*
17
+ // global:*global_with_bad_access_or_initialization*
18
+ // global-init:*global_with_initialization_issues*
18
19
// src:file_with_tricky_code.cc
19
20
// ---
20
21
// Note that the wild card is in fact an llvm::Regex, but * is automatically
@@ -43,6 +44,8 @@ class BlackList {
43
44
bool isIn (const GlobalVariable &G);
44
45
// Returns whether this module is blacklisted by filename.
45
46
bool isIn (const Module &M);
47
+ // Returns whether a global should be excluded from initialization checking.
48
+ bool isInInit (const GlobalVariable &G);
46
49
private:
47
50
StringMap<Regex*> Entries;
48
51
You can’t perform that action at this time.
0 commit comments