2 # RUN: rm -rf %t; split-file %s %t
4 ## codesign requires that each section in __LINKEDIT ends where the next one
5 ## starts and that they follow a certain order. This test enforces that invariant.
6 ## It also checks that the last section in __LINKEDIT covers the last byte of
9 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
10 # RUN: %lld %t/foo.o -dylib -o %t/libfoo.dylib
12 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
14 # RUN: %lld -lSystem -adhoc_codesign -o %t/test %t/libfoo.dylib %t/test.o
15 # RUN: llvm-objdump --macho --all-headers %t/test | FileCheck --check-prefixes=CHECK,OPCODE %s
17 # RUN: %lld -lSystem -adhoc_codesign -fixup_chains -o %t/chained_test %t/libfoo.dylib %t/test.o
18 # RUN: llvm-objdump --macho --all-headers %t/chained_test | FileCheck --check-prefixes=CHECK,CHAINED %s
20 # CHECK: segname __LINKEDIT
23 # CHECK-NEXT: fileoff [[#LINKEDIT_OFF:]]
24 # CHECK-NEXT: filesize [[#LINKEDIT_SIZE:]]
26 # OPCODE: cmd LC_DYLD_INFO_ONLY
27 # OPCODE-NEXT: cmdsize 48
28 # OPCODE-NEXT: rebase_off [[#REBASE_OFF:]]
29 # OPCODE-NEXT: rebase_size [[#REBASE_SIZE:]]
30 # OPCODE-NEXT: bind_off [[#BIND_OFF: REBASE_OFF + REBASE_SIZE]]
31 # OPCODE-NEXT: bind_size [[#BIND_SIZE:]]
32 # OPCODE-NEXT: weak_bind_off [[#WEAK_OFF: BIND_OFF + BIND_SIZE]]
33 # OPCODE-NEXT: weak_bind_size [[#WEAK_SIZE:]]
34 # OPCODE-NEXT: lazy_bind_off [[#LAZY_OFF: WEAK_OFF + WEAK_SIZE]]
35 # OPCODE-NEXT: lazy_bind_size [[#LAZY_SIZE:]]
36 # OPCODE-NEXT: export_off [[#EXPORT_OFF: LAZY_OFF + LAZY_SIZE]]
37 # OPCODE-NEXT: export_size [[#EXPORT_SIZE:]]
39 # CHAINED: cmd LC_DYLD_CHAINED_FIXUPS
40 # CHAINED-NEXT: cmdsize
41 # CHAINED-NEXT: dataoff [[#FIXUPS_OFF: LINKEDIT_OFF]]
42 # CHAINED-NEXT: datasize [[#FIXUPS_SIZE:]]
44 # CHAINED: cmd LC_DYLD_EXPORTS_TRIE
45 # CHAINED-NEXT: cmdsize
46 # CHAINED-NEXT: dataoff [[#EXPORT_OFF: FIXUPS_OFF + FIXUPS_SIZE]]
47 # CHAINED-NEXT: datasize [[#EXPORT_SIZE:]]
49 # CHECK: cmd LC_FUNCTION_STARTS
51 # CHECK-NEXT: dataoff [[#FUNCSTARTS_OFF: EXPORT_OFF + EXPORT_SIZE]]
52 # CHECK-NEXT: datasize [[#FUNCSTARTS_SIZE:]]
54 # CHECK: cmd LC_DATA_IN_CODE
56 # CHECK-NEXT: dataoff [[#DIC_OFF: FUNCSTARTS_OFF + FUNCSTARTS_SIZE]]
58 # CHECK: cmd LC_CODE_SIGNATURE
59 # CHECK-NEXT: cmdsize 16
60 # CHECK-NEXT: dataoff [[#SIG_OFF:]]
61 # CHECK-NEXT: datasize [[#SIG_SIZE: LINKEDIT_OFF + LINKEDIT_SIZE - SIG_OFF]]
64 .globl _foo, _weak_foo
65 .weak_definition _weak_foo