1RUN: llvm-readobj -h %p/Inputs/macho-universal.x86_64.i386 \
2RUN: | FileCheck %s -check-prefix MULTIHEADER
3
4RUN: llvm-readobj --sections %p/Inputs/macho-universal.x86_64.i386 \
5RUN: | FileCheck %s -check-prefix MULTISECTIONS
6
7RUN: llvm-readobj -h %p/Inputs/macho-universal-archive.x86_64.i386 \
8RUN: | FileCheck %s -check-prefix MULTIHEADER-ARCHIVE \
9RUN:                -DARFILE="%p/Inputs/macho-universal-archive.x86_64.i386"
10
11RUN: llvm-readobj --sections %p/Inputs/macho-universal-archive.x86_64.i386 \
12RUN: | FileCheck %s -check-prefix MULTISECTIONS-ARCHIVE \
13RUN:                -DARFILE="%p/Inputs/macho-universal-archive.x86_64.i386"
14
15MULTIHEADER: Format: Mach-O 64-bit x86-64
16MULTIHEADER: Arch: x86_64
17MULTIHEADER: AddressSize: 64bit
18MULTIHEADER: MachHeader {
19MULTIHEADER:   Magic: Magic64 (0xFEEDFACF)
20MULTIHEADER:   CpuType: X86-64 (0x1000007)
21MULTIHEADER:   CpuSubType: CPU_SUBTYPE_X86_64_ALL (0x3)
22MULTIHEADER:   FileType: Executable (0x2)
23MULTIHEADER:   NumOfLoadCommands: 16
24MULTIHEADER:   SizeOfLoadCommands: 880
25MULTIHEADER:   Flags [ (0x200085)
26MULTIHEADER:     MH_DYLDLINK (0x4)
27MULTIHEADER:     MH_NOUNDEFS (0x1)
28MULTIHEADER:     MH_PIE (0x200000)
29MULTIHEADER:     MH_TWOLEVEL (0x80)
30MULTIHEADER:   ]
31MULTIHEADER:   Reserved: 0x0
32MULTIHEADER: }
33
34MULTIHEADER: Format: Mach-O 32-bit i386
35MULTIHEADER: Arch: i386
36MULTIHEADER: AddressSize: 32bit
37MULTIHEADER: MachHeader {
38MULTIHEADER:   Magic: Magic (0xFEEDFACE)
39MULTIHEADER:   CpuType: X86 (0x7)
40MULTIHEADER:   CpuSubType: CPU_SUBTYPE_I386_ALL (0x3)
41MULTIHEADER:   FileType: Executable (0x2)
42MULTIHEADER:   NumOfLoadCommands: 16
43MULTIHEADER:   SizeOfLoadCommands: 716
44MULTIHEADER:   Flags [ (0x1200085)
45MULTIHEADER:     MH_DYLDLINK (0x4)
46MULTIHEADER:     MH_NOUNDEFS (0x1)
47MULTIHEADER:     MH_NO_HEAP_EXECUTION (0x1000000)
48MULTIHEADER:     MH_PIE (0x200000)
49MULTIHEADER:     MH_TWOLEVEL (0x80)
50MULTIHEADER:   ]
51MULTIHEADER: }
52
53
54
55MULTISECTIONS: Format: Mach-O 64-bit x86-64
56MULTISECTIONS: Arch: x86_64
57MULTISECTIONS: AddressSize: 64bit
58MULTISECTIONS: Sections [
59MULTISECTIONS:   Section {
60MULTISECTIONS:     Index: 0
61MULTISECTIONS:     Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)
62MULTISECTIONS:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
63MULTISECTIONS:     Address: 0x100000F60
64MULTISECTIONS:     Size: 0x12
65MULTISECTIONS:     Offset: 3936
66MULTISECTIONS:     Alignment: 4
67MULTISECTIONS:     RelocationOffset: 0x0
68MULTISECTIONS:     RelocationCount: 0
69MULTISECTIONS:     Type: Regular (0x0)
70MULTISECTIONS:     Attributes [ (0x800004)
71MULTISECTIONS:       PureInstructions (0x800000)
72MULTISECTIONS:       SomeInstructions (0x4)
73MULTISECTIONS:     ]
74MULTISECTIONS:     Reserved1: 0x0
75MULTISECTIONS:     Reserved2: 0x0
76MULTISECTIONS:   }
77MULTISECTIONS:   Section {
78MULTISECTIONS:     Index: 1
79MULTISECTIONS:     Name: __unwind_info (5F 5F 75 6E 77 69 6E 64 5F 69 6E 66 6F 00 00 00)
80MULTISECTIONS:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
81MULTISECTIONS:     Address: 0x100000F72
82MULTISECTIONS:     Size: 0x48
83MULTISECTIONS:     Offset: 3954
84MULTISECTIONS:     Alignment: 0
85MULTISECTIONS:     RelocationOffset: 0x0
86MULTISECTIONS:     RelocationCount: 0
87MULTISECTIONS:     Type: Regular (0x0)
88MULTISECTIONS:     Attributes [ (0x0)
89MULTISECTIONS:     ]
90MULTISECTIONS:     Reserved1: 0x0
91MULTISECTIONS:     Reserved2: 0x0
92MULTISECTIONS:   }
93MULTISECTIONS:   Section {
94MULTISECTIONS:     Index: 2
95MULTISECTIONS:     Name: __eh_frame (5F 5F 65 68 5F 66 72 61 6D 65 00 00 00 00 00 00)
96MULTISECTIONS:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
97MULTISECTIONS:     Address: 0x100000FC0
98MULTISECTIONS:     Size: 0x40
99MULTISECTIONS:     Offset: 4032
100MULTISECTIONS:     Alignment: 3
101MULTISECTIONS:     RelocationOffset: 0x0
102MULTISECTIONS:     RelocationCount: 0
103MULTISECTIONS:     Type: Regular (0x0)
104MULTISECTIONS:     Attributes [ (0x0)
105MULTISECTIONS:     ]
106MULTISECTIONS:     Reserved1: 0x0
107MULTISECTIONS:     Reserved2: 0x0
108MULTISECTIONS:   }
109MULTISECTIONS: ]
110
111MULTISECTIONS: Format: Mach-O 32-bit i386
112MULTISECTIONS: Arch: i386
113MULTISECTIONS: AddressSize: 32bit
114MULTISECTIONS: Sections [
115MULTISECTIONS:   Section {
116MULTISECTIONS:     Index: 0
117MULTISECTIONS:     Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)
118MULTISECTIONS:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
119MULTISECTIONS:     Address: 0x1FA0
120MULTISECTIONS:     Size: 0x15
121MULTISECTIONS:     Offset: 4000
122MULTISECTIONS:     Alignment: 4
123MULTISECTIONS:     RelocationOffset: 0x0
124MULTISECTIONS:     RelocationCount: 0
125MULTISECTIONS:     Type: Regular (0x0)
126MULTISECTIONS:     Attributes [ (0x800004)
127MULTISECTIONS:       PureInstructions (0x800000)
128MULTISECTIONS:       SomeInstructions (0x4)
129MULTISECTIONS:     ]
130MULTISECTIONS:     Reserved1: 0x0
131MULTISECTIONS:     Reserved2: 0x0
132MULTISECTIONS:   }
133MULTISECTIONS:   Section {
134MULTISECTIONS:     Index: 1
135MULTISECTIONS:     Name: __unwind_info (5F 5F 75 6E 77 69 6E 64 5F 69 6E 66 6F 00 00 00)
136MULTISECTIONS:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
137MULTISECTIONS:     Address: 0x1FB5
138MULTISECTIONS:     Size: 0x48
139MULTISECTIONS:     Offset: 4021
140MULTISECTIONS:     Alignment: 0
141MULTISECTIONS:     RelocationOffset: 0x0
142MULTISECTIONS:     RelocationCount: 0
143MULTISECTIONS:     Type: Regular (0x0)
144MULTISECTIONS:     Attributes [ (0x0)
145MULTISECTIONS:     ]
146MULTISECTIONS:     Reserved1: 0x0
147MULTISECTIONS:     Reserved2: 0x0
148MULTISECTIONS:   }
149MULTISECTIONS: ]
150
151MULTIHEADER-ARCHIVE: {{^$}}
152MULTIHEADER-ARCHIVE-NEXT: File: [[ARFILE]](hello.o)
153MULTIHEADER-ARCHIVE: Format: Mach-O 64-bit x86-64
154MULTIHEADER-ARCHIVE: Arch: x86_64
155MULTIHEADER-ARCHIVE: AddressSize: 64bit
156MULTIHEADER-ARCHIVE: MachHeader {
157MULTIHEADER-ARCHIVE:   Magic: Magic64 (0xFEEDFACF)
158MULTIHEADER-ARCHIVE:   CpuType: X86-64 (0x1000007)
159MULTIHEADER-ARCHIVE:   CpuSubType: CPU_SUBTYPE_X86_64_ALL (0x3)
160MULTIHEADER-ARCHIVE:   FileType: Relocatable (0x1)
161MULTIHEADER-ARCHIVE:   NumOfLoadCommands: 3
162MULTIHEADER-ARCHIVE:   SizeOfLoadCommands: 496
163MULTIHEADER-ARCHIVE:   Flags [ (0x2000)
164MULTIHEADER-ARCHIVE:     MH_SUBSECTIONS_VIA_SYMBOLS (0x2000)
165MULTIHEADER-ARCHIVE:   ]
166MULTIHEADER-ARCHIVE:   Reserved: 0x0
167MULTIHEADER-ARCHIVE: }
168MULTIHEADER-ARCHIVE-EMPTY:
169MULTIHEADER-ARCHIVE-NEXT: File: [[ARFILE]](foo.o)
170MULTIHEADER-ARCHIVE: Format: Mach-O 32-bit i386
171MULTIHEADER-ARCHIVE: Arch: i386
172MULTIHEADER-ARCHIVE: AddressSize: 32bit
173MULTIHEADER-ARCHIVE: MachHeader {
174MULTIHEADER-ARCHIVE:   Magic: Magic (0xFEEDFACE)
175MULTIHEADER-ARCHIVE:   CpuType: X86 (0x7)
176MULTIHEADER-ARCHIVE:   CpuSubType: CPU_SUBTYPE_I386_ALL (0x3)
177MULTIHEADER-ARCHIVE:   FileType: Relocatable (0x1)
178MULTIHEADER-ARCHIVE:   NumOfLoadCommands: 3
179MULTIHEADER-ARCHIVE:   SizeOfLoadCommands: 296
180MULTIHEADER-ARCHIVE:   Flags [ (0x2000)
181MULTIHEADER-ARCHIVE:     MH_SUBSECTIONS_VIA_SYMBOLS (0x2000)
182MULTIHEADER-ARCHIVE:   ]
183MULTIHEADER-ARCHIVE: }
184
185MULTISECTIONS-ARCHIVE: {{^$}}
186MULTISECTIONS-ARCHIVE-NEXT: File: [[ARFILE]](hello.o)
187MULTISECTIONS-ARCHIVE: Format: Mach-O 64-bit x86-64
188MULTISECTIONS-ARCHIVE: Arch: x86_64
189MULTISECTIONS-ARCHIVE: AddressSize: 64bit
190MULTISECTIONS-ARCHIVE: Sections [
191MULTISECTIONS-ARCHIVE:   Section {
192MULTISECTIONS-ARCHIVE:     Index: 0
193MULTISECTIONS-ARCHIVE:     Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)
194MULTISECTIONS-ARCHIVE:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
195MULTISECTIONS-ARCHIVE:     Address: 0x0
196MULTISECTIONS-ARCHIVE:     Size: 0x3B
197MULTISECTIONS-ARCHIVE:     Offset: 528
198MULTISECTIONS-ARCHIVE:     Alignment: 4
199MULTISECTIONS-ARCHIVE:     RelocationOffset: 0x2B8
200MULTISECTIONS-ARCHIVE:     RelocationCount: 2
201MULTISECTIONS-ARCHIVE:     Type: Regular (0x0)
202MULTISECTIONS-ARCHIVE:     Attributes [ (0x800004)
203MULTISECTIONS-ARCHIVE:       PureInstructions (0x800000)
204MULTISECTIONS-ARCHIVE:       SomeInstructions (0x4)
205MULTISECTIONS-ARCHIVE:     ]
206MULTISECTIONS-ARCHIVE:     Reserved1: 0x0
207MULTISECTIONS-ARCHIVE:     Reserved2: 0x0
208MULTISECTIONS-ARCHIVE:   }
209MULTISECTIONS-ARCHIVE:   Section {
210MULTISECTIONS-ARCHIVE:     Index: 1
211MULTISECTIONS-ARCHIVE:     Name: __cstring (5F 5F 63 73 74 72 69 6E 67 00 00 00 00 00 00 00)
212MULTISECTIONS-ARCHIVE:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
213MULTISECTIONS-ARCHIVE:     Address: 0x3B
214MULTISECTIONS-ARCHIVE:     Size: 0xD
215MULTISECTIONS-ARCHIVE:     Offset: 587
216MULTISECTIONS-ARCHIVE:     Alignment: 0
217MULTISECTIONS-ARCHIVE:     RelocationOffset: 0x0
218MULTISECTIONS-ARCHIVE:     RelocationCount: 0
219MULTISECTIONS-ARCHIVE:     Type: CStringLiterals (0x2)
220MULTISECTIONS-ARCHIVE:     Attributes [ (0x0)
221MULTISECTIONS-ARCHIVE:     ]
222MULTISECTIONS-ARCHIVE:     Reserved1: 0x0
223MULTISECTIONS-ARCHIVE:     Reserved2: 0x0
224MULTISECTIONS-ARCHIVE:   }
225MULTISECTIONS-ARCHIVE:   Section {
226MULTISECTIONS-ARCHIVE:     Index: 2
227MULTISECTIONS-ARCHIVE:     Name: __compact_unwind (5F 5F 63 6F 6D 70 61 63 74 5F 75 6E 77 69 6E 64)
228MULTISECTIONS-ARCHIVE:     Segment: __LD (5F 5F 4C 44 00 00 00 00 00 00 00 00 00 00 00 00)
229MULTISECTIONS-ARCHIVE:     Address: 0x48
230MULTISECTIONS-ARCHIVE:     Size: 0x20
231MULTISECTIONS-ARCHIVE:     Offset: 600
232MULTISECTIONS-ARCHIVE:     Alignment: 3
233MULTISECTIONS-ARCHIVE:     RelocationOffset: 0x2C8
234MULTISECTIONS-ARCHIVE:     RelocationCount: 1
235MULTISECTIONS-ARCHIVE:     Type: Regular (0x0)
236MULTISECTIONS-ARCHIVE:     Attributes [ (0x20000)
237MULTISECTIONS-ARCHIVE:       Debug (0x20000)
238MULTISECTIONS-ARCHIVE:     ]
239MULTISECTIONS-ARCHIVE:     Reserved1: 0x0
240MULTISECTIONS-ARCHIVE:     Reserved2: 0x0
241MULTISECTIONS-ARCHIVE:   }
242MULTISECTIONS-ARCHIVE:   Section {
243MULTISECTIONS-ARCHIVE:     Index: 3
244MULTISECTIONS-ARCHIVE:     Name: __eh_frame (5F 5F 65 68 5F 66 72 61 6D 65 00 00 00 00 00 00)
245MULTISECTIONS-ARCHIVE:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
246MULTISECTIONS-ARCHIVE:     Address: 0x68
247MULTISECTIONS-ARCHIVE:     Size: 0x40
248MULTISECTIONS-ARCHIVE:     Offset: 632
249MULTISECTIONS-ARCHIVE:     Alignment: 3
250MULTISECTIONS-ARCHIVE:     RelocationOffset: 0x0
251MULTISECTIONS-ARCHIVE:     RelocationCount: 0
252MULTISECTIONS-ARCHIVE:     Type: Coalesced (0xB)
253MULTISECTIONS-ARCHIVE:     Attributes [ (0x680000)
254MULTISECTIONS-ARCHIVE:       LiveSupport (0x80000)
255MULTISECTIONS-ARCHIVE:       NoTOC (0x400000)
256MULTISECTIONS-ARCHIVE:       StripStaticSyms (0x200000)
257MULTISECTIONS-ARCHIVE:     ]
258MULTISECTIONS-ARCHIVE:     Reserved1: 0x0
259MULTISECTIONS-ARCHIVE:     Reserved2: 0x0
260MULTISECTIONS-ARCHIVE:   }
261MULTISECTIONS-ARCHIVE: ]
262MULTISECTIONS-ARCHIVE-EMPTY:
263MULTISECTIONS-ARCHIVE-NEXT: File: [[ARFILE]](foo.o)
264MULTISECTIONS-ARCHIVE: Format: Mach-O 32-bit i386
265MULTISECTIONS-ARCHIVE: Arch: i386
266MULTISECTIONS-ARCHIVE: AddressSize: 32bit
267MULTISECTIONS-ARCHIVE: Sections [
268MULTISECTIONS-ARCHIVE:   Section {
269MULTISECTIONS-ARCHIVE:     Index: 0
270MULTISECTIONS-ARCHIVE:     Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)
271MULTISECTIONS-ARCHIVE:     Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
272MULTISECTIONS-ARCHIVE:     Address: 0x0
273MULTISECTIONS-ARCHIVE:     Size: 0x5
274MULTISECTIONS-ARCHIVE:     Offset: 324
275MULTISECTIONS-ARCHIVE:     Alignment: 4
276MULTISECTIONS-ARCHIVE:     RelocationOffset: 0x0
277MULTISECTIONS-ARCHIVE:     RelocationCount: 0
278MULTISECTIONS-ARCHIVE:     Type: Regular (0x0)
279MULTISECTIONS-ARCHIVE:     Attributes [ (0x800004)
280MULTISECTIONS-ARCHIVE:       PureInstructions (0x800000)
281MULTISECTIONS-ARCHIVE:       SomeInstructions (0x4)
282MULTISECTIONS-ARCHIVE:     ]
283MULTISECTIONS-ARCHIVE:     Reserved1: 0x0
284MULTISECTIONS-ARCHIVE:     Reserved2: 0x0
285MULTISECTIONS-ARCHIVE:   }
286MULTISECTIONS-ARCHIVE:   Section {
287MULTISECTIONS-ARCHIVE:     Index: 1
288MULTISECTIONS-ARCHIVE:     Name: __data (5F 5F 64 61 74 61 00 00 00 00 00 00 00 00 00 00)
289MULTISECTIONS-ARCHIVE:     Segment: __DATA (5F 5F 44 41 54 41 00 00 00 00 00 00 00 00 00 00)
290MULTISECTIONS-ARCHIVE:     Address: 0x8
291MULTISECTIONS-ARCHIVE:     Size: 0x4
292MULTISECTIONS-ARCHIVE:     Offset: 332
293MULTISECTIONS-ARCHIVE:     Alignment: 2
294MULTISECTIONS-ARCHIVE:     RelocationOffset: 0x0
295MULTISECTIONS-ARCHIVE:     RelocationCount: 0
296MULTISECTIONS-ARCHIVE:     Type: Regular (0x0)
297MULTISECTIONS-ARCHIVE:     Attributes [ (0x0)
298MULTISECTIONS-ARCHIVE:     ]
299MULTISECTIONS-ARCHIVE:     Reserved1: 0x0
300MULTISECTIONS-ARCHIVE:     Reserved2: 0x0
301MULTISECTIONS-ARCHIVE:   }
302MULTISECTIONS-ARCHIVE: ]
303
304