<div dir="ltr">I agree that we should produce compatible object files for relocatable outputs. So, as you wrote, we need to keep the original SHF_LINK_ORDER relations with the target executable sections.<div><br></div><div>The problem with <a href="https://reviews.llvm.org/D24277">D24277</a> approach regarding relocatable output would be that, when multiple .text sections are merged into one .text section, we need to merge .ARM.exidx sections as instructed by SHF_LINK_ORDER and then create one SHF_LINK_ORDER to point to the .text section. That means we would have to interpret SHF_LINK_ORDER for relocatable output.</div><div><br></div><div>Here's what I'm thinking: we don't have to merge sections for relocatable output at all. We can pass through all input sections to output with the same names without merging them, and let the final linking merge them.</div><div><br></div><div>In that way, I think we don't need to interpret SHF_LINK_ORDER ourselves, but instead just propagate SHF_LINK_ORDER.</div><div><br></div><div>Do you think this may work?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 7, 2016 at 4:07 AM, Peter Smith <span dir="ltr"><<a href="mailto:peter.smith@linaro.org" target="_blank">peter.smith@linaro.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">peter.smith added a comment.<br>
<br>
I think the approach in <a href="https://reviews.llvm.org/D24277" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D24277</a> will work for executables, but it won't be sufficient to produce relocatable object files with SHF_LINK_ORDER dependencies.<br>
<br>
I'll state what I think a linker has to do to support exceptions:<br>
<br>
Garbage collection:<br>
There are no relocations to any .ARM.exidx section so at a minimum they must be marked live.<br>
<br>
Output Sections:<br>
For a full link there must be one .ARM.exidx OutputSection containing all input .ARM.exidx sections with table entries in the same order as the functions described by the table entries.<br>
<br>
For a relocatable link (ABI compliant) the output object must have an .ARM.exidx OutputSection for each executable OutputSection that has exeception tables. The .ARM.exidx OutputSection has SHF_LINK_ORDER and a sh_link field to the OutputSection. The table entries must be in the same order as the functions in the executable OutputSection<br>
<br>
For a relocatable link (Consumable by lld only if it sorts the individual table entries) the output object must preserve the .ARM.exidx OutputSection name.<br>
<br>
Program Headers<br>
In an executable and shared object, the linker generates a PT_ARM_EXIDX program header that has the same address and size as the .ARM.exidx section.<br>
<br>
The part that requires most of the code for SHF_LINK_ORDER is the ABI compliant relocatable object. If this is implemented then executables/shared objects drop out for free.<br>
<br>
I could do another rewrite with a sorting of each individual entry rather than section. The actual table entry is not set up to do this easily although it is possible (see comment in <a href="https://reviews.llvm.org/D24277" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D24277</a>). With the small parts for garbage collection and PT_ARM_EXIDX that would give executable support, and relocatable support for lld, however the relocatable objects wouldn't be consumable by other linkers.<br>
<br>
Personally I'd like maintain ABI compatibility so that relocatable output can be consumed by other linkers such as ld and gold. In theory it should be possible to use a similar approach to <a href="https://reviews.llvm.org/D24277" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D24277</a> and set the sh_link field. I'm not sure it will be much simpler than what I have now or in the previous review though.<br>
<br>
I'll be out of the office till next Monday, I'll pick up any comments when I'm back.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D24258" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D24258</a><br>
<br>
<br>
<br>
</blockquote></div><br></div>