1 # RUN: yaml2obj %s -o %t
3 # RUN: llvm-objdump --private-headers %t | FileCheck %s --check-prefix=CHECK-ORIGINAL
5 ## Check offset, size and index of text segment command
6 # CHECK-ORIGINAL: Load command 1
7 # CHECK-ORIGINAL-NEXT cmdsize
8 # CHECK-ORIGINAL-NEXT segname __TEXT
9 # CHECK-ORIGINAL-NEXT vmaddr
10 # CHECK-ORIGINAL-NEXT vmsize
11 # CHECK-ORIGINAL-NEXT fileoff 0
12 # CHECK-ORIGINAL-NEXT filesize 16384
14 ## Check offset and index of code signature command
15 # CHECK-ORIGINAL: Load command 14
16 # CHECK-ORIGINAL-NEXT: cmd LC_CODE_SIGNATURE
17 # CHECK-ORIGINAL-NEXT: cmdsize 16
18 # CHECK-ORIGINAL-NEXT: dataoff 16544
19 # CHECK-ORIGINAL-NEXT: datasize 280
21 # RUN: llvm-install-name-tool -prepend_rpath abcd %t
23 # RUN: llvm-objdump --private-headers %t | FileCheck %s --check-prefix=CHECK-PREPEND
24 ## Verify that the binary contains the new RPATH command, as the first command
25 # CHECK-PREPEND: Load command 0
26 # CHECK-PREPEND-NEXT: cmd LC_RPATH
27 # CHECK-PREPEND-NEXT: cmdsize
28 # CHECK-PREPEND-NEXT: path abcd
30 ## Verify the text segment command index increased by 1
31 # CHECK-PREPEND: Load command 2
32 # CHECK-PREPEND-NEXT cmdsize
33 # CHECK-PREPEND-NEXT segname __TEXT
34 # CHECK-PREPEND-NEXT vmaddr
35 # CHECK-PREPEND-NEXT vmsize
36 # CHECK-PREPEND-NEXT fileoff 0
37 # CHECK-PREPEND-NEXT filesize 16384
39 ## Verify the code signature command index increased by 1
40 # CHECK-PREPEND: Load command 15
41 # CHECK-PREPEND-NEXT: cmd LC_CODE_SIGNATURE
42 # CHECK-PREPEND-NEXT: cmdsize 16
43 # CHECK-PREPEND-NEXT: dataoff 16544
44 # CHECK-PREPEND-NEXT: datasize 320
46 ## Verify the new signature is valid
47 # RUN: %python %p/Inputs/code-signature-check.py %t 16544 320 0 16544 | FileCheck %s --check-prefix=CHECK-TEXT-SEGMENT
48 ## Verify the text segment offset and text segment size values included in the signature header are accurate
49 # CHECK-TEXT-SEGMENT: execSegBase=0, execSegLimit=16384
51 # RUN: llvm-install-name-tool -delete_rpath abcd %t
53 # RUN: llvm-objdump --private-headers %t | FileCheck %s --check-prefix=CHECK-REMOVE
55 ## Verify text segment command index returned to orignal
56 # CHECK-REMOVE: Load command 1
57 # CHECK-REMOVE-NEXT cmdsize
58 # CHECK-REMOVE-NEXT segname __TEXT
59 # CHECK-REMOVE-NEXT vmaddr
60 # CHECK-REMOVE-NEXT vmsize
61 # CHECK-REMOVE-NEXT fileoff 0
62 # CHECK-REMOVE-NEXT filesize 16384
64 ## Verify text segment command index returned to original
65 # CHECK-REMOVE: Load command 14
66 # CHECK-REMOVE-NEXT: cmd LC_CODE_SIGNATURE
67 # CHECK-REMOVE-NEXT: cmdsize 16
68 # CHECK-REMOVE-NEXT: dataoff 16544
69 # CHECK-REMOVE-NEXT: datasize 320
71 ## Verify the new signature is valid and text segment values are accurate
72 # RUN: %python %p/Inputs/code-signature-check.py %t 16544 320 0 16544 | FileCheck %s --check-prefix=CHECK-TEXT-SEGMENT
120 content: 554889E531C0C745FC000000005DC3
121 - sectname: __unwind_info
133 content: 010000001C000000000000001C000000000000001C00000002000000A03F00003400000034000000B03F00000000000034000000030000000C000100100001000000000000000001
145 - cmd: LC_DYLD_INFO_ONLY
183 - cmd: LC_LOAD_DYLINKER
186 Content: '/usr/lib/dyld'
190 uuid: 42759668-1CBA-3094-8E2D-F01E1A66E815
191 - cmd: LC_BUILD_VERSION
200 - cmd: LC_SOURCE_VERSION
212 current_version: 84698117
213 compatibility_version: 65536
214 Content: '/usr/lib/libSystem.B.dylib'
216 - cmd: LC_FUNCTION_STARTS
220 - cmd: LC_DATA_IN_CODE
224 - cmd: LC_CODE_SIGNATURE
248 Name: _mh_execute_header
278 - __mh_execute_header