driver.test 11.2 KB
RUN: ld.lld -### foo.o -m i386pe | FileCheck -check-prefix=X86 %s
X86:      -out:a.exe
X86-SAME: -machine:x86
X86-SAME: -alternatename:__image_base__=___ImageBase
X86-SAME: foo.o

RUN: echo "-### foo.o -m i386pe" > %t.rsp
RUN: ld.lld @%t.rsp | FileCheck -check-prefix=X86 %s

RUN: ld.lld -### foo.o -m i386pep | FileCheck -check-prefix=X64 %s
X64:      -out:a.exe
X64-SAME: -machine:x64
X64-SAME: -alternatename:__image_base__=__ImageBase
X64-SAME: foo.o

RUN: ld.lld -### foo.o -m thumb2pe | FileCheck -check-prefix=ARM %s
ARM:      -out:a.exe
ARM-SAME: -machine:arm
ARM-SAME: -alternatename:__image_base__=__ImageBase
ARM-SAME: foo.o

RUN: ld.lld -### foo.o -m arm64pe | FileCheck -check-prefix=ARM64 %s
ARM64:      -out:a.exe
ARM64-SAME: -machine:arm64
ARM64-SAME: -alternatename:__image_base__=__ImageBase
ARM64-SAME: foo.o

RUN: ld.lld -### foo.o -m i386pep -shared | FileCheck -check-prefix=SHARED %s
RUN: ld.lld -### foo.o -m i386pep --shared | FileCheck -check-prefix=SHARED %s
SHARED:      -out:a.dll
SHARED-SAME: -dll

RUN: ld.lld -### foo.o -m i386pep -shared foo.def | FileCheck -check-prefix=DEF1 %s
DEF1: -def:foo.def

RUN: ld.lld -### foo.o -m i386pep -shared FOO.DEF | FileCheck -check-prefix=DEF2 %s
DEF2: -def:FOO.DEF

RUN: ld.lld -### foo.o -m i386pep -obar.exe | FileCheck -check-prefix=OUT %s
RUN: ld.lld -### foo.o -m i386pep -o bar.exe | FileCheck -check-prefix=OUT %s
OUT: -out:bar.exe

RUN: ld.lld -### foo.o -m i386pep --out-implib bar | FileCheck -check-prefix=IMPLIB %s
RUN: ld.lld -### foo.o -m i386pep --out-implib=bar | FileCheck -check-prefix=IMPLIB %s
RUN: ld.lld -### foo.o -m i386pep -out-implib bar | FileCheck -check-prefix=IMPLIB %s
RUN: ld.lld -### foo.o -m i386pep -out-implib=bar | FileCheck -check-prefix=IMPLIB %s
IMPLIB: -implib:bar

RUN: ld.lld -### foo.o -m i386pep -e bar | FileCheck -check-prefix=ENTRY %s
RUN: ld.lld -### foo.o -m i386pep -ebar | FileCheck -check-prefix=ENTRY %s
RUN: ld.lld -### foo.o -m i386pep -entry bar | FileCheck -check-prefix=ENTRY %s
RUN: ld.lld -### foo.o -m i386pep --entry bar | FileCheck -check-prefix=ENTRY %s
RUN: ld.lld -### foo.o -m i386pep -entry=bar | FileCheck -check-prefix=ENTRY %s
RUN: ld.lld -### foo.o -m i386pep --entry=bar | FileCheck -check-prefix=ENTRY %s
ENTRY: -entry:bar

RUN: ld.lld -### foo.o -m i386pep -mllvm bar -mllvm baz | FileCheck -check-prefix=MLLVM %s
MLLVM: -mllvm:bar -mllvm:baz

RUN: ld.lld -### foo.o -m i386pep -subsystem console | FileCheck -check-prefix=SUBSYSTEM %s
RUN: ld.lld -### foo.o -m i386pep --subsystem console | FileCheck -check-prefix=SUBSYSTEM %s
RUN: ld.lld -### foo.o -m i386pep -subsystem=console | FileCheck -check-prefix=SUBSYSTEM %s
RUN: ld.lld -### foo.o -m i386pep --subsystem=console | FileCheck -check-prefix=SUBSYSTEM %s
SUBSYSTEM: -subsystem:console

