summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp8
-rw-r--r--llvm/lib/MC/MCAsmInfoCOFF.cpp8
2 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index b726b21f6b9..b5dd2d4cca8 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1397,9 +1397,11 @@ MCSection *TargetLoweringObjectFileCOFF::getSectionForConstant(
const DataLayout &DL, SectionKind Kind, const Constant *C,
unsigned &Align) const {
if (Kind.isMergeableConst() && C &&
- getContext().getAsmInfo()->hasCOFFAssociativeComdats()) {
- // GNU binutils doesn't support the kind of symbol with a null
- // storage class that this generates.
+ getContext().getAsmInfo()->hasCOFFComdatConstants()) {
+ // This creates comdat sections with the given symbol name, but unless
+ // AsmPrinter::GetCPISymbol actually makes the symbol global, the symbol
+ // will be created with a null storage class, which makes GNU binutils
+ // error out.
const unsigned Characteristics = COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_LNK_COMDAT;
diff --git a/llvm/lib/MC/MCAsmInfoCOFF.cpp b/llvm/lib/MC/MCAsmInfoCOFF.cpp
index 8bb02c3f649..d8fb875b67c 100644
--- a/llvm/lib/MC/MCAsmInfoCOFF.cpp
+++ b/llvm/lib/MC/MCAsmInfoCOFF.cpp
@@ -45,6 +45,11 @@ MCAsmInfoCOFF::MCAsmInfoCOFF() {
// If this is a COFF target, assume that it supports associative comdats. It's
// part of the spec.
HasCOFFAssociativeComdats = true;
+
+ // We can generate constants in comdat sections that can be shared,
+ // but in order not to create null typed symbols, we actually need to
+ // make them global symbols as well.
+ HasCOFFComdatConstants = true;
}
void MCAsmInfoMicrosoft::anchor() {}
@@ -58,4 +63,7 @@ MCAsmInfoGNUCOFF::MCAsmInfoGNUCOFF() {
// comdats for jump tables, unwind information, and other data associated with
// a function.
HasCOFFAssociativeComdats = false;
+
+ // We don't create constants in comdat sections for MinGW.
+ HasCOFFComdatConstants = false;
}
OpenPOWER on IntegriCloud