xref: /llvm-project/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-add-rpath.test (revision 51f8d46491c7efd4e2054b036c13ef6266fceab3)
1c54959c0SAlexander Shaposhnikov## This test checks adding a new LC_RPATH load command to a MachO binary.
2c54959c0SAlexander Shaposhnikov
355c81d42SFangrui Song# RUN: yaml2obj %p/Inputs/i386.yaml -o %t.i386
4c54959c0SAlexander Shaposhnikov# RUN: llvm-install-name-tool -add_rpath @executable_path/. %t.i386
5c54959c0SAlexander Shaposhnikov# RUN: llvm-objdump -p %t.i386 | FileCheck --check-prefix=NEW-RPATH %s
6c54959c0SAlexander Shaposhnikov
755c81d42SFangrui Song# RUN: yaml2obj %p/Inputs/x86_64.yaml -o %t.x86_64
8c54959c0SAlexander Shaposhnikov# RUN: llvm-install-name-tool -add_rpath @executable_path/. %t.x86_64
9c54959c0SAlexander Shaposhnikov# RUN: llvm-objdump -p %t.x86_64 | FileCheck --check-prefix=NEW-RPATH %s
10c54959c0SAlexander Shaposhnikov
11c54959c0SAlexander Shaposhnikov# NEW-RPATH: cmd LC_RPATH
12c54959c0SAlexander Shaposhnikov# NEW-RPATH-NEXT: cmdsize
13c54959c0SAlexander Shaposhnikov# NEW-RPATH-NEXT: @executable_path/.
14c54959c0SAlexander Shaposhnikov
15c54959c0SAlexander Shaposhnikov# RUN: not llvm-install-name-tool -add_rpath @executable_path/. %t.i386 2>&1 \
16c54959c0SAlexander Shaposhnikov# RUN: | FileCheck --check-prefix=DUPLICATE-RPATH %s
17c54959c0SAlexander Shaposhnikov
18*51f8d464SKeith Smiley# DUPLICATE-RPATH: rpath '@executable_path/.' would create a duplicate load command
19c54959c0SAlexander Shaposhnikov
20c54959c0SAlexander Shaposhnikov# RUN: not llvm-install-name-tool -add_rpath @executable_path/. 2>&1 \
21c54959c0SAlexander Shaposhnikov# RUN: | FileCheck --check-prefix=NO-INPUT %s
22c54959c0SAlexander Shaposhnikov
23c54959c0SAlexander Shaposhnikov# NO-INPUT: no input file specified
24c966ed8dSAlexander Shaposhnikov
253b5db7fcSSameer Arora## Add same RPATH twice:
263b5db7fcSSameer Arora# RUN: not llvm-install-name-tool -add_rpath @executable_X \
273b5db7fcSSameer Arora# RUN:                            -add_rpath @executable_X %t.i386 2>&1 \
283b5db7fcSSameer Arora# RUN: | FileCheck --check-prefix=DOUBLE %s
293b5db7fcSSameer Arora
30*51f8d464SKeith Smiley# DOUBLE: rpath '@executable_X' would create a duplicate load command
313b5db7fcSSameer Arora
32c966ed8dSAlexander Shaposhnikov## Check that cmdsize accounts for NULL terminator.
33c966ed8dSAlexander Shaposhnikov# RUN: yaml2obj %p/Inputs/x86_64.yaml -o %t.x86_64
34c966ed8dSAlexander Shaposhnikov# RUN: llvm-install-name-tool -add_rpath abcd %t.x86_64
35c966ed8dSAlexander Shaposhnikov# RUN: llvm-objdump -p %t.x86_64 | FileCheck %s --check-prefix=RPATH-SIZE
36c966ed8dSAlexander Shaposhnikov
37c966ed8dSAlexander Shaposhnikov# RPATH-SIZE: cmd LC_RPATH
38c966ed8dSAlexander Shaposhnikov# RPATH-SIZE-NEXT: cmdsize 24
39c966ed8dSAlexander Shaposhnikov# RPATH-SIZE-NEXT: path abcd
40