[ASan] Collect unmangled names of global variables in Clang to print them in error reports.

Currently ASan instrumentation pass creates a string with global name
for each instrumented global (to include global names in the error report). Global
name is already mangled at this point, and we may not be able to demangle it
at runtime (e.g. there is no __cxa_demangle on Android).

Instead, create a string with fully qualified global name in Clang, and pass it
to ASan instrumentation pass in llvm.asan.globals metadata. If there is no metadata
for some global, ASan will use the original algorithm.

This fixes https://code.google.com/p/address-sanitizer/issues/detail?id=264.

llvm-svn: 212872
This commit is contained in:
Alexey Samsonov
2014-07-12 00:42:52 +00:00
parent fc31efe95a
commit 15c9669615
9 changed files with 86 additions and 47 deletions

View File

@@ -1015,8 +1015,10 @@ public:
return SanitizerBL;
}
void reportGlobalToASan(llvm::GlobalVariable *GV, SourceLocation Loc,
void reportGlobalToASan(llvm::GlobalVariable *GV, const VarDecl &D,
bool IsDynInit = false);
void reportGlobalToASan(llvm::GlobalVariable *GV, SourceLocation Loc,
StringRef Name, bool IsDynInit = false);
void addDeferredVTable(const CXXRecordDecl *RD) {
DeferredVTables.push_back(RD);