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