MC-COFF: Fix .bss section size. Fixes PR8335. Patch by NAKAMUTA Takumi!
authorMichael J. Spencer <bigcheesegs@gmail.com>
Sat, 9 Oct 2010 16:04:45 +0000 (16:04 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Sat, 9 Oct 2010 16:04:45 +0000 (16:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116155 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/WinCOFFObjectWriter.cpp
test/MC/COFF/bss.s [new file with mode: 0644]

index c6ea31a34e385849058f9b501d9e3c0a6d1dc50c..285717e83e2a885a4cb1c4cbf8dbea99fef0c150 100644 (file)
@@ -801,7 +801,7 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm,
     if (Sec->Number == -1)
       continue;
 
-    Sec->Header.SizeOfRawData = Layout.getSectionFileSize(i);
+    Sec->Header.SizeOfRawData = Layout.getSectionAddressSize(i);
 
     if (IsPhysicalSection(Sec)) {
       Sec->Header.PointerToRawData = offset;
diff --git a/test/MC/COFF/bss.s b/test/MC/COFF/bss.s
new file mode 100644 (file)
index 0000000..f44225b
--- /dev/null
@@ -0,0 +1,15 @@
+// The purpose of this test is to verify that bss sections are emited correctly.\r
+\r
+// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | coff-dump.py | FileCheck %s\r
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s | coff-dump.py | FileCheck %s\r
+\r
+    .bss\r
+    .globl _g0\r
+    .align 4\r
+_g0:\r
+    .long 0\r
+\r
+// CHECK:      Name           = .bss\r
+// CHECK-NEXT: VirtualSize    = 0\r
+// CHECK-NEXT: VirtualAddress = 0\r
+// CHECK-NEXT: SizeOfRawData  = 4\r