Sameer Arora | ca518c4 | 2020-06-30 11:01:45 -0700 | [diff] [blame] | 1 | ## This test checks updating a dynamic shared library ID in a MachO binary. |
| 2 | |
| 3 | # RUN: yaml2obj %s --docnum=1 -o %t |
| 4 | |
| 5 | ## Specifying -id once: |
| 6 | # RUN: llvm-install-name-tool -id /usr/lib/A_long_long_test %t |
Shoaib Meenai | 5f56da3 | 2020-06-30 17:20:00 -0700 | [diff] [blame] | 7 | # RUN: llvm-objdump -p %t | FileCheck %s --check-prefix=ID --implicit-check-not='name /usr' |
Sameer Arora | ca518c4 | 2020-06-30 11:01:45 -0700 | [diff] [blame] | 8 | |
Shoaib Meenai | 5f56da3 | 2020-06-30 17:20:00 -0700 | [diff] [blame] | 9 | # ID: name /usr/lib/A_long_long_test |
Sameer Arora | ca518c4 | 2020-06-30 11:01:45 -0700 | [diff] [blame] | 10 | |
| 11 | ## Specifying -id more than once: |
| 12 | # RUN: llvm-install-name-tool -id /usr/lib/B_long -id /usr/lib/K_long -id /usr/A_short %t |
Shoaib Meenai | 5f56da3 | 2020-06-30 17:20:00 -0700 | [diff] [blame] | 13 | # RUN: llvm-objdump -p %t | FileCheck %s --check-prefix=ID-MULTIPLE --implicit-check-not='name /usr' |
Sameer Arora | ca518c4 | 2020-06-30 11:01:45 -0700 | [diff] [blame] | 14 | |
Shoaib Meenai | 5f56da3 | 2020-06-30 17:20:00 -0700 | [diff] [blame] | 15 | # ID-MULTIPLE: name /usr/A_short |
Sameer Arora | ca518c4 | 2020-06-30 11:01:45 -0700 | [diff] [blame] | 16 | |
| 17 | ## Specifying -id with empty string: |
| 18 | # RUN: not llvm-install-name-tool -id '' %t 2>&1 | \ |
| 19 | # RUN: FileCheck %s --check-prefix=EMPTY |
| 20 | |
| 21 | # EMPTY: cannot specify an empty id |
| 22 | |
| 23 | ## Missing id argument: |
| 24 | # RUN: not llvm-install-name-tool %t -id 2>&1 | \ |
| 25 | # RUN: FileCheck %s --check-prefix=MISSING |
| 26 | |
| 27 | # MISSING: missing argument to -id option |
| 28 | |
| 29 | ## Shared dylib binary |
| 30 | --- !mach-o |
| 31 | FileHeader: |
| 32 | magic: 0xFEEDFACF |
| 33 | cputype: 0x01000007 |
| 34 | cpusubtype: 0x00000003 |
| 35 | filetype: 0x00000006 |
| 36 | ncmds: 1 |
| 37 | sizeofcmds: 56 |
| 38 | flags: 0x00002000 |
| 39 | reserved: 0x00000000 |
| 40 | LoadCommands: |
| 41 | - cmd: LC_ID_DYLIB |
| 42 | cmdsize: 56 |
| 43 | dylib: |
| 44 | name: 24 |
| 45 | timestamp: 2 |
| 46 | current_version: 82115073 |
| 47 | compatibility_version: 65536 |
| 48 | PayloadString: '/usr/lib/A' |
| 49 | |
| 50 | # RUN: yaml2obj %s --docnum=2 -o %t |
| 51 | |
| 52 | ## Check that -id option has no effect if binary is not a shared dylib: |
| 53 | # RUN: cp %t %t1 |
| 54 | # RUN: llvm-install-name-tool -id /usr/lib/J %t |
| 55 | # RUN: cmp %t %t1 |
| 56 | |
| 57 | ## Executable binary |
| 58 | --- !mach-o |
| 59 | FileHeader: |
| 60 | magic: 0xFEEDFACF |
| 61 | cputype: 0x01000007 |
| 62 | cpusubtype: 0x00000003 |
| 63 | filetype: 0x00000001 |
| 64 | ncmds: 0 |
| 65 | sizeofcmds: 0 |
| 66 | flags: 0x00002000 |
| 67 | reserved: 0x00000000 |