[llvm-dev] lld dynamic relocation creation issue

Rui Ueyama via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 3 13:50:27 PST 2016


We are refactoring the relocation generation code, but currently
Writer::scanReloc adds relocation entries for the dynamic relocations. If
"Out<ELFT>::RelaDyn->addReloc({&C, &RI});" is not called for your
relocation, then no dynamic relocation will be created for that.

What do you currently get? You didn't see any dynamic relocations for
R_AACH_ABS64 relocs, do you?

On Wed, Feb 3, 2016 at 5:50 AM, Adhemerval Zanella via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi all,
>
> Working on lld aarch64 support I came across an issue where I am not sure
> which
> would be best design approach to solve.
>
> The aarch64 R_AARCH64_ABS64 relocation for PIC/PIE build requires a dynamic
> relocation (R_AARCH64_RELATIVE) with the value set as the addend of the
> relocation.  For instance, when linking the crtbeginS.o which contains:
>
> Relocation section '.rela.init_array' at offset 0xd28 contains 1 entries:
>   Offset          Info           Type           Sym. Value    Sym. Name +
> Addend
> 000000000000  000200000101 R_AARCH64_ABS64   0000000000000000 .text + d4
>
> The resulting dynamic relocation on the shared object should be:
>
> Relocation section '.rela.dyn' at offset 0x548 contains 10 entries:
>   Offset          Info           Type           Sym. Value    Sym. Name +
> Addend
> 000000010dc0  000000000403 R_AARCH64_RELATIV                    7a8
>
> Where 0x7a8 (dynamic relocation r_addend) points to a function at
> .text segment (in this case frame_dummy).
>
> I am trying to made this on lld, but current step sequence is:
>
> - Write::run
>   \_ Write::createSections
>      \_ Write::scanRelocs
>         \_ Write::addReloc // Dynamic Relocation creation
>   \_ Write::writeSections
>      \_ OutputSectionBase::writeTo
>         \_ InputSection::writeTo
>            \_ InputSection::relocate
>               \_ TargetInfo::relocateOne
>
> The problem is only at TargetInfo::relocate the target (aarch64) will see
> that the relocation is a R_AARCH64_ABS64 one and thus will need to create
> a dynamic R_AARCH64_RELATIVE relocation.
>
> Also from comments at ELF/Writer.cpp:243 I noted that scanRelocs is done
> early as a design choice.  So I am not sure if it would be best to follow
> the second idea of the comment (and do the scan later *after* the
> relocations
> is computed) or if it would be better to allow the TargetInfo add a scan
> phase to handle such things (as other linker does).
>
> Suggestions, tips, advices?
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160203/7a54f10c/attachment.html>


More information about the llvm-dev mailing list