install-name-tool-rpath.test
4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
## This test checks updating a LC_RPATH load command in a MachO binary.
# RUN: yaml2obj %s -o %t
## Updating a single RPath entry:
# RUN: llvm-install-name-tool -rpath @executable_a/. @executable_A/. %t
# RUN: llvm-objdump -p %t | \
# RUN: FileCheck %s --check-prefix=RPATHS --implicit-check-not=@executable
# RPATHS: @executable_A/.
# RPATHS: @executable_short_test
# RPATHS: @executable_long_test/.
# RPATHS: @executable_d/.
## Updating multiple RPath entries:
# RUN: llvm-install-name-tool -rpath @executable_short_test/. @executable_test/. \
# RUN: -rpath @executable_long_test/. @executable_long_long_test/. %t
# RUN: llvm-objdump -p %t | \
# RUN: FileCheck %s --check-prefix=RPATHS-MULTIPLE --implicit-check-not=@executable
# RPATHS-MULTIPLE: @executable_A/.
# RPATHS-MULTIPLE: @executable_test/.
# RPATHS-MULTIPLE: @executable_long_long_test/.
# RPATHS-MULTIPLE: @executable_d/.
## Check that cmdsize accounts for NULL terminator:
# RUN: llvm-install-name-tool -rpath @executable_A/. ABCD %t
# RUN: llvm-objdump -p %t | FileCheck %s --check-prefix=RPATH-SIZE
# RPATH-SIZE: cmd LC_RPATH
# RPATH-SIZE-NEXT: cmdsize 24
# RPATH-SIZE-NEXT: path ABCD
## Updating and adding different RPaths:
# RUN: llvm-install-name-tool -rpath @executable_d/. @executable_D/. \
# RUN: -add_rpath @executable_e/. %t
# RUN: llvm-objdump -p %t | FileCheck %s --check-prefix=RPATHS-ADD --implicit-check-not=@executable
# RPATHS-ADD: ABCD
# RPATHS-ADD: @executable_test/.
# RPATHS-ADD: @executable_long_long_test/.
# RPATHS-ADD: @executable_D/.
# RPATHS-ADD: @executable_e/.
## Updating and deleting different RPaths:
# RUN: llvm-install-name-tool -rpath @executable_D/. @executable_d/. \
# RUN: -delete_rpath @executable_e/. %t
# RUN: llvm-objdump -p %t | FileCheck %s --check-prefix=RPATHS-DELETE --implicit-check-not=@executable
# RPATHS-DELETE: ABCD
# RPATHS-DELETE: @executable_test/.
# RPATHS-DELETE: @executable_long_long_test/.
# RPATHS-DELETE: @executable_d/.
# RUN: cp %t %t1
## Updating multiple RPath entries where one exists and the other doesn't:
# RUN: not llvm-install-name-tool -rpath @executable_test/. @executable/. \
# RUN: -rpath @executable_long_test/. @executable_long_longest/. %t 2>&1 | \
# RUN: FileCheck %s --check-prefix=RPATHS-FAIL
# RUN: cmp %t %t1
# RPATHS-FAIL: no LC_RPATH load command with path: @executable_long_test/.
## Updating a nonexistent RPath:
# RUN: not llvm-install-name-tool -rpath @executable_a/. @executable_AA/. %t 2>&1 | \
# RUN: FileCheck %s --check-prefix=ABSENT-RPATH
# RUN: cmp %t %t1
# ABSENT-RPATH: no LC_RPATH load command with path: @executable_a/.
## Updating to an existing RPath:
# RUN: not llvm-install-name-tool -rpath @executable_d/. ABCD %t 2>&1 | \
# RUN: FileCheck %s --check-prefix=EXISTING
# RUN: cmp %t %t1
# EXISTING: rpath ABCD would create a duplicate load command
## Duplicate RPath entries:
# RUN: not llvm-install-name-tool -rpath DDD1/. @exec_d/. \
# RUN: -rpath @exec_d/. DDD2/. %t 2>&1 | \
# RUN: FileCheck %s --check-prefix=DUPLICATE
# RUN: cmp %t %t1
# DUPLICATE: cannot specify both -rpath DDD1/. @exec_d/. and -rpath @exec_d/. DDD2/.
## Updating and deleting RPath at the same time:
# RUN: not llvm-install-name-tool -rpath @executable_d/. DD/. \
# RUN: -delete_rpath @executable_d/. %t 2>&1 | \
# RUN: FileCheck %s --check-prefix=COMBINED-DELETE
# RUN: cmp %t %t1
# COMBINED-DELETE: cannot specify both -delete_rpath @executable_d/. and -rpath @executable_d/. DD/.
## Updating and adding RPath at the same time:
# RUN: not llvm-install-name-tool -rpath @executable_e/. EE/. \
# RUN: -add_rpath @executable_e/. %t 2>&1 | \
# RUN: FileCheck %s --check-prefix=COMBINED-ADD
# RUN: cmp %t %t1
# COMBINED-ADD: cannot specify both -add_rpath @executable_e/. and -rpath @executable_e/. EE/.
## Missing an RPath argument:
# RUN: not llvm-install-name-tool %t -rpath @executable_e/. 2>&1 | \
# RUN: FileCheck %s --check-prefix=MISSING
# RUN: cmp %t %t1
## Missing both RPath arguments:
# RUN: not llvm-install-name-tool %t -rpath 2>&1 | \
# RUN: FileCheck %s --check-prefix=MISSING
# RUN: cmp %t %t1
# MISSING: missing argument to -rpath option
--- !mach-o
FileHeader:
magic: 0xFEEDFACF
cputype: 0x01000007
cpusubtype: 0x00000003
filetype: 0x00000001
ncmds: 4
sizeofcmds: 144
flags: 0x00002000
reserved: 0x00000000
LoadCommands:
- cmd: LC_RPATH
cmdsize: 32
path: 12
PayloadString: '@executable_a/.'
- cmd: LC_RPATH
cmdsize: 40
path: 12
PayloadString: '@executable_short_test/.'
- cmd: LC_RPATH
cmdsize: 40
path: 12
PayloadString: '@executable_long_test/.'
- cmd: LC_RPATH
cmdsize: 32
path: 12
PayloadString: '@executable_d/.'