[lld] r213697 - [PECOFF] Remember /noentry option so that later passes can handle it.

Rui Ueyama ruiu at google.com
Tue Jul 22 15:19:42 PDT 2014


Author: ruiu
Date: Tue Jul 22 17:19:42 2014
New Revision: 213697

URL: http://llvm.org/viewvc/llvm-project?rev=213697&view=rev
Log:
[PECOFF] Remember /noentry option so that later passes can handle it.

This is a part of a larger change to move the entry point
processing to a later pass than the driver. On Windows the default
entry point function varies depending on user-provided functions.
That means the driver is not able to correctly know the entry point
function name. Only passes after the core linker can infer it.

Modified:
    lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
    lld/trunk/lib/Driver/WinLinkDriver.cpp

Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=213697&r1=213696&r2=213697&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Tue Jul 22 17:19:42 2014
@@ -36,7 +36,7 @@ class Group;
 class PECOFFLinkingContext : public LinkingContext {
 public:
   PECOFFLinkingContext()
-      : _mutex(), _allocMutex(), _baseAddress(invalidBaseAddress),
+      : _mutex(), _allocMutex(), _hasEntry(true), _baseAddress(invalidBaseAddress),
         _stackReserve(1024 * 1024), _stackCommit(4096),
         _heapReserve(1024 * 1024), _heapCommit(4096), _noDefaultLibAll(false),
         _sectionDefaultAlignment(4096),
@@ -118,6 +118,9 @@ public:
       LinkingContext::setEntrySymbolName(decorateSymbol(name));
   }
 
+  void setHasEntry(bool val) { _hasEntry = val; }
+  bool hasEntry() const { return _hasEntry; }
+
   void setBaseAddress(uint64_t addr) { _baseAddress = addr; }
   uint64_t getBaseAddress() const;
 
@@ -305,6 +308,9 @@ private:
   std::recursive_mutex _mutex;
   mutable std::mutex _allocMutex;
 
+  // False if /noentry option is given.
+  bool _hasEntry;
+
   // The start address for the program. The default value for the executable is
   // 0x400000, but can be altered using /base command line option.
   uint64_t _baseAddress;

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=213697&r1=213696&r2=213697&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Tue Jul 22 17:19:42 2014
@@ -1196,6 +1196,10 @@ bool WinLinkDriver::parse(int argc, cons
       ctx.addInitialUndefinedSymbol(ctx.allocate(inputArg->getValue()));
       break;
 
+    case OPT_noentry:
+      ctx.setHasEntry(false);
+      break;
+
     case OPT_nodefaultlib_all:
       ctx.setNoDefaultLibAll(true);
       break;
@@ -1289,7 +1293,7 @@ bool WinLinkDriver::parse(int argc, cons
     ctx.addInitialUndefinedSymbol(entry);
 
   // Specify /noentry without /dll is an error.
-  if (parsedArgs->getLastArg(OPT_noentry) && !parsedArgs->getLastArg(OPT_dll)) {
+  if (!ctx.hasEntry() && !parsedArgs->getLastArg(OPT_dll)) {
     diag << "/noentry must be specified with /dll\n";
     return false;
   }





More information about the llvm-commits mailing list