RUN: ld.lld -### foo.o -m i386pep --major-os-version 7 --minor-os-version 8 | FileCheck -check-prefix=SUBSYSTEM_VERSION %s
RUN: ld.lld -### foo.o -m i386pep --major-subsystem-version 7 --minor-subsystem-version 8 | FileCheck -check-prefix=SUBSYSTEM_VERSION %s
RUN: ld.lld -### foo.o -m i386pep --major-os-version=7 --minor-os-version=8 --major-subsystem-version=7 --minor-subsystem-version=8 | FileCheck -check-prefix=SUBSYSTEM_VERSION %s
SUBSYSTEM_VERSION: -subsystem:default,7.8

RUN: ld.lld -### foo.o -m i386pep --minor-subsystem-version 8 | FileCheck -check-prefix=SUBSYSTEM_DEFAULT_MAJOR %s
SUBSYSTEM_DEFAULT_MAJOR: -subsystem:default,6.8

RUN: ld.lld -### foo.o -m i386pep --major-subsystem-version 7 | FileCheck -check-prefix=SUBSYSTEM_DEFAULT_MINOR %s
SUBSYSTEM_DEFAULT_MINOR: -subsystem:default,7

RUN: ld.lld -### foo.o -m i386pep --subsystem windows --major-os-version 7 --minor-os-version 8 | FileCheck -check-prefix=SUBSYSTEM_WINDOWS %s
SUBSYSTEM_WINDOWS: -subsystem:windows,7.8

RUN: ld.lld -### foo.o -m i386pep -stack 4194304,8192 | FileCheck -check-prefix=STACK %s
RUN: ld.lld -### foo.o -m i386pep --stack 4194304,8192 | FileCheck -check-prefix=STACK %s
STACK: -stack:4194304,8192

RUN: ld.lld -### foo.o -m i386pep -verbose | FileCheck -check-prefix=VERBOSE %s
RUN: ld.lld -### foo.o -m i386pep --verbose | FileCheck -check-prefix=VERBOSE %s
VERBOSE: -verbose

RUN: ld.lld -### -shared -m i386pe -e _DllMainCRTStartup@12 foo.o | FileCheck -check-prefix I386-ENTRY %s
I386-ENTRY: -entry:DllMainCRTStartup@12

RUN: ld.lld -### -m i386pep foo.o --whole-archive bar.a --no-whole-archive baz.a | FileCheck -check-prefix WHOLE-ARCHIVE %s
RUN: ld.lld -### -m i386pep foo.o -whole-archive bar.a -no-whole-archive baz.a | FileCheck -check-prefix WHOLE-ARCHIVE %s
WHOLE-ARCHIVE: foo.o -wholearchive:bar.a baz.a

RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix MINGW-FLAG %s
MINGW-FLAG: -lldmingw

RUN: ld.lld -### -m i386pep foo.o --exclude-all-symbols | FileCheck -check-prefix EXCLUDE-ALL %s
RUN: ld.lld -### -m i386pep foo.o -exclude-all-symbols | FileCheck -check-prefix EXCLUDE-ALL %s
EXCLUDE-ALL: -exclude-all-symbols

RUN: ld.lld -### -m i386pep foo.o --export-all-symbols | FileCheck -check-prefix EXPORT-ALL %s
RUN: ld.lld -### -m i386pep foo.o -export-all-symbols | FileCheck -check-prefix EXPORT-ALL %s
EXPORT-ALL: -export-all-symbols

RUN: ld.lld -### -m i386pep foo.o --output-def out.def | FileCheck -check-prefix OUTPUT-DEF %s
RUN: ld.lld -### -m i386pep foo.o --output-def=out.def | FileCheck -check-prefix OUTPUT-DEF %s
RUN: ld.lld -### -m i386pep foo.o -output-def out.def | FileCheck -check-prefix OUTPUT-DEF %s
RUN: ld.lld -### -m i386pep foo.o -output-def=out.def | FileCheck -check-prefix OUTPUT-DEF %s
OUTPUT-DEF: -output-def:out.def

