1// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | llvm-readobj -file-headers -s -sd -r -t -macho-segment -macho-dysymtab -macho-indirect-symbols | 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, 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
155f0:
156        .byte 0
157	.align	4, 0x90
158        .long 0
159
160// CHECK: File: <stdin>
161// CHECK: Format: Mach-O 32-bit i386
162// CHECK: Arch: i386
163// CHECK: AddressSize: 32bit
164// CHECK: MachHeader {
165// CHECK:   Magic: Magic (0xFEEDFACE)
166// CHECK:   CpuType: X86 (0x7)
167// CHECK:   CpuSubType: CPU_SUBTYPE_I386_ALL (0x3)
168// CHECK:   FileType: Relocatable (0x1)
169// CHECK:   NumOfLoadCommands: 4
170// CHECK:   SizeOfLoadCommands: 312
171// CHECK:   Flags [ (0x0)
172// CHECK:   ]
173// CHECK: }
174// CHECK: Sections [
175// CHECK:   Section {
176// CHECK:     Index: 0
177// CHECK:     Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)
178// CHECK:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
179// CHECK:     Address: 0x0
180// CHECK:     Size: 0x151
181// CHECK:     Offset: 340
182// CHECK:     Alignment: 4
183// CHECK:     RelocationOffset: 0x0
184// CHECK:     RelocationCount: 0
185// CHECK:     Type: 0x0
186// CHECK:     Attributes [ (0x800004)
187// CHECK:       PureInstructions (0x800000)
188// CHECK:       SomeInstructions (0x4)
189// CHECK:     ]
190// CHECK:     Reserved1: 0x0
191// CHECK:     Reserved2: 0x0
192// CHECK:     SectionData (
193// CHECK:       0000: C390C300 00000000 00000000 00000000  |................|
194// CHECK:       0010: C3C36690 C3000000 00000000 00000000  |..f.............|
195// CHECK:       0020: C30F1F00 C3000000 00000000 00000000  |................|
196// CHECK:       0030: C3C3C3C3 0F1F4000 C3000000 00000000  |......@.........|
197// CHECK:       0040: C3C3C30F 1F440000 C3000000 00000000  |.....D..........|
198// CHECK:       0050: C3C3660F 1F440000 C3000000 00000000  |..f..D..........|
199// CHECK:       0060: C30F1F80 00000000 C3000000 00000000  |................|
200// CHECK:       0070: C3C3C3C3 C3C3C3C3 C3000000 00000000  |................|
201// CHECK:       0080: C3C3C3C3 C3C3C366 0F1F8400 00000000  |.......f........|
202// CHECK:       0090: C3000000 00000000 00000000 00000000  |................|
203// CHECK:       00A0: C3C3C3C3 C3C3C366 0F1F8400 00000000  |.......f........|
204// CHECK:       00B0: C3000000 00000000 00000000 00000000  |................|
205// CHECK:       00C0: C3C3C3C3 C366662E 0F1F8400 00000000  |.....ff.........|
206// CHECK:       00D0: C3000000 00000000 00000000 00000000  |................|
207// CHECK:       00E0: C3C3C3C3 6666662E 0F1F8400 00000000  |....fff.........|
208// CHECK:       00F0: C3000000 00000000 00000000 00000000  |................|
209// CHECK:       0100: C3C3C366 6666662E 0F1F8400 00000000  |...ffff.........|
210// CHECK:       0110: C3000000 00000000 00000000 00000000  |................|
211// CHECK:       0120: C3C36666 6666662E 0F1F8400 00000000  |..fffff.........|
212// CHECK:       0130: C3000000 00000000 00000000 00000000  |................|
213// CHECK:       0140: C3666666 6666662E 0F1F8400 00000000  |.ffffff.........|
214// CHECK:       0150: C3                                   |.|
215// CHECK:     )
216// CHECK:   }
217// CHECK:   Section {
218// CHECK:     Index: 1
219// CHECK:     Name: __const (5F 5F 63 6F 6E 73 74 00 00 00 00 00 00 00 00 00)
220// CHECK:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
221// CHECK:     Address: 0x160
222// CHECK:     Size: 0x14
223// CHECK:     Offset: 692
224// CHECK:     Alignment: 4
225// CHECK:     RelocationOffset: 0x0
226// CHECK:     RelocationCount: 0
227// CHECK:     Type: 0x0
228// CHECK:     Attributes [ (0x0)
229// CHECK:     ]
230// CHECK:     Reserved1: 0x0
231// CHECK:     Reserved2: 0x0
232// CHECK:     SectionData (
233// CHECK:       0000: 00909090 90909090 90909090 90909090  |................|
234// CHECK:       0010: 00000000                             |....|
235// CHECK:     )
236// CHECK:   }
237// CHECK: ]
238// CHECK: Relocations [
239// CHECK: ]
240// CHECK: Symbols [
241// CHECK:   Symbol {
242// CHECK:     Name: f0 (1)
243// CHECK:     Type: Section (0xE)
244// CHECK:     Section: __const (0x2)
245// CHECK:     RefType: UndefinedNonLazy (0x0)
246// CHECK:     Flags [ (0x0)
247// CHECK:     ]
248// CHECK:     Value: 0x160
249// CHECK:   }
250// CHECK: ]
251// CHECK: Indirect Symbols {
252// CHECK:   Number: 0
253// CHECK:   Symbols [
254// CHECK:   ]
255// CHECK: }
256// CHECK: Segment {
257// CHECK:   Cmd: LC_SEGMENT
258// CHECK:   Name:
259// CHECK:   Size: 192
260// CHECK:   vmaddr: 0x0
261// CHECK:   vmsize: 0x174
262// CHECK:   fileoff: 340
263// CHECK:   filesize: 372
264// CHECK:   maxprot: rwx
265// CHECK:   initprot: rwx
266// CHECK:   nsects: 2
267// CHECK:   flags: 0x0
268// CHECK: }
269// CHECK: Dysymtab {
270// CHECK:   ilocalsym: 0
271// CHECK:   nlocalsym: 1
272// CHECK:   iextdefsym: 1
273// CHECK:   nextdefsym: 0
274// CHECK:   iundefsym: 1
275// CHECK:   nundefsym: 0
276// CHECK:   tocoff: 0
277// CHECK:   ntoc: 0
278// CHECK:   modtaboff: 0
279// CHECK:   nmodtab: 0
280// CHECK:   extrefsymoff: 0
281// CHECK:   nextrefsyms: 0
282// CHECK:   indirectsymoff: 0
283// CHECK:   nindirectsyms: 0
284// CHECK:   extreloff: 0
285// CHECK:   nextrel: 0
286// CHECK:   locreloff: 0
287// CHECK:   nlocrel: 0
288// CHECK: }
289