<div dir="ltr">Is there any reason -<span style="font-family:arial,sans-serif;font-size:13px">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.</span></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 25, 2013 at 2:01 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="im">On 7/25/2013 3:56 PM, Rui Ueyama wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I think I share the goal with you to make the foundation for better<br>
dead-strip, so thank you for suggesting. I'm not sure if marking a section<br>
as a whole as "safe" or "unsafe" is the best approach, though. Some<br>
comments.<br>
<br>
- If the compiler generated code is always "safe", and if we can<br>
distinguish it from hand-written assembly code by checking if there's a gap<br>
between symbols, can we just assume a section with no gap is always "safe"?<br>
</blockquote></div>
Gaps could just be caused due to alignment, but the code may be safe, which the compiler knows very well.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- "Safeness" is not an attribute of the section but of the symbol, I<br>
think. The symbol is "safe" if there's no direct reference to the symbol<br>
data. All references should go through relocations. A section may contain<br>
both "safe" and "unsafe" symbols.<br>
</blockquote></div>
Sections contain symbols. In the context of ELF, marking sections as safe/not is more desirable because of the switches (-ffunction-sections and -fdata-sections available already).<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- How about making the compiler to create a new section for each "safe"<br>
atom, as it does for inline functions?<br>
</blockquote></div>
You already have a switch called -ffunction-sections and -fdata-sections to put function and data in seperate sections.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
<br>
On Thu, Jul 25, 2013 at 10:54 AM, Shankar Easwaran<br>
<<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,<br>
<br>
Currently lld ties up all atoms in a section for ELF together. This<br>
proposal just breaks it by handling it differently.<br>
<br></div>
*This requires **NO ELF ABI changes.<br>
<br>
**Definitions :-*<div class="im"><br>
<br>
A section is not considered safe if there is some code that appears to be<br>
present between function boundaries (or) optimizes sections to place data<br>
at the end or beginning of a section (that contains no symbol).<br>
<br>
A section is considered safe if symbols contained within the section have<br>
been associated with their appropriate sizes and there is no data present<br>
between function boundaries.<br>
<br>
Examples of safe sections are, code generated by compilers.<br>
<br>
Examples of unsafe sections are, hand written assembly code.<br>
<br></div>
*Changes Needed :-*<div class="im"><br>
<br>
The change that I am trying to propose is the compiler emits a section,<br></div>
called (*.safe_sections) *that contains section indices on what sections<div class="im"><br>
are safe.<br>
<br>
The section would have a SHF_EXCLUDE flag, to prevent other linkers from<br>
consuming this section and making it to the output file.<br>
<br>
Data structure for this :-<br>
<br>
.safe_sections<br>
<total size><br>
<section index> <boolean flag -- safe/unsafe><br>
...<br>
...<br>
<br>
<br></div>
*Advantages<br>
*There are advantages that the atoms within a safe section could just be<div class="im"><br>
allocated in the output file which means better output file layout, and<br>
Better performance!<br>
<br>
This would also result in more atoms getting gc'ed.<br>
<br>
a) looking at profile information<br>
b) taking a order file<br>
<br></div>
*Changes needed in the assembler<br>
<br>
*a) add an additional flag in the section for people writing assembly<div class="im"><br>
code, to mark a section safe or unsafe.<br></div>
*<br>
**Changes needed in lld<br>
<br>
*a) Read the safe section if its present in the object file<div class="im"><br>
b) Tie atoms together within a section if the section is not safe<br></div>
*<br>
*Thanks<br>
<br>
Shankar Easwaran*<div class="im"><br>
*<br>
<br>
--<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted 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>