MC/Mach-O/x86: Optimal nop sequences should only be used for the .text sections,...
[oota-llvm.git] / test / MC / MachO / x86_32-optimal_nop.s
1 // RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s
2
3 # 1 byte nop test
4         .align 4, 0 # start with 16 byte alignment filled with zeros
5         ret
6         # nop
7         # 0x90
8         .align 1, 0x90
9         ret
10 # 2 byte nop test
11         .align 4, 0 # start with 16 byte alignment filled with zeros
12         ret
13         ret
14         # xchg %ax,%ax
15         # 0x66, 0x90
16         .align 2, 0x90
17         ret
18 # 3 byte nop test
19         .align 4, 0 # start with 16 byte alignment filled with zeros
20         ret
21         # nopl (%[re]ax)
22         # 0x0f, 0x1f, 0x00
23         .align 2, 0x90
24         ret
25 # 4 byte nop test
26         .align 4, 0 # start with 16 byte alignment filled with zeros
27         ret
28         ret
29         ret
30         ret
31         # nopl 0(%[re]ax)
32         # 0x0f, 0x1f, 0x40, 0x00
33         .align 3, 0x90
34         ret
35 # 5 byte nop test
36         .align 4, 0 # start with 16 byte alignment filled with zeros
37         ret
38         ret
39         ret
40         # nopl 0(%[re]ax,%[re]ax,1)
41         # 0x0f, 0x1f, 0x44, 0x00, 0x00
42         .align 3, 0x90
43         ret
44 # 6 byte nop test
45         .align 4, 0 # start with 16 byte alignment filled with zeros
46         ret
47         ret
48         # nopw 0(%[re]ax,%[re]ax,1)
49         # 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00
50         .align 3, 0x90
51         ret
52 # 7 byte nop test
53         .align 4, 0 # start with 16 byte alignment filled with zeros
54         ret
55         # nopl 0L(%[re]ax)
56         # 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
57         .align 3, 0x90
58         ret
59 # 8 byte nop test
60         .align 4, 0 # start with 16 byte alignment filled with zeros
61         ret
62         ret
63         ret
64         ret
65         ret
66         ret
67         ret
68         ret
69         # nopl 0L(%[re]ax,%[re]ax,1)
70         # 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
71         .align 3, 0x90
72         ret
73 # 9 byte nop test
74         .align 4, 0 # start with 16 byte alignment filled with zeros
75         ret
76         ret
77         ret
78         ret
79         ret
80         ret
81         ret
82         # nopw 0L(%[re]ax,%[re]ax,1)
83         # 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
84         .align 4, 0x90
85         ret
86 # 10 byte nop test
87         .align 4, 0 # start with 16 byte alignment filled with zeros
88         ret
89         ret
90         ret
91         ret
92         ret
93         ret
94         ret
95         # nopw %cs:0L(%[re]ax,%[re]ax,1)
96         # 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
97         .align 4, 0x90
98         ret
99 # 11 byte nop test
100         .align 4, 0 # start with 16 byte alignment filled with zeros
101         ret
102         ret
103         ret
104         ret
105         ret
106         # nopw %cs:0L(%[re]ax,%[re]ax,1)
107         # 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
108         .align 4, 0x90
109         ret
110 # 12 byte nop test
111         .align 4, 0 # start with 16 byte alignment filled with zeros
112         ret
113         ret
114         ret
115         ret
116         # nopw 0(%[re]ax,%[re]ax,1)
117         # nopw 0(%[re]ax,%[re]ax,1)
118         # 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00,
119         # 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00
120         .align 4, 0x90
121         ret
122 # 13 byte nop test
123         .align 4, 0 # start with 16 byte alignment filled with zeros
124         ret
125         ret
126         ret
127         # nopw 0(%[re]ax,%[re]ax,1)
128         # nopl 0L(%[re]ax)
129         # 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00,
130         # 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
131         .align 4, 0x90
132         ret
133 # 14 byte nop test
134         .align 4, 0 # start with 16 byte alignment filled with zeros
135         ret
136         ret
137         # nopl 0L(%[re]ax)
138         # nopl 0L(%[re]ax)
139         # 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00,
140         # 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
141         .align 4, 0x90
142         ret
143 # 15 byte nop test
144         .align 4, 0 # start with 16 byte alignment filled with zeros
145         ret
146         # nopl 0L(%[re]ax)
147         # nopl 0L(%[re]ax,%[re]ax,1)
148         # 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00,
149         # 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00
150         .align 4, 0x90
151         ret
152
153         # Only the .text sections gets optimal nops.
154         .section        __TEXT,__const
155 f0:
156         .byte 0
157         .align  4, 0x90
158         .long 0
159
160 // CHECK: ('cputype', 7)
161 // CHECK: ('cpusubtype', 3)
162 // CHECK: ('filetype', 1)
163 // CHECK: ('num_load_commands', 1)
164 // CHECK: ('load_commands_size', 296)
165 // CHECK: ('flag', 0)
166 // CHECK: ('load_commands', [
167 // CHECK:   # Load Command 0
168 // CHECK:  (('command', 1)
169 // CHECK:   ('size', 192)
170 // CHECK:   ('segment_name', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
171 // CHECK:   ('vm_addr', 0)
172 // CHECK:   ('vm_size', 372)
173 // CHECK:   ('file_offset', 324)
174 // CHECK:   ('file_size', 372)
175 // CHECK:   ('maxprot', 7)
176 // CHECK:   ('initprot', 7)
177 // CHECK:   ('num_sections', 2)
178 // CHECK:   ('flags', 0)
179 // CHECK:   ('sections', [
180 // CHECK:     # Section 0
181 // CHECK:    (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
182 // CHECK:     ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
183 // CHECK:     ('address', 0)
184 // CHECK:     ('size', 337)
185 // CHECK:     ('offset', 324)
186 // CHECK:     ('alignment', 4)
187 // CHECK:     ('reloc_offset', 0)
188 // CHECK:     ('num_reloc', 0)
189 // CHECK:     ('flags', 0x80000400)
190 // CHECK:     ('reserved1', 0)
191 // CHECK:     ('reserved2', 0)
192 // CHECK:    ),
193 // CHECK:   ('_relocations', [
194 // CHECK:   ])
195 // CHECK:   ('_section_data', '\xc3\x90\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc3\xc3f\x90\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc3\x0f\x1f\x00\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc3\xc3\xc3\xc3\x0f\x1f@\x00\xc3\x00\x00\x00\x00\x00\x00\x00\xc3\xc3\xc3\x0f\x1fD\x00\x00\xc3\x00\x00\x00\x00\x00\x00\x00\xc3\xc3f\x0f\x1fD\x00\x00\xc3\x00\x00\x00\x00\x00\x00\x00\xc3\x0f\x1f\x80\x00\x00\x00\x00\xc3\x00\x00\x00\x00\x00\x00\x00\xc3\xc3\xc3\xc3\xc3\xc3\xc3\xc3\xc3\x00\x00\x00\x00\x00\x00\x00\xc3\xc3\xc3\xc3\xc3\xc3\xc3f\x0f\x1f\x84\x00\x00\x00\x00\x00\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc3\xc3\xc3\xc3\xc3\xc3\xc3f\x0f\x1f\x84\x00\x00\x00\x00\x00\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc3\xc3\xc3\xc3\xc3\x0f\x1fD\x00\x00f\x0f\x1fD\x00\x00\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc3\xc3\xc3\xc3f\x0f\x1fD\x00\x00f\x0f\x1fD\x00\x00\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc3\xc3\xc3f\x0f\x1fD\x00\x00\x0f\x1f\x80\x00\x00\x00\x00\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc3\xc3\x0f\x1f\x80\x00\x00\x00\x00\x0f\x1f\x80\x00\x00\x00\x00\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc3\x0f\x1f\x80\x00\x00\x00\x00\x0f\x1f\x84\x00\x00\x00\x00\x00\xc3')
196 // CHECK:     # Section 1
197 // CHECK:    (('section_name', '__const\x00\x00\x00\x00\x00\x00\x00\x00\x00')
198 // CHECK:     ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
199 // CHECK:     ('address', 352)
200 // CHECK:     ('size', 20)
201 // CHECK:     ('offset', 676)
202 // CHECK:     ('alignment', 4)
203 // CHECK:     ('reloc_offset', 0)
204 // CHECK:     ('num_reloc', 0)
205 // CHECK:     ('flags', 0x0)
206 // CHECK:     ('reserved1', 0)
207 // CHECK:     ('reserved2', 0)
208 // CHECK:    ),
209 // CHECK:   ('_relocations', [
210 // CHECK:   ])
211 // CHECK:   ('_section_data', '\x00\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x00\x00\x00\x00')
212 // CHECK:   ])
213 // CHECK:  ),
214 // CHECK:   # Load Command 1
215 // CHECK:  (('command', 2)
216 // CHECK:   ('size', 24)
217 // CHECK:   ('symoff', 696)
218 // CHECK:   ('nsyms', 1)
219 // CHECK:   ('stroff', 708)
220 // CHECK:   ('strsize', 4)
221 // CHECK:   ('_string_data', '\x00f0\x00')
222 // CHECK:   ('_symbols', [
223 // CHECK:     # Symbol 0
224 // CHECK:    (('n_strx', 1)
225 // CHECK:     ('n_type', 0xe)
226 // CHECK:     ('n_sect', 2)
227 // CHECK:     ('n_desc', 0)
228 // CHECK:     ('n_value', 352)
229 // CHECK:     ('_string', 'f0')
230 // CHECK:    ),
231 // CHECK:   ])
232 // CHECK:  ),
233 // CHECK:   # Load Command 2
234 // CHECK:  (('command', 11)
235 // CHECK:   ('size', 80)
236 // CHECK:   ('ilocalsym', 0)
237 // CHECK:   ('nlocalsym', 1)
238 // CHECK:   ('iextdefsym', 1)
239 // CHECK:   ('nextdefsym', 0)
240 // CHECK:   ('iundefsym', 1)
241 // CHECK:   ('nundefsym', 0)
242 // CHECK:   ('tocoff', 0)
243 // CHECK:   ('ntoc', 0)
244 // CHECK:   ('modtaboff', 0)
245 // CHECK:   ('nmodtab', 0)
246 // CHECK:   ('extrefsymoff', 0)
247 // CHECK:   ('nextrefsyms', 0)
248 // CHECK:   ('indirectsymoff', 0)
249 // CHECK:   ('nindirectsyms', 0)
250 // CHECK:   ('extreloff', 0)
251 // CHECK:   ('nextrel', 0)
252 // CHECK:   ('locreloff', 0)
253 // CHECK:   ('nlocrel', 0)
254 // CHECK:   ('_indirect_symbols', [
255 // CHECK:   ])
256 // CHECK:  ),
257 // CHECK: ])