[PECOFF] Remove an InputElement placeholder for the entry name.
authorRui Ueyama <ruiu@google.com>
Thu, 15 Jan 2015 06:56:26 +0000 (06:56 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 15 Jan 2015 06:56:26 +0000 (06:56 +0000)
llvm-svn: 226133

lld/include/lld/ReaderWriter/PECOFFLinkingContext.h
lld/lib/Driver/WinLinkDriver.cpp
lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
lld/unittests/DriverTests/WinLinkDriverTest.cpp

index c93a8d3..bbf2b60 100644 (file)
@@ -336,9 +336,6 @@ public:
 
   virtual bool hasInputGraph() { return !!_inputGraph; }
 
-  void setEntryNode(SimpleFileNode *node) { _entryNode = node; }
-  SimpleFileNode *getEntryNode() const { return _entryNode; }
-
   void addLibraryFile(std::unique_ptr<FileNode> file);
 
   void setModuleDefinitionFile(const std::string val) {
@@ -462,9 +459,6 @@ private:
   // Microsoft Windows." This feature was somewhat useful before Windows 95.
   ArrayRef<uint8_t> _dosStub;
 
-  // The node containing the entry point file.
-  SimpleFileNode *_entryNode;
-
   // Name of the temporary file for lib.exe subcommand. For debugging
   // only.
   std::string _moduleDefinitionFile;
index 7e801b1..29e5edc 100644 (file)
@@ -1423,11 +1423,6 @@ bool WinLinkDriver::parse(int argc, const char *argv[],
 
   // Add the library group to the input graph.
   if (!isReadingDirectiveSection) {
-    // The container for the entry point file.
-    std::unique_ptr<SimpleFileNode> entry(new SimpleFileNode("<entry>"));
-    ctx.setEntryNode(entry.get());
-    ctx.getInputGraph().addInputElement(std::move(entry));
-
     // Add a group-end marker.
     ctx.getInputGraph().addInputElement(llvm::make_unique<GroupEnd>(0));
   }
index 178991b..d17f3b5 100644 (file)
@@ -106,6 +106,14 @@ void PECOFFLinkingContext::addLibraryFile(std::unique_ptr<FileNode> file) {
 
 bool PECOFFLinkingContext::createImplicitFiles(
     std::vector<std::unique_ptr<File>> &) {
+  pecoff::ResolvableSymbols* syms = getResolvableSymsFile();
+
+  // Create a file for the entry point function.
+  std::unique_ptr<SimpleFileNode> entry(new SimpleFileNode("<entry>"));
+  entry->appendInputFile(
+      llvm::make_unique<pecoff::EntryPointFile>(*this, syms));
+  getInputGraph().addInputElementFront(std::move(entry));
+
   // Create a file for __ImageBase.
   auto fileNode = llvm::make_unique<SimpleFileNode>("Implicit Files");
   fileNode->appendInputFile(
@@ -118,17 +126,12 @@ bool PECOFFLinkingContext::createImplicitFiles(
       llvm::make_unique<pecoff::LocallyImportedSymbolFile>(*this));
   getInputGraph().addInputElement(std::move(impFileNode));
 
-  pecoff::ResolvableSymbols* syms = getResolvableSymsFile();
-
   // Create a file for dllexported symbols.
   auto exportNode = llvm::make_unique<SimpleFileNode>("<export>");
   exportNode->appendInputFile(
       llvm::make_unique<pecoff::ExportedSymbolRenameFile>(*this, syms));
   addLibraryFile(std::move(exportNode));
 
-  // Create a file for the entry point function.
-  getEntryNode()->appendInputFile(
-      llvm::make_unique<pecoff::EntryPointFile>(*this, syms));
   return true;
 }
 
index e910e40..64a171a 100644 (file)
@@ -37,7 +37,7 @@ TEST_F(WinLinkParserTest, Basic) {
   EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_I386, _context.getMachineType());
   EXPECT_EQ("a.exe", _context.outputPath());
   EXPECT_EQ("start", _context.getEntrySymbolName());
-  EXPECT_EQ(5, inputFileCount());
+  EXPECT_EQ(4, inputFileCount());
   EXPECT_EQ("a.obj", inputFile(0));
   EXPECT_EQ("b.obj", inputFile(1));
   EXPECT_EQ("c.obj", inputFile(2));
@@ -77,7 +77,7 @@ TEST_F(WinLinkParserTest, StartsWithHyphen) {
       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(3, inputFileCount());
+  EXPECT_EQ(2, inputFileCount());
   EXPECT_EQ("a.obj", inputFile(0));
 }
 
@@ -86,7 +86,7 @@ TEST_F(WinLinkParserTest, UppercaseOption) {
       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(3, inputFileCount());
+  EXPECT_EQ(2, inputFileCount());
   EXPECT_EQ("a.obj", inputFile(0));
 }
 
@@ -109,7 +109,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(4, inputFileCount());
+  EXPECT_EQ(3, inputFileCount());
   EXPECT_EQ("foo.obj", inputFile(0));
   EXPECT_EQ("bar.obj", inputFile(1));
 }
@@ -117,7 +117,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(3, inputFileCount());
+  EXPECT_EQ(2, inputFileCount());
   EXPECT_EQ("foo.o", inputFile(0));
 }
 
@@ -137,11 +137,11 @@ TEST_F(WinLinkParserTest, Libpath) {
 TEST_F(WinLinkParserTest, InputOrder) {
   EXPECT_TRUE(parse("link.exe", "a.lib", "b.obj", "c.obj", "a.lib", "d.obj",
                     nullptr));
-  EXPECT_EQ(6, inputFileCount());
+  EXPECT_EQ(5, inputFileCount());
   EXPECT_EQ("b.obj", inputFile(0));
   EXPECT_EQ("c.obj", inputFile(1));
   EXPECT_EQ("d.obj", inputFile(2));
-  EXPECT_EQ("a.lib", inputFile(4));
+  EXPECT_EQ("a.lib", inputFile(3));
 }
 
 //
@@ -393,42 +393,42 @@ TEST_F(WinLinkParserTest, SectionMultiple) {
 TEST_F(WinLinkParserTest, DefaultLib) {
   EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",
                     "/defaultlib:kernel32", "a.obj", nullptr));
-  EXPECT_EQ(5, inputFileCount());
+  EXPECT_EQ(4, inputFileCount());
   EXPECT_EQ("a.obj", inputFile(0));
-  EXPECT_EQ("user32.lib", inputFile(2));
-  EXPECT_EQ("kernel32.lib", inputFile(3));
+  EXPECT_EQ("user32.lib", inputFile(1));
+  EXPECT_EQ("kernel32.lib", inputFile(2));
 }
 
 TEST_F(WinLinkParserTest, DefaultLibDuplicates) {
   EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",
                     "/defaultlib:user32.lib", "a.obj", nullptr));
-  EXPECT_EQ(4, inputFileCount());
+  EXPECT_EQ(3, inputFileCount());
   EXPECT_EQ("a.obj", inputFile(0));
-  EXPECT_EQ("user32.lib", inputFile(2));
+  EXPECT_EQ("user32.lib", inputFile(1));
 }
 
 TEST_F(WinLinkParserTest, NoDefaultLib) {
   EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",
                     "/defaultlib:kernel32", "/nodefaultlib:user32.lib", "a.obj",
                     nullptr));
