[lld] r192772 - Fix a bug that the empty string could be added to dead strip root.

Rui Ueyama ruiu at google.com
Tue Oct 15 22:06:52 PDT 2013


Author: ruiu
Date: Wed Oct 16 00:06:52 2013
New Revision: 192772

URL: http://llvm.org/viewvc/llvm-project?rev=192772&view=rev
Log:
Fix a bug that the empty string could be added to dead strip root.

Modified:
    lld/trunk/include/lld/Core/LinkingContext.h
    lld/trunk/lib/Driver/WinLinkDriver.cpp

Modified: lld/trunk/include/lld/Core/LinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=192772&r1=192771&r2=192772&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/LinkingContext.h (original)
+++ lld/trunk/include/lld/Core/LinkingContext.h Wed Oct 16 00:06:52 2013
@@ -88,6 +88,7 @@ public:
   /// deadStrip() returns true.
   void addDeadStripRoot(StringRef symbolName) {
     assert(_deadStrip && "only applicable when deadstripping enabled");
+    assert(!symbolName.empty() && "Empty symbol cannot be a dead strip root");
     _deadStripRoots.push_back(symbolName);
   }
 

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=192772&r1=192771&r2=192772&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Wed Oct 16 00:06:52 2013
@@ -501,7 +501,8 @@ WinLinkDriver::parse(int argc, const cha
   // symbols given by /include to the dead strip root set, so that it
   // won't be removed from the output.
   if (ctx.deadStrip()) {
-    ctx.addDeadStripRoot(ctx.entrySymbolName());
+    if (!ctx.entrySymbolName().empty())
+      ctx.addDeadStripRoot(ctx.entrySymbolName());
     for (const StringRef symbolName : ctx.initialUndefinedSymbols())
       ctx.addDeadStripRoot(symbolName);
   }





More information about the llvm-commits mailing list