[lld] r222483 - [PECOFF] Enable dead-stripping even if /debug option is given.

Rui Ueyama ruiu at google.com
Thu Nov 20 15:59:40 PST 2014


Author: ruiu
Date: Thu Nov 20 17:59:40 2014
New Revision: 222483

URL: http://llvm.org/viewvc/llvm-project?rev=222483&view=rev
Log:
[PECOFF] Enable dead-stripping even if /debug option is given.

/debug makes MSVC link.exe to not remove unused sections from
the resulting executable. We did the same thing before. However,
I realized that the removal of associative section depends on
the dead-stripping pass in LLD, so we cannot disable that. Or
LLD may produce slightly broken executables that have too much
data in it (which could result in nasty subtle bugs).

This patch is a temporary measure to create correct executable.
Currently /debug does not have any real effect for LLD anyway.

I'll improve associative section handling in another patch, so that
they are removed from output without depending on the dead-stripping
pass.

Modified:
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=222483&r1=222482&r2=222483&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Thu Nov 20 17:59:40 2014
@@ -1177,8 +1177,9 @@ bool WinLinkDriver::parse(int argc, cons
 
     case OPT_debug:
       // LLD is not yet capable of creating a PDB file, so /debug does not have
-      // any effect, other than disabling dead stripping.
-      ctx.setDeadStripping(false);
+      // any effect.
+      // TODO: This should disable dead stripping. Currently we can't do that
+      // because removal of associative sections depends on dead stripping.
       break;
 
     case OPT_verbose:

Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=222483&r1=222482&r2=222483&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Thu Nov 20 17:59:40 2014
@@ -547,7 +547,7 @@ TEST_F(WinLinkParserTest, SwapRunFromNet
 
 TEST_F(WinLinkParserTest, Debug) {
   EXPECT_TRUE(parse("link.exe", "/debug", "a.out", nullptr));
-  EXPECT_FALSE(_context.deadStrip());
+  EXPECT_TRUE(_context.deadStrip());
 }
 
 TEST_F(WinLinkParserTest, Fixed) {





More information about the llvm-commits mailing list