<div dir="ltr">This seems to be a reasonable optimization, and I don't have any particular concern about implementing it.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 7, 2016 at 6:58 AM, 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>
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>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Simon Atanasyan<br>
</font></span></blockquote></div><br></div>