[lld] r213713 - [PECOFF] Fix entry point functions selection

Rui Ueyama ruiu at google.com
Tue Jul 22 17:57:57 PDT 2014


Author: ruiu
Date: Tue Jul 22 19:57:57 2014
New Revision: 213713

URL: http://llvm.org/viewvc/llvm-project?rev=213713&view=rev
Log:
[PECOFF] Fix entry point functions selection

On Windows there are four "main" functions -- main, wmain, WinMain,
or wWinMain. Their parameter types are diffferent. The standard
library provides four different entry functions (i.e.
{w,}{WinMain,main}CRTStartup) for them. You need to use the right
entry routine for your "main" function.

If you give an /entry option, the specified name is used
unconditionally.

Otherwise, the linker needs to select the right one based on
user-supplied entry point function. This can be done after the
linker reads all the input files.

This patch moves the code to determine the entry point function
from the driver to a virtual input file. It also implements the
correct logic for the entry point function selection.

Added:
    lld/trunk/test/pecoff/Inputs/entry.obj.yaml
      - copied, changed from r213712, lld/trunk/test/pecoff/Inputs/subsystem.main.yaml
Removed:
    lld/trunk/lib/ReaderWriter/PECOFF/SetSubsystemPass.h
Modified:
    lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h
    lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
    lld/trunk/test/pecoff/Inputs/subsystem.main.yaml
    lld/trunk/test/pecoff/Inputs/subsystem.winmain.yaml
    lld/trunk/test/pecoff/alternatename.test
    lld/trunk/test/pecoff/entry.test
    lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp

Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=213713&r1=213712&r2=213713&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Tue Jul 22 19:57:57 2014
@@ -113,10 +113,8 @@ public:
   StringRef decorateSymbol(StringRef name) const;
   StringRef undecorateSymbol(StringRef name) const;
 
-  void setEntrySymbolName(StringRef name) {
-    if (!name.empty())
-      LinkingContext::setEntrySymbolName(decorateSymbol(name));
-  }
+  void setEntrySymbolName(StringRef name) { _entry = name; }
+  StringRef getEntrySymbolName() const { return _entry; }
 
   void setHasEntry(bool val) { _hasEntry = val; }
   bool hasEntry() const { return _hasEntry; }
@@ -308,6 +306,8 @@ private:
   std::recursive_mutex _mutex;
   mutable std::mutex _allocMutex;
 
+  std::string _entry;
+
   // False if /noentry option is given.
   bool _hasEntry;
 

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=213713&r1=213712&r2=213713&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Tue Jul 22 19:57:57 2014
@@ -638,22 +638,6 @@ static void processLibEnv(PECOFFLinkingC
       ctx.appendInputSearchPath(ctx.allocate(path));
 }
 