RUN: ld.lld -### -m i386pep foo.o -Xlink=-lldmap | FileCheck -check-prefix XLINK %s
XLINK: -lldmap

RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix DEBUG %s
DEBUG: -debug:dwarf

RUN: ld.lld -### -m i386pep foo.o -s | FileCheck -check-prefix STRIP %s
RUN: ld.lld -### -m i386pep foo.o --strip-all | FileCheck -check-prefix STRIP %s
STRIP-NOT: -debug:dwarf

RUN: ld.lld -### -m i386pep foo.o -S | FileCheck -check-prefix STRIP-DEBUG %s
RUN: ld.lld -### -m i386pep foo.o --strip-debug | FileCheck -check-prefix STRIP-DEBUG %s
STRIP-DEBUG: -debug:symtab
STRIP-DEBUG-NOT: -debug:dwarf

RUN: ld.lld -### -m i386pep foo.o -pdb out.pdb | FileCheck -check-prefix PDB %s
RUN: ld.lld -### -m i386pep foo.o -pdb=out.pdb | FileCheck -check-prefix PDB %s
PDB: -debug -pdb:out.pdb
PDB-NOT: -debug:dwarf

RUN: ld.lld -### -m i386pep foo.o -pdb= | FileCheck -check-prefix PDB-DEFAULT %s
PDB-DEFAULT: -debug
PDB-DEFAULT-NOT: -pdb:{{.*}}

RUN: ld.lld -### -m i386pep foo.o --large-address-aware | FileCheck -check-prefix LARGE-ADDRESS-AWARE %s
LARGE-ADDRESS-AWARE: -largeaddressaware

RUN: ld.lld -### -m i386pe foo.o | FileCheck -check-prefix DEFAULT-DISABLE-FLAGS %s
RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix DEFAULT-DISABLE-FLAGS %s
DEFAULT-DISABLE-FLAGS: -dynamicbase:no
RUN: ld.lld -### -m i386pe --dynamicbase foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s
RUN: ld.lld -### -m i386pep -dynamicbase foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s
RUN: ld.lld -### -m thumb2pe foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s
RUN: ld.lld -### -m arm64pe foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s
NO-DEFAULT-DISABLE-FLAGS-NOT: -dynamicbase:no

RUN: ld.lld -### -m i386pep foo.o --image-base 0x1230000 | FileCheck -check-prefix IMAGE-BASE %s
RUN: ld.lld -### -m i386pep foo.o -image-base 0x1230000 | FileCheck -check-prefix IMAGE-BASE %s
IMAGE-BASE: -base:0x1230000

RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix NO-GC-SECTIONS %s
RUN: ld.lld -### -m i386pep foo.o --gc-sections --no-gc-sections | FileCheck -check-prefix NO-GC-SECTIONS %s
NO-GC-SECTIONS: -opt:noref

RUN: ld.lld -### -m i386pep foo.o --gc-sections | FileCheck -check-prefix GC-SECTIONS %s
RUN: ld.lld -### -m i386pep foo.o -gc-sections | FileCheck -check-prefix GC-SECTIONS %s
GC-SECTIONS: -opt:ref

RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix ICF-NONE %s
RUN: ld.lld -### -m i386pep foo.o --icf=none | FileCheck -check-prefix ICF-NONE %s
RUN: ld.lld -### -m i386pep foo.o -icf=none | FileCheck -check-prefix ICF-NONE %s
RUN: ld.lld -### -m i386pep foo.o --icf=safe | FileCheck -check-prefix ICF-NONE %s
RUN: ld.lld -### -m i386pep foo.o -icf=safe | FileCheck -check-prefix ICF-NONE %s
ICF-NONE: -opt:noicf

RUN: ld.lld -### -m i386pep foo.o --icf=all | FileCheck -check-prefix ICF %s
RUN: ld.lld -### -m i386pep foo.o -icf=all | FileCheck -check-prefix ICF %s
ICF: -opt:icf

RUN: ld.lld -### -m i386pep --start-group foo.o --end-group

