mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-30 16:17:05 +00:00 
			
		
		
		
	[ASan]: Add minimalistic support for turning off initialization-order checking for globals of specified types. Tests for this behavior will go to ASan test suite in compiler-rt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167725 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -20,6 +20,7 @@ | |||||||
| #include "llvm/ADT/OwningPtr.h" | #include "llvm/ADT/OwningPtr.h" | ||||||
| #include "llvm/ADT/SmallVector.h" | #include "llvm/ADT/SmallVector.h" | ||||||
| #include "llvm/ADT/StringExtras.h" | #include "llvm/ADT/StringExtras.h" | ||||||
|  | #include "llvm/DerivedTypes.h" | ||||||
| #include "llvm/Function.h" | #include "llvm/Function.h" | ||||||
| #include "llvm/GlobalVariable.h" | #include "llvm/GlobalVariable.h" | ||||||
| #include "llvm/Module.h" | #include "llvm/Module.h" | ||||||
| @@ -92,8 +93,20 @@ bool BlackList::isIn(const Module &M) { | |||||||
|   return inSection("src", M.getModuleIdentifier()); |   return inSection("src", M.getModuleIdentifier()); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static StringRef GetGVTypeString(const GlobalVariable &G) { | ||||||
|  |   // Types of GlobalVariables are always pointer types. | ||||||
|  |   Type *GType = G.getType()->getElementType(); | ||||||
|  |   // For now we support blacklisting struct types only. | ||||||
|  |   if (GType->isStructTy()) { | ||||||
|  |     return GType->getStructName(); | ||||||
|  |   } | ||||||
|  |   return "<unknown type>"; | ||||||
|  | } | ||||||
|  |  | ||||||
| bool BlackList::isInInit(const GlobalVariable &G) { | bool BlackList::isInInit(const GlobalVariable &G) { | ||||||
|   return isIn(*G.getParent()) || inSection("global-init", G.getName()); |   return (isIn(*G.getParent()) || | ||||||
|  |           inSection("global-init", G.getName()) || | ||||||
|  |           inSection("global-init-type", GetGVTypeString(G))); | ||||||
| } | } | ||||||
|  |  | ||||||
| bool BlackList::inSection(const StringRef Section, | bool BlackList::inSection(const StringRef Section, | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
| // fun:*_ZN4base6subtle* | // fun:*_ZN4base6subtle* | ||||||
| // global:*global_with_bad_access_or_initialization* | // global:*global_with_bad_access_or_initialization* | ||||||
| // global-init:*global_with_initialization_issues* | // global-init:*global_with_initialization_issues* | ||||||
|  | // global-init-type:*Namespace::ClassName* | ||||||
| // src:file_with_tricky_code.cc | // src:file_with_tricky_code.cc | ||||||
| // --- | // --- | ||||||
| // Note that the wild card is in fact an llvm::Regex, but * is automatically | // Note that the wild card is in fact an llvm::Regex, but * is automatically | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user