## 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/.'