From d4e53f55f1f1883993b233e8308247b0489834af Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 17 Dec 2013 22:12:40 +0000 Subject: [PATCH] MC COFF: Emit the 'b' section flag for .bss sections in GNU assembly Without this, assembling clang's disassembly would produce an object file with the IMAGE_SCN_CNT_INITIALIZED_DATA section characteristic rather than the uninitialized one. link.exe would warn when merging comdats with different flags. llvm-svn: 197529 --- llvm/lib/MC/MCSectionCOFF.cpp | 2 ++ llvm/test/MC/COFF/bss_section.ll | 3 +++ 2 files changed, 5 insertions(+) diff --git a/llvm/lib/MC/MCSectionCOFF.cpp b/llvm/lib/MC/MCSectionCOFF.cpp index bb3502746402..ad9ca8840f4f 100644 --- a/llvm/lib/MC/MCSectionCOFF.cpp +++ b/llvm/lib/MC/MCSectionCOFF.cpp @@ -54,6 +54,8 @@ void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI, OS << "\t.section\t" << getSectionName() << ",\""; if (getKind().isText()) OS << 'x'; + else if (getKind().isBSS()) + OS << 'b'; if (getKind().isWriteable()) OS << 'w'; else diff --git a/llvm/test/MC/COFF/bss_section.ll b/llvm/test/MC/COFF/bss_section.ll index 60924f13064f..477b3dfbd3a6 100644 --- a/llvm/test/MC/COFF/bss_section.ll +++ b/llvm/test/MC/COFF/bss_section.ll @@ -4,3 +4,6 @@ @"\01?thingy@@3Ufoo@@B" = global %struct.foo zeroinitializer, align 4 ; CHECK: .bss + +@thingy_linkonce = linkonce_odr global %struct.foo zeroinitializer, align 4 +; CHECK: .section .bss,"bw",discard,_thingy_linkonce