1## This test checks updating a dependent shared library install name in a MachO binary. 2 3# RUN: yaml2obj %s -o %t 4 5## Specifying -change once: 6# RUN: cp %t %t.copy 7# RUN: llvm-install-name-tool -change /usr/dylib/LOAD /usr/long/long/dylib/LOAD %t.copy 8# RUN: llvm-objdump -p %t.copy | FileCheck %s --check-prefix=CHANGE --implicit-check-not='name /usr' 9 10# CHANGE: name /usr/long/long/dylib/LOAD 11# CHANGE: name /usr/dylib/WEAK 12 13## Specifying -change multiple times: 14# RUN: cp %t %t.copy 15# RUN: llvm-install-name-tool -change /usr/dylib/WEAK /usr/sh/WEAK \ 16# RUN: -change /usr/dylib/LOAD /usr/sh/LOAD %t.copy 17# RUN: llvm-objdump -p %t.copy | FileCheck %s --check-prefix=CHANGE-MULTIPLE --implicit-check-not='name /usr' 18 19# CHANGE-MULTIPLE: name /usr/sh/LOAD 20# CHANGE-MULTIPLE: name /usr/sh/WEAK 21 22## Changing same dependent library name multiple times: 23# RUN: cp %t %t.copy 24# RUN: llvm-install-name-tool -change /usr/dylib/LOAD /usr/LOAD \ 25# RUN: -change /usr/dylib/LOAD /usr/XXXX %t.copy 26# RUN: llvm-objdump -p %t.copy | FileCheck %s --check-prefix=CHANGE-REPEAT --implicit-check-not='name /usr' 27 28# CHANGE-REPEAT: name /usr/LOAD 29# CHANGE-REPEAT: name /usr/dylib/WEAK 30 31## Specifying dependent library names in a chain: 32# RUN: cp %t %t.copy 33# RUN: llvm-install-name-tool -change /usr/dylib/LOAD /usr/XX/LOAD \ 34# RUN: -change /usr/XX/LOAD /usr/YY/LOAD %t.copy 35# RUN: llvm-objdump -p %t.copy | FileCheck %s --check-prefix=CHANGE-CHAIN --implicit-check-not='name /usr' 36 37# CHANGE-CHAIN: name /usr/XX/LOAD 38# CHANGE-CHAIN: name /usr/dylib/WEAK 39 40## Changing multiple dependent library names where one exists and the other doesn't: 41# RUN: cp %t %t.copy 42# RUN: llvm-install-name-tool -change /usr/dylib/LOAD /usr/JOJO/LOAD \ 43# RUN: -change /usr/BIZARRE /usr/KOKO/LOAD %t.copy 44# RUN: llvm-objdump -p %t.copy | FileCheck %s --check-prefix=CHANGE-SWITCH --implicit-check-not='name /usr' 45 46# CHANGE-SWITCH: name /usr/JOJO/LOAD 47# CHANGE-SWITCH: name /usr/dylib/WEAK 48 49## Changing to a common dependent library name: 50# RUN: cp %t %t.copy 51# RUN: llvm-install-name-tool -change /usr/dylib/LOAD /usr/COMMON \ 52# RUN: -change /usr/dylib/WEAK /usr/COMMON %t.copy 53# RUN: llvm-objdump -p %t.copy | FileCheck %s --check-prefix=CHANGE-COMMON --implicit-check-not='name /usr' 54 55# CHANGE-COMMON: name /usr/COMMON 56# CHANGE-COMMON: name /usr/COMMON 57 58## Change all common dependent library names at once: 59# RUN: llvm-install-name-tool -change /usr/COMMON /usr/ONCE %t.copy 60# RUN: llvm-objdump -p %t.copy | FileCheck %s --check-prefix=CHANGE-ONCE --implicit-check-not='name /usr' 61 62# CHANGE-ONCE: name /usr/ONCE 63# CHANGE-ONCE: name /usr/ONCE 64 65## Check that -change option has no effect if the binary doesn't contain old install name: 66# RUN: cp %t %t1 67# RUN: llvm-install-name-tool -change /usr/JOJO/LOAD /usr/XX/LOAD \ 68# RUN: -change /usr/KOKO/WEAK /usr/YY/WEAK %t 69# RUN: cmp %t %t1 70 71## Missing a -change argument: 72# RUN: not llvm-install-name-tool %t -change /usr/ONCE 2>&1 | \ 73# RUN: FileCheck %s --check-prefix=MISSING 74 75## Missing both -change arguments: 76# RUN: not llvm-install-name-tool %t -change 2>&1 | \ 77# RUN: FileCheck %s --check-prefix=MISSING 78 79# MISSING: missing argument to -change option 80 81--- !mach-o 82FileHeader: 83 magic: 0xFEEDFACF 84 cputype: 0x01000007 85 cpusubtype: 0x00000003 86 filetype: 0x00000001 87 ncmds: 2 88 sizeofcmds: 80 89 flags: 0x00002000 90 reserved: 0x00000000 91LoadCommands: 92 - cmd: LC_LOAD_DYLIB 93 cmdsize: 40 94 dylib: 95 name: 24 96 timestamp: 2 97 current_version: 82115073 98 compatibility_version: 65536 99 Content: '/usr/dylib/LOAD' 100 - cmd: LC_LOAD_WEAK_DYLIB 101 cmdsize: 40 102 dylib: 103 name: 24 104 timestamp: 2 105 current_version: 82115073 106 compatibility_version: 65536 107 Content: '/usr/dylib/WEAK' 108