RUN: ld.lld -### foo.o -m i386pe -shared --kill-at | FileCheck -check-prefix=KILL-AT %s
RUN: ld.lld -### foo.o -m i386pe -shared -kill-at | FileCheck -check-prefix=KILL-AT %s
KILL-AT: -kill-at

RUN: ld.lld -### foo.o -m i386pep -Map bar.map | FileCheck -check-prefix=MAP %s
RUN: ld.lld -### foo.o -m i386pep --Map bar.map | FileCheck -check-prefix=MAP %s
RUN: ld.lld -### foo.o -m i386pep -Map=bar.map | FileCheck -check-prefix=MAP %s
RUN: ld.lld -### foo.o -m i386pep --Map=bar.map | FileCheck -check-prefix=MAP %s
MAP: -lldmap:bar.map

RUN: ld.lld -### foo.o -m i386pe -require-defined _foo --require-defined _bar -require-defined=_baz --require-defined=_foo2 | FileCheck -check-prefix=REQUIRE-DEFINED %s
REQUIRE-DEFINED: -include:_foo -include:_bar -include:_baz -include:_foo2

RUN: ld.lld -### foo.o -m i386pe -u _foo --undefined _bar -undefined=_baz --undefined=_foo2 -u_foo3 | FileCheck -check-prefix=UNDEFINED %s
UNDEFINED: -includeoptional:_foo -includeoptional:_bar -includeoptional:_baz -includeoptional:_foo2 -includeoptional:_foo3

RUN: ld.lld -### -m i386pep foo.o -Llibpath | FileCheck -check-prefix LIBPATH %s
LIBPATH: -libpath:libpath

RUN: ld.lld -### -m i386pep foo.o --reproduce=foo.tar | FileCheck -check-prefix REPRO %s
REPRO: -reproduce:foo.tar

RUN: ld.lld -### -m i386pep foo.o --no-insert-timestamp | FileCheck -check-prefix NOTIMESTAMP %s
RUN: ld.lld -### -m i386pep foo.o --insert-timestamp --no-insert-timestamp | FileCheck -check-prefix NOTIMESTAMP %s
NOTIMESTAMP: -timestamp:0
RUN: ld.lld -### -m i386pep foo.o --no-insert-timestamp --insert-timestamp | FileCheck -check-prefix TIMESTAMP %s
TIMESTAMP-NOT: -timestamp:0

RUN: ld.lld -### -m i386pep foo.o -appcontainer | FileCheck -check-prefix APPCONTAINER %s
RUN: ld.lld -### -m i386pep foo.o --appcontainer | FileCheck -check-prefix APPCONTAINER %s
APPCONTAINER: -appcontainer

RUN: ld.lld -m i386pep --version 2>&1 | FileCheck -check-prefix=VERSION %s
RUN: ld.lld -m i386pep -v 2>&1 | FileCheck -check-prefix=VERSION %s
RUN: not ld.lld -m i386pep -v xyz 2>&1 | FileCheck -check-prefix=VERSION %s
VERSION: LLD {{.*}} (compatible with GNU linkers)

RUN: ld.lld -m i386pep --help 2>&1 | FileCheck -check-prefix=HELP %s
HELP: USAGE:
HELP: --enable-auto-import

RUN: ld.lld -### -m i386pep foo.o -delayload user32.dll --delayload shell32.dll | FileCheck -check-prefix DELAYLOAD %s
RUN: ld.lld -### -m i386pep foo.o -delayload=user32.dll --delayload=shell32.dll | FileCheck -check-prefix DELAYLOAD %s
DELAYLOAD: -delayload:user32.dll -delayload:shell32.dll

RUN: not ld.lld -m i386pep -entry 2>&1 | FileCheck -check-prefix MISSING_ARG %s
MISSING_ARG: error: -entry: missing argument

RUN: not ld.lld -m i386pep --foo 2>&1 | FileCheck -check-prefix UNKNOWN_ARG %s
UNKNOWN_ARG: error: unknown argument: --foo

RUN: not ld.lld -m i386pep 2>&1 | FileCheck -check-prefix NO_INPUT_FILES %s
NO_INPUT_FILES: error: no input files