1 ## This test checks updating a LC_RPATH load command in a MachO binary.
3 # RUN: yaml2obj %s -o %t
5 ## Updating a single RPath entry:
6 # RUN: llvm-install-name-tool -rpath @executable_a/. @executable_A/. %t
7 # RUN: llvm-objdump -p %t | \
8 # RUN: FileCheck %s --check-prefix=RPATHS --implicit-check-not=@executable
10 # RPATHS: @executable_A/.
11 # RPATHS: @executable_short_test
12 # RPATHS: @executable_long_test/.
13 # RPATHS: @executable_d/.
15 ## Updating multiple RPath entries:
16 # RUN: llvm-install-name-tool -rpath @executable_short_test/. @executable_test/. \
17 # RUN: -rpath @executable_long_test/. @executable_long_long_test/. %t
18 # RUN: llvm-objdump -p %t | \
19 # RUN: FileCheck %s --check-prefix=RPATHS-MULTIPLE --implicit-check-not=@executable
21 # RPATHS-MULTIPLE: @executable_A/.
22 # RPATHS-MULTIPLE: @executable_test/.
23 # RPATHS-MULTIPLE: @executable_long_long_test/.
24 # RPATHS-MULTIPLE: @executable_d/.
26 ## Check that cmdsize accounts for NULL terminator:
27 # RUN: llvm-install-name-tool -rpath @executable_A/. ABCD %t
28 # RUN: llvm-objdump -p %t | FileCheck %s --check-prefix=RPATH-SIZE
30 # RPATH-SIZE: cmd LC_RPATH
31 # RPATH-SIZE-NEXT: cmdsize 24
32 # RPATH-SIZE-NEXT: path ABCD
34 ## Updating and adding different RPaths:
35 # RUN: llvm-install-name-tool -rpath @executable_d/. @executable_D/. \
36 # RUN: -add_rpath @executable_e/. %t
37 # RUN: llvm-objdump -p %t | FileCheck %s --check-prefix=RPATHS-ADD --implicit-check-not=@executable
40 # RPATHS-ADD: @executable_test/.
41 # RPATHS-ADD: @executable_long_long_test/.
42 # RPATHS-ADD: @executable_D/.
43 # RPATHS-ADD: @executable_e/.
45 ## Updating and deleting different RPaths:
46 # RUN: llvm-install-name-tool -rpath @executable_D/. @executable_d/. \
47 # RUN: -delete_rpath @executable_e/. %t
48 # RUN: llvm-objdump -p %t | FileCheck %s --check-prefix=RPATHS-DELETE --implicit-check-not=@executable
51 # RPATHS-DELETE: @executable_test/.
52 # RPATHS-DELETE: @executable_long_long_test/.
53 # RPATHS-DELETE: @executable_d/.
57 ## Updating multiple RPath entries where one exists and the other doesn't:
58 # RUN: not llvm-install-name-tool -rpath @executable_test/. @executable/. \
59 # RUN: -rpath @executable_long_test/. @executable_long_longest/. %t 2>&1 | \
60 # RUN: FileCheck %s --check-prefix=RPATHS-FAIL
63 # RPATHS-FAIL: no LC_RPATH load command with path: @executable_long_test/.
65 ## Updating a nonexistent RPath:
66 # RUN: not llvm-install-name-tool -rpath @executable_a/. @executable_AA/. %t 2>&1 | \
67 # RUN: FileCheck %s --check-prefix=ABSENT-RPATH
70 # ABSENT-RPATH: no LC_RPATH load command with path: @executable_a/.
72 ## Updating to an existing RPath:
73 # RUN: not llvm-install-name-tool -rpath @executable_d/. ABCD %t 2>&1 | \
74 # RUN: FileCheck %s --check-prefix=EXISTING
77 # EXISTING: rpath 'ABCD' would create a duplicate load command
79 ## Duplicate RPath entries:
80 # RUN: not llvm-install-name-tool -rpath DDD1/. @exec_d/. \
81 # RUN: -rpath @exec_d/. DDD2/. %t 2>&1 | \
82 # RUN: FileCheck %s --check-prefix=DUPLICATE
85 # DUPLICATE: cannot specify both -rpath 'DDD1/.' '@exec_d/.' and -rpath '@exec_d/.' 'DDD2/.'
87 ## Updating and deleting RPath at the same time:
88 # RUN: not llvm-install-name-tool -rpath @executable_d/. DD/. \
89 # RUN: -delete_rpath @executable_d/. %t 2>&1 | \
90 # RUN: FileCheck %s --check-prefix=COMBINED-DELETE
93 # COMBINED-DELETE: cannot specify both -delete_rpath '@executable_d/.' and -rpath '@executable_d/.' 'DD/.'
95 ## Updating and adding RPath at the same time:
96 # RUN: not llvm-install-name-tool -rpath @executable_e/. EE/. \
97 # RUN: -add_rpath @executable_e/. %t 2>&1 | \
98 # RUN: FileCheck %s --check-prefix=COMBINED-ADD
101 # COMBINED-ADD: cannot specify both -add_rpath '@executable_e/.' and -rpath '@executable_e/.' 'EE/.'
103 ## Missing an RPath argument:
104 # RUN: not llvm-install-name-tool %t -rpath @executable_e/. 2>&1 | \
105 # RUN: FileCheck %s --check-prefix=MISSING
108 ## Missing both RPath arguments:
109 # RUN: not llvm-install-name-tool %t -rpath 2>&1 | \
110 # RUN: FileCheck %s --check-prefix=MISSING
113 # MISSING: missing argument to -rpath option
120 cpusubtype: 0x00000003
130 Content: '@executable_a/.'
134 Content: '@executable_short_test/.'
138 Content: '@executable_long_test/.'
142 Content: '@executable_d/.'