llvm-project/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-id.test
Shoaib Meenai 5f56da3763 [llvm-install-name-tool] Tighten some path checks
Just having --implicit-check-not=/usr breaks when the LLVM checkout path
contains '/usr', since llvm-objdump prints out the path to the input
file in the first line. Tighten the checks by adding the 'name' prefix
that's used when printing load command payloads. An alternative would be
to redirect the input file into llvm-objdump, in which case it prints
out 'a.out' as the file name, but I'm not sure how reliable that
behavior is.
2020-06-30 17:20:00 -07:00

68 lines
1.9 KiB
Plaintext

## This test checks updating a dynamic shared library ID in a MachO binary.
# RUN: yaml2obj %s --docnum=1 -o %t
## Specifying -id once:
# RUN: llvm-install-name-tool -id /usr/lib/A_long_long_test %t
# RUN: llvm-objdump -p %t | FileCheck %s --check-prefix=ID --implicit-check-not='name /usr'
# ID: name /usr/lib/A_long_long_test
## Specifying -id more than once:
# RUN: llvm-install-name-tool -id /usr/lib/B_long -id /usr/lib/K_long -id /usr/A_short %t
# RUN: llvm-objdump -p %t | FileCheck %s --check-prefix=ID-MULTIPLE --implicit-check-not='name /usr'
# ID-MULTIPLE: name /usr/A_short
## Specifying -id with empty string:
# RUN: not llvm-install-name-tool -id '' %t 2>&1 | \
# RUN: FileCheck %s --check-prefix=EMPTY
# EMPTY: cannot specify an empty id
## Missing id argument:
# RUN: not llvm-install-name-tool %t -id 2>&1 | \
# RUN: FileCheck %s --check-prefix=MISSING
# MISSING: missing argument to -id option
## Shared dylib binary
--- !mach-o
FileHeader:
magic: 0xFEEDFACF
cputype: 0x01000007
cpusubtype: 0x00000003
filetype: 0x00000006
ncmds: 1
sizeofcmds: 56
flags: 0x00002000
reserved: 0x00000000
LoadCommands:
- cmd: LC_ID_DYLIB
cmdsize: 56
dylib:
name: 24
timestamp: 2
current_version: 82115073
compatibility_version: 65536
PayloadString: '/usr/lib/A'
# RUN: yaml2obj %s --docnum=2 -o %t
## Check that -id option has no effect if binary is not a shared dylib:
# RUN: cp %t %t1
# RUN: llvm-install-name-tool -id /usr/lib/J %t
# RUN: cmp %t %t1
## Executable binary
--- !mach-o
FileHeader:
magic: 0xFEEDFACF
cputype: 0x01000007
cpusubtype: 0x00000003
filetype: 0x00000001
ncmds: 0
sizeofcmds: 0
flags: 0x00002000
reserved: 0x00000000