1 ## This test verifies that the linkedit segment is
2 ## laid out in the right order.
4 # RUN: yaml2obj %s -o %t.original
5 # RUN: llvm-objcopy %t.original %t.copy
6 # RUN: obj2yaml %t.copy > %t.yaml
7 ## Print the results several times in order to capture the linkedit offsets
8 ## in the order they are needed, but still following the order of the load
9 ## commands where they appear.
10 # RUN: cat %t.yaml %t.yaml %t.yaml | FileCheck %s
12 # CHECK: cmd: LC_SEGMENT_64
13 # CHECK: segname: __LINKEDIT
14 # CHECK: fileoff: [[#LINKEDIT_FILEOFF:]]
15 # CHECK: filesize: [[#LINKEDIT_FILESIZE:]]
17 # CHECK: cmd: LC_DYLD_INFO_ONLY
18 # CHECK: rebase_off: [[#REBASE_OFF: LINKEDIT_FILEOFF]]
19 # CHECK: rebase_size: [[#REBASE_SIZE:]]
20 # CHECK: bind_off: [[#BIND_OFF: REBASE_OFF + REBASE_SIZE]]
21 # CHECK: bind_size: [[#BIND_SIZE:]]
22 # CHECK: weak_bind_off: [[#WEAK_BIND_OFF: BIND_OFF + BIND_SIZE]]
23 # CHECK: weak_bind_size: [[#WEAK_BIND_SIZE:]]
24 # CHECK: lazy_bind_off: [[#LAZY_BIND_OFF: WEAK_BIND_OFF + WEAK_BIND_SIZE]]
25 # CHECK: lazy_bind_size: [[#LAZY_BIND_SIZE:]]
26 # CHECK: export_off: [[#EXPORTS_OFF:LAZY_BIND_OFF + LAZY_BIND_SIZE]]
27 # CHECK: export_size: [[#EXPORTS_SIZE:]]
29 # CHECK: cmd: LC_FUNCTION_STARTS
30 # CHECK: dataoff: [[#FUNCTION_STARTS_FILEOFF: EXPORTS_OFF + EXPORTS_SIZE]]
31 # CHECK: datasize: [[#FUNCTION_STARTS_FILESIZE:]]
33 # CHECK: cmd: LC_DATA_IN_CODE
34 # CHECK: dataoff: [[#DATA_IN_CODE_FILEOFF: FUNCTION_STARTS_FILEOFF + FUNCTION_STARTS_FILESIZE]]
35 # CHECK: datasize: [[#DATA_IN_CODE_FILESIZE:]]
37 ## Jump over LC_CODE_SIGNATURE, which needs to be checked last
41 # CHECK: cmd: LC_SYMTAB
42 # CHECK: symoff: [[#SYMTAB_SYMOFF: DATA_IN_CODE_FILEOFF + DATA_IN_CODE_FILESIZE]]
43 # CHECK: nsyms: [[#SYMTAB_NSYMS:]]
45 ## Skip over the strings table offset/size (part of LC_SYMTAB) until next loop.
47 # CHECK: cmd: LC_DYSYMTAB
48 # CHECK: indirectsymoff: [[#DYSYMTAB_INDIRECTSYMOFF: SYMTAB_SYMOFF + mul(SYMTAB_NSYMS, 16)]]
49 # CHECK: nindirectsyms: [[#DYSYMTAB_NINDIRECTSYMS:]]
53 # CHECK: cmd: LC_SYMTAB
54 # CHECK: stroff: [[#SYMTAB_STROFF: DYSYMTAB_INDIRECTSYMOFF + mul(DYSYMTAB_NINDIRECTSYMS, 4)]]
55 # CHECK: strsize: [[#SYMTAB_STRSIZE:]]
57 # CHECK: cmd: LC_CODE_SIGNATURE
58 ## LC_CODE_SIGNATURE needs to be aligned to 16 bytes boundaries.
59 # CHECK: dataoff: [[#CODE_SIGNATURE_FILEOFF: mul(div(SYMTAB_STROFF + SYMTAB_STRSIZE + 8, 16), 16)]]
60 # CHECK: datasize: [[#CODE_SIGNATURE_FILESIZE:LINKEDIT_FILEOFF + LINKEDIT_FILESIZE - CODE_SIGNATURE_FILEOFF]]
108 content: E80B000000E80C000000C39000000000
121 content: FF256A400000FF256C400000
122 - sectname: __stub_helper
134 content: 4C8D1D6D4000004153FF2555000000906800000000E9E6FFFFFF
135 - sectname: __unwind_info
147 content: 010000001C000000000000001C000000000000001C00000002000000803F00003400000034000000913F00000000000034000000030000000C000100100001000000000000000000
150 segname: __DATA_CONST
161 segname: __DATA_CONST
172 content: '0000000000000000'
185 - sectname: __la_symbol_ptr
197 content: AC3F0000010000000000000000000000
210 content: '0000000000000000'
222 - cmd: LC_DYLD_INFO_ONLY
254 indirectsymoff: 49424
260 - cmd: LC_LOAD_DYLINKER
263 Content: '/usr/lib/dyld'
267 uuid: D565F8BE-1140-391A-BD6E-9CED386430F2
268 - cmd: LC_BUILD_VERSION
277 - cmd: LC_SOURCE_VERSION
290 compatibility_version: 0
291 Content: libFoo-classic.dylib
298 current_version: 85943299
299 compatibility_version: 65536
300 Content: '/usr/lib/libSystem.B.dylib'
302 - cmd: LC_FUNCTION_STARTS
306 - cmd: LC_DATA_IN_CODE
310 - cmd: LC_CODE_SIGNATURE
316 - Opcode: REBASE_OPCODE_SET_TYPE_IMM
318 - Opcode: REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
321 - Opcode: REBASE_OPCODE_DO_REBASE_IMM_TIMES
323 - Opcode: REBASE_OPCODE_DONE
326 - Opcode: BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
329 - Opcode: BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
332 - Opcode: BIND_OPCODE_SET_TYPE_IMM
335 - Opcode: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
337 ULEBExtraData: [ 0x8 ]
339 - Opcode: BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB
341 ULEBExtraData: [ 0xFFFFFFFFFFFFFFF8 ]
343 - Opcode: BIND_OPCODE_DO_BIND
346 - Opcode: BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
349 - Opcode: BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
351 Symbol: dyld_stub_binder
352 - Opcode: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
354 ULEBExtraData: [ 0x0 ]
356 - Opcode: BIND_OPCODE_DO_BIND
359 - Opcode: BIND_OPCODE_DONE
363 - Opcode: BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
366 - Opcode: BIND_OPCODE_SET_TYPE_IMM
369 - Opcode: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
371 ULEBExtraData: [ 0x8 ]
373 - Opcode: BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB
375 ULEBExtraData: [ 0xFFFFFFFFFFFFFFF8 ]
377 - Opcode: BIND_OPCODE_DO_BIND
380 - Opcode: BIND_OPCODE_DONE
384 - Opcode: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
386 ULEBExtraData: [ 0x0 ]
388 - Opcode: BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
391 - Opcode: BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
394 - Opcode: BIND_OPCODE_DO_BIND
397 - Opcode: BIND_OPCODE_DONE
400 - Opcode: BIND_OPCODE_DONE
403 - Opcode: BIND_OPCODE_DONE
406 - Opcode: BIND_OPCODE_DONE
409 - Opcode: BIND_OPCODE_DONE
412 - Opcode: BIND_OPCODE_DONE
434 Name: _mh_execute_header
479 - __mh_execute_header
490 IndirectSymbols: [ 0x3, 0x4, 0x5, 0x3, 0x4 ]
491 FunctionStarts: [ 0x3F80 ]