[llvm-commits] [llvm] r116151 - in /llvm/trunk: lib/MC/WinCOFFStreamer.cpp test/MC/COFF/basic-coff.s test/MC/COFF/module-asm.ll
Michael J. Spencer
bigcheesegs at gmail.com
Sat Oct 9 08:44:27 PDT 2010
Author: mspencer
Date: Sat Oct 9 10:44:27 2010
New Revision: 116151
URL: http://llvm.org/viewvc/llvm-project?rev=116151&view=rev
Log:
MC-COFF: Implement InitSections. Fixes PR8335.
Added:
llvm/trunk/test/MC/COFF/module-asm.ll
Modified:
llvm/trunk/lib/MC/WinCOFFStreamer.cpp
llvm/trunk/test/MC/COFF/basic-coff.s
Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=116151&r1=116150&r2=116151&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Sat Oct 9 10:44:27 2010
@@ -79,6 +79,41 @@
virtual void EmitDwarfFileDirective(unsigned FileNo,StringRef Filename);
virtual void EmitInstruction(const MCInst &Instruction);
virtual void Finish();
+
+private:
+ void SetSection(StringRef Section,
+ unsigned Characteristics,
+ SectionKind Kind) {
+ SwitchSection(getContext().getCOFFSection(Section, Characteristics, Kind));
+ }
+
+ void SetSectionText() {
+ SetSection(".text",
+ COFF::IMAGE_SCN_CNT_CODE
+ | COFF::IMAGE_SCN_MEM_EXECUTE
+ | COFF::IMAGE_SCN_MEM_READ,
+ SectionKind::getText());
+ EmitCodeAlignment(4, 0);
+ }
+
+ void SetSectionData() {
+ SetSection(".data",
+ COFF::IMAGE_SCN_CNT_INITIALIZED_DATA
+ | COFF::IMAGE_SCN_MEM_READ
+ | COFF::IMAGE_SCN_MEM_WRITE,
+ SectionKind::getDataRel());
+ EmitCodeAlignment(4, 0);
+ }
+
+ void SetSectionBSS() {
+ SetSection(".bss",
+ COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA
+ | COFF::IMAGE_SCN_MEM_READ
+ | COFF::IMAGE_SCN_MEM_WRITE,
+ SectionKind::getBSS());
+ EmitCodeAlignment(4, 0);
+ }
+
};
} // end anonymous namespace.
@@ -128,6 +163,10 @@
// MCStreamer interface
void WinCOFFStreamer::InitSections() {
+ SetSectionText();
+ SetSectionData();
+ SetSectionBSS();
+ SetSectionText();
}
void WinCOFFStreamer::EmitLabel(MCSymbol *Symbol) {
Modified: llvm/trunk/test/MC/COFF/basic-coff.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/basic-coff.s?rev=116151&r1=116150&r2=116151&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/basic-coff.s (original)
+++ llvm/trunk/test/MC/COFF/basic-coff.s Sat Oct 9 10:44:27 2010
@@ -74,9 +74,9 @@
// CHECK: PointerToLineNumbers = 0x0
// CHECK: NumberOfRelocations = 0
// CHECK: NumberOfLineNumbers = 0
-// CHECK: Charateristics = 0xC0100040
+// CHECK: Charateristics = 0xC0300040
// CHECK: IMAGE_SCN_CNT_INITIALIZED_DATA
-// CHECK: IMAGE_SCN_ALIGN_1BYTES
+// CHECK: IMAGE_SCN_ALIGN_4BYTES
// CHECK: IMAGE_SCN_MEM_READ
// CHECK: IMAGE_SCN_MEM_WRITE
// CHECK: SectionData =
@@ -94,7 +94,7 @@
// CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3)
// CHECK: NumberOfAuxSymbols = 1
// CHECK: AuxillaryData =
-// CHECK: 15 00 00 00 02 00 00 00 - 00 00 00 00 01 00 00 00 |................|
+// CHECK: 18 00 00 00 02 00 00 00 - 00 00 00 00 01 00 00 00 |................|
// CHECK: 00 00 |..|
// CHECK: }
// CHECK: 2 = {
Added: llvm/trunk/test/MC/COFF/module-asm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/module-asm.ll?rev=116151&view=auto
==============================================================================
--- llvm/trunk/test/MC/COFF/module-asm.ll (added)
+++ llvm/trunk/test/MC/COFF/module-asm.ll Sat Oct 9 10:44:27 2010
@@ -0,0 +1,26 @@
+; The purpose of this test is to verify that various module level assembly
+; constructs work.
+
+; RUN: llc -filetype=obj -mtriple i686-pc-win32 %s -o - | coff-dump.py | FileCheck %s
+; RUN: llc -filetype=obj -mtriple x86_64-pc-win32 %s -o - | coff-dump.py | FileCheck %s
+
+module asm ".text"
+module asm "_foo:"
+module asm " ret"
+
+; CHECK: Name = .text
+; CHECK-NEXT: VirtualSize = 0
+; CHECK-NEXT: VirtualAddress = 0
+; CHECK-NEXT: SizeOfRawData = {{[0-9]+}}
+; CHECK-NEXT: PointerToRawData = 0x{{[0-9A-F]+}}
+; CHECK-NEXT: PointerToRelocations = 0x{{[0-9A-F]+}}
+; CHECK-NEXT: PointerToLineNumbers = 0x0
+; CHECK-NEXT: NumberOfRelocations = 0
+; CHECK-NEXT: NumberOfLineNumbers = 0
+; CHECK-NEXT: Charateristics = 0x60300020
+; CHECK-NEXT: IMAGE_SCN_CNT_CODE
+; CHECK-NEXT: IMAGE_SCN_ALIGN_4BYTES
+; CHECK-NEXT: IMAGE_SCN_MEM_EXECUTE
+; CHECK-NEXT: IMAGE_SCN_MEM_READ
+; CHECK-NEXT: SectionData =
+; CHECK-NEXT: C3
More information about the llvm-commits
mailing list