MC COFF: Emit the 'b' section flag for .bss sections in GNU assembly
authorReid Kleckner <reid@kleckner.net>
Tue, 17 Dec 2013 22:12:40 +0000 (22:12 +0000)
committerReid Kleckner <reid@kleckner.net>
Tue, 17 Dec 2013 22:12:40 +0000 (22:12 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197529 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCSectionCOFF.cpp
test/MC/COFF/bss_section.ll

index bb35027464021972184982fe0b205a25f5899fbb..ad9ca8840f4f4169fdb693a96a20fcc3d0357229 100644 (file)
@@ -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
index 60924f13064f78ad56ba02c5cea390370e79c0f3..477b3dfbd3a60f9986db92199df0e70977a549fe 100644 (file)
@@ -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