<div dir="ltr">On Mon, Sep 2, 2013 at 8:08 PM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">First, I dont think setEntrySymbolName should add to the list of undefined symbols as soon as you see it.<br></blockquote>

<div><br></div><div>So, if we do that in Driver.cpp (not in code to process command line options in each driver file), we do not add entry symbol to the dead strip list? </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
If you still want to do that, make the setEntrySymbolName overridden in PECOFFLinkingContext and add your code there.<br>
<br>
Default the behavior on how it was originally, that it just sets the internal protected variable, as ELF/MachO has the same usecase.<br>
<br>
Thanks<br>
<br>
Shankar Easwaran<div class="im"><br>
<br>
On 9/2/2013 9:51 PM, Rui Ueyama wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
Just rolling back this patch will again regress COFF handling, so I don't<br>
want to simply revert. Instead, I think I can add code to Driver.cpp to<br>
copy entry symbol name to deadStripRoot. In this way the two symbols won't<br>
be added in your example. What do you think?<br>
<br>
<br>
On Mon, Sep 2, 2013 at 6:50 PM, Shankar Easwaran <<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>><u></u>wrote:<br>
<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
Hi Ruiu,<br>
<br>
This cannot be done, there is a genuine case that if you set the entry<br>
symbol twice like this<br>
<br>
lld -flavor gnu -target x86_64 -e _start -e main<br>
<br>
I want to take only the last entry symbol, now this will trigger an<br>
undefine symbol twice.<br>
<br>
Can you please revert this change as it breaks ELF ?<br>
<br>
Thanks<br>
<br>
Shankar Easwaran<br>
<br>
<br>
<br>
On 9/2/2013 8:00 PM, Rui Ueyama wrote:<br>
<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
Author: ruiu<br>
Date: Mon Sep  2 20:00:01 2013<br>
New Revision: 189776<br>
<br></div>
URL: <a href="http://llvm.org/viewvc/llvm-**project?rev=189776&view=rev" target="_blank">http://llvm.org/viewvc/llvm-**<u></u>project?rev=189776&view=rev</a><<a href="http://llvm.org/viewvc/llvm-project?rev=189776&view=rev" target="_blank">ht<u></u>tp://llvm.org/viewvc/llvm-<u></u>project?rev=189776&view=rev</a>><div class="im">

<br>
Log:<br>
Partially revert r189718 to add entry symbol to dead strip root.<br>
<br>
Also added a test to verify that entry symbol is not stripped even if<br>
dead stripping is enabled.<br>
<br>
Added:<br></div>
      lld/trunk/test/pecoff/entry.**<u></u>test<br>
Modified:<br>
      lld/trunk/include/lld/Core/**<u></u>LinkingContext.h<br>
<br>
Modified: lld/trunk/include/lld/Core/**<u></u>LinkingContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-**project/lld/trunk/include/lld/**" target="_blank">http://llvm.org/viewvc/llvm-**<u></u>project/lld/trunk/include/lld/<u></u>**</a><br>
Core/LinkingContext.h?rev=**<u></u>189776&r1=189775&r2=189776&**<u></u>view=diff<<a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=189776&r1=189775&r2=189776&view=diff" target="_blank">http://llvm.org/<u></u>viewvc/llvm-project/lld/trunk/<u></u>include/lld/Core/<u></u>LinkingContext.h?rev=189776&<u></u>r1=189775&r2=189776&view=diff</a>><br>


==============================<u></u>**============================<u></u>==**<br>
==================<br>
--- lld/trunk/include/lld/Core/**<u></u>LinkingContext.h (original)<br>
+++ lld/trunk/include/lld/Core/**<u></u>LinkingContext.h Mon Sep  2 20:00:01<div class="im"><br>
2013<br>
@@ -184,7 +184,9 @@ public:<br>
     // Set the entry symbol name. You may also need to call<br>
addDeadStripRoot() for<br>
     // the symbol if your platform supports dead-stripping, so that the<br>
symbol<br>
     // will not be removed from the output.<br>
-  virtual void setEntrySymbolName(StringRef name) {<br>
+  void setEntrySymbolName(StringRef name) {<br>
+    // Entry function have to be resolved as an undefined symbol.<br></div>
+    addInitialUndefinedSymbol(**<u></u>name);<br>
       _entrySymbolName = name;<br>
     }<br>
<br>
Added: lld/trunk/test/pecoff/entry.**<u></u>test<br>
URL: <a href="http://llvm.org/viewvc/llvm-**project/lld/trunk/test/pecoff/**" target="_blank">http://llvm.org/viewvc/llvm-**<u></u>project/lld/trunk/test/pecoff/<u></u>**</a><br>
entry.test?rev=189776&view=**<u></u>auto<<a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/entry.test?rev=189776&view=auto" target="_blank">http://llvm.org/viewvc/<u></u>llvm-project/lld/trunk/test/<u></u>pecoff/entry.test?rev=189776&<u></u>view=auto</a>><br>


==============================<u></u>**============================<u></u>==**<br>
==================<br>
--- lld/trunk/test/pecoff/entry.**<u></u>test (added)<br>
+++ lld/trunk/test/pecoff/entry.**<u></u>test Mon Sep  2 20:00:01 2013<div class="im"><br>
@@ -0,0 +1,9 @@<br>
+# REQUIRES: debug<br>
+# Verify that entry atom will not be dead-stripped.<br>
+<br>
+# RUN: yaml2obj %p/Inputs/main.obj.yaml > %t.obj<br>
+# RUN: lld -flavor link /mllvm -debug-only=WriterPECOFF /out:%t.exe \<br>
+# RUN:   /subsystem:console /entry:_main /force -- %t.obj >& %t.log<br>
+# RUN: FileCheck %s < %t.log<br>
+<br>
+CHECK: : _main<br>
<br>
<br></div>
______________________________<u></u>**_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/**mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/**<u></u>mailman/listinfo/llvm-commits</a><<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank"><u></u>http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a>><br>


<br>
<br>
<br>
</blockquote><div class="im">
--<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted<br>
by the Linux Foundation<br>
<br>
<br>
</div></blockquote></blockquote><div class="HOEnZb"><div class="h5">
<br>
<br>
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation<br>
<br>
</div></div></blockquote></div><br></div></div>