mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 04:33:05 +00:00
MC-COFF: Implement InitSections. Fixes PR8335.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116151 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7d4900416a
commit
192d136750
@ -79,6 +79,41 @@ public:
|
||||
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 @@ void WinCOFFStreamer::AddCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
// MCStreamer interface
|
||||
|
||||
void WinCOFFStreamer::InitSections() {
|
||||
SetSectionText();
|
||||
SetSectionData();
|
||||
SetSectionBSS();
|
||||
SetSectionText();
|
||||
}
|
||||
|
||||
void WinCOFFStreamer::EmitLabel(MCSymbol *Symbol) {
|
||||
|
@ -74,9 +74,9 @@ L_.str: # @.str
|
||||
// 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 @@ L_.str: # @.str
|
||||
// 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 = {
|
||||
|
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…
Reference in New Issue
Block a user