<div dir="ltr"><div>2016-09-08 4:09 GMT+03:00 Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span>:<br></div><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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Wed, Sep 7, 2016 at 2:22 AM, 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 a comment.<br>
<span><br>
> I'm wondering why we need to remove empty output sections from output. I cannot think of a reason to not leave them as is except small file/virtual address space wastes for the section table slot for the empty section. Do we need to handle it as a special case?<br>
<br>
<br>
</span>Besides wasting some (small) space in ELF image I see two potential issues<br>
<br>
a) What type and attributes will you assign for those empty sections? If you flag them with SHF_ALLOC you may end up having extra LOAD segments in ELF image. If you don't, then you'll have to treat them specially in assignAddresses.<br></blockquote><div><br></div></span><div>If you do the latter, you'd probably need to add only a few lines to assignAddresses, which seems a fairly good deal.</div><span class=""><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
b) All "special" sections listed in linker script (like .got, .eh_frame and so on) will have duplicates in ELF image, because they don't consist of input sections. I don't know if this is a real problem, but looks confusing at the very least (IMHO)<br></blockquote><div><br></div></span><div>By duplicates, do you mean we'll end up having two or more special sections with the same name (e.g. having two .got sections)? If so, I think I don't understand how this would happen. What am I missing?</div></div></div></div></blockquote><div><br></div><div>Imagine you have something like this in the linker script:</div><div><br></div><div>SECTIONS {</div><div>  ...</div><div>  .got : {} </div><div>  ...</div><div>}</div></div><br></div><div class="gmail_extra">This is sometimes used to specify section position in the list of output sections. Linker script processor will see this line, create empty .got section and add it to OutputSections.</div><div class="gmail_extra">After that real .got section will be added to the list in finalizeSections() and you'll end up having 2 .got sections in result image, right?</div></div>