summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-07-23 22:15:19 +0000
committerMartin Storsjo <martin@martin.st>2018-07-23 22:15:19 +0000
commit100fc97051c19ef3675fc105dd428955b7f5f285 (patch)
tree00b6e680652ba6b2a59572b25b5777c17101b498 /llvm/lib/MC
parentc2b701408e3a94df1dcdc96ed2891ca916441a87 (diff)
downloadbcm5719-llvm-100fc97051c19ef3675fc105dd428955b7f5f285.tar.gz
bcm5719-llvm-100fc97051c19ef3675fc105dd428955b7f5f285.zip
[COFF] Fix assembly output of comdat sections without an attached symbol
Since SVN r335286, the .xdata sections are produced without an attached symbol, which requires using a different syntax when printing assembly output. Instead of the usual syntax of '.section <name>,"dr",discard,<symbol>', use '.section <name>,"dr"' + '.linkonce discard' (which is what GCC uses for all assembly output). This fixes PR38254. Differential Revision: https://reviews.llvm.org/D49651 llvm-svn: 337756
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r--llvm/lib/MC/MCSectionCOFF.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/llvm/lib/MC/MCSectionCOFF.cpp b/llvm/lib/MC/MCSectionCOFF.cpp
index 72a7fc36a46..c861963eec8 100644
--- a/llvm/lib/MC/MCSectionCOFF.cpp
+++ b/llvm/lib/MC/MCSectionCOFF.cpp
@@ -69,35 +69,40 @@ void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
OS << '"';
if (getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT) {
- OS << ",";
+ if (COMDATSymbol)
+ OS << ",";
+ else
+ OS << "\n\t.linkonce\t";
switch (Selection) {
case COFF::IMAGE_COMDAT_SELECT_NODUPLICATES:
- OS << "one_only,";
+ OS << "one_only";
break;
case COFF::IMAGE_COMDAT_SELECT_ANY:
- OS << "discard,";
+ OS << "discard";
break;
case COFF::IMAGE_COMDAT_SELECT_SAME_SIZE:
- OS << "same_size,";
+ OS << "same_size";
break;
case COFF::IMAGE_COMDAT_SELECT_EXACT_MATCH:
- OS << "same_contents,";
+ OS << "same_contents";
break;
case COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE:
- OS << "associative,";
+ OS << "associative";
break;
case COFF::IMAGE_COMDAT_SELECT_LARGEST:
- OS << "largest,";
+ OS << "largest";
break;
case COFF::IMAGE_COMDAT_SELECT_NEWEST:
- OS << "newest,";
+ OS << "newest";
break;
default:
assert(false && "unsupported COFF selection type");
break;
}
- assert(COMDATSymbol);
- COMDATSymbol->print(OS, &MAI);
+ if (COMDATSymbol) {
+ OS << ",";
+ COMDATSymbol->print(OS, &MAI);
+ }
}
OS << '\n';
}
OpenPOWER on IntegriCloud