[PATCH] D50253: lld-link: Simplify LinkerDriver::findDefaultEntry()

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 3 06:39:51 PDT 2018


thakis created this revision.
thakis added a reviewer: ruiu.

No behavior change. Not repeating the CRTStartup names makes fixing PR36523 simpler.


https://reviews.llvm.org/D50253

Files:
  COFF/Driver.cpp


Index: COFF/Driver.cpp
===================================================================
--- COFF/Driver.cpp
+++ COFF/Driver.cpp
@@ -426,27 +426,18 @@
 // each of which corresponds to a user-defined "main" function. This function
 // infers an entry point from a user-defined "main" function.
 StringRef LinkerDriver::findDefaultEntry() {
-  // As a special case, if /nodefaultlib is given, we directly look for an
-  // entry point. This is because, if no default library is linked, users
-  // need to define an entry point instead of a "main".
-  if (Config->NoDefaultLibAll) {
-    for (StringRef S : {"mainCRTStartup", "wmainCRTStartup",
-                        "WinMainCRTStartup", "wWinMainCRTStartup"}) {
-      if (findUnderscoreMangle(S))
-        return mangle(S);
-    }
-    return "";
-  }
-
   // User-defined main functions and their corresponding entry points.
   static const char *Entries[][2] = {
       {"main", "mainCRTStartup"},
       {"wmain", "wmainCRTStartup"},
       {"WinMain", "WinMainCRTStartup"},
       {"wWinMain", "wWinMainCRTStartup"},
   };
   for (auto E : Entries) {
-    if (findUnderscoreMangle(E[0]))
+    // As a special case, if /nodefaultlib is given, we directly look for an
+    // entry point. This is because, if no default library is linked, users
+    // need to define an entry point instead of a "main".
+    if (findUnderscoreMangle(E[Config->NoDefaultLibAll]))
       return mangle(E[1]);
   }
   return "";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50253.158998.patch
Type: text/x-patch
Size: 1467 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180803/d3cf648e/attachment.bin>


More information about the llvm-commits mailing list