-// Returns a default entry point symbol name depending on context image type and
-// subsystem. These default names are MS CRT compliant.
-static StringRef getDefaultEntrySymbolName(PECOFFLinkingContext &ctx) {
-  if (ctx.isDll()) {
-    if (ctx.getMachineType() == llvm::COFF::IMAGE_FILE_MACHINE_I386)
-      return "_DllMainCRTStartup at 12";
-    return "_DllMainCRTStartup";
-  }
-  llvm::COFF::WindowsSubsystem subsystem = ctx.getSubsystem();
-  if (subsystem == llvm::COFF::WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_GUI)
-    return "WinMainCRTStartup";
-  if (subsystem == llvm::COFF::WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_CUI)
-    return "mainCRTStartup";
-  return "";
-}
-
 namespace {
 class DriverStringSaver : public llvm::cl::StringSaver {
 public:
@@ -1285,13 +1269,6 @@ bool WinLinkDriver::parse(int argc, cons
     }
   }
 
-  // Use the default entry name if /entry option is not given.
-  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 (!ctx.hasEntry() && !parsedArgs->getLastArg(OPT_dll)) {
     diag << "/noentry must be specified with /dll\n";

Modified: lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h?rev=213713&r1=213712&r2=213713&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h Tue Jul 22 19:57:57 2014
@@ -16,6 +16,8 @@
 
 #include <mutex>
 
+using llvm::COFF::WindowsSubsystem;
+
 namespace lld {
 namespace pecoff {
 
@@ -274,5 +276,104 @@ private:
   mutable llvm::BumpPtrAllocator _alloc;
 };
 
+// Windows has not only one but many entry point functions. The
+// appropriate one is automatically selected based on the subsystem
+// setting and the user-supplied entry point function.
+//
+// http://msdn.microsoft.com/en-us/library/f9t8842e.aspx
+class EntryPointFile : public SimpleFile {
+public:
+  EntryPointFile(const PECOFFLinkingContext &ctx,
+                 std::shared_ptr<ResolvableSymbols> syms)
+      : SimpleFile("<entry>"), _ctx(const_cast<PECOFFLinkingContext *>(&ctx)),
+        _syms(syms), _firstTime(true) {}
+
+  const atom_collection<UndefinedAtom> &undefined() const override {
+    return const_cast<EntryPointFile *>(this)->getUndefinedAtoms();
+  }
+
+private:
+  const atom_collection<UndefinedAtom> &getUndefinedAtoms() {
+    std::lock_guard<std::mutex> lock(_mutex);
+    if (!_firstTime)
+      return _undefinedAtoms;
+    _firstTime = false;
+
+    if (_ctx->hasEntry()) {
+      StringRef entrySym = _ctx->allocate(_ctx->decorateSymbol(getEntry()));
+      _undefinedAtoms._atoms.push_back(
+          new (_alloc) SimpleUndefinedAtom(*this, entrySym));
+      if (_ctx->deadStrip())
+        _ctx->addDeadStripRoot(entrySym);
+    }
+    return _undefinedAtoms;
+  }
+
+  // Returns the entry point function name. It also sets the inferred
+  // subsystem if it's unknown.
+  std::string getEntry() const {
+    StringRef opt = _ctx->getEntrySymbolName();
+    if (!opt.empty())
+      return opt;
+
+    const std::string wWinMainCRTStartup = "wWinMainCRTStartup";
+    const std::string WinMainCRTStartup = "WinMainCRTStartup";
+    const std::string wmainCRTStartup = "wmainCRTStartup";
+    const std::string mainCRTStartup = "mainCRTStartup";
+    auto windows = WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_GUI;
+    auto console = WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_CUI;
+
+    if (_ctx->isDll()) {
+      _ctx->setSubsystem(windows);
+      if (_ctx->getMachineType() == llvm::COFF::IMAGE_FILE_MACHINE_I386)
+        return "_DllMainCRTStartup at 12";
+      return "_DllMainCRTStartup";
+    }
+
+    // Returns true if a given name exists in an input object file.
+    auto defined = [&](StringRef name) -> bool {
+      return _syms->defined().count(_ctx->decorateSymbol(name));
+    };
+
+    switch (_ctx->getSubsystem()) {
+    case WindowsSubsystem::IMAGE_SUBSYSTEM_UNKNOWN: {
+      if (defined("wWinMain")) {
+        _ctx->setSubsystem(windows);
+        return wWinMainCRTStartup;
+      }
+      if (defined("WinMain")) {
+        _ctx->setSubsystem(windows);
+        return WinMainCRTStartup;
+      }
+      if (defined("wmain")) {
+        _ctx->setSubsystem(console);
+        return wmainCRTStartup;
+      }
+      if (!defined("main"))
+        llvm::errs() << "Cannot infer subsystem; assuming /subsystem:console\n";
+      _ctx->setSubsystem(console);
+      return mainCRTStartup;
+    }
+    case WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_GUI:
+      if (defined("WinMain"))
+        return WinMainCRTStartup;
+      return wWinMainCRTStartup;
+    case WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_CUI:
+      if (defined("wmain"))
+        return wmainCRTStartup;
+      return mainCRTStartup;
+    default:
+      return mainCRTStartup;
+    }
+  }
+
+  PECOFFLinkingContext *_ctx;
+  atom_collection_vector<UndefinedAtom> _undefinedAtoms;
+  std::mutex _mutex;
+  std::shared_ptr<ResolvableSymbols> _syms;
+  llvm::BumpPtrAllocator _alloc;
+  bool _firstTime;
+};
+
 } // end namespace pecoff
 } // end namespace lld

Modified: lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp?rev=213713&r1=213712&r2=213713&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp Tue Jul 22 19:57:57 2014
@@ -13,7 +13,6 @@
 #include "IdataPass.h"
 #include "LinkerGeneratedSymbolFile.h"
 #include "LoadConfigPass.h"
-#include "SetSubsystemPass.h"
 
 #include "lld/Core/PassManager.h"
 #include "lld/Core/Simple.h"
@@ -128,6 +127,13 @@ bool PECOFFLinkingContext::createImplici
   auto *renameFile = new pecoff::ExportedSymbolRenameFile(*this, syms);
   exportNode->appendInputFile(std::unique_ptr<File>(renameFile));
   getLibraryGroup()->addFile(std::move(exportNode));
+
+  // Create a file for the entry point function.
+  std::unique_ptr<SimpleFileNode> entryFileNode(new SimpleFileNode("<entry>"));
+  entryFileNode->appendInputFile(
+      std::unique_ptr<File>(new pecoff::EntryPointFile(*this, syms)));
+  getInputGraph().insertElementAt(std::move(entryFileNode),
+                                  InputGraph::Position::END);
   return true;
 }
 
