<div dir="ltr">Sure. One thing I want to remind you is that there is a place in Writer.cpp where we assume all synthetic sections were appended to end of Sections list. Look for `llvm::reverse`. If you add synthetic section thunks right before/after non-synthetic sections, you also want to change that.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 29, 2016 at 1:18 PM, Simon Atanasyan <span dir="ltr"><<a href="mailto:simon@atanasyan.com" target="_blank">simon@atanasyan.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Sorry for delay with reply.<br>
<br>
It looks like now thunks can be implemented as a synthetic sections.<br>
In that case we give flexible solution and will be able to put thunks<br>
before/after related sections, using different alignment etc. As far<br>
as I know BFD linker uses the same approach at least for MIPS thunks.<br>
I will try to implement this idea.<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, Sep 8, 2016 at 1:44 AM, Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> wrote:<br>
> This seems to be a reasonable optimization, and I don't have any particular<br>
> concern about implementing it.<br>
><br>
> On Wed, Sep 7, 2016 at 6:58 AM, Simon Atanasyan <<a href="mailto:simon@atanasyan.com">simon@atanasyan.com</a>> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> MIPS LA25 thunk is used to call PIC function from non-PIC code.<br>
>> Usually it contains three instructions:<br>
>><br>
>> lui   $25, %hi(func)<br>
>> addiu $25, $25, %lo(func)<br>
>> j     func<br>
>><br>
>> We can write such thunk in an arbitrary place of the generated file.<br>
>> But if a PIC function requires the thunk is the first routine in a<br>
>> section, we can optimize the code and escape jump instruction. To do<br>
>> so we just write the following thunk right before the PIC routine.<br>
>><br>
>> lui   $25, %hi(func)<br>
>> addiu $25, $25, %lo(func)<br>
>><br>
>> In fact GNU bfd/gold linkers write all MIPS LA25 thunks required for<br>
>> the section "A" into a separate input section "S" and put section "S"<br>
>> before "A". The last thunk in the section "S" might have an optimized<br>
>> two-instructions form.<br>
>><br>
>> I would like to implement such optimization in LLD. My question is<br>
>> about ARM thunks - is it okay to write them before corresponding input<br>
>> section not after like LLD does now?<br>
<br>
--<br>
Simon Atanasyan<br>
</div></div></blockquote></div><br></div>