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_CHAINED_FIXUPS
18 # CHECK: dataoff: [[#CHAINED_FIXUPS_FILEOFF: LINKEDIT_FILEOFF]]
19 # CHECK: datasize: [[#CHAINED_FIXUPS_FILESIZE:]]
21 # CHECK: cmd: LC_DYLD_EXPORTS_TRIE
22 # CHECK: dataoff: [[#DYLD_EXPORTS_TRIE_FILEOFF: CHAINED_FIXUPS_FILEOFF + CHAINED_FIXUPS_FILESIZE]]
23 # CHECK: datasize: [[#DYLD_EXPORTS_TRIE_FILESIZE:]]
25 ## Jump over LC_SYMTAB and LC_DYSYMTAB, which will be checked during
28 # CHECK: cmd: LC_FUNCTION_STARTS
29 # CHECK: dataoff: [[#FUNCTION_STARTS_FILEOFF: DYLD_EXPORTS_TRIE_FILEOFF + DYLD_EXPORTS_TRIE_FILESIZE]]
30 # CHECK: datasize: [[#FUNCTION_STARTS_FILESIZE:]]
32 # CHECK: cmd: LC_DATA_IN_CODE
33 # CHECK: dataoff: [[#DATA_IN_CODE_FILEOFF: FUNCTION_STARTS_FILEOFF + FUNCTION_STARTS_FILESIZE]]
34 # CHECK: datasize: [[#DATA_IN_CODE_FILESIZE:]]
36 ## Jump over LC_CODE_SIGNATURE, which needs to be checked last
40 # CHECK: cmd: LC_SYMTAB
41 # CHECK: symoff: [[#SYMTAB_SYMOFF: DATA_IN_CODE_FILEOFF + DATA_IN_CODE_FILESIZE]]
42 # CHECK: nsyms: [[#SYMTAB_NSYMS:]]
44 ## Skip over the strings table offset/size (part of LC_SYMTAB) until next loop.
46 # CHECK: cmd: LC_DYSYMTAB
47 # CHECK: indirectsymoff: [[#DYSYMTAB_INDIRECTSYMOFF: SYMTAB_SYMOFF + mul(SYMTAB_NSYMS, 16)]]
48 # CHECK: nindirectsyms: [[#DYSYMTAB_NINDIRECTSYMS:]]
52 # CHECK: cmd: LC_SYMTAB
53 # CHECK: stroff: [[#SYMTAB_STROFF: DYSYMTAB_INDIRECTSYMOFF + mul(DYSYMTAB_NINDIRECTSYMS, 4)]]
54 # CHECK: strsize: [[#SYMTAB_STRSIZE:]]
56 # CHECK: cmd: LC_CODE_SIGNATURE
57 ## LC_CODE_SIGNATURE needs to be aligned to 16 bytes boundaries.
58 # CHECK: dataoff: [[#CODE_SIGNATURE_FILEOFF: mul(div(SYMTAB_STROFF + SYMTAB_STRSIZE + 8, 16), 16)]]
59 # CHECK: datasize: [[#CODE_SIGNATURE_FILESIZE:LINKEDIT_FILEOFF + LINKEDIT_FILESIZE - CODE_SIGNATURE_FILEOFF]]
107 content: E80B000000E80C000000C39000000000
120 content: FF254E000000FF2550000000
121 - sectname: __unwind_info
133 content: 010000001C000000000000001C000000000000001C000000020000009C3F00003400000034000000AD3F00000000000034000000030000000C000100100001000000000000000000
136 segname: __DATA_CONST
147 segname: __DATA_CONST
158 content: '00000000000010800100000000000080'
170 - cmd: LC_DYLD_CHAINED_FIXUPS
174 - cmd: LC_DYLD_EXPORTS_TRIE
198 indirectsymoff: 33000
204 - cmd: LC_LOAD_DYLINKER
207 Content: '/usr/lib/dyld'
211 uuid: F74FD957-51B1-3D8E-AE70-D8A248BB5D93
212 - cmd: LC_BUILD_VERSION
221 - cmd: LC_SOURCE_VERSION
234 compatibility_version: 0
235 Content: libFoo-chained-fixups.dylib
242 current_version: 85943299
243 compatibility_version: 65536
244 Content: '/usr/lib/libSystem.B.dylib'
246 - cmd: LC_FUNCTION_STARTS
250 - cmd: LC_DATA_IN_CODE
254 - cmd: LC_CODE_SIGNATURE
278 Name: _mh_execute_header
313 - __mh_execute_header
322 IndirectSymbols: [ 0x2, 0x3, 0x2, 0x3 ]
323 FunctionStarts: [ 0x3F9C ]
324 ChainedFixups: [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x50, 0x0,
325 0x0, 0x0, 0x58, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0,
326 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
327 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
328 0x0, 0x0, 0x0, 0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0,
329 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x0, 0x0, 0x0,
330 0x0, 0x10, 0x6, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x0,
331 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,
332 0x1, 0x2, 0x0, 0x0, 0xFD, 0xC, 0x0, 0x0, 0x0, 0x5F,
333 0x66, 0x6F, 0x6F, 0x0, 0x5F, 0x77, 0x65, 0x61, 0x6B,
334 0x5F, 0x66, 0x6F, 0x6F, 0x0 ]