diff options
author | Rui Ueyama <ruiu@google.com> | 2013-11-22 22:52:15 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2013-11-22 22:52:15 +0000 |
commit | 82e366e78f3a6bf5cedba54b3785fa295ad441fe (patch) | |
tree | 708663b4a4e279052ce2af94a3d3745958588be8 | |
parent | 1b4a66957068224e7cad08cef53768bef1ccf000 (diff) | |
download | bcm5719-llvm-82e366e78f3a6bf5cedba54b3785fa295ad441fe.tar.gz bcm5719-llvm-82e366e78f3a6bf5cedba54b3785fa295ad441fe.zip |
[PECOFF] Do not set the entry address if /noentry option is given.
This is the first step towards DLL creation support. Resource-only DLLs
don't have entry point address.
llvm-svn: 195510
-rw-r--r-- | lld/lib/Driver/WinLinkDriver.cpp | 8 | ||||
-rw-r--r-- | lld/lib/Driver/WinLinkOptions.td | 2 | ||||
-rw-r--r-- | lld/unittests/DriverTests/WinLinkDriverTest.cpp | 15 |
3 files changed, 24 insertions, 1 deletions
diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp index 7e9a55cfcbd..7864f034e96 100644 --- a/lld/lib/Driver/WinLinkDriver.cpp +++ b/lld/lib/Driver/WinLinkDriver.cpp @@ -891,12 +891,18 @@ WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ctx, new PECOFFFileNode(ctx, path))); // Use the default entry name if /entry option is not given. - if (ctx.entrySymbolName().empty()) + if (ctx.entrySymbolName().empty() && !parsedArgs->getLastArg(OPT_noentry)) ctx.setEntrySymbolName(getDefaultEntrySymbolName(ctx)); StringRef entry = ctx.entrySymbolName(); if (!entry.empty()) ctx.addInitialUndefinedSymbol(entry); + // Specify /noentry without /dll is an error. + if (parsedArgs->getLastArg(OPT_noentry) && !parsedArgs->getLastArg(OPT_dll)) { + diagnostics << "/noentry must be specified with /dll\n"; + return false; + } + // Specifying both /opt:ref and /opt:noref is an error. if (parsedArgs->getLastArg(OPT_ref) && parsedArgs->getLastArg(OPT_ref_no)) { diagnostics << "/opt:ref must not be specified with /opt:noref\n"; diff --git a/lld/lib/Driver/WinLinkOptions.td b/lld/lib/Driver/WinLinkOptions.td index 6404680bd62..8e9f5b21d2c 100644 --- a/lld/lib/Driver/WinLinkOptions.td +++ b/lld/lib/Driver/WinLinkOptions.td @@ -50,6 +50,8 @@ def incl : Joined<["/", "-"], "include:">, def incl_c : Separate<["/", "-"], "include">, Alias<incl>; def nodefaultlib_all : F<"nodefaultlib">; +def noentry : F<"noentry">; +def dll : F<"dll">; def debug : F<"debug">; def swaprun_cd : F<"swaprun:cd">; diff --git a/lld/unittests/DriverTests/WinLinkDriverTest.cpp b/lld/unittests/DriverTests/WinLinkDriverTest.cpp index 89a590fbd91..fbe6cdd8498 100644 --- a/lld/unittests/DriverTests/WinLinkDriverTest.cpp +++ b/lld/unittests/DriverTests/WinLinkDriverTest.cpp @@ -341,6 +341,21 @@ TEST_F(WinLinkParserTest, DisallowLib) { } // +// Tests for DLL. +// + +TEST_F(WinLinkParserTest, NoEntry) { + EXPECT_TRUE(parse("link.exe", "/noentry", "/dll", "a.obj", nullptr)); + EXPECT_EQ("", _context.entrySymbolName()); +} + +TEST_F(WinLinkParserTest, NoEntryError) { + // /noentry without /dll is an error. + EXPECT_FALSE(parse("link.exe", "/noentry", "a.obj", nullptr)); + EXPECT_EQ("/noentry must be specified with /dll\n", errorMessage()); +} + +// // Tests for boolean flags. // |