[PATCH] [-cxx-abi microsoft] Stick zero initialized symbols into the .bss section for COFF
David Majnemer
david.majnemer at gmail.com
Sun Aug 11 21:11:50 PDT 2013
Hi rnk,
We need to do two things:
- Initialize BSSSection in MCObjectFileInfo::InitCOFFMCObjectFileInfo
- Teach TargetLoweringObjectFileCOFF::SelectSectionForGlobal what to do
with it
This fixes PR16861.
http://llvm-reviews.chandlerc.com/D1361
Files:
lib/CodeGen/TargetLoweringObjectFileImpl.cpp
lib/MC/MCObjectFileInfo.cpp
test/MC/COFF/bss_section.ll
Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -771,15 +771,18 @@
}
if (Kind.isText())
- return getTextSection();
+ return TextSection;
if (Kind.isThreadLocal())
- return getTLSDataSection();
+ return TLSDataSection;
- if (Kind.isReadOnly() && ReadOnlySection != 0)
+ if (Kind.isReadOnly())
return ReadOnlySection;
- return getDataSection();
+ if (Kind.isBSS())
+ return BSSSection;
+
+ return DataSection;
}
void TargetLoweringObjectFileCOFF::
Index: lib/MC/MCObjectFileInfo.cpp
===================================================================
--- lib/MC/MCObjectFileInfo.cpp
+++ lib/MC/MCObjectFileInfo.cpp
@@ -496,6 +496,12 @@
void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
// COFF
+ BSSSection =
+ Ctx->getCOFFSection(".bss",
+ COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
+ COFF::IMAGE_SCN_MEM_READ |
+ COFF::IMAGE_SCN_MEM_WRITE,
+ SectionKind::getBSS());
TextSection =
Ctx->getCOFFSection(".text",
COFF::IMAGE_SCN_CNT_CODE |
Index: test/MC/COFF/bss_section.ll
===================================================================
--- /dev/null
+++ test/MC/COFF/bss_section.ll
@@ -0,0 +1,6 @@
+; RUN: llc -mtriple i386-pc-win32 < %s | FileCheck %s
+
+%struct.foo = type { i32, i32 }
+
+@"\01?thingy@@3Ufoo@@B" = global %struct.foo zeroinitializer, align 4
+; CHECK: .bss
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1361.1.patch
Type: text/x-patch
Size: 1641 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130811/d4d58c95/attachment.bin>
More information about the llvm-commits
mailing list