forked from OSchip/llvm-project
parent
53fe155b3f
commit
f49a5844b6
|
@ -473,7 +473,7 @@ void CodeGenFunction::EmitStaticVarDecl(const VarDecl &D,
|
||||||
LocalDeclMap.find(&D)->second = Address(castedAddr, elemTy, alignment);
|
LocalDeclMap.find(&D)->second = Address(castedAddr, elemTy, alignment);
|
||||||
CGM.setStaticLocalDeclAddress(&D, castedAddr);
|
CGM.setStaticLocalDeclAddress(&D, castedAddr);
|
||||||
|
|
||||||
CGM.getSanitizerMetadata()->reportGlobalToASan(var, D);
|
CGM.getSanitizerMetadata()->reportGlobal(var, D);
|
||||||
|
|
||||||
// Emit global variable debug descriptor for static vars.
|
// Emit global variable debug descriptor for static vars.
|
||||||
CGDebugInfo *DI = getDebugInfo();
|
CGDebugInfo *DI = getDebugInfo();
|
||||||
|
|
|
@ -4795,7 +4795,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
|
||||||
if (NeedsGlobalCtor || NeedsGlobalDtor)
|
if (NeedsGlobalCtor || NeedsGlobalDtor)
|
||||||
EmitCXXGlobalVarDeclInitFunc(D, GV, NeedsGlobalCtor);
|
EmitCXXGlobalVarDeclInitFunc(D, GV, NeedsGlobalCtor);
|
||||||
|
|
||||||
SanitizerMD->reportGlobalToASan(GV, *D, NeedsGlobalCtor);
|
SanitizerMD->reportGlobal(GV, *D, NeedsGlobalCtor);
|
||||||
|
|
||||||
// Emit global variable debug information.
|
// Emit global variable debug information.
|
||||||
if (CGDebugInfo *DI = getModuleDebugInfo())
|
if (CGDebugInfo *DI = getModuleDebugInfo())
|
||||||
|
@ -5677,8 +5677,8 @@ CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S,
|
||||||
if (Entry)
|
if (Entry)
|
||||||
*Entry = GV;
|
*Entry = GV;
|
||||||
|
|
||||||
SanitizerMD->reportGlobalToASan(GV, S->getStrTokenLoc(0), "<string literal>",
|
SanitizerMD->reportGlobal(GV, S->getStrTokenLoc(0), "<string literal>",
|
||||||
QualType());
|
QualType());
|
||||||
|
|
||||||
return ConstantAddress(castStringLiteralToDefaultAddressSpace(*this, GV),
|
return ConstantAddress(castStringLiteralToDefaultAddressSpace(*this, GV),
|
||||||
GV->getValueType(), Alignment);
|
GV->getValueType(), Alignment);
|
||||||
|
|
|
@ -28,10 +28,10 @@ static bool isAsanHwasanOrMemTag(const SanitizerSet& SS) {
|
||||||
SanitizerKind::MemTag);
|
SanitizerKind::MemTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SanitizerMetadata::reportGlobalToASan(llvm::GlobalVariable *GV,
|
void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV,
|
||||||
SourceLocation Loc, StringRef Name,
|
SourceLocation Loc, StringRef Name,
|
||||||
QualType Ty, bool IsDynInit,
|
QualType Ty, bool IsDynInit,
|
||||||
bool IsExcluded) {
|
bool IsExcluded) {
|
||||||
if (!isAsanHwasanOrMemTag(CGM.getLangOpts().Sanitize))
|
if (!isAsanHwasanOrMemTag(CGM.getLangOpts().Sanitize))
|
||||||
return;
|
return;
|
||||||
IsDynInit &= !CGM.isInNoSanitizeList(GV, Loc, Ty, "init");
|
IsDynInit &= !CGM.isInNoSanitizeList(GV, Loc, Ty, "init");
|
||||||
|
@ -61,8 +61,8 @@ void SanitizerMetadata::reportGlobalToASan(llvm::GlobalVariable *GV,
|
||||||
AsanGlobals->addOperand(ThisGlobal);
|
AsanGlobals->addOperand(ThisGlobal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SanitizerMetadata::reportGlobalToASan(llvm::GlobalVariable *GV,
|
void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV, const VarDecl &D,
|
||||||
const VarDecl &D, bool IsDynInit) {
|
bool IsDynInit) {
|
||||||
if (!isAsanHwasanOrMemTag(CGM.getLangOpts().Sanitize))
|
if (!isAsanHwasanOrMemTag(CGM.getLangOpts().Sanitize))
|
||||||
return;
|
return;
|
||||||
std::string QualName;
|
std::string QualName;
|
||||||
|
@ -75,15 +75,15 @@ void SanitizerMetadata::reportGlobalToASan(llvm::GlobalVariable *GV,
|
||||||
IsExcluded = true;
|
IsExcluded = true;
|
||||||
if (D.hasAttr<DisableSanitizerInstrumentationAttr>())
|
if (D.hasAttr<DisableSanitizerInstrumentationAttr>())
|
||||||
IsExcluded = true;
|
IsExcluded = true;
|
||||||
reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), IsDynInit,
|
reportGlobal(GV, D.getLocation(), OS.str(), D.getType(), IsDynInit,
|
||||||
IsExcluded);
|
IsExcluded);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SanitizerMetadata::disableSanitizerForGlobal(llvm::GlobalVariable *GV) {
|
void SanitizerMetadata::disableSanitizerForGlobal(llvm::GlobalVariable *GV) {
|
||||||
// For now, just make sure the global is not modified by the ASan
|
// For now, just make sure the global is not modified by the ASan
|
||||||
// instrumentation.
|
// instrumentation.
|
||||||
if (isAsanHwasanOrMemTag(CGM.getLangOpts().Sanitize))
|
if (isAsanHwasanOrMemTag(CGM.getLangOpts().Sanitize))
|
||||||
reportGlobalToASan(GV, SourceLocation(), "", QualType(), false, true);
|
reportGlobal(GV, SourceLocation(), "", QualType(), false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SanitizerMetadata::disableSanitizerForInstruction(llvm::Instruction *I) {
|
void SanitizerMetadata::disableSanitizerForInstruction(llvm::Instruction *I) {
|
||||||
|
|
|
@ -36,11 +36,11 @@ class SanitizerMetadata {
|
||||||
CodeGenModule &CGM;
|
CodeGenModule &CGM;
|
||||||
public:
|
public:
|
||||||
SanitizerMetadata(CodeGenModule &CGM);
|
SanitizerMetadata(CodeGenModule &CGM);
|
||||||
void reportGlobalToASan(llvm::GlobalVariable *GV, const VarDecl &D,
|
void reportGlobal(llvm::GlobalVariable *GV, const VarDecl &D,
|
||||||
bool IsDynInit = false);
|
bool IsDynInit = false);
|
||||||
void reportGlobalToASan(llvm::GlobalVariable *GV, SourceLocation Loc,
|
void reportGlobal(llvm::GlobalVariable *GV, SourceLocation Loc,
|
||||||
StringRef Name, QualType Ty, bool IsDynInit = false,
|
StringRef Name, QualType Ty, bool IsDynInit = false,
|
||||||
bool IsExcluded = false);
|
bool IsExcluded = false);
|
||||||
void disableSanitizerForGlobal(llvm::GlobalVariable *GV);
|
void disableSanitizerForGlobal(llvm::GlobalVariable *GV);
|
||||||
void disableSanitizerForInstruction(llvm::Instruction *I);
|
void disableSanitizerForInstruction(llvm::Instruction *I);
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue