mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 17:32:36 +00:00
MC-COFF: Implement InitSections. Fixes PR8335.
llvm-svn: 116151
This commit is contained in:
parent
9e8793d7d6
commit
4dc462314c
@ -79,6 +79,41 @@ public:
|
|||||||
virtual void EmitDwarfFileDirective(unsigned FileNo,StringRef Filename);
|
virtual void EmitDwarfFileDirective(unsigned FileNo,StringRef Filename);
|
||||||
virtual void EmitInstruction(const MCInst &Instruction);
|
virtual void EmitInstruction(const MCInst &Instruction);
|
||||||
virtual void Finish();
|
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.
|
} // end anonymous namespace.
|
||||||
|
|
||||||
@ -128,6 +163,10 @@ void WinCOFFStreamer::AddCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
|||||||
// MCStreamer interface
|
// MCStreamer interface
|
||||||
|
|
||||||
void WinCOFFStreamer::InitSections() {
|
void WinCOFFStreamer::InitSections() {
|
||||||
|
SetSectionText();
|
||||||
|
SetSectionData();
|
||||||
|
SetSectionBSS();
|
||||||
|
SetSectionText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinCOFFStreamer::EmitLabel(MCSymbol *Symbol) {
|
void WinCOFFStreamer::EmitLabel(MCSymbol *Symbol) {
|
||||||
|
@ -74,9 +74,9 @@ L_.str: # @.str
|
|||||||
// CHECK: PointerToLineNumbers = 0x0
|
// CHECK: PointerToLineNumbers = 0x0
|
||||||
// CHECK: NumberOfRelocations = 0
|
// CHECK: NumberOfRelocations = 0
|
||||||
// CHECK: NumberOfLineNumbers = 0
|
// CHECK: NumberOfLineNumbers = 0
|
||||||
// CHECK: Charateristics = 0xC0100040
|
// CHECK: Charateristics = 0xC0300040
|
||||||
// CHECK: IMAGE_SCN_CNT_INITIALIZED_DATA
|
// 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_READ
|
||||||
// CHECK: IMAGE_SCN_MEM_WRITE
|
// CHECK: IMAGE_SCN_MEM_WRITE
|
||||||
// CHECK: SectionData =
|
// CHECK: SectionData =
|
||||||
@ -94,7 +94,7 @@ L_.str: # @.str
|
|||||||
// CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3)
|
// CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3)
|
||||||
// CHECK: NumberOfAuxSymbols = 1
|
// CHECK: NumberOfAuxSymbols = 1
|
||||||
// CHECK: AuxillaryData =
|
// 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: 00 00 |..|
|
||||||
// CHECK: }
|
// CHECK: }
|
||||||
// CHECK: 2 = {
|
// CHECK: 2 = {
|
||||||
|
26
test/MC/COFF/module-asm.ll
Normal file
26
test/MC/COFF/module-asm.ll
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user