-  EXPECT_EQ(4, inputFileCount());
+  EXPECT_EQ(3, inputFileCount());
   EXPECT_EQ("a.obj", inputFile(0));
-  EXPECT_EQ("kernel32.lib", inputFile(2));
+  EXPECT_EQ("kernel32.lib", inputFile(1));
 }
 
 TEST_F(WinLinkParserTest, NoDefaultLibCase) {
   EXPECT_TRUE(parse("link.exe", "/defaultlib:user32",
                     "/defaultlib:kernel32", "/nodefaultlib:USER32.LIB", "a.obj",
                     nullptr));
-  EXPECT_EQ(4, inputFileCount());
+  EXPECT_EQ(3, inputFileCount());
   EXPECT_EQ("a.obj", inputFile(0));
-  EXPECT_EQ("kernel32.lib", inputFile(2));
+  EXPECT_EQ("kernel32.lib", inputFile(1));
 }
 
 TEST_F(WinLinkParserTest, NoDefaultLibAll) {
   EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",
                     "/defaultlib:kernel32", "/nodefaultlib", "a.obj", nullptr));
-  EXPECT_EQ(3, inputFileCount());
+  EXPECT_EQ(2, inputFileCount());
   EXPECT_EQ("a.obj", inputFile(0));
 }
 
@@ -436,9 +436,9 @@ TEST_F(WinLinkParserTest, DisallowLib) {
   EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",
                     "/defaultlib:kernel32", "/disallowlib:user32.lib", "a.obj",
                     nullptr));
-  EXPECT_EQ(4, inputFileCount());
+  EXPECT_EQ(3, inputFileCount());
   EXPECT_EQ("a.obj", inputFile(0));
-  EXPECT_EQ("kernel32.lib", inputFile(2));
+  EXPECT_EQ("kernel32.lib", inputFile(1));
 }
 
 //
@@ -704,7 +704,7 @@ TEST_F(WinLinkParserTest, Ignore) {
                     "/safeseh:no", "/functionpadmin", "/maxilksize:1024",
                     "a.obj", nullptr));
   EXPECT_EQ("", errorMessage());
-  EXPECT_EQ(3, inputFileCount());
+  EXPECT_EQ(2, inputFileCount());
   EXPECT_EQ("a.obj", inputFile(0));
 }
 
@@ -717,7 +717,7 @@ TEST_F(WinLinkParserTest, DashDash) {
                     "--", "b.obj", "-c.obj", nullptr));
   EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _context.getSubsystem());
   EXPECT_EQ("a.exe", _context.outputPath());
-  EXPECT_EQ(5, inputFileCount());
+  EXPECT_EQ(4, inputFileCount());
   EXPECT_EQ("a.obj", inputFile(0));
   EXPECT_EQ("b.obj", inputFile(1));
   EXPECT_EQ("-c.obj", inputFile(2));