xref: /llvm-project/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-id.test (revision c0da287c30c9f511ccb07fdd42c997be2caea9ec)
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
7# RUN: llvm-objdump -p %t | FileCheck %s --check-prefix=ID --implicit-check-not='name /usr'
8
9# ID: name /usr/lib/A_long_long_test
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
13# RUN: llvm-objdump -p %t | FileCheck %s --check-prefix=ID-MULTIPLE --implicit-check-not='name /usr'
14
15# ID-MULTIPLE: name /usr/A_short
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
31FileHeader:
32  magic:           0xFEEDFACF
33  cputype:         0x01000007
34  cpusubtype:      0x00000003
35  filetype:        0x00000006
36  ncmds:           1
37  sizeofcmds:      56
38  flags:           0x00002000
39  reserved:        0x00000000
40LoadCommands:
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    Content:                    '/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
59FileHeader:
60  magic:           0xFEEDFACF
61  cputype:         0x01000007
62  cpusubtype:      0x00000003
63  filetype:        0x00000001
64  ncmds:           0
65  sizeofcmds:      0
66  flags:           0x00002000
67  reserved:        0x00000000
68