<div dir="ltr">I've not been following this thread at all. However, skimming the original post, I fail to find a nice summary of what problem is trying to be solved.<div><br></div><div>By reading the rest of the thread I divine that the goal is faster links and better dead code stripping?</div>
<div><br></div><div>Making that clearer would help. Naming your sections something other than "safe" (which has *very* different connotations) would help more.</div><div><br></div><div><br></div><div>However, I question several fundamental assumptions:</div>
<div>1) We should be very certain that -ffunction-sections is not a viable solution as it exists and is well supported in other toolchains and environments.</div><div><br></div><div>2) We should talk to other ELF producers and coordinate to make sure we don't end up creating a twisty maze of extensions here.</div>
<div><br></div><div>3) We should step back and consider leapfrogging to a fully specialized format to reap even more performance benefits rather than messily patching ELF.</div><div><br></div><div><br></div><div>#3 may prove irrelevant if this is the only major hurdle for speeding up ELF links. My impression was otherwise.</div>
<div><br></div><div>#2 hasn't been done by the other ELF producers, but we should strive to do better.</div><div><br></div><div>#1 can be solved via science.</div><div><br></div></div><div class="gmail_extra"><br><br>
<div class="gmail_quote">On Tue, Jul 30, 2013 at 5:33 PM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 7/30/2013 5:43 PM, Nick Kledzik wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Jul 29, 2013, at 10:09 AM, Shankar Easwaran wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 7/29/2013 11:24 AM, Nick Kledzik wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Jul 25, 2013, at 2:10 PM, Rui Ueyama wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is there any reason -ffunction-sections and -fdata-sections wouldn't work? If it'll work, it may be be better to say "if you want to get a better linker output use these options", rather than defining new ELF section.<br>

</blockquote>
>From my understanding, -ffunction-sections is a good semantic match.  But it introduces a lot of bloat in the .o file which the linker must process.<br>
<br>
For reference, with mach-o we just added a flag to the overall .o file that says all sections are "safe".  The compiler always generates safe object files (unless there is inline code with non-local labels) and always sets the flag.   Hand written assembly files did not have the flag by default, but savvy assembly programmers can set it.<br>

</blockquote>
We could set this flag for ELF too in the ELF header, but it wouldnot not confirm to the ELF ABI.<br>
<br>
To account safe sections, we should just create an additional section in the ELF (gcc creates a lot many sections to handle executable stack and for LTO). This would just be another section to dictate what sections are safe.<br>

</blockquote>
Or just create a new empty section with a magic name whose existence tells the linker that all sections are safe.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Isnt it better to have this flag set for every section in Darwin too, makes it flexible. I am not sure about the ABI concerns on Darwin though.<br>
</blockquote>
I don't see the benefit of that level of detail.  Either the compiler produced the object file, so all sections are safe. Or it was hand written.  If hand written, it is much easier to either say all sections are safe or none are.  Listing which are safe and which are not would be a pain.<br>

</blockquote></div></div>
I can think of two usecases when the compiler needs to emit safe sections on a section by section basis.<br>
<br>
* code having inline assembly (it only affects the text section)<br>
* the compiler trying to do some optimizations that deals with data placed outside function boundaries.<br>
<br>
Does this make sense ?<div class="HOEnZb"><div class="h5"><br>
<br>
Thanks<br>
<br>
Shankar Easwaran<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>