<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 19, 2016 at 3:55 PM, Eugene Leviant <span dir="ltr"><<a href="mailto:evgeny.leviant@gmail.com" target="_blank">evgeny.leviant@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">evgeny777 added inline comments.<br>
<br>
================<br>
<span class="">Comment at: ELF/LinkerScript.cpp:245<br>
@@ +244,3 @@<br>
+      if (!isDiscarded(C))<br>
+        addInputSection(Factory, C, getOutputSectionName(C), Result);<br>
+<br>
----------------<br>
</span><span class="">ruiu wrote:<br>
> Does this work? It adds the same section again if it is mentioned in a linker script.<br>
</span>Yes. When input section is added to output section, the OutSec member variable of InputSectionBase<ELFT> class points to output section class instance. It is being checked inside LinkerScript<ELFT>::isDiscarded method:<br>
```<br>
<span class="">return !S || !S->Live || S->OutSec || getOutputSection(S) == "/DISCARD/";<br>
</span>```<br>
<br>
So input section can't be added twice<br></blockquote><div><br></div><div>I see. The reason why I didn't find it is probably because it is inside isDiscarded -- it does more than what the name implies. I'd remove `S->OutSec` and move that piece of code to LinkerScript::createSections to make it explicit.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
<br>
Repository:<br>
  rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D22455" rel="noreferrer" target="_blank">https://reviews.llvm.org/D22455</a><br>
<br>
<br>
<br>
</div></div></blockquote></div><br></div></div>