forked from OSchip/llvm-project
[PECOFF] Use Windows style options instead of Unix style as primary options.
LLD still accepts both Unix and Windows style options when it's run as link.exe. This patch does not change functionality. llvm-svn: 187086
This commit is contained in:
parent
b64e95f49e
commit
d1d116aa89
|
@ -80,7 +80,7 @@ bool checkNumber(StringRef version, const char *errorMessage,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse an argument for -base, -stack or -heap. The expected string
|
// Parse an argument for /base, /stack or /heap. The expected string
|
||||||
// is "<integer>[,<integer>]".
|
// is "<integer>[,<integer>]".
|
||||||
bool parseMemoryOption(const StringRef &arg, raw_ostream &diagnostics,
|
bool parseMemoryOption(const StringRef &arg, raw_ostream &diagnostics,
|
||||||
uint64_t &reserve, uint64_t &commit) {
|
uint64_t &reserve, uint64_t &commit) {
|
||||||
|
@ -97,7 +97,7 @@ bool parseMemoryOption(const StringRef &arg, raw_ostream &diagnostics,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse -base command line option. The argument for the parameter is in the
|
// Parse /base command line option. The argument for the parameter is in the
|
||||||
// form of "<address>[:<size>]".
|
// form of "<address>[:<size>]".
|
||||||
bool parseBaseOption(PECOFFTargetInfo &info, const StringRef &arg,
|
bool parseBaseOption(PECOFFTargetInfo &info, const StringRef &arg,
|
||||||
raw_ostream &diagnostics) {
|
raw_ostream &diagnostics) {
|
||||||
|
@ -117,7 +117,7 @@ bool parseBaseOption(PECOFFTargetInfo &info, const StringRef &arg,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse -stack command line option
|
// Parse /stack command line option
|
||||||
bool parseStackOption(PECOFFTargetInfo &info, const StringRef &arg,
|
bool parseStackOption(PECOFFTargetInfo &info, const StringRef &arg,
|
||||||
raw_ostream &diagnostics) {
|
raw_ostream &diagnostics) {
|
||||||
uint64_t reserve;
|
uint64_t reserve;
|
||||||
|
@ -129,7 +129,7 @@ bool parseStackOption(PECOFFTargetInfo &info, const StringRef &arg,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse -heap command line option.
|
// Parse /heap command line option.
|
||||||
bool parseHeapOption(PECOFFTargetInfo &info, const StringRef &arg,
|
bool parseHeapOption(PECOFFTargetInfo &info, const StringRef &arg,
|
||||||
raw_ostream &diagnostics) {
|
raw_ostream &diagnostics) {
|
||||||
uint64_t reserve;
|
uint64_t reserve;
|
||||||
|
@ -166,7 +166,7 @@ bool parseMinOSVersion(PECOFFTargetInfo &info, const StringRef &osVersion,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse -subsystem command line option. The form of -subsystem is
|
// Parse /subsystem command line option. The form of /subsystem is
|
||||||
// "subsystem_name[,majorOSVersion[.minorOSVersion]]".
|
// "subsystem_name[,majorOSVersion[.minorOSVersion]]".
|
||||||
bool parseSubsystemOption(PECOFFTargetInfo &info, std::string arg,
|
bool parseSubsystemOption(PECOFFTargetInfo &info, std::string arg,
|
||||||
raw_ostream &diagnostics) {
|
raw_ostream &diagnostics) {
|
||||||
|
@ -280,7 +280,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[],
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle -help
|
// handle /help
|
||||||
if (parsedArgs->getLastArg(OPT_help)) {
|
if (parsedArgs->getLastArg(OPT_help)) {
|
||||||
table.PrintHelp(llvm::outs(), argv[0], "LLVM Linker", false);
|
table.PrintHelp(llvm::outs(), argv[0], "LLVM Linker", false);
|
||||||
return true;
|
return true;
|
||||||
|
@ -300,66 +300,66 @@ bool WinLinkDriver::parse(int argc, const char *argv[],
|
||||||
info.appendLLVMOption((*it)->getValue());
|
info.appendLLVMOption((*it)->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle -base
|
// handle /base
|
||||||
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_base))
|
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_base))
|
||||||
if (!parseBaseOption(info, arg->getValue(), diagnostics))
|
if (!parseBaseOption(info, arg->getValue(), diagnostics))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Handle -stack
|
// handle /stack
|
||||||
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_stack))
|
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_stack))
|
||||||
if (!parseStackOption(info, arg->getValue(), diagnostics))
|
if (!parseStackOption(info, arg->getValue(), diagnostics))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Handle -heap
|
// handle /heap
|
||||||
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_heap))
|
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_heap))
|
||||||
if (!parseHeapOption(info, arg->getValue(), diagnostics))
|
if (!parseHeapOption(info, arg->getValue(), diagnostics))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Handle -subsystem
|
// handle /subsystem
|
||||||
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_subsystem))
|
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_subsystem))
|
||||||
if (!parseSubsystemOption(info, arg->getValue(), diagnostics))
|
if (!parseSubsystemOption(info, arg->getValue(), diagnostics))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Handle -entry
|
// handle /entry
|
||||||
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_entry))
|
if (llvm::opt::Arg *arg = parsedArgs->getLastArg(OPT_entry))
|
||||||
info.setEntrySymbolName(arg->getValue());
|
info.setEntrySymbolName(arg->getValue());
|
||||||
|
|
||||||
// Handle -libpath
|
// handle /libpath
|
||||||
for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_libpath),
|
for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_libpath),
|
||||||
ie = parsedArgs->filtered_end();
|
ie = parsedArgs->filtered_end();
|
||||||
it != ie; ++it) {
|
it != ie; ++it) {
|
||||||
info.appendInputSearchPath((*it)->getValue());
|
info.appendInputSearchPath((*it)->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle -force
|
// handle /force
|
||||||
if (parsedArgs->getLastArg(OPT_force))
|
if (parsedArgs->getLastArg(OPT_force))
|
||||||
info.setAllowRemainingUndefines(true);
|
info.setAllowRemainingUndefines(true);
|
||||||
|
|
||||||
// Handle -nxcompat:no
|
// handle /nxcompat:no
|
||||||
if (parsedArgs->getLastArg(OPT_no_nxcompat))
|
if (parsedArgs->getLastArg(OPT_no_nxcompat))
|
||||||
info.setNxCompat(false);
|
info.setNxCompat(false);
|
||||||
|
|
||||||
// Handle -largeaddressaware
|
// handle /largeaddressaware
|
||||||
if (parsedArgs->getLastArg(OPT_largeaddressaware))
|
if (parsedArgs->getLastArg(OPT_largeaddressaware))
|
||||||
info.setLargeAddressAware(true);
|
info.setLargeAddressAware(true);
|
||||||
|
|
||||||
// Handle -fixed
|
// handle /fixed
|
||||||
if (parsedArgs->getLastArg(OPT_fixed))
|
if (parsedArgs->getLastArg(OPT_fixed))
|
||||||
info.setBaseRelocationEnabled(false);
|
info.setBaseRelocationEnabled(false);
|
||||||
|
|
||||||
// Handle -tsaware:no
|
// handle /tsaware:no
|
||||||
if (parsedArgs->getLastArg(OPT_no_tsaware))
|
if (parsedArgs->getLastArg(OPT_no_tsaware))
|
||||||
info.setTerminalServerAware(false);
|
info.setTerminalServerAware(false);
|
||||||
|
|
||||||
// Handle -include
|
// handle /include
|
||||||
if (llvm::opt::Arg *sym = parsedArgs->getLastArg(OPT_incl))
|
if (llvm::opt::Arg *sym = parsedArgs->getLastArg(OPT_incl))
|
||||||
info.addInitialUndefinedSymbol(sym->getValue());
|
info.addInitialUndefinedSymbol(sym->getValue());
|
||||||
|
|
||||||
// Handle -out
|
// handle /out
|
||||||
if (llvm::opt::Arg *outpath = parsedArgs->getLastArg(OPT_out))
|
if (llvm::opt::Arg *outpath = parsedArgs->getLastArg(OPT_out))
|
||||||
info.setOutputPath(outpath->getValue());
|
info.setOutputPath(outpath->getValue());
|
||||||
|
|
||||||
// Handle -defaultlib
|
// handle /defaultlib
|
||||||
std::vector<StringRef> defaultLibs;
|
std::vector<StringRef> defaultLibs;
|
||||||
for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_defaultlib),
|
for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_defaultlib),
|
||||||
ie = parsedArgs->filtered_end();
|
ie = parsedArgs->filtered_end();
|
||||||
|
@ -384,13 +384,13 @@ bool WinLinkDriver::parse(int argc, const char *argv[],
|
||||||
for (const StringRef path : inputPaths)
|
for (const StringRef path : inputPaths)
|
||||||
info.appendInputFileOrLibrary(path);
|
info.appendInputFileOrLibrary(path);
|
||||||
|
|
||||||
// Add the library files specified by -defaultlib option. The files
|
// Add the library files specified by /defaultlib option. The files
|
||||||
// specified by the option should have lower precedence than the other files
|
// specified by the option should have lower precedence than the other files
|
||||||
// added above, which is important for link.exe compatibility.
|
// added above, which is important for link.exe compatibility.
|
||||||
for (const StringRef path : defaultLibs)
|
for (const StringRef path : defaultLibs)
|
||||||
info.appendLibraryFile(path);
|
info.appendLibraryFile(path);
|
||||||
|
|
||||||
// If -out option was not specified, the default output file name is
|
// If /out option was not specified, the default output file name is
|
||||||
// constructed by replacing an extension of the first input file
|
// constructed by replacing an extension of the first input file
|
||||||
// with ".exe".
|
// with ".exe".
|
||||||
if (info.outputPath().empty() && !inputPaths.empty())
|
if (info.outputPath().empty() && !inputPaths.empty())
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# RUN: yaml2obj %p/Inputs/hello.obj.yaml > %t.obj
|
# RUN: yaml2obj %p/Inputs/hello.obj.yaml > %t.obj
|
||||||
#
|
#
|
||||||
# RUN: lld -flavor link -out %t1 -subsystem console -force -- %t.obj \
|
# RUN: lld -flavor link /out:%t1 /subsystem:console /force -- %t.obj \
|
||||||
# RUN: && llvm-objdump -s %t1 | FileCheck %s --check-prefix=BASEREL
|
# RUN: && llvm-objdump -s %t1 | FileCheck %s --check-prefix=BASEREL
|
||||||
#
|
#
|
||||||
# RUN: lld -flavor link -out %t1 -subsystem console -force -fixed -- %t.obj \
|
# RUN: lld -flavor link /out:%t1 /subsystem:console /force /fixed -- %t.obj \
|
||||||
# RUN: && llvm-objdump -s %t1 | FileCheck %s --check-prefix=NOBASEREL
|
# RUN: && llvm-objdump -s %t1 | FileCheck %s --check-prefix=NOBASEREL
|
||||||
|
|
||||||
# Because llvm-objdump cannot pretty-print the contents of .reloc section, we
|
# Because llvm-objdump cannot pretty-print the contents of .reloc section, we
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# RUN: yaml2obj %p/Inputs/nop.obj.yaml > %t.obj
|
# RUN: yaml2obj %p/Inputs/nop.obj.yaml > %t.obj
|
||||||
#
|
#
|
||||||
# RUN: lld -flavor link -out %t1 -- %t.obj \
|
# RUN: lld -flavor link /out:%t1 -- %t.obj \
|
||||||
# RUN: && llvm-readobj -file-headers %t1 | FileCheck -check-prefix=DEFAULT %s
|
# RUN: && llvm-readobj -file-headers %t1 | FileCheck -check-prefix=DEFAULT %s
|
||||||
#
|
#
|
||||||
# RUN: lld -flavor link -out %t1 -base 8388608 -- %t.obj \
|
# RUN: lld -flavor link /out:%t1 /base:8388608 -- %t.obj \
|
||||||
# RUN: && llvm-readobj -file-headers %t1 | FileCheck -check-prefix=BASE %s
|
# RUN: && llvm-readobj -file-headers %t1 | FileCheck -check-prefix=BASE %s
|
||||||
|
|
||||||
DEFAULT: ImageBase: 0x400000
|
DEFAULT: ImageBase: 0x400000
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# RUN: yaml2obj %p/Inputs/grouped-sections.obj.yaml > %t.obj
|
# RUN: yaml2obj %p/Inputs/grouped-sections.obj.yaml > %t.obj
|
||||||
#
|
#
|
||||||
# RUN: lld -flavor link -out %t1 -subsystem console -force -- %t.obj \
|
# RUN: lld -flavor link /out:%t1 /subsystem:console /force -- %t.obj \
|
||||||
# RUN: && llvm-objdump -s %t1 | FileCheck %s
|
# RUN: && llvm-objdump -s %t1 | FileCheck %s
|
||||||
#
|
#
|
||||||
# The file "grouped-sections.obj" has three data sections in the following
|
# The file "grouped-sections.obj" has three data sections in the following
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
# RUN: yaml2obj %p/Inputs/hello.obj.yaml > %t.obj
|
# RUN: yaml2obj %p/Inputs/hello.obj.yaml > %t.obj
|
||||||
|
|
||||||
# RUN: lld -flavor link -out %t1 -subsystem console -force -- %t.obj \
|
# RUN: lld -flavor link /out:%t1 /subsystem:console /force -- %t.obj \
|
||||||
# RUN: && llvm-readobj -file-headers %t1 | FileCheck -check-prefix=FILE %s
|
# RUN: && llvm-readobj -file-headers %t1 | FileCheck -check-prefix=FILE %s
|
||||||
|
|
||||||
FILE: ImageOptionalHeader {
|
FILE: ImageOptionalHeader {
|
||||||
FILE: SizeOfInitializedData: 512
|
FILE: SizeOfInitializedData: 512
|
||||||
FILE: }
|
FILE: }
|
||||||
|
|
||||||
# RUN: lld -flavor link -out %t1 -subsystem console -force -- %t.obj \
|
# RUN: lld -flavor link /out:%t1 /subsystem:console /force -- %t.obj \
|
||||||
# RUN: && llvm-readobj -sections %t1 | FileCheck -check-prefix=SECTIONS %s
|
# RUN: && llvm-readobj -sections %t1 | FileCheck -check-prefix=SECTIONS %s
|
||||||
|
|
||||||
SECTIONS: Format: COFF-i386
|
SECTIONS: Format: COFF-i386
|
||||||
|
|
|
@ -3,19 +3,19 @@
|
||||||
#
|
#
|
||||||
# RUN: yaml2obj %p/Inputs/vars-main.obj.yaml > %t.obj
|
# RUN: yaml2obj %p/Inputs/vars-main.obj.yaml > %t.obj
|
||||||
#
|
#
|
||||||
# RUN: lld -flavor link -out %t1 -subsystem console -- %t.obj \
|
# RUN: lld -flavor link /out:%t1 /subsystem:console -- %t.obj \
|
||||||
# RUN: %p/Inputs/vars.lib && llvm-objdump -d %t1 | FileCheck %s
|
# RUN: %p/Inputs/vars.lib && llvm-objdump -d %t1 | FileCheck %s
|
||||||
#
|
#
|
||||||
# RUN: lld -flavor link -out %t1 -subsystem console -libpath %p/Inputs \
|
# RUN: lld -flavor link /out:%t1 /subsystem:console /libpath:%p/Inputs \
|
||||||
# RUN: -- %t.obj vars.lib && llvm-objdump -d %t1 | FileCheck %s
|
# RUN: -- %t.obj vars.lib && llvm-objdump -d %t1 | FileCheck %s
|
||||||
#
|
#
|
||||||
# RUN: lld -flavor link -out %t1 -subsystem console -libpath %p/Inputs \
|
# RUN: lld -flavor link /out:%t1 /subsystem:console /libpath:%p/Inputs \
|
||||||
# RUN: -defaultlib vars.lib -- %t.obj && llvm-objdump -d %t1 | FileCheck %s
|
# RUN: /defaultlib:vars.lib -- %t.obj && llvm-objdump -d %t1 | FileCheck %s
|
||||||
#
|
#
|
||||||
# RUN: LIB=%p/Inputs lld -flavor link -out %t1 -subsystem console \
|
# RUN: LIB=%p/Inputs lld -flavor link /out:%t1 /subsystem:console \
|
||||||
# RUN: -- %t.obj vars.lib && llvm-objdump -d %t1 | FileCheck %s
|
# RUN: -- %t.obj vars.lib && llvm-objdump -d %t1 | FileCheck %s
|
||||||
#
|
#
|
||||||
# RUN: LINK="-out %t1 -subsystem console -- %t.obj" lld -flavor link \
|
# RUN: LINK="/out:%t1 /subsystem:console -- %t.obj" lld -flavor link \
|
||||||
# RUN: %p/Inputs/vars.lib && llvm-objdump -d %t1 | FileCheck %s
|
# RUN: %p/Inputs/vars.lib && llvm-objdump -d %t1 | FileCheck %s
|
||||||
|
|
||||||
CHECK: Disassembly of section .text:
|
CHECK: Disassembly of section .text:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# RUN: yaml2obj %p/Inputs/nop.obj.yaml > %t.obj
|
# RUN: yaml2obj %p/Inputs/nop.obj.yaml > %t.obj
|
||||||
#
|
#
|
||||||
# RUN: not lld -flavor link -out %t1 -subsystem console \
|
# RUN: not lld -flavor link /out:%t1 /subsystem:console \
|
||||||
# RUN: -include nosuchsym -- %t.obj 2> %t1
|
# RUN: /include:nosuchsym -- %t.obj 2> %t1
|
||||||
# RUN: FileCheck %s < %t1
|
# RUN: FileCheck %s < %t1
|
||||||
|
|
||||||
CHECK: Undefined Symbol: Linker Internal File : nosuchsym
|
CHECK: Undefined Symbol: Linker Internal File : nosuchsym
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# RUN: yaml2obj %p/Inputs/main.obj.yaml > %t.obj
|
# RUN: yaml2obj %p/Inputs/main.obj.yaml > %t.obj
|
||||||
#
|
#
|
||||||
# RUN: lld -flavor link -out %t1 -subsystem console -- %t.obj \
|
# RUN: lld -flavor link /out:%t1 /subsystem:console -- %t.obj \
|
||||||
# RUN: %p/Inputs/static.lib && llvm-objdump -d %t1 | FileCheck %s
|
# RUN: %p/Inputs/static.lib && llvm-objdump -d %t1 | FileCheck %s
|
||||||
|
|
||||||
CHECK: Disassembly of section .text:
|
CHECK: Disassembly of section .text:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# RUN: yaml2obj %p/Inputs/static-data1.obj.yaml > %t2.obj
|
# RUN: yaml2obj %p/Inputs/static-data1.obj.yaml > %t2.obj
|
||||||
# RUN: yaml2obj %p/Inputs/static-data2.obj.yaml > %t3.obj
|
# RUN: yaml2obj %p/Inputs/static-data2.obj.yaml > %t3.obj
|
||||||
#
|
#
|
||||||
# RUN: lld -flavor link -out %t1 -subsystem console -- %t1.obj %t2.obj %t3.obj \
|
# RUN: lld -flavor link /out:%t1 /subsystem:console -- %t1.obj %t2.obj %t3.obj \
|
||||||
# RUN: && llvm-objdump -d %t1 | FileCheck %s
|
# RUN: && llvm-objdump -d %t1 | FileCheck %s
|
||||||
|
|
||||||
CHECK: Disassembly of section .text:
|
CHECK: Disassembly of section .text:
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# RUN: llvm-objdump -d %t.obj | FileCheck -check-prefix=BEFORE %s
|
# RUN: llvm-objdump -d %t.obj | FileCheck -check-prefix=BEFORE %s
|
||||||
#
|
#
|
||||||
# RUN: lld -flavor link -out %t1 -subsystem console -force -- %t.obj \
|
# RUN: lld -flavor link /out:%t1 /subsystem:console /force -- %t.obj \
|
||||||
# RUN: && llvm-objdump -d %t1 | FileCheck -check-prefix=AFTER %s
|
# RUN: && llvm-objdump -d %t1 | FileCheck -check-prefix=AFTER %s
|
||||||
|
|
||||||
BEFORE: Disassembly of section .text:
|
BEFORE: Disassembly of section .text:
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
#
|
#
|
||||||
# RUN: yaml2obj %p/Inputs/nop.obj.yaml > %t.obj
|
# RUN: yaml2obj %p/Inputs/nop.obj.yaml > %t.obj
|
||||||
#
|
#
|
||||||
# RUN: lld -flavor link -out %t1 -subsystem console,3.11 -- %t.obj \
|
# RUN: lld -flavor link /out:%t1 /subsystem:console,3.11 -- %t.obj \
|
||||||
# RUN: && llvm-readobj -file-headers %t1 | FileCheck -check-prefix=FILE %s
|
# RUN: && llvm-readobj -file-headers %t1 | FileCheck -check-prefix=FILE %s
|
||||||
#
|
#
|
||||||
# RUN: lld -flavor link -out %t1 -- %t.obj \
|
# RUN: lld -flavor link /out:%t1 -- %t.obj \
|
||||||
# RUN: && llvm-readobj -sections %t1 | FileCheck -check-prefix=SECTIONS %s
|
# RUN: && llvm-readobj -sections %t1 | FileCheck -check-prefix=SECTIONS %s
|
||||||
|
|
||||||
FILE: Format: COFF-i386
|
FILE: Format: COFF-i386
|
||||||
|
|
|
@ -32,8 +32,8 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, Basic) {
|
TEST_F(WinLinkParserTest, Basic) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-subsystem", "console", "-out", "a.exe",
|
EXPECT_FALSE(parse("link.exe", "/subsystem:console", "/out:a.exe",
|
||||||
"-entry", "_start", "a.obj", "b.obj", "c.obj", nullptr));
|
"-entry:_start", "a.obj", "b.obj", "c.obj", nullptr));
|
||||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _info.getSubsystem());
|
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _info.getSubsystem());
|
||||||
EXPECT_EQ("a.exe", _info.outputPath());
|
EXPECT_EQ("a.exe", _info.outputPath());
|
||||||
EXPECT_EQ("_start", _info.entrySymbolName());
|
EXPECT_EQ("_start", _info.entrySymbolName());
|
||||||
|
@ -57,9 +57,9 @@ TEST_F(WinLinkParserTest, Basic) {
|
||||||
EXPECT_TRUE(_info.initialUndefinedSymbols().empty());
|
EXPECT_TRUE(_info.initialUndefinedSymbols().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, WindowsStyleOption) {
|
TEST_F(WinLinkParserTest, UnixStyleOption) {
|
||||||
EXPECT_FALSE(parse("link.exe", "/subsystem:console", "/out:a.exe", "a.obj",
|
EXPECT_FALSE(parse("link.exe", "-subsystem", "console", "-out", "a.exe",
|
||||||
nullptr));
|
"a.obj", nullptr));
|
||||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _info.getSubsystem());
|
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _info.getSubsystem());
|
||||||
EXPECT_EQ("a.exe", _info.outputPath());
|
EXPECT_EQ("a.exe", _info.outputPath());
|
||||||
EXPECT_EQ(1, inputFileCount());
|
EXPECT_EQ(1, inputFileCount());
|
||||||
|
@ -82,7 +82,7 @@ TEST_F(WinLinkParserTest, NonStandardFileExtension) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, Libpath) {
|
TEST_F(WinLinkParserTest, Libpath) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-libpath", "dir1", "-libpath", "dir2",
|
EXPECT_FALSE(parse("link.exe", "/libpath:dir1", "/libpath:dir2",
|
||||||
"a.obj", nullptr));
|
"a.obj", nullptr));
|
||||||
const std::vector<StringRef> &paths = _info.getInputSearchPaths();
|
const std::vector<StringRef> &paths = _info.getInputSearchPaths();
|
||||||
EXPECT_EQ(2U, paths.size());
|
EXPECT_EQ(2U, paths.size());
|
||||||
|
@ -91,90 +91,90 @@ TEST_F(WinLinkParserTest, Libpath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, MinMajorOSVersion) {
|
TEST_F(WinLinkParserTest, MinMajorOSVersion) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-subsystem", "windows,3", "foo.o", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/subsystem:windows,3", "foo.o", nullptr));
|
||||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI, _info.getSubsystem());
|
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI, _info.getSubsystem());
|
||||||
EXPECT_EQ(3, _info.getMinOSVersion().majorVersion);
|
EXPECT_EQ(3, _info.getMinOSVersion().majorVersion);
|
||||||
EXPECT_EQ(0, _info.getMinOSVersion().minorVersion);
|
EXPECT_EQ(0, _info.getMinOSVersion().minorVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, MinMajorMinorOSVersion) {
|
TEST_F(WinLinkParserTest, MinMajorMinorOSVersion) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-subsystem", "windows,3.1", "foo.o", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/subsystem:windows,3.1", "foo.o", nullptr));
|
||||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI, _info.getSubsystem());
|
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI, _info.getSubsystem());
|
||||||
EXPECT_EQ(3, _info.getMinOSVersion().majorVersion);
|
EXPECT_EQ(3, _info.getMinOSVersion().majorVersion);
|
||||||
EXPECT_EQ(1, _info.getMinOSVersion().minorVersion);
|
EXPECT_EQ(1, _info.getMinOSVersion().minorVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, Base) {
|
TEST_F(WinLinkParserTest, Base) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-base", "8388608", "a.obj", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/base:8388608", "a.obj", nullptr));
|
||||||
EXPECT_EQ(0x800000U, _info.getBaseAddress());
|
EXPECT_EQ(0x800000U, _info.getBaseAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, StackReserve) {
|
TEST_F(WinLinkParserTest, StackReserve) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-stack", "8192", "a.obj", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/stack:8192", "a.obj", nullptr));
|
||||||
EXPECT_EQ(8192U, _info.getStackReserve());
|
EXPECT_EQ(8192U, _info.getStackReserve());
|
||||||
EXPECT_EQ(4096U, _info.getStackCommit());
|
EXPECT_EQ(4096U, _info.getStackCommit());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, StackReserveAndCommit) {
|
TEST_F(WinLinkParserTest, StackReserveAndCommit) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-stack", "16384,8192", "a.obj", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/stack:16384,8192", "a.obj", nullptr));
|
||||||
EXPECT_EQ(16384U, _info.getStackReserve());
|
EXPECT_EQ(16384U, _info.getStackReserve());
|
||||||
EXPECT_EQ(8192U, _info.getStackCommit());
|
EXPECT_EQ(8192U, _info.getStackCommit());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, HeapReserve) {
|
TEST_F(WinLinkParserTest, HeapReserve) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-heap", "8192", "a.obj", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/heap:8192", "a.obj", nullptr));
|
||||||
EXPECT_EQ(8192U, _info.getHeapReserve());
|
EXPECT_EQ(8192U, _info.getHeapReserve());
|
||||||
EXPECT_EQ(4096U, _info.getHeapCommit());
|
EXPECT_EQ(4096U, _info.getHeapCommit());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, HeapReserveAndCommit) {
|
TEST_F(WinLinkParserTest, HeapReserveAndCommit) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-heap", "16384,8192", "a.obj", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/heap:16384,8192", "a.obj", nullptr));
|
||||||
EXPECT_EQ(16384U, _info.getHeapReserve());
|
EXPECT_EQ(16384U, _info.getHeapReserve());
|
||||||
EXPECT_EQ(8192U, _info.getHeapCommit());
|
EXPECT_EQ(8192U, _info.getHeapCommit());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, Force) {
|
TEST_F(WinLinkParserTest, Force) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-force", "a.obj", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/force", "a.obj", nullptr));
|
||||||
EXPECT_TRUE(_info.allowRemainingUndefines());
|
EXPECT_TRUE(_info.allowRemainingUndefines());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, NoNxCompat) {
|
TEST_F(WinLinkParserTest, NoNxCompat) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-nxcompat:no", "a.obj", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/nxcompat:no", "a.obj", nullptr));
|
||||||
EXPECT_FALSE(_info.isNxCompat());
|
EXPECT_FALSE(_info.isNxCompat());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, LargeAddressAware) {
|
TEST_F(WinLinkParserTest, LargeAddressAware) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-largeaddressaware", "a.obj", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/largeaddressaware", "a.obj", nullptr));
|
||||||
EXPECT_TRUE(_info.getLargeAddressAware());
|
EXPECT_TRUE(_info.getLargeAddressAware());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, NoLargeAddressAware) {
|
TEST_F(WinLinkParserTest, NoLargeAddressAware) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-largeaddressaware:no", "a.obj", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/largeaddressaware:no", "a.obj", nullptr));
|
||||||
EXPECT_FALSE(_info.getLargeAddressAware());
|
EXPECT_FALSE(_info.getLargeAddressAware());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, Fixed) {
|
TEST_F(WinLinkParserTest, Fixed) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-fixed", "a.out", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/fixed", "a.out", nullptr));
|
||||||
EXPECT_FALSE(_info.getBaseRelocationEnabled());
|
EXPECT_FALSE(_info.getBaseRelocationEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, NoFixed) {
|
TEST_F(WinLinkParserTest, NoFixed) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-fixed:no", "a.out", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/fixed:no", "a.out", nullptr));
|
||||||
EXPECT_TRUE(_info.getBaseRelocationEnabled());
|
EXPECT_TRUE(_info.getBaseRelocationEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, TerminalServerAware) {
|
TEST_F(WinLinkParserTest, TerminalServerAware) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-tsaware", "a.out", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/tsaware", "a.out", nullptr));
|
||||||
EXPECT_TRUE(_info.isTerminalServerAware());
|
EXPECT_TRUE(_info.isTerminalServerAware());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, NoTerminalServerAware) {
|
TEST_F(WinLinkParserTest, NoTerminalServerAware) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-tsaware:no", "a.out", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/tsaware:no", "a.out", nullptr));
|
||||||
EXPECT_FALSE(_info.isTerminalServerAware());
|
EXPECT_FALSE(_info.isTerminalServerAware());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WinLinkParserTest, Include) {
|
TEST_F(WinLinkParserTest, Include) {
|
||||||
EXPECT_FALSE(parse("link.exe", "-include", "foo", "a.out", nullptr));
|
EXPECT_FALSE(parse("link.exe", "/include:foo", "a.out", nullptr));
|
||||||
auto symbols = _info.initialUndefinedSymbols();
|
auto symbols = _info.initialUndefinedSymbols();
|
||||||
EXPECT_FALSE(symbols.empty());
|
EXPECT_FALSE(symbols.empty());
|
||||||
EXPECT_EQ("foo", symbols[0]);
|
EXPECT_EQ("foo", symbols[0]);
|
||||||
|
|
Loading…
Reference in New Issue