1 ## This file contains test cases for generating sections in Mach-O object files.
3 ## a) Test that yaml2obj emits sections and obj2yaml converts them back.
5 # RUN: yaml2obj --docnum=1 %s | obj2yaml | FileCheck %s
11 cpusubtype: 0x80000003
43 addr: 0x0000000100001160
55 addr: 0x0000000100001D7C
65 - sectname: __stub_helper
67 addr: 0x0000000100001DD8
77 - sectname: __gcc_except_tab
79 addr: 0x0000000100001E80
91 addr: 0x0000000100001F70
100 reserved3: 0x00000000
101 - sectname: __unwind_info
103 addr: 0x0000000100001F80
110 reserved1: 0x00000000
111 reserved2: 0x00000000
112 reserved3: 0x00000000
127 addr: 0x0000000100002000
134 reserved1: 0x0000000F
135 reserved2: 0x00000000
136 reserved3: 0x00000000
137 - sectname: __nl_symbol_ptr
139 addr: 0x0000000100002018
146 reserved1: 0x00000012
147 reserved2: 0x00000000
148 reserved3: 0x00000000
149 - sectname: __la_symbol_ptr
151 addr: 0x0000000100002028
158 reserved1: 0x00000014
159 reserved2: 0x00000000
160 reserved3: 0x00000000
172 - cmd: LC_DYLD_INFO_ONLY
204 indirectsymoff: 13560
210 - cmd: LC_LOAD_DYLINKER
215 uuid: 461A1B28-822F-3F38-B670-645419E636F5
216 - cmd: LC_VERSION_MIN_MACOSX
220 - cmd: LC_SOURCE_VERSION
232 current_version: 7864576
233 compatibility_version: 65536
239 current_version: 80349697
240 compatibility_version: 65536
241 - cmd: LC_FUNCTION_STARTS
245 - cmd: LC_DATA_IN_CODE
252 #CHECK: - cmd: LC_SEGMENT_64
253 #CHECK: segname: __PAGEZERO
254 #CHECK: - cmd: LC_SEGMENT_64
255 #CHECK: segname: __TEXT
257 #CHECK: - sectname: __text
258 #CHECK: segname: __TEXT
259 #CHECK: addr: 0x100001160
261 #CHECK: offset: 0x1160
265 #CHECK: flags: 0x80000400
266 #CHECK: reserved1: 0x0
267 #CHECK: reserved2: 0x0
268 #CHECK: reserved3: 0x0
269 #CHECK: - sectname: __stubs
270 #CHECK: segname: __TEXT
271 #CHECK: - sectname: __stub_helper
272 #CHECK: segname: __TEXT
273 #CHECK: - sectname: __gcc_except_tab
274 #CHECK: segname: __TEXT
275 #CHECK: - sectname: __cstring
276 #CHECK: segname: __TEXT
277 #CHECK: - sectname: __unwind_info
278 #CHECK: segname: __TEXT
279 #CHECK: - cmd: LC_SEGMENT_64
280 #CHECK: segname: __DATA
282 #CHECK: - sectname: __got
283 #CHECK: segname: __DATA
284 #CHECK: - sectname: __nl_symbol_ptr
285 #CHECK: segname: __DATA
286 #CHECK: - sectname: __la_symbol_ptr
287 #CHECK: segname: __DATA
289 ## b) Test that yaml2obj emits an error message if we specify an offset that
290 ## makes the current section and the previous one overlap.
292 # RUN: not yaml2obj --docnum=2 %s -o %t2.macho 2>&1 | FileCheck %s --check-prefix=OVERLAP
294 # OVERLAP: yaml2obj: error: wrote too much data somewhere, section offsets in section __sec2 for segment __SEC don't line up: [cursor=0x121], [fileStart=0x0], [sectionOffset=0x1]
300 cpusubtype: 0x80000003
321 addr: 0x0000000000000000
328 reserved1: 0x00000000
329 reserved2: 0x00000000
330 reserved3: 0x00000000
333 addr: 0x0000000000000000
335 offset: 0x00000001 ## Specify an offset that makes __sec1 and __sec2 overlap.
340 reserved1: 0x00000000
341 reserved2: 0x00000000
342 reserved3: 0x00000000