[lld] r195510 - [PECOFF] Do not set the entry address if /noentry option is given.

Rui Ueyama ruiu at google.com
Fri Nov 22 14:52:15 PST 2013


Author: ruiu
Date: Fri Nov 22 16:52:15 2013
New Revision: 195510

URL: http://llvm.org/viewvc/llvm-project?rev=195510&view=rev
Log:
[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.

Modified:
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/lib/Driver/WinLinkOptions.td
    lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=195510&r1=195509&r2=195510&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Fri Nov 22 16:52:15 2013
@@ -891,12 +891,18 @@ WinLinkDriver::parse(int argc, const cha
         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";

Modified: lld/trunk/lib/Driver/WinLinkOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkOptions.td?rev=195510&r1=195509&r2=195510&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkOptions.td (original)
+++ lld/trunk/lib/Driver/WinLinkOptions.td Fri Nov 22 16:52:15 2013
@@ -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">;

Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=195510&r1=195509&r2=195510&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Fri Nov 22 16:52:15 2013
@@ -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.
 //
 





More information about the llvm-commits mailing list