[lld] r189776 - Partially revert r189718 to add entry symbol to dead strip root.

Rui Ueyama ruiu at google.com
Mon Sep 2 18:00:02 PDT 2013


Author: ruiu
Date: Mon Sep  2 20:00:01 2013
New Revision: 189776

URL: http://llvm.org/viewvc/llvm-project?rev=189776&view=rev
Log:
Partially revert r189718 to add entry symbol to dead strip root.

Also added a test to verify that entry symbol is not stripped even if
dead stripping is enabled.

Added:
    lld/trunk/test/pecoff/entry.test
Modified:
    lld/trunk/include/lld/Core/LinkingContext.h

Modified: lld/trunk/include/lld/Core/LinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=189776&r1=189775&r2=189776&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/LinkingContext.h (original)
+++ lld/trunk/include/lld/Core/LinkingContext.h Mon Sep  2 20:00:01 2013
@@ -184,7 +184,9 @@ public:
   // Set the entry symbol name. You may also need to call addDeadStripRoot() for
   // the symbol if your platform supports dead-stripping, so that the symbol
   // will not be removed from the output.
-  virtual void setEntrySymbolName(StringRef name) {
+  void setEntrySymbolName(StringRef name) {
+    // Entry function have to be resolved as an undefined symbol.
+    addInitialUndefinedSymbol(name);
     _entrySymbolName = name;
   }
 

Added: lld/trunk/test/pecoff/entry.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/entry.test?rev=189776&view=auto
==============================================================================
--- lld/trunk/test/pecoff/entry.test (added)
+++ lld/trunk/test/pecoff/entry.test Mon Sep  2 20:00:01 2013
@@ -0,0 +1,9 @@
+# REQUIRES: debug
+# 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:%t.exe \
+# RUN:   /subsystem:console /entry:_main /force -- %t.obj >& %t.log
+# RUN: FileCheck %s < %t.log
+
+CHECK: : _main





More information about the llvm-commits mailing list