parent
2050b61451
commit
ea6c8e9c1f
|
@ -23,14 +23,14 @@ namespace {
|
|||
class DarwinLdParserTest
|
||||
: public ParserTest<DarwinLdDriver, MachOLinkingContext> {
|
||||
protected:
|
||||
const LinkingContext *linkingContext() override { return &_context; }
|
||||
const LinkingContext *linkingContext() override { return &_ctx; }
|
||||
};
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, Basic) {
|
||||
EXPECT_TRUE(parse("ld", "foo.o", "bar.o", "-arch", "i386", nullptr));
|
||||
EXPECT_FALSE(_context.allowRemainingUndefines());
|
||||
EXPECT_FALSE(_context.deadStrip());
|
||||
EXPECT_FALSE(_ctx.allowRemainingUndefines());
|
||||
EXPECT_FALSE(_ctx.deadStrip());
|
||||
EXPECT_EQ(2, inputFileCount());
|
||||
EXPECT_EQ("foo.o", inputFile(0));
|
||||
EXPECT_EQ("bar.o", inputFile(1));
|
||||
|
@ -38,143 +38,143 @@ TEST_F(DarwinLdParserTest, Basic) {
|
|||
|
||||
TEST_F(DarwinLdParserTest, Output) {
|
||||
EXPECT_TRUE(parse("ld", "-o", "my.out", "foo.o", "-arch", "i386", nullptr));
|
||||
EXPECT_EQ("my.out", _context.outputPath());
|
||||
EXPECT_EQ("my.out", _ctx.outputPath());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, Dylib) {
|
||||
EXPECT_TRUE(parse("ld", "-dylib", "foo.o", "-arch", "i386", nullptr));
|
||||
EXPECT_EQ(llvm::MachO::MH_DYLIB, _context.outputMachOType());
|
||||
EXPECT_EQ(llvm::MachO::MH_DYLIB, _ctx.outputMachOType());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, Relocatable) {
|
||||
EXPECT_TRUE(parse("ld", "-r", "foo.o", "-arch", "i386", nullptr));
|
||||
EXPECT_EQ(llvm::MachO::MH_OBJECT, _context.outputMachOType());
|
||||
EXPECT_EQ(llvm::MachO::MH_OBJECT, _ctx.outputMachOType());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, Bundle) {
|
||||
EXPECT_TRUE(parse("ld", "-bundle", "foo.o", "-arch", "i386", nullptr));
|
||||
EXPECT_EQ(llvm::MachO::MH_BUNDLE, _context.outputMachOType());
|
||||
EXPECT_EQ(llvm::MachO::MH_BUNDLE, _ctx.outputMachOType());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, Preload) {
|
||||
EXPECT_TRUE(parse("ld", "-preload", "foo.o", "-arch", "i386", nullptr));
|
||||
EXPECT_EQ(llvm::MachO::MH_PRELOAD, _context.outputMachOType());
|
||||
EXPECT_EQ(llvm::MachO::MH_PRELOAD, _ctx.outputMachOType());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, Static) {
|
||||
EXPECT_TRUE(parse("ld", "-static", "foo.o", "-arch", "i386", nullptr));
|
||||
EXPECT_EQ(llvm::MachO::MH_EXECUTE, _context.outputMachOType());
|
||||
EXPECT_EQ(llvm::MachO::MH_EXECUTE, _ctx.outputMachOType());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, Entry) {
|
||||
EXPECT_TRUE(parse("ld", "-e", "entryFunc", "foo.o", "-arch", "i386",nullptr));
|
||||
EXPECT_EQ("entryFunc", _context.entrySymbolName());
|
||||
EXPECT_EQ("entryFunc", _ctx.entrySymbolName());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, DeadStrip) {
|
||||
EXPECT_TRUE(parse("ld", "-arch", "x86_64", "-dead_strip", "foo.o", nullptr));
|
||||
EXPECT_TRUE(_context.deadStrip());
|
||||
EXPECT_TRUE(_ctx.deadStrip());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, DeadStripRootsExe) {
|
||||
EXPECT_TRUE(parse("ld", "-arch", "x86_64", "-dead_strip", "foo.o", nullptr));
|
||||
EXPECT_FALSE(_context.globalsAreDeadStripRoots());
|
||||
EXPECT_FALSE(_ctx.globalsAreDeadStripRoots());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, DeadStripRootsDylib) {
|
||||
EXPECT_TRUE(parse("ld", "-arch", "x86_64", "-dylib", "-dead_strip", "foo.o",
|
||||
nullptr));
|
||||
EXPECT_TRUE(_context.globalsAreDeadStripRoots());
|
||||
EXPECT_TRUE(_ctx.globalsAreDeadStripRoots());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, Arch) {
|
||||
EXPECT_TRUE(parse("ld", "-arch", "x86_64", "foo.o", nullptr));
|
||||
EXPECT_EQ(MachOLinkingContext::arch_x86_64, _context.arch());
|
||||
EXPECT_EQ((uint32_t)llvm::MachO::CPU_TYPE_X86_64, _context.getCPUType());
|
||||
EXPECT_EQ(llvm::MachO::CPU_SUBTYPE_X86_64_ALL, _context.getCPUSubType());
|
||||
EXPECT_EQ(MachOLinkingContext::arch_x86_64, _ctx.arch());
|
||||
EXPECT_EQ((uint32_t)llvm::MachO::CPU_TYPE_X86_64, _ctx.getCPUType());
|
||||
EXPECT_EQ(llvm::MachO::CPU_SUBTYPE_X86_64_ALL, _ctx.getCPUSubType());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, Arch_x86) {
|
||||
EXPECT_TRUE(parse("ld", "-arch", "i386", "foo.o", nullptr));
|
||||
EXPECT_EQ(MachOLinkingContext::arch_x86, _context.arch());
|
||||
EXPECT_EQ((uint32_t)llvm::MachO::CPU_TYPE_I386, _context.getCPUType());
|
||||
EXPECT_EQ(llvm::MachO::CPU_SUBTYPE_X86_ALL, _context.getCPUSubType());
|
||||
EXPECT_EQ(MachOLinkingContext::arch_x86, _ctx.arch());
|
||||
EXPECT_EQ((uint32_t)llvm::MachO::CPU_TYPE_I386, _ctx.getCPUType());
|
||||
EXPECT_EQ(llvm::MachO::CPU_SUBTYPE_X86_ALL, _ctx.getCPUSubType());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, Arch_armv6) {
|
||||
EXPECT_TRUE(parse("ld", "-arch", "armv6", "foo.o", nullptr));
|
||||
EXPECT_EQ(MachOLinkingContext::arch_armv6, _context.arch());
|
||||
EXPECT_EQ((uint32_t)llvm::MachO::CPU_TYPE_ARM, _context.getCPUType());
|
||||
EXPECT_EQ(llvm::MachO::CPU_SUBTYPE_ARM_V6, _context.getCPUSubType());
|
||||
EXPECT_EQ(MachOLinkingContext::arch_armv6, _ctx.arch());
|
||||
EXPECT_EQ((uint32_t)llvm::MachO::CPU_TYPE_ARM, _ctx.getCPUType());
|
||||
EXPECT_EQ(llvm::MachO::CPU_SUBTYPE_ARM_V6, _ctx.getCPUSubType());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, Arch_armv7) {
|
||||
EXPECT_TRUE(parse("ld", "-arch", "armv7", "foo.o", nullptr));
|
||||
EXPECT_EQ(MachOLinkingContext::arch_armv7, _context.arch());
|
||||
EXPECT_EQ((uint32_t)llvm::MachO::CPU_TYPE_ARM, _context.getCPUType());
|
||||
EXPECT_EQ(llvm::MachO::CPU_SUBTYPE_ARM_V7, _context.getCPUSubType());
|
||||
EXPECT_EQ(MachOLinkingContext::arch_armv7, _ctx.arch());
|
||||
EXPECT_EQ((uint32_t)llvm::MachO::CPU_TYPE_ARM, _ctx.getCPUType());
|
||||
EXPECT_EQ(llvm::MachO::CPU_SUBTYPE_ARM_V7, _ctx.getCPUSubType());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, Arch_armv7s) {
|
||||
EXPECT_TRUE(parse("ld", "-arch", "armv7s", "foo.o", nullptr));
|
||||
EXPECT_EQ(MachOLinkingContext::arch_armv7s, _context.arch());
|
||||
EXPECT_EQ((uint32_t)llvm::MachO::CPU_TYPE_ARM, _context.getCPUType());
|
||||
EXPECT_EQ(llvm::MachO::CPU_SUBTYPE_ARM_V7S, _context.getCPUSubType());
|
||||
EXPECT_EQ(MachOLinkingContext::arch_armv7s, _ctx.arch());
|
||||
EXPECT_EQ((uint32_t)llvm::MachO::CPU_TYPE_ARM, _ctx.getCPUType());
|
||||
EXPECT_EQ(llvm::MachO::CPU_SUBTYPE_ARM_V7S, _ctx.getCPUSubType());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, MinMacOSX10_7) {
|
||||
EXPECT_TRUE(parse("ld", "-macosx_version_min", "10.7", "foo.o",
|
||||
"-arch", "x86_64", nullptr));
|
||||
EXPECT_EQ(MachOLinkingContext::OS::macOSX, _context.os());
|
||||
EXPECT_TRUE(_context.minOS("10.7", ""));
|
||||
EXPECT_FALSE(_context.minOS("10.8", ""));
|
||||
EXPECT_EQ(MachOLinkingContext::OS::macOSX, _ctx.os());
|
||||
EXPECT_TRUE(_ctx.minOS("10.7", ""));
|
||||
EXPECT_FALSE(_ctx.minOS("10.8", ""));
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, MinMacOSX10_8) {
|
||||
EXPECT_TRUE(parse("ld", "-macosx_version_min", "10.8.3", "foo.o",
|
||||
"-arch", "x86_64", nullptr));
|
||||
EXPECT_EQ(MachOLinkingContext::OS::macOSX, _context.os());
|
||||
EXPECT_TRUE(_context.minOS("10.7", ""));
|
||||
EXPECT_TRUE(_context.minOS("10.8", ""));
|
||||
EXPECT_EQ(MachOLinkingContext::OS::macOSX, _ctx.os());
|
||||
EXPECT_TRUE(_ctx.minOS("10.7", ""));
|
||||
EXPECT_TRUE(_ctx.minOS("10.8", ""));
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, iOS5) {
|
||||
EXPECT_TRUE(parse("ld", "-ios_version_min", "5.0", "foo.o",
|
||||
"-arch", "armv7", nullptr));
|
||||
EXPECT_EQ(MachOLinkingContext::OS::iOS, _context.os());
|
||||
EXPECT_TRUE(_context.minOS("", "5.0"));
|
||||
EXPECT_FALSE(_context.minOS("", "6.0"));
|
||||
EXPECT_EQ(MachOLinkingContext::OS::iOS, _ctx.os());
|
||||
EXPECT_TRUE(_ctx.minOS("", "5.0"));
|
||||
EXPECT_FALSE(_ctx.minOS("", "6.0"));
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, iOS6) {
|
||||
EXPECT_TRUE(parse("ld", "-ios_version_min", "6.0", "foo.o", "-arch", "armv7",
|
||||
nullptr));
|
||||
EXPECT_EQ(MachOLinkingContext::OS::iOS, _context.os());
|
||||
EXPECT_TRUE(_context.minOS("", "5.0"));
|
||||
EXPECT_TRUE(_context.minOS("", "6.0"));
|
||||
EXPECT_EQ(MachOLinkingContext::OS::iOS, _ctx.os());
|
||||
EXPECT_TRUE(_ctx.minOS("", "5.0"));
|
||||
EXPECT_TRUE(_ctx.minOS("", "6.0"));
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, iOS_Simulator5) {
|
||||
EXPECT_TRUE(parse("ld", "-ios_simulator_version_min", "5.0", "a.o",
|
||||
"-arch", "i386", nullptr));
|
||||
EXPECT_EQ(MachOLinkingContext::OS::iOS_simulator, _context.os());
|
||||
EXPECT_TRUE(_context.minOS("", "5.0"));
|
||||
EXPECT_FALSE(_context.minOS("", "6.0"));
|
||||
EXPECT_EQ(MachOLinkingContext::OS::iOS_simulator, _ctx.os());
|
||||
EXPECT_TRUE(_ctx.minOS("", "5.0"));
|
||||
EXPECT_FALSE(_ctx.minOS("", "6.0"));
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, iOS_Simulator6) {
|
||||
EXPECT_TRUE(parse("ld", "-ios_simulator_version_min", "6.0", "a.o",
|
||||
"-arch", "i386", nullptr));
|
||||
EXPECT_EQ(MachOLinkingContext::OS::iOS_simulator, _context.os());
|
||||
EXPECT_TRUE(_context.minOS("", "5.0"));
|
||||
EXPECT_TRUE(_context.minOS("", "6.0"));
|
||||
EXPECT_EQ(MachOLinkingContext::OS::iOS_simulator, _ctx.os());
|
||||
EXPECT_TRUE(_ctx.minOS("", "5.0"));
|
||||
EXPECT_TRUE(_ctx.minOS("", "6.0"));
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, compatibilityVersion) {
|
||||
EXPECT_TRUE(
|
||||
parse("ld", "-dylib", "-compatibility_version", "1.2.3", "a.o",
|
||||
"-arch", "i386",nullptr));
|
||||
EXPECT_EQ(_context.compatibilityVersion(), 0x10203U);
|
||||
EXPECT_EQ(_ctx.compatibilityVersion(), 0x10203U);
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, compatibilityVersionInvalidType) {
|
||||
|
@ -191,7 +191,7 @@ TEST_F(DarwinLdParserTest, currentVersion) {
|
|||
EXPECT_TRUE(
|
||||
parse("ld", "-dylib", "-current_version", "1.2.3", "a.o", "-arch", "i386",
|
||||
nullptr));
|
||||
EXPECT_EQ(_context.currentVersion(), 0x10203U);
|
||||
EXPECT_EQ(_ctx.currentVersion(), 0x10203U);
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, currentVersionInvalidType) {
|
||||
|
@ -210,7 +210,7 @@ TEST_F(DarwinLdParserTest, bundleLoader) {
|
|||
EXPECT_TRUE(
|
||||
parse("ld", "-bundle", "-bundle_loader", "/bin/ls", "a.o",
|
||||
"-arch", "i386", nullptr));
|
||||
EXPECT_EQ(_context.bundleLoader(), "/bin/ls");
|
||||
EXPECT_EQ(_ctx.bundleLoader(), "/bin/ls");
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, bundleLoaderInvalidType) {
|
||||
|
@ -222,7 +222,7 @@ TEST_F(DarwinLdParserTest, deadStrippableDylib) {
|
|||
EXPECT_TRUE(
|
||||
parse("ld", "-dylib", "-mark_dead_strippable_dylib", "a.o",
|
||||
"-arch", "i386", nullptr));
|
||||
EXPECT_EQ(true, _context.deadStrippableDylib());
|
||||
EXPECT_EQ(true, _ctx.deadStrippableDylib());
|
||||
}
|
||||
|
||||
TEST_F(DarwinLdParserTest, deadStrippableDylibInvalidType) {
|
||||
|
@ -233,7 +233,7 @@ TEST_F(DarwinLdParserTest, deadStrippableDylibInvalidType) {
|
|||
TEST_F(DarwinLdParserTest, llvmOptions) {
|
||||
EXPECT_TRUE(parse("ld", "-mllvm", "-debug-only", "-mllvm", "foo", "a.o",
|
||||
"-arch", "i386", nullptr));
|
||||
const std::vector<const char *> &options = _context.llvmOptions();
|
||||
const std::vector<const char *> &options = _ctx.llvmOptions();
|
||||
EXPECT_EQ(options.size(), 2UL);
|
||||
EXPECT_EQ(strcmp(options[0],"-debug-only"), 0);
|
||||
EXPECT_EQ(strcmp(options[1],"foo"), 0);
|
||||
|
|
|
@ -51,10 +51,10 @@ protected:
|
|||
|
||||
// Call the parser.
|
||||
raw_string_ostream os(_errorMessage);
|
||||
return D::parse(vec.size(), &vec[0], _context, os);
|
||||
return D::parse(vec.size(), &vec[0], _ctx, os);
|
||||
}
|
||||
|
||||
T _context;
|
||||
T _ctx;
|
||||
std::string _errorMessage;
|
||||
};
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace {
|
|||
class GnuLdParserTest
|
||||
: public ParserTest<GnuLdDriver, std::unique_ptr<ELFLinkingContext>> {
|
||||
protected:
|
||||
const LinkingContext *linkingContext() override { return _context.get(); }
|
||||
const LinkingContext *linkingContext() override { return _ctx.get(); }
|
||||
};
|
||||
|
||||
class LinkerScriptTest : public testing::Test {
|
||||
|
@ -59,121 +59,121 @@ TEST_F(GnuLdParserTest, Empty) {
|
|||
|
||||
TEST_F(GnuLdParserTest, Output) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "-o", "foo", nullptr));
|
||||
EXPECT_EQ("foo", _context->outputPath());
|
||||
EXPECT_EQ("foo", _ctx->outputPath());
|
||||
}
|
||||
|
||||
TEST_F(GnuLdParserTest, OutputDefault) {
|
||||
EXPECT_TRUE(parse("ld", "abc.o", nullptr));
|
||||
EXPECT_EQ("a.out", _context->outputPath());
|
||||
EXPECT_EQ("a.out", _ctx->outputPath());
|
||||
}
|
||||
|
||||
// --noinhibit-exec
|
||||
|
||||
TEST_F(GnuLdParserTest, NoinhibitExec) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "--noinhibit-exec", nullptr));
|
||||
EXPECT_TRUE(_context->allowRemainingUndefines());
|
||||
EXPECT_TRUE(_ctx->allowRemainingUndefines());
|
||||
}
|
||||
|
||||
// --entry
|
||||
|
||||
TEST_F(GnuLdParserTest, Entry) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "--entry", "foo", nullptr));
|
||||
EXPECT_EQ("foo", _context->entrySymbolName());
|
||||
EXPECT_EQ("foo", _ctx->entrySymbolName());
|
||||
}
|
||||
|
||||
TEST_F(GnuLdParserTest, EntryShort) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "-e", "foo", nullptr));
|
||||
EXPECT_EQ("foo", _context->entrySymbolName());
|
||||
EXPECT_EQ("foo", _ctx->entrySymbolName());
|
||||
}
|
||||
|
||||
TEST_F(GnuLdParserTest, EntryJoined) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "--entry=foo", nullptr));
|
||||
EXPECT_EQ("foo", _context->entrySymbolName());
|
||||
EXPECT_EQ("foo", _ctx->entrySymbolName());
|
||||
}
|
||||
|
||||
// --export-dynamic
|
||||
|
||||
TEST_F(GnuLdParserTest, ExportDynamic) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "--export-dynamic", nullptr));
|
||||
EXPECT_TRUE(_context->shouldExportDynamic());
|
||||
EXPECT_TRUE(_ctx->shouldExportDynamic());
|
||||
}
|
||||
|
||||
TEST_F(GnuLdParserTest, NoExportDynamic) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "--no-export-dynamic", nullptr));
|
||||
EXPECT_FALSE(_context->shouldExportDynamic());
|
||||
EXPECT_FALSE(_ctx->shouldExportDynamic());
|
||||
}
|
||||
|
||||
// --init
|
||||
|
||||
TEST_F(GnuLdParserTest, Init) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "-init", "foo", "-init", "bar", nullptr));
|
||||
EXPECT_EQ("bar", _context->initFunction());
|
||||
EXPECT_EQ("bar", _ctx->initFunction());
|
||||
}
|
||||
|
||||
TEST_F(GnuLdParserTest, InitJoined) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "-init=foo", nullptr));
|
||||
EXPECT_EQ("foo", _context->initFunction());
|
||||
EXPECT_EQ("foo", _ctx->initFunction());
|
||||
}
|
||||
|
||||
// --soname
|
||||
|
||||
TEST_F(GnuLdParserTest, SOName) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "--soname=foo", nullptr));
|
||||
EXPECT_EQ("foo", _context->sharedObjectName());
|
||||
EXPECT_EQ("foo", _ctx->sharedObjectName());
|
||||
}
|
||||
|
||||
TEST_F(GnuLdParserTest, SONameSingleDash) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "-soname=foo", nullptr));
|
||||
EXPECT_EQ("foo", _context->sharedObjectName());
|
||||
EXPECT_EQ("foo", _ctx->sharedObjectName());
|
||||
}
|
||||
|
||||
TEST_F(GnuLdParserTest, SONameH) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "-h", "foo", nullptr));
|
||||
EXPECT_EQ("foo", _context->sharedObjectName());
|
||||
EXPECT_EQ("foo", _ctx->sharedObjectName());
|
||||
}
|
||||
|
||||
// -rpath
|
||||
|
||||
TEST_F(GnuLdParserTest, Rpath) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "-rpath", "foo:bar", nullptr));
|
||||
EXPECT_EQ(2, _context->getRpathList().size());
|
||||
EXPECT_EQ("foo", _context->getRpathList()[0]);
|
||||
EXPECT_EQ("bar", _context->getRpathList()[1]);
|
||||
EXPECT_EQ(2, _ctx->getRpathList().size());
|
||||
EXPECT_EQ("foo", _ctx->getRpathList()[0]);
|
||||
EXPECT_EQ("bar", _ctx->getRpathList()[1]);
|
||||
}
|
||||
|
||||
TEST_F(GnuLdParserTest, RpathEq) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "-rpath=foo", nullptr));
|
||||
EXPECT_EQ(1, _context->getRpathList().size());
|
||||
EXPECT_EQ("foo", _context->getRpathList()[0]);
|
||||
EXPECT_EQ(1, _ctx->getRpathList().size());
|
||||
EXPECT_EQ("foo", _ctx->getRpathList()[0]);
|
||||
}
|
||||
|
||||
// --defsym
|
||||
|
||||
TEST_F(GnuLdParserTest, DefsymDecimal) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "--defsym=sym=1000", nullptr));
|
||||
assert(_context.get());
|
||||
auto map = _context->getAbsoluteSymbols();
|
||||
assert(_ctx.get());
|
||||
auto map = _ctx->getAbsoluteSymbols();
|
||||
EXPECT_EQ((size_t)1, map.size());
|
||||
EXPECT_EQ((uint64_t)1000, map["sym"]);
|
||||
}
|
||||
|
||||
TEST_F(GnuLdParserTest, DefsymHexadecimal) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "--defsym=sym=0x1000", nullptr));
|
||||
auto map = _context->getAbsoluteSymbols();
|
||||
auto map = _ctx->getAbsoluteSymbols();
|
||||
EXPECT_EQ((size_t)1, map.size());
|
||||
EXPECT_EQ((uint64_t)0x1000, map["sym"]);
|
||||
}
|
||||
|
||||
TEST_F(GnuLdParserTest, DefsymAlias) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "--defsym=sym=abc", nullptr));
|
||||
auto map = _context->getAliases();
|
||||
auto map = _ctx->getAliases();
|
||||
EXPECT_EQ((size_t)1, map.size());
|
||||
EXPECT_EQ("abc", map["sym"]);
|
||||
}
|
||||
|
||||
TEST_F(GnuLdParserTest, DefsymOctal) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "--defsym=sym=0777", nullptr));
|
||||
auto map = _context->getAbsoluteSymbols();
|
||||
auto map = _ctx->getAbsoluteSymbols();
|
||||
EXPECT_EQ((size_t)1, map.size());
|
||||
EXPECT_EQ((uint64_t)0777, map["sym"]);
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ TEST_F(GnuLdParserTest, DefsymMisssingValue) {
|
|||
TEST_F(GnuLdParserTest, AsNeeded) {
|
||||
EXPECT_TRUE(parse("ld", "a.o", "--as-needed", "b.o", "c.o",
|
||||
"--no-as-needed", "d.o", nullptr));
|
||||
std::vector<std::unique_ptr<Node>> &nodes = _context->getNodes();
|
||||
std::vector<std::unique_ptr<Node>> &nodes = _ctx->getNodes();
|
||||
EXPECT_EQ((size_t)4, nodes.size());
|
||||
EXPECT_FALSE(cast<FileNode>(nodes[0].get())->asNeeded());
|
||||
EXPECT_TRUE(cast<FileNode>(nodes[1].get())->asNeeded());
|
||||
|
|
|
@ -26,57 +26,57 @@ namespace {
|
|||
class WinLinkParserTest
|
||||
: public ParserTest<WinLinkDriver, PECOFFLinkingContext> {
|
||||
protected:
|
||||
const LinkingContext *linkingContext() override { return &_context; }
|
||||
const LinkingContext *linkingContext() override { return &_ctx; }
|
||||
};
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Basic) {
|
||||
EXPECT_TRUE(parse("link.exe", "/subsystem:console", "/out:a.exe",
|
||||
"-entry:start", "a.obj", "b.obj", "c.obj", nullptr));
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _context.getSubsystem());
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_I386, _context.getMachineType());
|
||||
EXPECT_EQ("a.exe", _context.outputPath());
|
||||
EXPECT_EQ("start", _context.getEntrySymbolName());
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _ctx.getSubsystem());
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_I386, _ctx.getMachineType());
|
||||
EXPECT_EQ("a.exe", _ctx.outputPath());
|
||||
EXPECT_EQ("start", _ctx.getEntrySymbolName());
|
||||
EXPECT_EQ(4, inputFileCount());
|
||||
EXPECT_EQ("a.obj", inputFile(0));
|
||||
EXPECT_EQ("b.obj", inputFile(1));
|
||||
EXPECT_EQ("c.obj", inputFile(2));
|
||||
EXPECT_TRUE(_context.getInputSearchPaths().empty());
|
||||
EXPECT_TRUE(_ctx.getInputSearchPaths().empty());
|
||||
|
||||
// Unspecified flags will have default values.
|
||||
EXPECT_FALSE(_context.isDll());
|
||||
EXPECT_EQ(6, _context.getMinOSVersion().majorVersion);
|
||||
EXPECT_EQ(0, _context.getMinOSVersion().minorVersion);
|
||||
EXPECT_EQ(0x400000U, _context.getBaseAddress());
|
||||
EXPECT_EQ(1024 * 1024U, _context.getStackReserve());
|
||||
EXPECT_EQ(4096U, _context.getStackCommit());
|
||||
EXPECT_EQ(4096U, _context.getSectionDefaultAlignment());
|
||||
EXPECT_FALSE(_context.allowRemainingUndefines());
|
||||
EXPECT_TRUE(_context.isNxCompat());
|
||||
EXPECT_FALSE(_context.getLargeAddressAware());
|
||||
EXPECT_TRUE(_context.getAllowBind());
|
||||
EXPECT_TRUE(_context.getAllowIsolation());
|
||||
EXPECT_FALSE(_context.getSwapRunFromCD());
|
||||
EXPECT_FALSE(_context.getSwapRunFromNet());
|
||||
EXPECT_TRUE(_context.getBaseRelocationEnabled());
|
||||
EXPECT_TRUE(_context.isTerminalServerAware());
|
||||
EXPECT_TRUE(_context.getDynamicBaseEnabled());
|
||||
EXPECT_TRUE(_context.getCreateManifest());
|
||||
EXPECT_EQ("", _context.getManifestDependency());
|
||||
EXPECT_FALSE(_context.getEmbedManifest());
|
||||
EXPECT_EQ(1, _context.getManifestId());
|
||||
EXPECT_TRUE(_context.getManifestUAC());
|
||||
EXPECT_EQ("'asInvoker'", _context.getManifestLevel());
|
||||
EXPECT_EQ("'false'", _context.getManifestUiAccess());
|
||||
EXPECT_TRUE(_context.deadStrip());
|
||||
EXPECT_FALSE(_context.logInputFiles());
|
||||
EXPECT_FALSE(_ctx.isDll());
|
||||
EXPECT_EQ(6, _ctx.getMinOSVersion().majorVersion);
|
||||
EXPECT_EQ(0, _ctx.getMinOSVersion().minorVersion);
|
||||
EXPECT_EQ(0x400000U, _ctx.getBaseAddress());
|
||||
EXPECT_EQ(1024 * 1024U, _ctx.getStackReserve());
|
||||
EXPECT_EQ(4096U, _ctx.getStackCommit());
|
||||
EXPECT_EQ(4096U, _ctx.getSectionDefaultAlignment());
|
||||
EXPECT_FALSE(_ctx.allowRemainingUndefines());
|
||||
EXPECT_TRUE(_ctx.isNxCompat());
|
||||
EXPECT_FALSE(_ctx.getLargeAddressAware());
|
||||
EXPECT_TRUE(_ctx.getAllowBind());
|
||||
EXPECT_TRUE(_ctx.getAllowIsolation());
|
||||
EXPECT_FALSE(_ctx.getSwapRunFromCD());
|
||||
EXPECT_FALSE(_ctx.getSwapRunFromNet());
|
||||
EXPECT_TRUE(_ctx.getBaseRelocationEnabled());
|
||||
EXPECT_TRUE(_ctx.isTerminalServerAware());
|
||||
EXPECT_TRUE(_ctx.getDynamicBaseEnabled());
|
||||
EXPECT_TRUE(_ctx.getCreateManifest());
|
||||
EXPECT_EQ("", _ctx.getManifestDependency());
|
||||
EXPECT_FALSE(_ctx.getEmbedManifest());
|
||||
EXPECT_EQ(1, _ctx.getManifestId());
|
||||
EXPECT_TRUE(_ctx.getManifestUAC());
|
||||
EXPECT_EQ("'asInvoker'", _ctx.getManifestLevel());
|
||||
EXPECT_EQ("'false'", _ctx.getManifestUiAccess());
|
||||
EXPECT_TRUE(_ctx.deadStrip());
|
||||
EXPECT_FALSE(_ctx.logInputFiles());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, StartsWithHyphen) {
|
||||
EXPECT_TRUE(
|
||||
parse("link.exe", "-subsystem:console", "-out:a.exe", "a.obj", nullptr));
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _context.getSubsystem());
|
||||
EXPECT_EQ("a.exe", _context.outputPath());
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _ctx.getSubsystem());
|
||||
EXPECT_EQ("a.exe", _ctx.outputPath());
|
||||
EXPECT_EQ(2, inputFileCount());
|
||||
EXPECT_EQ("a.obj", inputFile(0));
|
||||
}
|
||||
|
@ -84,15 +84,15 @@ TEST_F(WinLinkParserTest, StartsWithHyphen) {
|
|||
TEST_F(WinLinkParserTest, UppercaseOption) {
|
||||
EXPECT_TRUE(
|
||||
parse("link.exe", "/SUBSYSTEM:CONSOLE", "/OUT:a.exe", "a.obj", nullptr));
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _context.getSubsystem());
|
||||
EXPECT_EQ("a.exe", _context.outputPath());
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _ctx.getSubsystem());
|
||||
EXPECT_EQ("a.exe", _ctx.outputPath());
|
||||
EXPECT_EQ(2, inputFileCount());
|
||||
EXPECT_EQ("a.obj", inputFile(0));
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Mllvm) {
|
||||
EXPECT_TRUE(parse("link.exe", "/mllvm:-debug", "a.obj", nullptr));
|
||||
const std::vector<const char *> &options = _context.llvmOptions();
|
||||
const std::vector<const char *> &options = _ctx.llvmOptions();
|
||||
EXPECT_EQ(1U, options.size());
|
||||
EXPECT_STREQ("-debug", options[0]);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ TEST_F(WinLinkParserTest, NoInputFiles) {
|
|||
|
||||
TEST_F(WinLinkParserTest, NoFileExtension) {
|
||||
EXPECT_TRUE(parse("link.exe", "foo", "bar", nullptr));
|
||||
EXPECT_EQ("foo.exe", _context.outputPath());
|
||||
EXPECT_EQ("foo.exe", _ctx.outputPath());
|
||||
EXPECT_EQ(3, inputFileCount());
|
||||
EXPECT_EQ("foo.obj", inputFile(0));
|
||||
EXPECT_EQ("bar.obj", inputFile(1));
|
||||
|
@ -116,7 +116,7 @@ TEST_F(WinLinkParserTest, NoFileExtension) {
|
|||
|
||||
TEST_F(WinLinkParserTest, NonStandardFileExtension) {
|
||||
EXPECT_TRUE(parse("link.exe", "foo.o", nullptr));
|
||||
EXPECT_EQ("foo.exe", _context.outputPath());
|
||||
EXPECT_EQ("foo.exe", _ctx.outputPath());
|
||||
EXPECT_EQ(2, inputFileCount());
|
||||
EXPECT_EQ("foo.o", inputFile(0));
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ TEST_F(WinLinkParserTest, NonStandardFileExtension) {
|
|||
TEST_F(WinLinkParserTest, Libpath) {
|
||||
EXPECT_TRUE(
|
||||
parse("link.exe", "/libpath:dir1", "/libpath:dir2", "a.obj", nullptr));
|
||||
const std::vector<StringRef> &paths = _context.getInputSearchPaths();
|
||||
const std::vector<StringRef> &paths = _ctx.getInputSearchPaths();
|
||||
EXPECT_EQ(2U, paths.size());
|
||||
EXPECT_EQ("dir1", paths[0]);
|
||||
EXPECT_EQ("dir2", paths[1]);
|
||||
|
@ -150,14 +150,14 @@ TEST_F(WinLinkParserTest, InputOrder) {
|
|||
|
||||
TEST_F(WinLinkParserTest, AlternateName) {
|
||||
EXPECT_TRUE(parse("link.exe", "/alternatename:sym1=sym2", "a.out", nullptr));
|
||||
EXPECT_EQ("sym1", _context.getAlternateName("sym2"));
|
||||
EXPECT_EQ("", _context.getAlternateName("foo"));
|
||||
EXPECT_EQ("sym1", _ctx.getAlternateName("sym2"));
|
||||
EXPECT_EQ("", _ctx.getAlternateName("foo"));
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Export) {
|
||||
EXPECT_TRUE(parse("link.exe", "/export:foo", "a.out", nullptr));
|
||||
const std::vector<PECOFFLinkingContext::ExportDesc> &exports =
|
||||
_context.getDllExports();
|
||||
_ctx.getDllExports();
|
||||
EXPECT_EQ(1U, exports.size());
|
||||
EXPECT_EQ("_foo", exports[0].name);
|
||||
EXPECT_EQ(-1, exports[0].ordinal);
|
||||
|
@ -169,7 +169,7 @@ TEST_F(WinLinkParserTest, ExportWithOptions) {
|
|||
EXPECT_TRUE(parse("link.exe", "/export:foo,@8,noname,data",
|
||||
"/export:bar,@10,data", "a.out", nullptr));
|
||||
const std::vector<PECOFFLinkingContext::ExportDesc> &exports =
|
||||
_context.getDllExports();
|
||||
_ctx.getDllExports();
|
||||
EXPECT_EQ(2U, exports.size());
|
||||
EXPECT_EQ("_foo", exports[0].name);
|
||||
EXPECT_EQ(8, exports[0].ordinal);
|
||||
|
@ -185,7 +185,7 @@ TEST_F(WinLinkParserTest, ExportDuplicateExports) {
|
|||
EXPECT_TRUE(
|
||||
parse("link.exe", "/export:foo", "/export:foo,@2", "a.out", nullptr));
|
||||
const std::vector<PECOFFLinkingContext::ExportDesc> &exports =
|
||||
_context.getDllExports();
|
||||
_ctx.getDllExports();
|
||||
EXPECT_EQ(1U, exports.size());
|
||||
EXPECT_EQ("_foo", exports[0].name);
|
||||
EXPECT_EQ(-1, exports[0].ordinal);
|
||||
|
@ -206,17 +206,17 @@ TEST_F(WinLinkParserTest, ExportInvalid2) {
|
|||
|
||||
TEST_F(WinLinkParserTest, MachineX86) {
|
||||
EXPECT_TRUE(parse("link.exe", "/machine:x86", "a.obj", nullptr));
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_I386, _context.getMachineType());
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_I386, _ctx.getMachineType());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, MachineX64) {
|
||||
EXPECT_TRUE(parse("link.exe", "/machine:x64", "a.obj", nullptr));
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_AMD64, _context.getMachineType());
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_AMD64, _ctx.getMachineType());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, MachineArm) {
|
||||
EXPECT_TRUE(parse("link.exe", "/machine:arm", "a.obj", nullptr));
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_ARMNT, _context.getMachineType());
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_ARMNT, _ctx.getMachineType());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, MachineUnknown) {
|
||||
|
@ -226,33 +226,33 @@ TEST_F(WinLinkParserTest, MachineUnknown) {
|
|||
|
||||
TEST_F(WinLinkParserTest, MajorImageVersion) {
|
||||
EXPECT_TRUE(parse("link.exe", "/version:7", "foo.o", nullptr));
|
||||
EXPECT_EQ(7, _context.getImageVersion().majorVersion);
|
||||
EXPECT_EQ(0, _context.getImageVersion().minorVersion);
|
||||
EXPECT_EQ(7, _ctx.getImageVersion().majorVersion);
|
||||
EXPECT_EQ(0, _ctx.getImageVersion().minorVersion);
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, MajorMinorImageVersion) {
|
||||
EXPECT_TRUE(parse("link.exe", "/version:72.35", "foo.o", nullptr));
|
||||
EXPECT_EQ(72, _context.getImageVersion().majorVersion);
|
||||
EXPECT_EQ(35, _context.getImageVersion().minorVersion);
|
||||
EXPECT_EQ(72, _ctx.getImageVersion().majorVersion);
|
||||
EXPECT_EQ(35, _ctx.getImageVersion().minorVersion);
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, MinMajorOSVersion) {
|
||||
EXPECT_TRUE(parse("link.exe", "/subsystem:windows,3", "foo.o", nullptr));
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI, _context.getSubsystem());
|
||||
EXPECT_EQ(3, _context.getMinOSVersion().majorVersion);
|
||||
EXPECT_EQ(0, _context.getMinOSVersion().minorVersion);
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI, _ctx.getSubsystem());
|
||||
EXPECT_EQ(3, _ctx.getMinOSVersion().majorVersion);
|
||||
EXPECT_EQ(0, _ctx.getMinOSVersion().minorVersion);
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, MinMajorMinorOSVersion) {
|
||||
EXPECT_TRUE(parse("link.exe", "/subsystem:windows,3.1", "foo.o", nullptr));
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI, _context.getSubsystem());
|
||||
EXPECT_EQ(3, _context.getMinOSVersion().majorVersion);
|
||||
EXPECT_EQ(1, _context.getMinOSVersion().minorVersion);
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI, _ctx.getSubsystem());
|
||||
EXPECT_EQ(3, _ctx.getMinOSVersion().majorVersion);
|
||||
EXPECT_EQ(1, _ctx.getMinOSVersion().minorVersion);
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Base) {
|
||||
EXPECT_TRUE(parse("link.exe", "/base:8388608", "a.obj", nullptr));
|
||||
EXPECT_EQ(0x800000U, _context.getBaseAddress());
|
||||
EXPECT_EQ(0x800000U, _ctx.getBaseAddress());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, InvalidBase) {
|
||||
|
@ -263,14 +263,14 @@ TEST_F(WinLinkParserTest, InvalidBase) {
|
|||
|
||||
TEST_F(WinLinkParserTest, StackReserve) {
|
||||
EXPECT_TRUE(parse("link.exe", "/stack:8192", "a.obj", nullptr));
|
||||
EXPECT_EQ(8192U, _context.getStackReserve());
|
||||
EXPECT_EQ(4096U, _context.getStackCommit());
|
||||
EXPECT_EQ(8192U, _ctx.getStackReserve());
|
||||
EXPECT_EQ(4096U, _ctx.getStackCommit());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, StackReserveAndCommit) {
|
||||
EXPECT_TRUE(parse("link.exe", "/stack:16384,8192", "a.obj", nullptr));
|
||||
EXPECT_EQ(16384U, _context.getStackReserve());
|
||||
EXPECT_EQ(8192U, _context.getStackCommit());
|
||||
EXPECT_EQ(16384U, _ctx.getStackReserve());
|
||||
EXPECT_EQ(8192U, _ctx.getStackCommit());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, InvalidStackSize) {
|
||||
|
@ -280,14 +280,14 @@ TEST_F(WinLinkParserTest, InvalidStackSize) {
|
|||
|
||||
TEST_F(WinLinkParserTest, HeapReserve) {
|
||||
EXPECT_TRUE(parse("link.exe", "/heap:8192", "a.obj", nullptr));
|
||||
EXPECT_EQ(8192U, _context.getHeapReserve());
|
||||
EXPECT_EQ(4096U, _context.getHeapCommit());
|
||||
EXPECT_EQ(8192U, _ctx.getHeapReserve());
|
||||
EXPECT_EQ(4096U, _ctx.getHeapCommit());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, HeapReserveAndCommit) {
|
||||
EXPECT_TRUE(parse("link.exe", "/heap:16384,8192", "a.obj", nullptr));
|
||||
EXPECT_EQ(16384U, _context.getHeapReserve());
|
||||
EXPECT_EQ(8192U, _context.getHeapCommit());
|
||||
EXPECT_EQ(16384U, _ctx.getHeapReserve());
|
||||
EXPECT_EQ(8192U, _ctx.getHeapCommit());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, InvalidHeapSize) {
|
||||
|
@ -297,7 +297,7 @@ TEST_F(WinLinkParserTest, InvalidHeapSize) {
|
|||
|
||||
TEST_F(WinLinkParserTest, SectionAlignment) {
|
||||
EXPECT_TRUE(parse("link.exe", "/align:8192", "a.obj", nullptr));
|
||||
EXPECT_EQ(8192U, _context.getSectionDefaultAlignment());
|
||||
EXPECT_EQ(8192U, _ctx.getSectionDefaultAlignment());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, InvalidAlignment) {
|
||||
|
@ -308,7 +308,7 @@ TEST_F(WinLinkParserTest, InvalidAlignment) {
|
|||
|
||||
TEST_F(WinLinkParserTest, Include) {
|
||||
EXPECT_TRUE(parse("link.exe", "/include:foo", "a.out", nullptr));
|
||||
auto symbols = _context.initialUndefinedSymbols();
|
||||
auto symbols = _ctx.initialUndefinedSymbols();
|
||||
EXPECT_FALSE(symbols.empty());
|
||||
EXPECT_EQ("foo", symbols[0]);
|
||||
}
|
||||
|
@ -316,9 +316,9 @@ TEST_F(WinLinkParserTest, Include) {
|
|||
TEST_F(WinLinkParserTest, Merge) {
|
||||
EXPECT_TRUE(parse("link.exe", "/merge:.foo=.bar", "/merge:.bar=.baz",
|
||||
"a.out", nullptr));
|
||||
EXPECT_EQ(".baz", _context.getOutputSectionName(".foo"));
|
||||
EXPECT_EQ(".baz", _context.getOutputSectionName(".bar"));
|
||||
EXPECT_EQ(".abc", _context.getOutputSectionName(".abc"));
|
||||
EXPECT_EQ(".baz", _ctx.getOutputSectionName(".foo"));
|
||||
EXPECT_EQ(".baz", _ctx.getOutputSectionName(".bar"));
|
||||
EXPECT_EQ(".abc", _ctx.getOutputSectionName(".abc"));
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Merge_Circular) {
|
||||
|
@ -328,12 +328,12 @@ TEST_F(WinLinkParserTest, Merge_Circular) {
|
|||
|
||||
TEST_F(WinLinkParserTest, Implib) {
|
||||
EXPECT_TRUE(parse("link.exe", "/implib:foo.dll.lib", "a.out", nullptr));
|
||||
EXPECT_EQ("foo.dll.lib", _context.getOutputImportLibraryPath());
|
||||
EXPECT_EQ("foo.dll.lib", _ctx.getOutputImportLibraryPath());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, ImplibDefault) {
|
||||
EXPECT_TRUE(parse("link.exe", "/out:foobar.dll", "a.out", nullptr));
|
||||
EXPECT_EQ("foobar.lib", _context.getOutputImportLibraryPath());
|
||||
EXPECT_EQ("foobar.lib", _ctx.getOutputImportLibraryPath());
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -352,7 +352,7 @@ const uint32_t write = llvm::COFF::IMAGE_SCN_MEM_WRITE;
|
|||
#define TEST_SECTION(testname, arg, expect) \
|
||||
TEST_F(WinLinkParserTest, testname) { \
|
||||
EXPECT_TRUE(parse("link.exe", "/section:.text," arg, "a.obj", nullptr)); \
|
||||
EXPECT_EQ(expect, _context.getSectionAttributes(".text", execute | read)); \
|
||||
EXPECT_EQ(expect, _ctx.getSectionAttributes(".text", execute | read)); \
|
||||
}
|
||||
|
||||
TEST_SECTION(SectionD, "d", execute | read | discardable)
|
||||
|
@ -368,12 +368,12 @@ TEST_SECTION(SectionW, "w", write)
|
|||
TEST_F(WinLinkParserTest, Section) {
|
||||
EXPECT_TRUE(parse("link.exe", "/section:.text,dekprsw",
|
||||
"/section:.text,!dekprsw", "a.obj", nullptr));
|
||||
EXPECT_EQ(0U, _context.getSectionAttributes(".text", execute | read));
|
||||
EXPECT_EQ(0U, _ctx.getSectionAttributes(".text", execute | read));
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, SectionNegate) {
|
||||
EXPECT_TRUE(parse("link.exe", "/section:.text,!e", "a.obj", nullptr));
|
||||
EXPECT_EQ(read, _context.getSectionAttributes(".text", execute | read));
|
||||
EXPECT_EQ(read, _ctx.getSectionAttributes(".text", execute | read));
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, SectionMultiple) {
|
||||
|
@ -381,7 +381,7 @@ TEST_F(WinLinkParserTest, SectionMultiple) {
|
|||
"/section:.foo,!d", "a.obj", nullptr));
|
||||
uint32_t flags = execute | read | not_paged | discardable;
|
||||
uint32_t expected = execute | read | write | not_paged;
|
||||
EXPECT_EQ(expected, _context.getSectionAttributes(".foo", flags));
|
||||
EXPECT_EQ(expected, _ctx.getSectionAttributes(".foo", flags));
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
@ -447,9 +447,9 @@ TEST_F(WinLinkParserTest, DisallowLib) {
|
|||
|
||||
TEST_F(WinLinkParserTest, NoEntry) {
|
||||
EXPECT_TRUE(parse("link.exe", "/noentry", "/dll", "a.obj", nullptr));
|
||||
EXPECT_TRUE(_context.isDll());
|
||||
EXPECT_EQ(0x10000000U, _context.getBaseAddress());
|
||||
EXPECT_EQ("", _context.entrySymbolName());
|
||||
EXPECT_TRUE(_ctx.isDll());
|
||||
EXPECT_EQ(0x10000000U, _ctx.getBaseAddress());
|
||||
EXPECT_EQ("", _ctx.entrySymbolName());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, NoEntryError) {
|
||||
|
@ -465,9 +465,9 @@ TEST_F(WinLinkParserTest, NoEntryError) {
|
|||
TEST_F(WinLinkParserTest, DelayLoad) {
|
||||
EXPECT_TRUE(parse("link.exe", "/delayload:abc.dll", "/delayload:def.dll",
|
||||
"a.obj", nullptr));
|
||||
EXPECT_TRUE(_context.isDelayLoadDLL("abc.dll"));
|
||||
EXPECT_TRUE(_context.isDelayLoadDLL("DEF.DLL"));
|
||||
EXPECT_FALSE(_context.isDelayLoadDLL("xyz.dll"));
|
||||
EXPECT_TRUE(_ctx.isDelayLoadDLL("abc.dll"));
|
||||
EXPECT_TRUE(_ctx.isDelayLoadDLL("DEF.DLL"));
|
||||
EXPECT_FALSE(_ctx.isDelayLoadDLL("xyz.dll"));
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -476,14 +476,14 @@ TEST_F(WinLinkParserTest, DelayLoad) {
|
|||
|
||||
TEST_F(WinLinkParserTest, SafeSEH) {
|
||||
EXPECT_TRUE(parse("link.exe", "/safeseh", "a.obj", nullptr));
|
||||
EXPECT_TRUE(_context.requireSEH());
|
||||
EXPECT_FALSE(_context.noSEH());
|
||||
EXPECT_TRUE(_ctx.requireSEH());
|
||||
EXPECT_FALSE(_ctx.noSEH());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, NoSafeSEH) {
|
||||
EXPECT_TRUE(parse("link.exe", "/safeseh:no", "a.obj", nullptr));
|
||||
EXPECT_FALSE(_context.requireSEH());
|
||||
EXPECT_TRUE(_context.noSEH());
|
||||
EXPECT_FALSE(_ctx.requireSEH());
|
||||
EXPECT_TRUE(_ctx.noSEH());
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -492,101 +492,101 @@ TEST_F(WinLinkParserTest, NoSafeSEH) {
|
|||
|
||||
TEST_F(WinLinkParserTest, Force) {
|
||||
EXPECT_TRUE(parse("link.exe", "/force", "a.obj", nullptr));
|
||||
EXPECT_TRUE(_context.allowRemainingUndefines());
|
||||
EXPECT_TRUE(_ctx.allowRemainingUndefines());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, ForceUnresolved) {
|
||||
EXPECT_TRUE(parse("link.exe", "/force:unresolved", "a.obj", nullptr));
|
||||
EXPECT_TRUE(_context.allowRemainingUndefines());
|
||||
EXPECT_TRUE(_ctx.allowRemainingUndefines());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, NoNxCompat) {
|
||||
EXPECT_TRUE(parse("link.exe", "/nxcompat:no", "a.obj", nullptr));
|
||||
EXPECT_FALSE(_context.isNxCompat());
|
||||
EXPECT_FALSE(_ctx.isNxCompat());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, LargeAddressAware) {
|
||||
EXPECT_TRUE(parse("link.exe", "/largeaddressaware", "a.obj", nullptr));
|
||||
EXPECT_TRUE(_context.getLargeAddressAware());
|
||||
EXPECT_TRUE(_ctx.getLargeAddressAware());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, NoLargeAddressAware) {
|
||||
EXPECT_TRUE(parse("link.exe", "/largeaddressaware:no", "a.obj", nullptr));
|
||||
EXPECT_FALSE(_context.getLargeAddressAware());
|
||||
EXPECT_FALSE(_ctx.getLargeAddressAware());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, AllowBind) {
|
||||
EXPECT_TRUE(parse("link.exe", "/allowbind", "a.obj", nullptr));
|
||||
EXPECT_TRUE(_context.getAllowBind());
|
||||
EXPECT_TRUE(_ctx.getAllowBind());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, NoAllowBind) {
|
||||
EXPECT_TRUE(parse("link.exe", "/allowbind:no", "a.obj", nullptr));
|
||||
EXPECT_FALSE(_context.getAllowBind());
|
||||
EXPECT_FALSE(_ctx.getAllowBind());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, AllowIsolation) {
|
||||
EXPECT_TRUE(parse("link.exe", "/allowisolation", "a.obj", nullptr));
|
||||
EXPECT_TRUE(_context.getAllowIsolation());
|
||||
EXPECT_TRUE(_ctx.getAllowIsolation());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, NoAllowIsolation) {
|
||||
EXPECT_TRUE(parse("link.exe", "/allowisolation:no", "a.obj", nullptr));
|
||||
EXPECT_FALSE(_context.getAllowIsolation());
|
||||
EXPECT_FALSE(_ctx.getAllowIsolation());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, SwapRunFromCD) {
|
||||
EXPECT_TRUE(parse("link.exe", "/swaprun:cd", "a.obj", nullptr));
|
||||
EXPECT_TRUE(_context.getSwapRunFromCD());
|
||||
EXPECT_TRUE(_ctx.getSwapRunFromCD());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, SwapRunFromNet) {
|
||||
EXPECT_TRUE(parse("link.exe", "/swaprun:net", "a.obj", nullptr));
|
||||
EXPECT_TRUE(_context.getSwapRunFromNet());
|
||||
EXPECT_TRUE(_ctx.getSwapRunFromNet());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Debug) {
|
||||
EXPECT_TRUE(parse("link.exe", "/debug", "a.obj", nullptr));
|
||||
EXPECT_TRUE(_context.deadStrip());
|
||||
EXPECT_TRUE(_context.getDebug());
|
||||
EXPECT_EQ("a.pdb", _context.getPDBFilePath());
|
||||
EXPECT_TRUE(_ctx.deadStrip());
|
||||
EXPECT_TRUE(_ctx.getDebug());
|
||||
EXPECT_EQ("a.pdb", _ctx.getPDBFilePath());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, PDB) {
|
||||
EXPECT_TRUE(parse("link.exe", "/debug", "/pdb:foo.pdb", "a.obj", nullptr));
|
||||
EXPECT_TRUE(_context.getDebug());
|
||||
EXPECT_EQ("foo.pdb", _context.getPDBFilePath());
|
||||
EXPECT_TRUE(_ctx.getDebug());
|
||||
EXPECT_EQ("foo.pdb", _ctx.getPDBFilePath());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Fixed) {
|
||||
EXPECT_TRUE(parse("link.exe", "/fixed", "a.out", nullptr));
|
||||
EXPECT_FALSE(_context.getBaseRelocationEnabled());
|
||||
EXPECT_FALSE(_context.getDynamicBaseEnabled());
|
||||
EXPECT_FALSE(_ctx.getBaseRelocationEnabled());
|
||||
EXPECT_FALSE(_ctx.getDynamicBaseEnabled());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, NoFixed) {
|
||||
EXPECT_TRUE(parse("link.exe", "/fixed:no", "a.out", nullptr));
|
||||
EXPECT_TRUE(_context.getBaseRelocationEnabled());
|
||||
EXPECT_TRUE(_ctx.getBaseRelocationEnabled());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, TerminalServerAware) {
|
||||
EXPECT_TRUE(parse("link.exe", "/tsaware", "a.out", nullptr));
|
||||
EXPECT_TRUE(_context.isTerminalServerAware());
|
||||
EXPECT_TRUE(_ctx.isTerminalServerAware());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, NoTerminalServerAware) {
|
||||
EXPECT_TRUE(parse("link.exe", "/tsaware:no", "a.out", nullptr));
|
||||
EXPECT_FALSE(_context.isTerminalServerAware());
|
||||
EXPECT_FALSE(_ctx.isTerminalServerAware());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, DynamicBase) {
|
||||
EXPECT_TRUE(parse("link.exe", "/dynamicbase", "a.out", nullptr));
|
||||
EXPECT_TRUE(_context.getDynamicBaseEnabled());
|
||||
EXPECT_TRUE(_ctx.getDynamicBaseEnabled());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, NoDynamicBase) {
|
||||
EXPECT_TRUE(parse("link.exe", "/dynamicbase:no", "a.out", nullptr));
|
||||
EXPECT_FALSE(_context.getDynamicBaseEnabled());
|
||||
EXPECT_FALSE(_ctx.getDynamicBaseEnabled());
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -609,54 +609,54 @@ TEST_F(WinLinkParserTest, FailIfMismatch_Mismatch) {
|
|||
//
|
||||
TEST_F(WinLinkParserTest, Manifest_Default) {
|
||||
EXPECT_TRUE(parse("link.exe", "/manifest", "a.out", nullptr));
|
||||
EXPECT_TRUE(_context.getCreateManifest());
|
||||
EXPECT_FALSE(_context.getEmbedManifest());
|
||||
EXPECT_EQ(1, _context.getManifestId());
|
||||
EXPECT_EQ("'asInvoker'", _context.getManifestLevel());
|
||||
EXPECT_EQ("'false'", _context.getManifestUiAccess());
|
||||
EXPECT_TRUE(_ctx.getCreateManifest());
|
||||
EXPECT_FALSE(_ctx.getEmbedManifest());
|
||||
EXPECT_EQ(1, _ctx.getManifestId());
|
||||
EXPECT_EQ("'asInvoker'", _ctx.getManifestLevel());
|
||||
EXPECT_EQ("'false'", _ctx.getManifestUiAccess());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Manifest_No) {
|
||||
EXPECT_TRUE(parse("link.exe", "/manifest:no", "a.out", nullptr));
|
||||
EXPECT_FALSE(_context.getCreateManifest());
|
||||
EXPECT_FALSE(_ctx.getCreateManifest());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Manifestuac_no) {
|
||||
EXPECT_TRUE(parse("link.exe", "/manifestuac:NO", "a.out", nullptr));
|
||||
EXPECT_FALSE(_context.getManifestUAC());
|
||||
EXPECT_FALSE(_ctx.getManifestUAC());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Manifestuac_Level) {
|
||||
EXPECT_TRUE(parse("link.exe", "/manifestuac:level='requireAdministrator'",
|
||||
"a.out", nullptr));
|
||||
EXPECT_EQ("'requireAdministrator'", _context.getManifestLevel());
|
||||
EXPECT_EQ("'false'", _context.getManifestUiAccess());
|
||||
EXPECT_EQ("'requireAdministrator'", _ctx.getManifestLevel());
|
||||
EXPECT_EQ("'false'", _ctx.getManifestUiAccess());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Manifestuac_UiAccess) {
|
||||
EXPECT_TRUE(parse("link.exe", "/manifestuac:uiAccess='true'", "a.out", nullptr));
|
||||
EXPECT_EQ("'asInvoker'", _context.getManifestLevel());
|
||||
EXPECT_EQ("'true'", _context.getManifestUiAccess());
|
||||
EXPECT_EQ("'asInvoker'", _ctx.getManifestLevel());
|
||||
EXPECT_EQ("'true'", _ctx.getManifestUiAccess());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Manifestuac_LevelAndUiAccess) {
|
||||
EXPECT_TRUE(parse("link.exe",
|
||||
"/manifestuac:level='requireAdministrator' uiAccess='true'",
|
||||
"a.out", nullptr));
|
||||
EXPECT_EQ("'requireAdministrator'", _context.getManifestLevel());
|
||||
EXPECT_EQ("'true'", _context.getManifestUiAccess());
|
||||
EXPECT_EQ("'requireAdministrator'", _ctx.getManifestLevel());
|
||||
EXPECT_EQ("'true'", _ctx.getManifestUiAccess());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Manifestfile) {
|
||||
EXPECT_TRUE(parse("link.exe", "/manifestfile:bar.manifest",
|
||||
"a.out", nullptr));
|
||||
EXPECT_EQ("bar.manifest", _context.getManifestOutputPath());
|
||||
EXPECT_EQ("bar.manifest", _ctx.getManifestOutputPath());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, Manifestdependency) {
|
||||
EXPECT_TRUE(parse("link.exe", "/manifestdependency:foo bar", "a.out",
|
||||
nullptr));
|
||||
EXPECT_EQ("foo bar", _context.getManifestDependency());
|
||||
EXPECT_EQ("foo bar", _ctx.getManifestDependency());
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -665,7 +665,7 @@ TEST_F(WinLinkParserTest, Manifestdependency) {
|
|||
|
||||
TEST_F(WinLinkParserTest, OptNoRef) {
|
||||
EXPECT_TRUE(parse("link.exe", "/opt:noref", "a.obj", nullptr));
|
||||
EXPECT_FALSE(_context.deadStrip());
|
||||
EXPECT_FALSE(_ctx.deadStrip());
|
||||
}
|
||||
|
||||
TEST_F(WinLinkParserTest, OptIgnore) {
|
||||
|
@ -684,9 +684,9 @@ TEST_F(WinLinkParserTest, OptUnknown) {
|
|||
|
||||
TEST_F(WinLinkParserTest, Profile) {
|
||||
EXPECT_TRUE(parse("link.exe", "/profile", "a.obj", nullptr));
|
||||
EXPECT_TRUE(_context.deadStrip());
|
||||
EXPECT_TRUE(_context.getBaseRelocationEnabled());
|
||||
EXPECT_TRUE(_context.getDynamicBaseEnabled());
|
||||
EXPECT_TRUE(_ctx.deadStrip());
|
||||
EXPECT_TRUE(_ctx.getBaseRelocationEnabled());
|
||||
EXPECT_TRUE(_ctx.getDynamicBaseEnabled());
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -715,8 +715,8 @@ TEST_F(WinLinkParserTest, Ignore) {
|
|||
TEST_F(WinLinkParserTest, DashDash) {
|
||||
EXPECT_TRUE(parse("link.exe", "/subsystem:console", "/out:a.exe", "a.obj",
|
||||
"--", "b.obj", "-c.obj", nullptr));
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _context.getSubsystem());
|
||||
EXPECT_EQ("a.exe", _context.outputPath());
|
||||
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _ctx.getSubsystem());
|
||||
EXPECT_EQ("a.exe", _ctx.outputPath());
|
||||
EXPECT_EQ(4, inputFileCount());
|
||||
EXPECT_EQ("a.obj", inputFile(0));
|
||||
EXPECT_EQ("b.obj", inputFile(1));
|
||||
|
|
Loading…
Reference in New Issue