aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 578d09f..12c7d48 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2657,12 +2657,22 @@ StringRef CGDebugInfo::getVTableName(const CXXRecordDecl *RD) {
// existing information in the DWARF. The type is assumed to be 'void *'.
void CGDebugInfo::emitVTableSymbol(llvm::GlobalVariable *VTable,
const CXXRecordDecl *RD) {
- if (!CGM.getTarget().getCXXABI().isItaniumFamily() ||
- CGM.getTarget().getTriple().isOSBinFormatCOFF())
+ if (!CGM.getTarget().getCXXABI().isItaniumFamily())
return;
if (DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
return;
+ // On COFF platform, we shouldn't emit a reference to an external entity (i.e.
+ // VTable) into debug info, which is constructed within a discardable section.
+ // If that entity ends up implicitly dllimported from another DLL, the linker
+ // may produce a runtime pseudo-relocation for it (BFD-ld only. LLD prohibits
+ // to emit such relocation). If the debug section is stripped, the runtime
+ // pseudo-relocation points to memory space outside of the module, causing an
+ // access violation.
+ if (CGM.getTarget().getTriple().isOSBinFormatCOFF() &&
+ VTable->isDeclarationForLinker())
+ return;
+
ASTContext &Context = CGM.getContext();
StringRef SymbolName = "_vtable$";
SourceLocation Loc;