<div dir="ltr"><div class="gmail_extra"><div>On Tue, Apr 2, 2013 at 8:31 PM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br></div>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Section flags:<br>
* SHF_VALID_SIZE<br>
   * There shall be a symbol with st_value of 0.<br>
</blockquote></div>
Is this to deal with weak symbols ?</blockquote><div><br></div><div style>No, it's so the entire section is covered.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
   * For each symbol, st_value + st_size shall be the st_value of another<br>
symbol, or sh_size (the end of the section).<br>
</blockquote></div>
This wouldnot handle the case for hand coded assembly files, where the user forgets about specifying the size of the function<br>
(Not  a requirement though). This also doesnot handle the case when symbols in the section are aligned differently.</blockquote><div><br></div><div style>Hence why we have a special flag for it.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
   * For each symbol, the range [st_value, st_value + st_size) shall be<br>
non-overlapping.<br>
</blockquote></div>
What if the symbol is 0 sized ? the next symbol and the current symbol will be overlapping right ?</blockquote><div><br></div><div style>It's a half open range. I put wording in for this specific case, but removed it because it's already handled by being half open.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

* SHF_SUBSECTION_VIA_SYMBOLS - SHF_VALID_SIZE must also be set.<br>
   * The range [st_value, st_value + st_size) of each symbol in the section<br>
may be moved to a different relative location.<br>
</blockquote></div>
Isnt this same as the functionality that you get by using -ffunction-sections/-fdata-<u></u>sections ?</blockquote><div><br></div><div style>Yes. But without the large overhead from all the extra sections.</div><div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im"><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
* SHF_DEADSTRIP - This section may be removed if it is dead. If<br>
SHF_SUBSECTION_VIA_SYMBOLS is also set, symbols and their data may be<br>
removed if dead.<br>
</blockquote></div>
When will this be used ?<br>
<br>
I think this is duplicate of what -ffunction-sections/-fdata-<u></u>sections will provide. You can dead strip a section<br>
and the symbols contained in it, since the compiler has created a seperate section for that.</blockquote><div><br></div><div style>It's an alternative version of it that is more expressive and safer.</div><div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im"><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
   This is separate because the assembler may have preformed relaxation<br>
within a section, but you would still like the entire section to be removed<br>
if it is not referenced. This also provides a way to limit the effect of<br>
--gc-sections without hard coding the names of sections not to remove (such<br>
as .init and .fini).<br>
<br>
Symbol flags (which we'll have to find a place to embed, probably st_other<br>
which has 6 free bits):<br>
* STF_NO_DEADSTRIP - Never remove this symbol or symbols it references even<br>
if it is in a SHF_SUBSECTION_VIA_SYMBOLS or SHF_DEADSTRIP section<br>
</blockquote></div>
The linker will save space only if SHF_SUBSECTION_VIA_SYMBOLS is set, which otherwise doesnot get any benefit right ?<span class=""><font color="#888888"><br>
<br>
Shankar Easwaran</font></span></blockquote><div><br></div><div style>By default the linker will only be allowed to remove SHF_DEAD_STRIP {sub,}sections unless you specify --gc-sections. If an entire section is dead, it can be removed. It doesn't have to be SHF_SUBSECTION_VIA_SYMBOLS.</div>
<div><br></div><div>- Michael Spencer<br></div><div> </div></div></div></div>