166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// This test checks that the COFF object emitter works for the most basic
266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// programs.
366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | coff-dump.py | FileCheck %s
566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// I WOULD RUN, BUT THIS FAILS: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s
666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman.def	 _main;
866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	.scl	2;
966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	.type	32;
1066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	.endef
1166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	.text
1266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	.globl	_main
1366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	.align	16, 0x90
1466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman_main:                                  # @main
1566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# BB#0:                                 # %entry
1666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	subl	$4, %esp
1766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	movl	$L_.str, (%esp)
1866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	calll	_printf
1966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	xorl	%eax, %eax
2066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	addl	$4, %esp
2166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	ret
2266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
2366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	.data
2466b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanL_.str:                                 # @.str
2566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	.asciz	 "Hello World"
2666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
2766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK: {
2866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:   MachineType              = IMAGE_FILE_MACHINE_I386 (0x14C)
2966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:   NumberOfSections         = 2
3066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:   TimeDateStamp            = {{[0-9]+}}
3166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:   PointerToSymbolTable     = 0x{{[0-9A-F]+}}
3266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:   NumberOfSymbols          = 6
3366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:   SizeOfOptionalHeader     = 0
3466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:   Characteristics          = 0x0
3566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:   Sections                 = [
3666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:     1 = {
3766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Name                     = .text
3866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       VirtualSize              = 0
3966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       VirtualAddress           = 0
4066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       SizeOfRawData            = {{[0-9]+}}
4166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       PointerToRawData         = 0x{{[0-9A-F]+}}
4266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       PointerToRelocations     = 0x{{[0-9A-F]+}}
4366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       PointerToLineNumbers     = 0x0
4466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       NumberOfRelocations      = 2
4566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       NumberOfLineNumbers      = 0
4666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Charateristics           = 0x60500020
4766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         IMAGE_SCN_CNT_CODE
4866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         IMAGE_SCN_ALIGN_16BYTES
4966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         IMAGE_SCN_MEM_EXECUTE
5066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         IMAGE_SCN_MEM_READ
5166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       SectionData              =
5266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Relocations              = [
5366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         0 = {
5466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:           VirtualAddress           = 0x{{[0-9A-F]+}}
5566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:           SymbolTableIndex         = 2
5666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:           Type                     = IMAGE_REL_I386_DIR32 (6)
5766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:           SymbolName               = .data
5866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         }
5966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         1 = {
6066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:           VirtualAddress           = 0x{{[0-9A-F]+}}
6166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:           SymbolTableIndex         = 5
6266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:           Type                     = IMAGE_REL_I386_REL32 (20)
6366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:           SymbolName               = _printf
6466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         }
6566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       ]
6666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:     }
6766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:     2 = {
6866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Name                     = .data
6966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       VirtualSize              = 0
7066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       VirtualAddress           = 0
7166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       SizeOfRawData            = {{[0-9]+}}
7266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       PointerToRawData         = 0x{{[0-9A-F]+}}
7366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       PointerToRelocations     = 0x0
7466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       PointerToLineNumbers     = 0x0
7566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       NumberOfRelocations      = 0
7666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       NumberOfLineNumbers      = 0
7766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Charateristics           = 0xC0300040
7866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         IMAGE_SCN_CNT_INITIALIZED_DATA
7966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         IMAGE_SCN_ALIGN_4BYTES
8066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         IMAGE_SCN_MEM_READ
8166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         IMAGE_SCN_MEM_WRITE
8266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       SectionData              =
8366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         48 65 6C 6C 6F 20 57 6F - 72 6C 64 00             |Hello World.|
8466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Relocations              = None
8566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:     }
8666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:   ]
8766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:   Symbols                  = [
8866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:     0 = {
8966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Name                     = .text
9066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Value                    = 0
9166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       SectionNumber            = 1
9266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       SimpleType               = IMAGE_SYM_TYPE_NULL (0)
9366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       ComplexType              = IMAGE_SYM_DTYPE_NULL (0)
9466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       StorageClass             = IMAGE_SYM_CLASS_STATIC (3)
9566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       NumberOfAuxSymbols       = 1
9666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       AuxillaryData            =
9766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         15 00 00 00 02 00 00 00 - 00 00 00 00 01 00 00 00 |................|
9866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         00 00                                             |..|
9966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:     }
10066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:     2 = {
10166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Name                     = .data
10266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Value                    = 0
10366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       SectionNumber            = 2
10466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       SimpleType               = IMAGE_SYM_TYPE_NULL (0)
10566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       ComplexType              = IMAGE_SYM_DTYPE_NULL (0)
10666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       StorageClass             = IMAGE_SYM_CLASS_STATIC (3)
10766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       NumberOfAuxSymbols       = 1
10866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       AuxillaryData            =
10966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         0C 00 00 00 00 00 00 00 - 00 00 00 00 02 00 00 00 |................|
11066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:         00 00                                             |..|
11166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:     }
11266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:     4 = {
11366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Name                     = _main
11466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Value                    = 0
11566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       SectionNumber            = 1
11666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       SimpleType               = IMAGE_SYM_TYPE_NULL (0)
11766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       ComplexType              = IMAGE_SYM_DTYPE_FUNCTION (2)
11866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       StorageClass             = IMAGE_SYM_CLASS_EXTERNAL (2)
11966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       NumberOfAuxSymbols       = 0
12066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       AuxillaryData            =
12166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:     }
12266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:     5 = {
12366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Name                     = _printf
12466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       Value                    = 0
12566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       SectionNumber            = 0
12666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       SimpleType               = IMAGE_SYM_TYPE_NULL (0)
12766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       ComplexType              = IMAGE_SYM_DTYPE_NULL (0)
12866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       StorageClass             = IMAGE_SYM_CLASS_EXTERNAL (2)
12966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       NumberOfAuxSymbols       = 0
13066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:       AuxillaryData            =
13166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:     }
13266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK:   ]
13366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// CHECK: }
134