[llvm-dev] [LLD] Writing thunks before the corresponding section
Rui Ueyama via llvm-dev
llvm-dev at lists.llvm.org
Wed Sep 7 15:44:46 PDT 2016
This seems to be a reasonable optimization, and I don't have any particular
concern about implementing it.
On Wed, Sep 7, 2016 at 6:58 AM, Simon Atanasyan <simon at atanasyan.com> wrote:
> Hi,
>
> MIPS LA25 thunk is used to call PIC function from non-PIC code.
> Usually it contains three instructions:
>
> lui $25, %hi(func)
> addiu $25, $25, %lo(func)
> j func
>
> We can write such thunk in an arbitrary place of the generated file.
> But if a PIC function requires the thunk is the first routine in a
> section, we can optimize the code and escape jump instruction. To do
> so we just write the following thunk right before the PIC routine.
>
> lui $25, %hi(func)
> addiu $25, $25, %lo(func)
>
> In fact GNU bfd/gold linkers write all MIPS LA25 thunks required for
> the section "A" into a separate input section "S" and put section "S"
> before "A". The last thunk in the section "S" might have an optimized
> two-instructions form.
>
> I would like to implement such optimization in LLD. My question is
> about ARM thunks - is it okay to write them before corresponding input
> section not after like LLD does now?
>
> --
> Simon Atanasyan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160907/6ce4dd16/attachment.html>
More information about the llvm-dev
mailing list