Modernize with range-based for loops.
[oota-llvm.git] / test / tools / dsymutil / X86 / dsym-companion.test
1 RUN: llvm-dsymutil -o - %p/../Inputs/basic.macho.i386 -f | llvm-readobj -file-headers -program-headers -sections -symbols - | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK32
2 RUN: llvm-dsymutil -o - -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 -f | llvm-readobj -file-headers -program-headers -sections -symbols - | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK64
3
4 This test checks that the dSYM companion binaries generated in 32 and 64 bits
5 are correct. The check are pretty strict (we check even the offsets and sizes
6 of the sections) in order to test the VM address layout algorithm. As the
7 debug sections are generated, this is a bit risky, but I don't expect
8 llvm-dsymutil's output to change much for these tiny C programs so this should
9 be OK.
10 The 32bits version doesn't have object files, thus it has basically no debug
11 sections.
12
13 CHECK32: Format: Mach-O 32-bit i386
14 CHECK32: Arch: i386
15 CHECK32: AddressSize: 32bit
16 CHECK64: Format: Mach-O 64-bit x86-64
17 CHECK64: Arch: x86_64
18 CHECK64: AddressSize: 64bit
19 CHECK:   MachHeader {
20 CHECK32:   Magic: Magic (0xFEEDFACE)
21 CHECK32:   CpuType: X86 (0x7)
22 CHECK32:   CpuSubType: CPU_SUBTYPE_I386_ALL (0x3)
23 CHECK64:   Magic: Magic64 (0xFEEDFACF)
24 CHECK64:   CpuType: X86-64 (0x1000007)
25 CHECK64:   CpuSubType: CPU_SUBTYPE_X86_64_ALL (0x3)
26 CHECK:     FileType: DWARFSymbol (0xA)
27 CHECK:     NumOfLoadCommands: 7
28 CHECK:     Flags [ (0x0)
29 CHECK:   }
30 CHECK:   Sections [
31 CHECK:     Section {
32 CHECK:       Name: __text
33 CHECK:       Segment: __TEXT
34 CHECK32:     Address: 0x1E90
35 CHECK32:     Size: 0x11A
36 CHECK64:     Address: 0x100000EA0
37 CHECK64:     Size: 0x109
38 CHECK:       Offset: 0
39 CHECK:       Alignment: 4
40 CHECK:       RelocationOffset: 0x0
41 CHECK:       RelocationCount: 0
42 CHECK:       Type: 0x0
43 CHECK:       Attributes [ (0x800004)
44 CHECK:         PureInstructions (0x800000)
45 CHECK:         SomeInstructions (0x4)
46 CHECK:       ]
47 CHECK:       Reserved1: 0x0
48 CHECK:       Reserved2: 0x0
49 CHECK:     }
50 CHECK:     Section {
51 CHECK:       Name: __unwind_info
52 CHECK:       Segment: __TEXT
53 CHECK32:     Address: 0x1FAC
54 CHECK64:     Address: 0x100000FAC
55 CHECK:       Size: 0x48
56 CHECK:       Offset: 0
57 CHECK:       Alignment: 2
58 CHECK:       RelocationOffset: 0x0
59 CHECK:       RelocationCount: 0
60 CHECK:       Type: 0x0
61 CHECK:       Attributes [ (0x0)
62 CHECK:       ]
63 CHECK:       Reserved1: 0x0
64 CHECK:       Reserved2: 0x0
65 CHECK:     }
66 CHECK32:  Section {
67 CHECK32:    Name: __nl_symbol_ptr
68 CHECK32:    Segment: __DATA
69 CHECK32:    Address: 0x2000
70 CHECK32:    Size: 0x4
71 CHECK32:    Offset: 0
72 CHECK32:    Alignment: 2
73 CHECK32:    RelocationOffset: 0x0
74 CHECK32:    RelocationCount: 0
75 CHECK32:    Type: 0x6
76 CHECK32:    Attributes [ (0x0)
77 CHECK32:    ]
78 CHECK32:    Reserved1: 0x0
79 CHECK32:    Reserved2: 0x0
80 CHECK32:  }
81 CHECK:     Section {
82 CHECK:       Name: __data
83 CHECK:       Segment: __DATA
84 CHECK32:     Address: 0x2004
85 CHECK64:     Address: 0x100001000
86 CHECK:       Size: 0x4
87 CHECK:       Offset: 0
88 CHECK:       Alignment: 2
89 CHECK:       RelocationOffset: 0x0
90 CHECK:       RelocationCount: 0
91 CHECK:       Type: 0x0
92 CHECK:       Attributes [ (0x0)
93 CHECK:       ]
94 CHECK:       Reserved1: 0x0
95 CHECK:       Reserved2: 0x0
96 CHECK:     }
97 CHECK:     Section {
98 CHECK:       Name: __common
99 CHECK:       Segment: __DATA
100 CHECK32:     Address: 0x2008
101 CHECK64:     Address: 0x100001004
102 CHECK:       Size: 0x4
103 CHECK:       Offset: 0
104 CHECK:       Alignment: 2
105 CHECK:       RelocationOffset: 0x0
106 CHECK:       RelocationCount: 0
107 CHECK:       Type: LocReloc (0x1)
108 CHECK:       Attributes [ (0x0)
109 CHECK:       ]
110 CHECK:       Reserved1: 0x0
111 CHECK:       Reserved2: 0x0
112 CHECK:     }
113 CHECK:     Section {
114 CHECK:       Name: __bss
115 CHECK:       Segment: __DATA
116 CHECK32:     Address: 0x200C
117 CHECK64:     Address: 0x100001008
118 CHECK:       Size: 0x4
119 CHECK:       Offset: 0
120 CHECK:       Alignment: 2
121 CHECK:       RelocationOffset: 0x0
122 CHECK:       RelocationCount: 0
123 CHECK:       Type: LocReloc (0x1)
124 CHECK:       Attributes [ (0x0)
125 CHECK:       ]
126 CHECK:       Reserved1: 0x0
127 CHECK:       Reserved2: 0x0
128 CHECK:     }
129 CHECK64:   Section {
130 CHECK64:     Name: __debug_line
131 CHECK64:     Segment: __DWARF
132 CHECK64:     Address: 0x100003000
133 CHECK64:     Size: 0xEA
134 CHECK64:     Offset: 8192
135 CHECK64:     Alignment: 0
136 CHECK64:     RelocationOffset: 0x0
137 CHECK64:     RelocationCount: 0
138 CHECK64:     Type: 0x0
139 CHECK64:     Attributes [ (0x0)
140 CHECK64:     ]
141 CHECK64:     Reserved1: 0x0
142 CHECK64:     Reserved2: 0x0
143 CHECK64:   }
144 CHECK64:   Section {
145 CHECK64:     Name: __debug_pubnames
146 CHECK64:     Segment: __DWARF
147 CHECK64:     Address: 0x1000030EA
148 CHECK64:     Size: 0x7F
149 CHECK64:     Offset: 8426
150 CHECK64:     Alignment: 0
151 CHECK64:     RelocationOffset: 0x0
152 CHECK64:     RelocationCount: 0
153 CHECK64:     Type: 0x0
154 CHECK64:     Attributes [ (0x0)
155 CHECK64:     ]
156 CHECK64:     Reserved1: 0x0
157 CHECK64:     Reserved2: 0x0
158 CHECK64:   }
159 CHECK64:   Section {
160 CHECK64:     Name: __debug_pubtypes
161 CHECK64:     Segment: __DWARF
162 CHECK64:     Address: 0x100003169
163 CHECK64:     Size: 0x57
164 CHECK64:     Offset: 8553
165 CHECK64:     Alignment: 0
166 CHECK64:     RelocationOffset: 0x0
167 CHECK64:     RelocationCount: 0
168 CHECK64:     Type: 0x0
169 CHECK64:     Attributes [ (0x0)
170 CHECK64:     ]
171 CHECK64:     Reserved1: 0x0
172 CHECK64:     Reserved2: 0x0
173 CHECK64:   }
174 CHECK64:   Section {
175 CHECK64:     Name: __debug_aranges
176 CHECK64:     Segment: __DWARF
177 CHECK64:     Address: 0x1000031C0
178 CHECK64:     Size: 0xB0
179 CHECK64:     Offset: 8640
180 CHECK64:     Alignment: 0
181 CHECK64:     RelocationOffset: 0x0
182 CHECK64:     RelocationCount: 0
183 CHECK64:     Type: 0x0
184 CHECK64:     Attributes [ (0x0)
185 CHECK64:     ]
186 CHECK64:     Reserved1: 0x0
187 CHECK64:     Reserved2: 0x0
188 CHECK64:   }
189 CHECK64:   Section {
190 CHECK64:     Name: __debug_info
191 CHECK64:     Segment: __DWARF
192 CHECK64:     Address: 0x100003270
193 CHECK64:     Size: 0x1BC
194 CHECK64:     Offset: 8816
195 CHECK64:     Alignment: 0
196 CHECK64:     RelocationOffset: 0x0
197 CHECK64:     RelocationCount: 0
198 CHECK64:     Type: 0x0
199 CHECK64:     Attributes [ (0x0)
200 CHECK64:     ]
201 CHECK64:     Reserved1: 0x0
202 CHECK64:     Reserved2: 0x0
203 CHECK64:   }
204 CHECK:     Section {
205 CHECK:       Name: __debug_abbrev
206 CHECK:       Segment: __DWARF
207 CHECK32:     Address: 0x4000
208 CHECK32:     Size: 0x1
209 CHECK32:     Offset: 8192
210 CHECK64:     Address: 0x10000342C
211 CHECK64:     Size: 0x8F
212 CHECK64:     Offset: 9260
213 CHECK:       Alignment: 0
214 CHECK:       RelocationOffset: 0x0
215 CHECK:       RelocationCount: 0
216 CHECK:       Type: 0x0
217 CHECK:       Attributes [ (0x0)
218 CHECK:       ]
219 CHECK:       Reserved1: 0x0
220 CHECK:       Reserved2: 0x0
221 CHECK:     }
222 CHECK:     Section {
223 CHECK:       Name: __debug_str
224 CHECK:       Segment: __DWARF
225 CHECK32:     Address: 0x4001
226 CHECK32:     Size: 0x1
227 CHECK32:     Offset: 8193
228 CHECK64:     Address: 0x1000034BB
229 CHECK64:     Size: 0x9F
230 CHECK64:     Offset: 9403
231 CHECK:       Alignment: 0
232 CHECK:       RelocationOffset: 0x0
233 CHECK:       RelocationCount: 0
234 CHECK:       Type: 0x0
235 CHECK:       Attributes [ (0x0)
236 CHECK:       ]
237 CHECK:       Reserved1: 0x0
238 CHECK:       Reserved2: 0x0
239 CHECK:     }
240 CHECK:   ]
241 CHECK:   Symbols [
242 CHECK:     Symbol {
243 CHECK:       Name: _inc (2)
244 CHECK:       Type: Section (0xE)
245 CHECK:       Section: __text
246 CHECK:       RefType: UndefinedNonLazy (0x0)
247 CHECK:       Flags [ (0x0)
248 CHECK:       ]
249 CHECK32:     Value: 0x1F20
250 CHECK64:     Value: 0x100000F20
251 CHECK:     }
252 CHECK:     Symbol {
253 CHECK:       Name: _inc (2)
254 CHECK:       Type: Section (0xE)
255 CHECK:       Section: __text
256 CHECK:       RefType: UndefinedNonLazy (0x0)
257 CHECK:       Flags [ (0x0)
258 CHECK:       ]
259 CHECK32:     Value: 0x1F90
260 CHECK64:     Value: 0x100000F90
261 CHECK:     }
262 CHECK:     Symbol {
263 CHECK:       Name: _baz (7)
264 CHECK:       Type: Section (0xE)
265 CHECK:       Section: __data
266 CHECK:       RefType: UndefinedNonLazy (0x0)
267 CHECK:       Flags [ (0x0)
268 CHECK:       ]
269 CHECK32:     Value: 0x2004
270 CHECK64:     Value: 0x100001000
271 CHECK:     }
272 CHECK:     Symbol {
273 CHECK:       Name: _private_int (12)
274 CHECK:       Type: Section (0xE)
275 CHECK:       Section: __bss
276 CHECK:       RefType: UndefinedNonLazy (0x0)
277 CHECK:       Flags [ (0x0)
278 CHECK:       ]
279 CHECK32:     Value: 0x200C
280 CHECK64:     Value: 0x100001008
281 CHECK:     }
282 CHECK:     Symbol {
283 CHECK:       Name: __mh_execute_header (25)
284 CHECK:       Extern
285 CHECK:       Type: Section (0xE)
286 CHECK:       Section: __text
287 CHECK:       RefType: UndefinedNonLazy (0x0)
288 CHECK:       Flags [ (0x10)
289 CHECK:         ReferencedDynamically (0x10)
290 CHECK:       ]
291 CHECK32:     Value: 0x1000
292 CHECK64:     Value: 0x100000000
293 CHECK:     }
294 CHECK:     Symbol {
295 CHECK:       Name: _bar (45)
296 CHECK:       Extern
297 CHECK:       Type: Section (0xE)
298 CHECK:       Section: __text
299 CHECK:       RefType: UndefinedNonLazy (0x0)
300 CHECK:       Flags [ (0x0)
301 CHECK:       ]
302 CHECK32:     Value: 0x1F40
303 CHECK64:     Value: 0x100000F40
304 CHECK:     }
305 CHECK:     Symbol {
306 CHECK:       Name: _foo (50)
307 CHECK:       Extern
308 CHECK:       Type: Section (0xE)
309 CHECK:       Section: __text
310 CHECK:       RefType: UndefinedNonLazy (0x0)
311 CHECK:       Flags [ (0x0)
312 CHECK:       ]
313 CHECK32:     Value: 0x1EC0
314 CHECK64:     Value: 0x100000ED0
315 CHECK:     }
316 CHECK:     Symbol {
317 CHECK:       Name: _main (55)
318 CHECK:       Extern
319 CHECK:       Type: Section (0xE)
320 CHECK:       Section: __text
321 CHECK:       RefType: UndefinedNonLazy (0x0)
322 CHECK:       Flags [ (0x0)
323 CHECK:       ]
324 CHECK32:     Value: 0x1E90
325 CHECK64:     Value: 0x100000EA0
326 CHECK:     }
327 CHECK:     Symbol {
328 CHECK:       Name: _val (61)
329 CHECK:       Extern
330 CHECK:       Type: Section (0xE)
331 CHECK:       Section: __common
332 CHECK:       RefType: UndefinedNonLazy (0x0)
333 CHECK:       Flags [ (0x0)
334 CHECK:       ]
335 CHECK32:     Value: 0x2008
336 CHECK64:     Value: 0x100001004
337 CHECK:     }
338 CHECK:   ]
339