xref: /llvm-project/lld/test/ELF/driver.test (revision 16711b431b843dd2143d38fdf6b0591dfb1783e0)
1# REQUIRES: x86
2
3# RUN: not ld.lld --unknown1 --unkn=own2 -m foo /no/such/file -lnosuchlib \
4# RUN:   2>&1 | FileCheck -check-prefix=UNKNOWN %s
5
6# UNKNOWN: error: unknown argument '--unknown1'
7# UNKNOWN: error: unknown argument '--unkn=own2'
8# UNKNOWN: error: unknown emulation: foo
9# UNKNOWN: error: cannot open /no/such/file
10# UNKNOWN: error: unable to find library -lnosuchlib
11
12# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
13# RUN: not ld.lld %t -o /no/such/file 2>&1 | FileCheck -check-prefix=MISSING %s
14# MISSING: error: cannot open output file /no/such/file
15
16# RUN: ld.lld --help 2>&1 | FileCheck -check-prefix=HELP %s
17# HELP: USAGE:
18# HELP: : supported targets:{{.*}} elf
19
20# RUN: not ld.lld --versin 2>&1 | FileCheck -check-prefix=SPELLVERSION %s
21# SPELLVERSION: error: unknown argument '--versin', did you mean '--version'
22
23## Attempt to link DSO with -r
24# RUN: ld.lld -shared %t -o %t.so
25# RUN: not ld.lld -r %t.so %t -o /dev/null 2>&1 | FileCheck -check-prefix=ERR %s
26# ERR: error: attempted static link of dynamic object
27
28# RUN: not ld.lld -r -shared -pie --export-dynamic %t -o /dev/null 2>&1 | FileCheck -check-prefix=ERR2 %s
29# ERR2: error: -r and -shared may not be used together
30# ERR2: error: -r and -pie may not be used together
31# ERR2: error: -r and --export-dynamic may not be used together
32
33# RUN: not ld.lld -r --icf=all --gdb-index --debug-names %t -o /dev/null 2>&1 | FileCheck -check-prefix=ERR4 %s
34# ERR4: error: -r and --gdb-index may not be used together
35# ERR4: error: -r and --icf may not be used together
36# ERR4: error: -r and --debug-names may not be used together
37
38# RUN: not ld.lld -shared -pie %t -o /dev/null 2>&1 | FileCheck -check-prefix=ERR7 %s
39# ERR7: error: -shared and -pie may not be used together
40
41## "--output=foo" is equivalent to "-o foo".
42# RUN: not ld.lld %t --output=/no/such/file 2>&1 | FileCheck -check-prefix=ERR8 %s
43# ERR8: error: cannot open output file /no/such/file
44
45## "-output=foo" is equivalent to "-o utput=foo".
46# RUN: not ld.lld %t -output=/no/such/file 2>&1 | FileCheck -check-prefix=ERR9 %s
47# ERR9: error: cannot open output file utput=/no/such/file
48
49# RUN: ld.lld %t -z foo -o /dev/null 2>&1 | FileCheck -check-prefix=ERR10 %s --implicit-check-not=warning:
50# RUN: ld.lld %t -z foo -z rel -z rela -z max-page-size=1 -z common-page-size=1 -o /dev/null --version 2>&1 | \
51# RUN:   FileCheck -check-prefix=ERR10 %s --implicit-check-not=warning:
52# ERR10: warning: unknown -z value: foo
53
54## Check we report "unknown -z value" error even with -v.
55# RUN: ld.lld %t -z foo -z rel -o /dev/null -v 2>&1 | FileCheck -check-prefix=ERR10 %s --implicit-check-not=warning:
56
57## Note: in GNU ld, --fatal-warning still leads to a warning.
58# RUN: not ld.lld %t -z foo --fatal-warnings 2>&1 | FileCheck --check-prefix=ERR10-FATAL %s
59# ERR10-FATAL: error: unknown -z value: foo
60
61# RUN: not ld.lld %t -z max-page-size 2>&1 | FileCheck -check-prefix=ERR11 %s
62# ERR11: error: invalid max-page-size:
63
64.globl _start
65_start:
66  nop
67