[NFC][RemoveDIs] Prefer iterators over inst-pointers in InstCombine
[llvm-project.git] / llvm / test / MC / COFF / section.s
blob9c1a11effa3418eaad15cd277375f7dbcdb447d5
1 // RUN: llvm-mc -triple i386-pc-win32 -filetype=obj %s | llvm-readobj -S - | FileCheck %s
2 // RUN: llvm-mc -triple x86_64-pc-win32 -filetype=obj %s | llvm-readobj -S - | FileCheck %s
3 // RUN: not llvm-mc -triple x86_64-pc-win32 -filetype=obj --defsym ERR=1 %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR
5 .section .foo$bar; .long 1
6 .section .foo@bar; .long 1
7 .section ABCDEFGHIJKLMNOPQRSTUVWXYZ; .long 1
8 .section abcdefghijklmnopqrstuvwxyz; .long 1
9 .section _0123456789; .long 1
11 // CHECK: Sections [
12 // CHECK: Section {
13 // CHECK: Name: .foo$bar
14 // CHECK: }
15 // CHECK: Section {
16 // CHECK: Name: .foo@bar
17 // CHECK: }
18 // CHECK: Section {
19 // CHECK: Name: ABCDEFGHIJKLMNOPQRSTUVWXYZ
20 // CHECK: }
21 // CHECK: Section {
22 // CHECK: Name: abcdefghijklmnopqrstuvwxyz
23 // CHECK: }
24 // CHECK: Section {
25 // CHECK: Name: _0123456789
26 // CHECK: }
28 // Test that the defaults are used
29 .section s ; .long 1
30 .section s_, "" ; .long 1
31 .section s_a,"a"; .long 1
32 .section s_b,"b"; .long 1
33 .section s_d,"d"; .long 1
34 .section s_D,"D"; .long 1
35 .section s_n,"n"; .long 1
36 .section s_r,"r"; .long 1
37 .section s_s,"s"; .long 1
38 .section s_w,"w"; .long 1
39 .section s_x,"x"; .long 1
40 .section s_y,"y"; .long 1
41 .section s_i,"i"; .long 1
43 // CHECK: Section {
44 // CHECK: Name: s
45 // CHECK: Characteristics [
46 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
47 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
48 // CHECK-NEXT: IMAGE_SCN_MEM_READ
49 // CHECK-NEXT: IMAGE_SCN_MEM_WRITE
50 // CHECK-NEXT: ]
51 // CHECK: }
52 // CHECK: Section {
53 // CHECK: Name: s_
54 // CHECK: Characteristics [
55 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
56 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
57 // CHECK-NEXT: IMAGE_SCN_MEM_READ
58 // CHECK-NEXT: IMAGE_SCN_MEM_WRITE
59 // CHECK-NEXT: ]
60 // CHECK: }
61 // CHECK: Section {
62 // CHECK: Name: s_a
63 // CHECK: Characteristics [
64 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
65 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
66 // CHECK-NEXT: IMAGE_SCN_MEM_READ
67 // CHECK-NEXT: IMAGE_SCN_MEM_WRITE
68 // CHECK-NEXT: ]
69 // CHECK: }
70 // CHECK: Section {
71 // CHECK: Name: s_b
72 // CHECK: Characteristics [
73 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
74 // CHECK-NEXT: IMAGE_SCN_CNT_UNINITIALIZED_DATA
75 // CHECK-NEXT: IMAGE_SCN_MEM_READ
76 // CHECK-NEXT: IMAGE_SCN_MEM_WRITE
77 // CHECK-NEXT: ]
78 // CHECK: }
79 // CHECK: Section {
80 // CHECK: Name: s_d
81 // CHECK: Characteristics [
82 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
83 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
84 // CHECK-NEXT: IMAGE_SCN_MEM_READ
85 // CHECK-NEXT: IMAGE_SCN_MEM_WRITE
86 // CHECK-NEXT: ]
87 // CHECK: }
88 // CHECK: Section {
89 // CHECK: Name: s_D
90 // CHECK: Characteristics [
91 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
92 // CHECK-NEXT: IMAGE_SCN_MEM_DISCARDABLE
93 // CHECK-NEXT: IMAGE_SCN_MEM_READ
94 // CHECK-NEXT: IMAGE_SCN_MEM_WRITE
95 // CHECK-NEXT: ]
96 // CHECK: }
97 // CHECK: Section {
98 // CHECK: Name: s_n
99 // CHECK: Characteristics [
100 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
101 // CHECK-NEXT: IMAGE_SCN_LNK_REMOVE
102 // CHECK-NEXT: IMAGE_SCN_MEM_READ
103 // CHECK-NEXT: IMAGE_SCN_MEM_WRITE
104 // CHECK-NEXT: ]
105 // CHECK: }
106 // CHECK: Section {
107 // CHECK: Name: s_r
108 // CHECK: Characteristics [
109 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
110 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
111 // CHECK-NEXT: IMAGE_SCN_MEM_READ
112 // CHECK-NEXT: ]
113 // CHECK: }
114 // CHECK: Section {
115 // CHECK: Name: s_s
116 // CHECK: Characteristics [
117 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
118 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
119 // CHECK-NEXT: IMAGE_SCN_MEM_READ
120 // CHECK-NEXT: IMAGE_SCN_MEM_SHARED
121 // CHECK-NEXT: IMAGE_SCN_MEM_WRITE
122 // CHECK-NEXT: ]
123 // CHECK: }
124 // CHECK: Section {
125 // CHECK: Name: s_w
126 // CHECK: Characteristics [
127 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
128 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
129 // CHECK-NEXT: IMAGE_SCN_MEM_READ
130 // CHECK-NEXT: IMAGE_SCN_MEM_WRITE
131 // CHECK-NEXT: ]
132 // CHECK: }
133 // CHECK: Section {
134 // CHECK: Name: s_x
135 // CHECK: Characteristics [
136 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
137 // CHECK-NEXT: IMAGE_SCN_CNT_CODE
138 // CHECK-NEXT: IMAGE_SCN_MEM_EXECUTE
139 // CHECK-NEXT: IMAGE_SCN_MEM_READ
140 // CHECK-NEXT: ]
141 // CHECK: }
142 // CHECK: Section {
143 // CHECK: Name: s_y
144 // CHECK: Characteristics [
145 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
146 // CHECK-NEXT: ]
147 // CHECK: }
148 // CHECK: Section {
149 // CHECK: Name: s_i
150 // CHECK: Characteristics [
151 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
152 // CHECK-NEXT: IMAGE_SCN_LNK_INFO
153 // CHECK-NEXT: IMAGE_SCN_MEM_READ
154 // CHECK-NEXT: IMAGE_SCN_MEM_WRITE
155 // CHECK-NEXT: ]
156 // CHECK: }
158 // w makes read-only to readable
159 .section s_rw,"rw"; .long 1
160 // CHECK: Section {
161 // CHECK: Name: s_rw
162 // CHECK: Characteristics [
163 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
164 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
165 // CHECK-NEXT: IMAGE_SCN_MEM_READ
166 // CHECK-NEXT: IMAGE_SCN_MEM_WRITE
167 // CHECK-NEXT: ]
168 // CHECK: }
170 // r cancels w
171 .section s_wr,"wr"; .long 1
172 // CHECK: Section {
173 // CHECK: Name: s_wr
174 // CHECK: Characteristics [
175 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
176 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
177 // CHECK-NEXT: IMAGE_SCN_MEM_READ
178 // CHECK-NEXT: ]
179 // CHECK: }
181 // y cancels both
182 .section s_rwy,"rwy"; .long 1
183 // CHECK: Section {
184 // CHECK: Name: s_rwy
185 // CHECK: Characteristics [
186 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
187 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
188 // CHECK-NEXT: ]
189 // CHECK: }
191 // Sections starting with ".debug" are implicitly discardable. This is
192 // compatible with gas.
193 .section .debug_asdf,"dr"; .long 1
194 // CHECK: Section {
195 // CHECK: Name: .debug_asdf
196 // CHECK: Characteristics [
197 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
198 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
199 // CHECK-NEXT: IMAGE_SCN_MEM_DISCARDABLE
200 // CHECK-NEXT: IMAGE_SCN_MEM_READ
201 // CHECK-NEXT: ]
202 // CHECK: }
204 /// The section name can be quoted.
205 .section "@#$-{","n"
206 // CHECK: Section {
207 // CHECK-NEXT: Number:
208 // CHECK-NEXT: Name: @#$-{
210 // CHECK-NOT: Section {
211 // CHECK: ]
213 .section data1; .quad 0
215 .pushsection data2; .quad 0
216 .popsection
218 // Back to section data1
219 .quad 2
221 // CHECK: Section {
222 // CHECK-NEXT: Number:
223 // CHECK-NEXT: Name: data1
224 // CHECK: RawDataSize: 16
226 // CHECK: Section {
227 // CHECK-NEXT: Number:
228 // CHECK-NEXT: Name: data2
229 // CHECK: RawDataSize: 8
231 .section .data3,"dw"; .quad 1
233 .pushsection .data4,"dw"; .quad 1
234 .popsection
236 .pushsection .data5,"dr"; .quad 1
237 .popsection
239 // in section .data3
240 .quad 4
242 // Notice the different section flags here.
243 // This shouldn't overwrite the intial section flags.
244 .pushsection .data4,"dr"; .quad 1
245 .popsection
247 // CHECK: Section {
248 // CHECK-NEXT: Number:
249 // CHECK-NEXT: Name: .data3
250 // CHECK: RawDataSize: 16
251 // CHECK: Characteristics [
252 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
253 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
254 // CHECK-NEXT: IMAGE_SCN_MEM_READ
255 // CHECK-NEXT: IMAGE_SCN_MEM_WRITE
256 // CHECK-NEXT: ]
258 // CHECK: Section {
259 // CHECK-NEXT: Number:
260 // CHECK-NEXT: Name: .data4
261 // CHECK: RawDataSize: 16
262 // CHECK: Characteristics [
263 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
264 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
265 // CHECK-NEXT: IMAGE_SCN_MEM_READ
266 // CHECK-NEXT: IMAGE_SCN_MEM_WRITE
267 // CHECK-NEXT: ]
269 // CHECK: Section {
270 // CHECK-NEXT: Number:
271 // CHECK-NEXT: Name: .data5
272 // CHECK: RawDataSize: 8
273 // CHECK: Characteristics [
274 // CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES
275 // CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
276 // CHECK-NEXT: IMAGE_SCN_MEM_READ
277 // CHECK-NEXT: ]
279 .ifdef ERR
280 // ERR: :[[#@LINE+1]]:12: error: .popsection without corresponding .pushsection
281 .popsection
282 .endif