3 # Test merging code sections with data sections.
5 # RUN: llvm-mc -triple x86_64-windows-msvc %s -filetype=obj -o %t.obj
6 # RUN: lld-link -machine:amd64 -dll -noentry -out:%t.dll %t.obj -merge:.testx=.testd -merge:.testx2=.testbss -merge:.testd2=.testx3 -merge:.testbss2=.testx4
8 # RUN: llvm-readobj --sections %t.dll | FileCheck %s
10 # CHECK-NEXT: Section {
11 # CHECK-NEXT: Number: 1
12 # CHECK-NEXT: Name: .testbss (2E 74 65 73 74 62 73 73)
13 # CHECK-NEXT: VirtualSize: 0x18
14 # CHECK-NEXT: VirtualAddress: 0x1000
15 # CHECK-NEXT: RawDataSize: 512
16 # CHECK-NEXT: PointerToRawData: 0x400
17 # CHECK-NEXT: PointerToRelocations: 0x0
18 # CHECK-NEXT: PointerToLineNumbers: 0x0
19 # CHECK-NEXT: RelocationCount: 0
20 # CHECK-NEXT: LineNumberCount: 0
21 # CHECK-NEXT: Characteristics [ (0xC0000020)
22 # CHECK-NEXT: IMAGE_SCN_CNT_CODE (0x20)
23 # CHECK-NEXT: IMAGE_SCN_MEM_READ (0x40000000)
24 # CHECK-NEXT: IMAGE_SCN_MEM_WRITE (0x80000000)
27 # CHECK-NEXT: Section {
28 # CHECK-NEXT: Number: 2
29 # CHECK-NEXT: Name: .testd (2E 74 65 73 74 64 00 00)
30 # CHECK-NEXT: VirtualSize: 0x18
31 # CHECK-NEXT: VirtualAddress: 0x2000
32 # CHECK-NEXT: RawDataSize: 512
33 # CHECK-NEXT: PointerToRawData: 0x600
34 # CHECK-NEXT: PointerToRelocations: 0x0
35 # CHECK-NEXT: PointerToLineNumbers: 0x0
36 # CHECK-NEXT: RelocationCount: 0
37 # CHECK-NEXT: LineNumberCount: 0
38 # CHECK-NEXT: Characteristics [ (0x40000020)
39 # CHECK-NEXT: IMAGE_SCN_CNT_CODE (0x20)
40 # CHECK-NEXT: IMAGE_SCN_MEM_READ (0x40000000)
43 # CHECK-NEXT: Section {
44 # CHECK-NEXT: Number: 3
45 # CHECK-NEXT: Name: .testx3 (2E 74 65 73 74 78 33 00)
46 # CHECK-NEXT: VirtualSize: 0x12
47 # CHECK-NEXT: VirtualAddress: 0x3000
48 # CHECK-NEXT: RawDataSize: 512
49 # CHECK-NEXT: PointerToRawData: 0x800
50 # CHECK-NEXT: PointerToRelocations: 0x0
51 # CHECK-NEXT: PointerToLineNumbers: 0x0
52 # CHECK-NEXT: RelocationCount: 0
53 # CHECK-NEXT: LineNumberCount: 0
54 # CHECK-NEXT: Characteristics [ (0x60000020)
55 # CHECK-NEXT: IMAGE_SCN_CNT_CODE (0x20)
56 # CHECK-NEXT: IMAGE_SCN_MEM_EXECUTE (0x20000000)
57 # CHECK-NEXT: IMAGE_SCN_MEM_READ (0x40000000)
60 # CHECK-NEXT: Section {
61 # CHECK-NEXT: Number: 4
62 # CHECK-NEXT: Name: .testx4 (2E 74 65 73 74 78 34 00)
63 # CHECK-NEXT: VirtualSize: 0x14
64 # CHECK-NEXT: VirtualAddress: 0x4000
65 # CHECK-NEXT: RawDataSize: 512
66 # CHECK-NEXT: PointerToRawData: 0xA00
67 # CHECK-NEXT: PointerToRelocations: 0x0
68 # CHECK-NEXT: PointerToLineNumbers: 0x0
69 # CHECK-NEXT: RelocationCount: 0
70 # CHECK-NEXT: LineNumberCount: 0
71 # CHECK-NEXT: Characteristics [ (0x60000020)
72 # CHECK-NEXT: IMAGE_SCN_CNT_CODE (0x20)
73 # CHECK-NEXT: IMAGE_SCN_MEM_EXECUTE (0x20000000)
74 # CHECK-NEXT: IMAGE_SCN_MEM_READ (0x40000000)
79 # RUN: llvm-objdump -d %t.dll | FileCheck -check-prefix=DISASM %s
80 # DISASM: Disassembly of section .testbss:
82 # DISASM-NEXT: 0000000180001000 <.testbss>:
83 # DISASM-NEXT: 180001000: 00 00 addb %al, (%rax)
84 # DISASM-NEXT: 180001002: 00 00 addb %al, (%rax)
85 # DISASM-NEXT: 180001004: cc int3
86 # DISASM-NEXT: 180001005: cc int3
87 # DISASM-NEXT: 180001006: cc int3
88 # DISASM-NEXT: 180001007: cc int3
89 # DISASM-NEXT: 180001008: cc int3
90 # DISASM-NEXT: 180001009: cc int3
91 # DISASM-NEXT: 18000100a: cc int3
92 # DISASM-NEXT: 18000100b: cc int3
93 # DISASM-NEXT: 18000100c: cc int3
94 # DISASM-NEXT: 18000100d: cc int3
95 # DISASM-NEXT: 18000100e: cc int3
96 # DISASM-NEXT: 18000100f: cc int3
97 # DISASM-NEXT: 180001010: 48 c7 c0 02 00 00 00 movq $0x2, %rax
98 # DISASM-NEXT: 180001017: c3 retq
100 # DISASM-NEXT: Disassembly of section .testd:
102 # DISASM-NEXT: 0000000180002000 <.testd>:
103 # DISASM-NEXT: 180002000: 01 00 addl %eax, (%rax)
104 # DISASM-NEXT: 180002002: cc int3
105 # DISASM-NEXT: 180002003: cc int3
106 # DISASM-NEXT: 180002004: cc int3
107 # DISASM-NEXT: 180002005: cc int3
108 # DISASM-NEXT: 180002006: cc int3
109 # DISASM-NEXT: 180002007: cc int3
110 # DISASM-NEXT: 180002008: cc int3
111 # DISASM-NEXT: 180002009: cc int3
112 # DISASM-NEXT: 18000200a: cc int3
113 # DISASM-NEXT: 18000200b: cc int3
114 # DISASM-NEXT: 18000200c: cc int3
115 # DISASM-NEXT: 18000200d: cc int3
116 # DISASM-NEXT: 18000200e: cc int3
117 # DISASM-NEXT: 18000200f: cc int3
118 # DISASM-NEXT: 180002010: 48 c7 c0 01 00 00 00 movq $0x1, %rax
119 # DISASM-NEXT: 180002017: c3 retq
121 # DISASM-NEXT: Disassembly of section .testx3:
123 # DISASM-NEXT: 0000000180003000 <.testx3>:
124 # DISASM-NEXT: 180003000: 48 c7 c0 03 00 00 00 movq $0x3, %rax
125 # DISASM-NEXT: 180003007: c3 retq
126 # DISASM-NEXT: 180003008: cc int3
127 # DISASM-NEXT: 180003009: cc int3
128 # DISASM-NEXT: 18000300a: cc int3
129 # DISASM-NEXT: 18000300b: cc int3
130 # DISASM-NEXT: 18000300c: cc int3
131 # DISASM-NEXT: 18000300d: cc int3
132 # DISASM-NEXT: 18000300e: cc int3
133 # DISASM-NEXT: 18000300f: cc int3
134 # DISASM-NEXT: 180003010: 02 00 addb (%rax), %al
136 # DISASM-NEXT: Disassembly of section .testx4:
138 # DISASM-NEXT: 0000000180004000 <.testx4>:
139 # DISASM-NEXT: 180004000: 48 c7 c0 04 00 00 00 movq $0x4, %rax
140 # DISASM-NEXT: 180004007: c3 retq
141 # DISASM-NEXT: 180004008: cc int3
142 # DISASM-NEXT: 180004009: cc int3
143 # DISASM-NEXT: 18000400a: cc int3
144 # DISASM-NEXT: 18000400b: cc int3
145 # DISASM-NEXT: 18000400c: cc int3
146 # DISASM-NEXT: 18000400d: cc int3
147 # DISASM-NEXT: 18000400e: cc int3
148 # DISASM-NEXT: 18000400f: cc int3
149 # DISASM-NEXT: 180004010: 00 00 addb %al, (%rax)
150 # DISASM-NEXT: 180004012: 00 00 addb %al, (%rax)
153 .section .testx, "xr"
158 .section .testx2, "xr"
163 .section .testd, "dr"
167 .section .testbss, "b"
171 .section .testx3, "xr"
176 .section .testx4, "xr"
181 .section .testd2, "dr"
185 .section .testbss2, "b"