@@ -296,7 +302,6 @@ std::string PECOFFLinkingContext::getOut
 }
 
 void PECOFFLinkingContext::addPasses(PassManager &pm) {
-  pm.add(std::unique_ptr<Pass>(new pecoff::SetSubsystemPass(*this)));
   pm.add(std::unique_ptr<Pass>(new pecoff::EdataPass(*this)));
   pm.add(std::unique_ptr<Pass>(new pecoff::IdataPass(*this)));
   pm.add(std::unique_ptr<Pass>(new LayoutPass(registry())));

Removed: lld/trunk/lib/ReaderWriter/PECOFF/SetSubsystemPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/SetSubsystemPass.h?rev=213712&view=auto
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/SetSubsystemPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/SetSubsystemPass.h (removed)
@@ -1,58 +0,0 @@
-//===- lib/ReaderWriter/PECOFF/SetSubsystemPass.h -------------------------===//
-//
-//                             The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLD_READER_WRITER_PE_COFF_SET_SUBSYSTEM_PASS_H
-#define LLD_READER_WRITER_PE_COFF_SET_SUBSYSTEM_PASS_H
-
-#include "lld/ReaderWriter/PECOFFLinkingContext.h"
-
-using llvm::COFF::WindowsSubsystem;
-
-namespace lld {
-namespace pecoff {
-
-/// If "main" or "wmain" is defined, /subsystem:console is the default. If
-/// "WinMain" or "wWinMain" is defined, /subsystem:windows is the default.
-class SetSubsystemPass : public lld::Pass {
-public:
-  SetSubsystemPass(PECOFFLinkingContext &ctx) : _ctx(ctx) {}
-
-  void perform(std::unique_ptr<MutableFile> &file) override {
-    if (_ctx.getSubsystem() != WindowsSubsystem::IMAGE_SUBSYSTEM_UNKNOWN)
-      return;
-    StringRef main = _ctx.decorateSymbol("main");
-    StringRef wmain = _ctx.decorateSymbol("wmain");
-    StringRef winmain = _ctx.decorateSymbol("WinMain");
-    StringRef wwinmain = _ctx.decorateSymbol("wWinMain");
-    for (auto *atom : file->defined()) {
-      StringRef s = atom->name();
-      if (s == main || s == wmain) {
-        _ctx.setSubsystem(WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_CUI);
-        return;
-      }
-      if (s == winmain || s == wwinmain) {
-        _ctx.setSubsystem(WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_GUI);
-        return;
-      }
-    }
-    if (_ctx.isDll()) {
-      _ctx.setSubsystem(WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_GUI);
-      return;
-    }
-    llvm_unreachable("Failed to infer the subsystem.");
-  }
-
-private:
-  PECOFFLinkingContext &_ctx;
-};
-
-} // namespace pecoff
-} // namespace lld
-
-#endif

Copied: lld/trunk/test/pecoff/Inputs/entry.obj.yaml (from r213712, lld/trunk/test/pecoff/Inputs/subsystem.main.yaml)
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/entry.obj.yaml?p2=lld/trunk/test/pecoff/Inputs/entry.obj.yaml&p1=lld/trunk/test/pecoff/Inputs/subsystem.main.yaml&r1=213712&r2=213713&rev=213713&view=diff
==============================================================================
--- lld/trunk/test/pecoff/Inputs/subsystem.main.yaml (original)
+++ lld/trunk/test/pecoff/Inputs/entry.obj.yaml Tue Jul 22 19:57:57 2014
@@ -2,11 +2,13 @@
 header:
   Machine:         IMAGE_FILE_MACHINE_I386
   Characteristics: [  ]
+
 sections:
   - Name:            .text
     Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
     Alignment:       4
-    SectionData:     B82A000000C3
+    SectionData:     A100000000030500000000C3
+
 symbols:
   - Name:            .text
     Value:           0
@@ -14,13 +16,8 @@ symbols:
     SimpleType:      IMAGE_SYM_TYPE_NULL
     ComplexType:     IMAGE_SYM_DTYPE_NULL
     StorageClass:    IMAGE_SYM_CLASS_STATIC
-    SectionDefinition:
-      Length:          6
-      NumberOfRelocations: 0
-      NumberOfLinenumbers: 0
-      CheckSum:        0
-      Number:          0
-  - Name:            _main
+
+  - Name:            _foo
     Value:           0
     SectionNumber:   1
     SimpleType:      IMAGE_SYM_TYPE_NULL

Modified: lld/trunk/test/pecoff/Inputs/subsystem.main.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/subsystem.main.yaml?rev=213713&r1=213712&r2=213713&view=diff
==============================================================================
--- lld/trunk/test/pecoff/Inputs/subsystem.main.yaml (original)
+++ lld/trunk/test/pecoff/Inputs/subsystem.main.yaml Tue Jul 22 19:57:57 2014
@@ -26,4 +26,10 @@ symbols:
     SimpleType:      IMAGE_SYM_TYPE_NULL
     ComplexType:     IMAGE_SYM_DTYPE_NULL
     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
+  - Name:            _mainCRTStartup
+    Value:           0
+    SectionNumber:   1
+    SimpleType:      IMAGE_SYM_TYPE_NULL
+    ComplexType:     IMAGE_SYM_DTYPE_NULL
+    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
 ...

Modified: lld/trunk/test/pecoff/Inputs/subsystem.winmain.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/subsystem.winmain.yaml?rev=213713&r1=213712&r2=213713&view=diff
==============================================================================
--- lld/trunk/test/pecoff/Inputs/subsystem.winmain.yaml (original)
+++ lld/trunk/test/pecoff/Inputs/subsystem.winmain.yaml Tue Jul 22 19:57:57 2014
@@ -26,4 +26,10 @@ symbols:
     SimpleType:      IMAGE_SYM_TYPE_NULL
     ComplexType:     IMAGE_SYM_DTYPE_NULL
     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
+  - Name:            _WinMainCRTStartup
+    Value:           0
+    SectionNumber:   1
+    SimpleType:      IMAGE_SYM_TYPE_NULL
+    ComplexType:     IMAGE_SYM_DTYPE_NULL
+    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
 ...

Modified: lld/trunk/test/pecoff/alternatename.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/alternatename.test?rev=213713&r1=213712&r2=213713&view=diff
==============================================================================
--- lld/trunk/test/pecoff/alternatename.test (original)
+++ lld/trunk/test/pecoff/alternatename.test Tue Jul 22 19:57:57 2014
@@ -2,13 +2,13 @@
 # RUN: yaml2obj %p/Inputs/alternatename2.obj.yaml > %t2.obj
 # RUN: yaml2obj %p/Inputs/alternatename3.obj.yaml > %t3.obj
 #
-# RUN: lld -flavor link /out:%t1.exe /alternatename:_main=_foo -- %t1.obj
+# RUN: lld -flavor link /force /out:%t1.exe /alternatename:_main=_foo -- %t1.obj
 # RUN: llvm-objdump -d %t1.exe | FileCheck -check-prefix=CHECK1 %s
 #
-# RUN: lld -flavor link /out:%t2.exe /alternatename:_main=_foo  -- %t1.obj %t2.obj
+# RUN: lld -flavor link /force /out:%t2.exe /alternatename:_main=_foo  -- %t1.obj %t2.obj
 # RUN: llvm-objdump -d %t2.exe | FileCheck -check-prefix=CHECK2 %s
 #
-# RUN: lld -flavor link /out:%t3.exe -- %t3.obj
+# RUN: lld -flavor link /force /out:%t3.exe -- %t3.obj
 # RUN: llvm-objdump -d %t3.exe | FileCheck -check-prefix=CHECK3 %s
 
 CHECK1:      nop

Modified: lld/trunk/test/pecoff/entry.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/entry.test?rev=213713&r1=213712&r2=213713&view=diff
==============================================================================
--- lld/trunk/test/pecoff/entry.test (original)
+++ lld/trunk/test/pecoff/entry.test Tue Jul 22 19:57:57 2014
@@ -1,9 +1,27 @@
 # REQUIRES: asserts
-# Verify that entry atom will not be dead-stripped.
 
-# RUN: yaml2obj %p/Inputs/main.obj.yaml > %t.obj
-# RUN: lld -flavor link /mllvm:-debug-only=WriterPECOFF /out:%t1.exe \
-# RUN:   /subsystem:console /entry:main /force -- %t.obj >& %t1.log
-# RUN: FileCheck -check-prefix=CHECK %s < %t1.log
+# RUN: yaml2obj %p/Inputs/entry.obj.yaml > %t.obj
 
-CHECK: : _main
+# RUN: not lld -flavor link /out:%t.exe /alternatename:_main=_foo \
+# RUN:   -- %t.obj 2> %t.log
+# RUN: FileCheck -check-prefix=MAIN %s < %t.log
+
+MAIN: _mainCRTStartup
+
+# RUN: not lld -flavor link /out:%t.exe /alternatename:_wmain=_foo \
+# RUN:   -- %t.obj 2> %t.log
+# RUN: FileCheck -check-prefix=WMAIN %s < %t.log
+
+WMAIN: _wmainCRTStartup
+
+# RUN: not lld -flavor link /out:%t.exe /alternatename:_WinMain=_foo \
+# RUN:   -- %t.obj 2> %t.log
+# RUN: FileCheck -check-prefix=WINMAIN %s < %t.log
+
+WINMAIN: _WinMainCRTStartup
+
+# RUN: not lld -flavor link /out:%t.exe /alternatename:_wWinMain=_foo \
+# RUN:   -- %t.obj 2> %t.log
+# RUN: FileCheck -check-prefix=WWINMAIN %s < %t.log
+
+WWINMAIN: _wWinMainCRTStartup

Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=213713&r1=213712&r2=213713&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Tue Jul 22 19:57:57 2014
@@ -38,7 +38,7 @@ TEST_F(WinLinkParserTest, Basic) {
   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.entrySymbolName());
+  EXPECT_EQ("start", _context.getEntrySymbolName());
   EXPECT_EQ(4, inputFileCount());
   EXPECT_EQ("a.obj", inputFile(0));
   EXPECT_EQ("b.obj", inputFile(1));
@@ -684,27 +684,3 @@ TEST_F(WinLinkParserTest, DashDash) {
   EXPECT_EQ("b.obj", inputFile(1));
   EXPECT_EQ("-c.obj", inputFile(2));
 }
-
-//
-// Tests for entry symbol name.
-//
-
-TEST_F(WinLinkParserTest, DefEntryNameConsole) {
-  EXPECT_TRUE(parse("link.exe", "/subsystem:console", "a.obj", nullptr));
-  EXPECT_EQ("_mainCRTStartup", _context.entrySymbolName());
-}
-
-TEST_F(WinLinkParserTest, DefEntryNameWindows) {
-  EXPECT_TRUE(parse("link.exe", "/subsystem:windows", "a.obj", nullptr));
-  EXPECT_EQ("_WinMainCRTStartup", _context.entrySymbolName());
-}
-
-TEST_F(WinLinkParserTest, DefEntryNameDll32) {
-  EXPECT_TRUE(parse("link.exe", "/dll", "/machine:x86", "a.obj", nullptr));
-  EXPECT_EQ("__DllMainCRTStartup at 12", _context.entrySymbolName());
-}
-
-TEST_F(WinLinkParserTest, DefEntryNameDll64) {
-  EXPECT_TRUE(parse("link.exe", "/dll", "/machine:x64", "a.obj", nullptr));
-  EXPECT_EQ("_DllMainCRTStartup", _context.entrySymbolName());
-}





More information about the llvm-commits mailing list